From 93862bd7cb91129cece07391c00ab9e6f81111d0 Mon Sep 17 00:00:00 2001 From: Eric Bélanger Date: Mon, 2 Nov 2009 23:31:15 -0500 Subject: makepkg: Place packages symlinks in build dir when PKGDEST is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When PKGDEST is used, symlinks to the packages will be put in the build directory. This combines the convenience of a global package cache with the ease of having a package (i.e. a symlink) in the build directory for testing and installation purpose. Signed-off-by: Eric Bélanger [Allan: add comment documenting clean-up addition] Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 1d9d8f13..b4366a56 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -148,6 +148,15 @@ clean_up() { rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package_${pkg}.log"* done fi + + # clean up dangling symlinks to packages + for pkg in ${pkgname[@]}; do + for file in ${pkg}-*-*-${CARCH}${PKGEXT}; do + if [[ -h $file && ! -e $file ]]; then + rm -f $file + fi + done + done fi fi @@ -1002,21 +1011,22 @@ create_package() { *) warning "$(gettext "'%s' is not a valid archive extension.")" \ "$PKGEXT" ; EXT=$PKGEXT ;; esac - local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${EXT}" + local tar_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${EXT}" + local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${PKGEXT}" local ret=0 # when fileglobbing, we want * in an empty directory to expand to # the null string rather than itself shopt -s nullglob - bsdtar -cf - $comp_files * > "$pkg_file" || ret=$? + bsdtar -cf - $comp_files * > "$tar_file" || ret=$? shopt -u nullglob if (( ! ret )); then case "$PKGEXT" in - *tar.gz) gzip -f -n "$pkg_file" ;; - *tar.bz2) bzip2 -f "$pkg_file" ;; - *tar.xz) xz -z -f "$pkg_file" ;; + *tar.gz) gzip -f -n "$tar_file" ;; + *tar.bz2) bzip2 -f "$tar_file" ;; + *tar.xz) xz -z -f "$tar_file" ;; esac ret=$? fi @@ -1025,6 +1035,15 @@ create_package() { error "$(gettext "Failed to create package file.")" exit 1 # TODO: error code fi + + if (( ! ret )) && [[ "$PKGDEST" != "${startdir}" ]]; then + ln -sf "${pkg_file}" "${pkg_file/$PKGDEST/$startdir}" + ret=$? + fi + + if (( ret )); then + warning "$(gettext "Failed to create symlink to package file.")" + fi } create_srcpackage() { -- cgit v1.2.3-24-g4f1b