diff options
author | Rick Farina (Zero_Chaos) <zerochaos@gentoo.org> | 2012-11-01 19:59:50 -0400 |
---|---|---|
committer | Rick Farina (Zero_Chaos) <zerochaos@gentoo.org> | 2012-11-01 19:59:50 -0400 |
commit | 64c1787ab549a95c7350fd03c2a22c5f6a073b19 (patch) | |
tree | 40ba29fcbae8755bc252ed25264d94bcf25eb144 | |
parent | Revert "Use relative path." (diff) | |
download | catalyst-64c1787ab549a95c7350fd03c2a22c5f6a073b19.tar.gz catalyst-64c1787ab549a95c7350fd03c2a22c5f6a073b19.tar.bz2 catalyst-64c1787ab549a95c7350fd03c2a22c5f6a073b19.zip |
Revert "Make sure we have ${destdir} on copy_to_chroot and simplify exec_in_chroot."
This reverts commit 17b34223a4afc1f070ac2fb9bdfb51e47c03db61.
-rw-r--r-- | targets/support/functions.sh | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/targets/support/functions.sh b/targets/support/functions.sh index af57c10f..a0eaae28 100644 --- a/targets/support/functions.sh +++ b/targets/support/functions.sh @@ -1,7 +1,6 @@ copy_to_chroot() { local src_file=$1 local dest_dir=${clst_chroot_path}${2:-/tmp} - mkdir -p ${dest_dir} echo "copying ${src_file##*/} to ${dest_dir}" cp -pPR "${src_file}" "${dest_dir}"/ } @@ -19,19 +18,34 @@ exec_in_chroot(){ # copies the file to the /tmp directory of the chroot # and executes it. local file_name=$(basename ${1}) - local subdir=${2} - local destdir=${subdir}/tmp - destdir=${destdir#/} - - copy_to_chroot ${1} ${destdir} - chroot_path=${clst_chroot_path}${subdir} - copy_to_chroot ${clst_sharedir}/targets/support/chroot-functions.sh \ - ${destdir} - echo "Running ${file_name} in chroot ${chroot_path}" - ${clst_CHROOT} ${chroot_path} ${destdir}/${file_name} || exit 1 - - delete_from_chroot ${destdir}/${file_name} - delete_from_chroot ${destdir}/chroot-functions.sh + local subdir=${2#/} + + if [ "${subdir}" != "" ] + then + copy_to_chroot ${1} ${subdir}/tmp/ + chroot_path=${clst_chroot_path}${subdir} + copy_to_chroot ${clst_sharedir}/targets/support/chroot-functions.sh \ + ${subdir}/tmp/ + echo "Running ${file_name} in chroot ${chroot_path}" + ${clst_CHROOT} ${chroot_path} /tmp/${file_name} || exit 1 + else + copy_to_chroot ${1} tmp/ + chroot_path=${clst_chroot_path} + copy_to_chroot ${clst_sharedir}/targets/support/chroot-functions.sh \ + tmp/ + echo "Running ${file_name} in chroot ${chroot_path}" + ${clst_CHROOT} ${chroot_path}/ /tmp/${file_name} || exit 1 + fi + + rm -f ${chroot_path}/tmp/${file_name} + if [ "${subdir}" != "" ] + then + delete_from_chroot ${subdir}/tmp/${file_name} + delete_from_chroot ${subdir}/tmp/chroot-functions.sh + else + delete_from_chroot tmp/chroot-functions.sh + delete_from_chroot tmp/${file_name} + fi } #return codes |