Commit 3fb7af9a authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-restore: temp. implementation of python requires translation to spec

parent aa44e477
...@@ -29,18 +29,28 @@ __epm_filter_pip_to_rpm() ...@@ -29,18 +29,28 @@ __epm_filter_pip_to_rpm()
-e "s|pyjwt|jwt|" \ -e "s|pyjwt|jwt|" \
-e "s|pyyaml|yaml|" \ -e "s|pyyaml|yaml|" \
-e "s|attrs|attr|" \ -e "s|attrs|attr|" \
-e "s|pygments|Pygments|" \
-e "s|patch_ng|patch-ng|" \
-e "s|memcached|memcache|" \ -e "s|memcached|memcache|" \
-e "s|pyopenssl|OpenSSL|" -e "s|pyopenssl|OpenSSL|"
} }
# TODO: remove me
fill_sign()
{
local sign="$1"
echo "$2" | grep -E -- "$sign[[:space:]]*[0-9.]+?" | sed -E -- "s|.*$sign[[:space:]]*([0-9.]+?).*|\1|"
}
__epm_restore_pip() __epm_restore_pip()
{ {
local req_file="$1" local req_file="$1"
info "Install requirements from $req_file ..." [ -n "$dryrun" ] || info "Install requirements from $req_file ..."
local ilist='' local ilist=''
while read l ; do while read l ; do
local t="$(echo "$l" | sed -e "s| *[<>]*=.*||" | __epm_filter_pip_to_rpm)" local t="$(echo "$l" | sed -e "s| *[<>!]*=.*||" | __epm_filter_pip_to_rpm)"
if echo "$l" | grep -qE "^ *#" || [ -z "$l" ] ; then if echo "$l" | grep -qE "^ *#" || [ -z "$l" ] ; then
continue continue
fi fi
...@@ -56,14 +66,35 @@ __epm_restore_pip() ...@@ -56,14 +66,35 @@ __epm_restore_pip()
echo " $t is python2 only requirement, skipped" echo " $t is python2 only requirement, skipped"
continue continue
fi fi
if [ -n "$dryrun" ] ; then
local pi=''
local sign ll
for sign in "<=" "<" ">=" ">" "==" "!="; do
ll=$(fill_sign "$sign" "$l")
[ -n "$ll" ] || continue
[ "$sign" = "==" ] && sign="="
[ "$sign" = "!=" ] && sign=">="
pi="$pi
%py3_use $t $sign $ll"
done
[ -n "$pi" ] || pi="%py3_use $t"
echo "$pi"
continue
else
# TODO: python3-egg-info($t) # TODO: python3-egg-info($t)
local pi="python3($t)" local pi="python3($t)"
echo " $l -> $t -> $pi" echo " $l -> $t -> $pi"
fi
[ -n "$t" ] || continue [ -n "$t" ] || continue
ilist="$ilist $pi" ilist="$ilist $pi"
done < $req_file done < $req_file
epm install $ilist if [ -n "$dryrun" ] ; then
echo "$ilist"
return
fi
docmd epm install $ilist
} }
__epm_restore_by() __epm_restore_by()
...@@ -75,13 +106,17 @@ __epm_restore_by() ...@@ -75,13 +106,17 @@ __epm_restore_by()
assure_exists ldd-requires assure_exists ldd-requires
showcmd ldd-requires $req_file showcmd ldd-requires $req_file
local TOINSTALL="$(a= ldd-requires $req_file | grep "^apt-get install" | sed -e "s|^apt-get install ||")" local TOINSTALL="$(a= ldd-requires $req_file | grep "^apt-get install" | sed -e "s|^apt-get install ||")"
if [ -n "$dryrun" ] ; then
estrlist list $TOINSTALL
return
fi
[ -n "$TOINSTALL" ] || { info "There are no missed packages is found for $req_file binary." ; return ; } [ -n "$TOINSTALL" ] || { info "There are no missed packages is found for $req_file binary." ; return ; }
epm install $TOINSTALL docmd epm install $TOINSTALL
return return
fi fi
case $(basename $req_file) in case $(basename $req_file) in
requirements.txt) requirements.txt|requires.txt)
[ -s "$req_file" ] && __epm_restore_pip "$req_file" [ -s "$req_file" ] && __epm_restore_pip "$req_file"
;; ;;
Gemfile|package.json) Gemfile|package.json)
...@@ -108,7 +143,7 @@ epm_restore() ...@@ -108,7 +143,7 @@ epm_restore()
fi fi
# if run with empty args # if run with empty args
for i in requirements.txt Gemfile; do for i in requirements.txt Gemfile requires.txt; do
__epm_restore_by $i __epm_restore_by $i
done done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment