On Wed, Nov 4, 2009 at 2:37 AM, Eric Bélanger <snowmaniscool@gmail.com> wrote:
On Wed, Nov 4, 2009 at 1:45 AM, Allan McRae <allan@archlinux.org> wrote:
Eric Bélanger wrote:
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?
The way I handle this is to just send them directly with git send-email using the "In reply to" value to keep the thread... um... threaded. Any comments about the patch and what you have changed to fix things can go under the "---" after the sign-off. Of course, you can inline them as you have and push them to a git repo somewhere and we can just pull from there.
OK. I'll do that. I was inlining them manually to keep everything in the same thread.
Also, can you insert newlines into you commit message to keep them at about 80 characters per line.
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com> --- 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 ${pkgname[@]}; do rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + [[ "$PKGDEST" != "${startdir}" ]] \ + && rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" done fi fi
I am not happy with this way of cleaning up the symlinks to packages. If the package is not a split package, then the package name will be $pkgname-... and not $pkgbase (although, they are likely the same thing).
I was following (maybe too closely) the log files removal as template here. I'll change it to pkgname.
I am also not sure what the second clean-up (in the "$PKGFUNC -eq 1" test) is doing that has not already by the one above it.
Yeah, it probably can be removed.
However, thinking about this more, we do not remove old packages when using --clean so why remove symlinks to old packages. Only when package symlinks are pointing to packages that no longer exist in PKGDEST have we made a mess that needs cleaned up. So how about something like:
for pkg in ${pkgname[@]}; do for file in ${pkg}-*-*-${CARCH}${PKGEXT}; do if [[ -h $file & ! -e $file ]]; then rm -f $file fi done fi
Sure. I'll use this instead. I don't use the --clean option so I am indifferent. I'll send a new patch tomorrow.
Eric
Everything else in the patch is fine.
Allan
Here's the new patch. I struggled getting git to work so hopefully it's OK. BTW, the 'git send-email' --in-reply-to option asks for an identifier. I can't seem to find it in the patches or email headers in gmail. Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com> --- scripts/makepkg.sh.in | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 92b0454..02ebf16 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -145,6 +145,14 @@ clean_up() { rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"* done fi + + 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 @@ -999,21 +1007,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 +1031,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