On Tue, Nov 3, 2009 at 10:29 PM, Allan McRae <[email protected]> wrote: > Eric Bélanger wrote: >> >> On Tue, Nov 3, 2009 at 7:34 PM, Eric Bélanger <[email protected]> >> wrote: >> >>> >>> On Tue, Nov 3, 2009 at 6:46 PM, Allan McRae <[email protected]> wrote: >>> >>>> >>>> Eric Bélanger wrote: >>>> >>>>> >>>>> On Tue, Nov 3, 2009 at 8:55 AM, Eric Bélanger <[email protected]> >>>>> wrote: >>>>> >>>>> >>>>>> >>>>>> On Tue, Nov 3, 2009 at 3:13 AM, Ray Rashif <[email protected]> >>>>>> wrote: >>>>>> >>>>>> >>>>>>> >>>>>>> 2009/11/3 Eric Bélanger <[email protected]> >>>>>>> >>>>>>> This is really convenient, but would it not be good if the >>>>>>> symlink(s) are >>>>>>> removed upon --clean? >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> Sure, that can be easily done. >>>>>> >>>>>> >>>>>> >>>>> >>>>> I'm not sure if removing the symlinks if --clean is used is a good >>>>> idea after all. After a successful build, you would probably want to >>>>> have the package's symlink to be still there so you can test/install >>>>> the package. >>>>> >>>>> >>>> >>>> I agree that keeping the current symlink is good, but then do you have >>>> to >>>> remove old symlinks manually? I think this is a situation with no best >>>> answer, but removing symlinks on --clean may be the better one. >>>> >>> >>> I've haven't thought about old symlinks. I'll remove them on --clean. >>> >>> >>>> >>>> And here is another thought I just had. Do we want to error out if the >>>> symlinnk creation fails but the building of the package is successful? >>>> Or >>>> jsut print a warning? >>>> >>>> >>> >>> Maybe a warning would be better. >>> >>> >> >> I added a warning. BTW, should the tar_file and pkg_file be local >> variables? I'll submit anew patch once I get an answer. >> > > Yes they should. > > Allan >
Here's the latest patch. I hope everything is correct. BTW, do you want me to continue sending patches as attachment too? I see that 'git send-email' doesn't so I guess you can grab the inline patch or get it directly from git. Is that correct? Signed-off-by: Eric Bélanger <[email protected]> --- scripts/makepkg.sh.in | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 92b0454..aaf576b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -138,11 +138,17 @@ clean_up() { if [ -n "$pkgbase" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" if [ "$PKGFUNC" -eq 1 ]; then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" elif [ "$SPLITPKG" -eq 1 ]; then for pkg in ${pkgna...@]}; do rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" done fi fi @@ -999,21 +1005,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 -eq 0 ]; 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 @@ -1022,6 +1029,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 -ne 0 ]; then + warning "$(gettext "Failed to create symlink to package file.")" + fi } create_srcpackage() { -- 1.6.5.2
From 4de2c807e99ccca6ba939419f339db06a86e3518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20B=C3=A9langer?= <[email protected]> Date: Mon, 2 Nov 2009 23:31:15 -0500 Subject: [PATCH] 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 <[email protected]> --- scripts/makepkg.sh.in | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 92b0454..aaf576b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -138,11 +138,17 @@ clean_up() { if [ -n "$pkgbase" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" if [ "$PKGFUNC" -eq 1 ]; then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" elif [ "$SPLITPKG" -eq 1 ]; then for pkg in ${pkgna...@]}; do rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" done fi fi @@ -999,21 +1005,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 -eq 0 ]; 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 @@ -1022,6 +1029,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 -ne 0 ]; then + warning "$(gettext "Failed to create symlink to package file.")" + fi } create_srcpackage() { -- 1.6.5.2
