Commit 0aa44339 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm pack: refactoring, move script runnning to a seprate func

parent 3ab97a11
...@@ -23,9 +23,9 @@ load_helper epm-repack ...@@ -23,9 +23,9 @@ load_helper epm-repack
[ -n "$EPM_PACK_SCRIPTS_DIR" ] || EPM_PACK_SCRIPTS_DIR="$CONFIGDIR/pack.d" [ -n "$EPM_PACK_SCRIPTS_DIR" ] || EPM_PACK_SCRIPTS_DIR="$CONFIGDIR/pack.d"
# <packname> <abstarname> [packversion]
# we run this function in a tmpdir # fills returntarname with returned tar name or empty
__epm_pack() __epm_pack_run_handler()
{ {
local packname="$1" local packname="$1"
local tarname="$2" local tarname="$2"
...@@ -33,7 +33,7 @@ __epm_pack() ...@@ -33,7 +33,7 @@ __epm_pack()
returntarname='' returntarname=''
local repackcode="$EPM_PACK_SCRIPTS_DIR/$packname.sh" local repackcode="$EPM_PACK_SCRIPTS_DIR/$packname.sh"
[ -x "$repackcode" ] || fatal "Can't find script $repackcode for packname $packname" [ -x "$repackcode" ] || return
[ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_PACK_SCRIPTS_DIR dir. The pack script can be outdated." [ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_PACK_SCRIPTS_DIR dir. The pack script can be outdated."
# a file to keep filename of generated tarball # a file to keep filename of generated tarball
...@@ -43,10 +43,19 @@ __epm_pack() ...@@ -43,10 +43,19 @@ __epm_pack()
local bashopt='' local bashopt=''
[ -n "$debug" ] && bashopt='-x' [ -n "$debug" ] && bashopt='-x'
#info "Running $($script --description 2>/dev/null) ..." #info "Running $($script --description 2>/dev/null) ..."
( unset EPMCURDIR ; export PATH=$SCPATH ;docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" "$packversion" ) || fatal ( unset EPMCURDIR ; export PATH=$SCPATH ; docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" "$packversion" ) || fatal
returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname" returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname"
[ -s "$returntarname" ] || fatal "pack script for $packname return unexist $returntarname file"
return 0
}
[ -s "$returntarname" ] || fatal "pack script $repackcode return unexist $returntarname file" # we run this function in a tmpdir
__epm_pack()
{
local packname="$1"
# fills returntarname with packed tar
__epm_pack_run_handler "$@" || fatal "Can't find pack script for packname $packname"
if [ -n "$download_only" ] ; then if [ -n "$download_only" ] ; then
mv $returntarname $EPMCURDIR mv $returntarname $EPMCURDIR
...@@ -64,6 +73,7 @@ __epm_pack() ...@@ -64,6 +73,7 @@ __epm_pack()
[ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname" [ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname"
fi fi
local pkgname
if [ -n "$repacked_pkgs" ] ; then if [ -n "$repacked_pkgs" ] ; then
# remove packed file if we have repacked one # remove packed file if we have repacked one
rm -v "$returntarname" rm -v "$returntarname"
...@@ -128,16 +138,15 @@ epm_pack() ...@@ -128,16 +138,15 @@ epm_pack()
tarname="$(realpath "$pkg_files")" tarname="$(realpath "$pkg_files")"
elif [ -d "$tarname" ] ; then elif [ -d "$tarname" ] ; then
tarname="$(realpath "$tarname")" tarname="$(realpath "$tarname")"
cd $tmpdir || fatal
elif [ -s "$tarname" ] ; then elif [ -s "$tarname" ] ; then
# get full path for real name # get full path for real name
tarname="$(realpath "$tarname")" tarname="$(realpath "$tarname")"
cd $tmpdir || fatal
else else
# just pass name # just pass name
true true
fi fi
cd $tmpdir || fatal
__epm_pack "$packname" "$tarname" "$packversion" __epm_pack "$packname" "$tarname" "$packversion"
} }
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