Commit 6d6a2a01 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm repack: rewrite __epm_repack() via __epm_repack_single(), fix repack rule detection

parent 9387be94
...@@ -132,31 +132,26 @@ __prepare_source_package() ...@@ -132,31 +132,26 @@ __prepare_source_package()
# FIXME: Нужно как-то обеспечить непродолжение выполнения.
# used in epm install # used in epm install
# fill repacked_pkgs __epm_repack_single()
__epm_repack()
{ {
repacked_pkgs='' local pkg="$1"
case $PKGFORMAT in case $PKGFORMAT in
rpm) rpm)
load_helper epm-repack-rpm load_helper epm-repack-rpm
__epm_repack_to_rpm "$@" || return __epm_repack_to_rpm "$pkg" || return
;; ;;
deb) deb)
# FIXME: only one package in $@ is supported if __epm_have_repack_rule "$pkg" ; then
#local pkgname="$(epm print name from "$@")" # we have repack rules only for rpm, so use rpm step in any case
#__set_version_pkgname "$1"
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$PKGNAME.sh"
if [ -x "$repackcode" ] ; then
load_helper epm-repack-rpm load_helper epm-repack-rpm
load_helper epm-repack-deb load_helper epm-repack-deb
__epm_repack_to_rpm "$@" || return __epm_repack_to_rpm "$pkg" || return
[ -n "$repacked_pkgs" ] || return [ -n "$repacked_pkg" ] || return
__epm_repack_to_deb $repacked_pkgs __epm_repack_to_deb $repacked_pkg || return
else else
load_helper epm-repack-deb load_helper epm-repack-deb
__epm_repack_to_deb "$@" || return __epm_repack_to_deb "$pkg" || return
fi fi
;; ;;
*) *)
...@@ -167,6 +162,18 @@ __epm_repack() ...@@ -167,6 +162,18 @@ __epm_repack()
return 0 return 0
} }
# fill repacked_pkgs
__epm_repack()
{
local pkg
repacked_pkgs=''
for pkg in $* ; do
__epm_repack_single "$pkg" || fatal "Error with $pkg repacking."
[ -n "$repacked_pkgs" ] && repacked_pkgs="$repacked_pkgs $repacked_pkg" || repacked_pkgs="$repacked_pkg"
done
}
__epm_repack_if_needed() __epm_repack_if_needed()
{ {
# return 1 if there is a package in host package format # return 1 if there is a package in host package format
......
...@@ -18,17 +18,16 @@ ...@@ -18,17 +18,16 @@
# #
# fills repacked_pkgs # fills repacked_pkg
__epm_repack_to_deb() __epm_repack_to_deb()
{ {
local pkg local pkg="$1"
local pkgs="$*"
assure_exists alien assure_exists alien
assure_exists fakeroot assure_exists fakeroot
assure_exists rpm assure_exists rpm
repacked_pkgs='' repacked_pkg=''
local TDIR local TDIR
TDIR="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal TDIR="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
...@@ -36,7 +35,10 @@ __epm_repack_to_deb() ...@@ -36,7 +35,10 @@ __epm_repack_to_deb()
umask 022 umask 022
for pkg in $pkgs ; do if echo "$pkg" | grep -q "\.deb" ; then
warning "Repack deb to deb is not supported yet."
fi
abspkg="$(realpath "$pkg")" abspkg="$(realpath "$pkg")"
info "Repacking $abspkg to local deb format (inside $TDIR) ..." info "Repacking $abspkg to local deb format (inside $TDIR) ..."
...@@ -47,15 +49,16 @@ __epm_repack_to_deb() ...@@ -47,15 +49,16 @@ __epm_repack_to_deb()
cd $TDIR || fatal cd $TDIR || fatal
__prepare_source_package "$pkg" __prepare_source_package "$pkg"
showcmd_store_output fakeroot alien -d -k $scripts "$alpkg" showcmd_store_output fakeroot alien -d -k $verbose $scripts "$alpkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g") local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
if [ -n "$DEBCONVERTED" ] ; then if [ -n "$DEBCONVERTED" ] ; then
repacked_pkgs="$repacked_pkgs $(realpath $DEBCONVERTED)" repacked_pkg="$repacked_pkg $(realpath $DEBCONVERTED)"
remove_on_exit "$(realpath $DEBCONVERTED)" remove_on_exit "$(realpath $DEBCONVERTED)"
else
warning "Can't find converted deb for source binary package '$pkg'"
fi fi
clean_store_output clean_store_output
cd - >/dev/null cd - >/dev/null
done
return 0 return 0
} }
......
...@@ -124,10 +124,10 @@ __try_install_eepm_rpmbuild() ...@@ -124,10 +124,10 @@ __try_install_eepm_rpmbuild()
RPMBUILD=/usr/bin/rpmbuild RPMBUILD=/usr/bin/rpmbuild
} }
# will fill repacked_pkgs var # will fill repacked_pkg var
__epm_repack_to_rpm() __epm_repack_to_rpm()
{ {
local pkgs="$*" local pkg="$1"
# Note: install epm-repack for static (package based) dependencies # Note: install epm-repack for static (package based) dependencies
assure_exists alien || fatal assure_exists alien || fatal
...@@ -151,18 +151,18 @@ __epm_repack_to_rpm() ...@@ -151,18 +151,18 @@ __epm_repack_to_rpm()
umask 022 umask 022
# TODO: improve # TODO: improve
if echo "$pkgs" | grep -q "\.deb" ; then if echo "$pkg" | grep -q "\.deb" ; then
assure_exists dpkg || fatal assure_exists dpkg || fatal
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен # TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf # assure_exists debconf
fi fi
local pkg
local alpkg local alpkg
local abspkg local abspkg
local tmpbuilddir local tmpbuilddir
repacked_pkgs=''
for pkg in $pkgs ; do repacked_pkg=''
# TODO: keep home? # TODO: keep home?
HOME="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal HOME="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
remove_on_exit $HOME remove_on_exit $HOME
...@@ -236,12 +236,11 @@ __epm_repack_to_rpm() ...@@ -236,12 +236,11 @@ __epm_repack_to_rpm()
local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)" local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)"
if [ -s "$repacked_rpm" ] ; then if [ -s "$repacked_rpm" ] ; then
remove_on_exit "$repacked_rpm" remove_on_exit "$repacked_rpm"
[ -n "$repacked_pkgs" ] && repacked_pkgs="$repacked_pkgs $repacked_rpm" || repacked_pkgs="$repacked_rpm" repacked_pkg="$repacked_rpm"
else else
warning "Can't find converted rpm for source binary package '$pkg' (got $repacked_rpm)" warning "Can't find converted rpm for source binary package '$pkg' (got $repacked_rpm)"
fi fi
cd $EPMCURDIR >/dev/null cd $EPMCURDIR >/dev/null
done
true true
} }
......
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