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

epm-repack: move copy creating to __epm_repack_copy() and use it

parent 1f7ddd0f
...@@ -53,6 +53,32 @@ __epm_check_if_needed_repack() ...@@ -53,6 +53,32 @@ __epm_check_if_needed_repack()
warning 'There is repack rule for $pkgname package. It is better install this package via epm install --repack or epm play.' warning 'There is repack rule for $pkgname package. It is better install this package via epm install --repack or epm play.'
} }
# make light and independent copy to target
# note: target file can be read only
# args: abs_source target
__epm_repack_copy()
{
local abspkg="$1"
local target="$2"
# if source file is not writable, try CoW or fallback to ordinal copy
#if [ ! -w "$abspkg" ] ; then
# cp --reflink=auto $verbose $abspkg $target 2>/dev/null && return
# return
#fi
# firstly try CoW
cp --reflink=always $verbose $abspkg $target 2>/dev/null && return
# next try create hardlink
cp -l $verbose $abspkg $target 2>/dev/null && return
# next try create symlink
cp -s $verbose $abspkg $target 2>/dev/null && return
# just make copy as fallback
cp $verbose $abspkg $target && return
fatal "Can't copy $abspkg to $target"
}
# arg: rpm or deb # arg: rpm or deb
# fills split_replaced_pkgs with packages of that type # fills split_replaced_pkgs with packages of that type
__epm_split_by_pkg_type() __epm_split_by_pkg_type()
......
...@@ -44,7 +44,7 @@ __epm_repack_to_deb() ...@@ -44,7 +44,7 @@ __epm_repack_to_deb()
alpkg=$(basename $pkg) alpkg=$(basename $pkg)
# don't use abs package path: copy package to temp dir and use there # don't use abs package path: copy package to temp dir and use there
cp -l $verbose $abspkg $TDIR/$alpkg 2>/dev/null || cp -s $verbose $abspkg $TDIR/$alpkg 2>/dev/null || cp $verbose $abspkg $TDIR/$alpkg || fatal __epm_repack_copy $abspkg $TDIR/$alpkg
cd $TDIR || fatal cd $TDIR || fatal
__prepare_source_package "$(pwd)/$alpkg" __prepare_source_package "$(pwd)/$alpkg"
......
...@@ -137,7 +137,7 @@ __epm_repack_to_rpm() ...@@ -137,7 +137,7 @@ __epm_repack_to_rpm()
alpkg=$(basename $pkg) alpkg=$(basename $pkg)
# don't use abs package path: copy package to temp dir and use there # don't use abs package path: copy package to temp dir and use there
cp -l $verbose $abspkg $tmpbuilddir/../$alpkg 2>/dev/null || cp -s $verbose $abspkg $tmpbuilddir/../$alpkg 2>/dev/null || cp $verbose $abspkg $tmpbuilddir/../$alpkg || fatal __epm_repack_copy $abspkg $tmpbuilddir/../$alpkg
[ -r "$pkg.eepm.yaml" ] && cp $verbose $pkg.eepm.yaml $tmpbuilddir/../$alpkg.eepm.yaml [ -r "$pkg.eepm.yaml" ] && cp $verbose $pkg.eepm.yaml $tmpbuilddir/../$alpkg.eepm.yaml
cd $tmpbuilddir/../ || fatal cd $tmpbuilddir/../ || fatal
......
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