[pacman-dev] [PATCH] Compress manpages only after checking for $srcdir and $pkgdir
Move the manpage compression code from tidy_install to create_package. Since tidy_install could remove a backup file, it should go before check_package. Alternatively, we could move all the code from tidy_install into create_package since those two are always called together. Fixes FS#33318. Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- scripts/makepkg.sh.in | 58 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index ebc24f7..be433ad 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1497,34 +1497,6 @@ tidy_install() { done fi - if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then - msg2 "$(gettext "Compressing man and info pages...")" - local file files inode link - while read -rd ' ' inode; do - read file - find ${MAN_DIRS[@]} -type l 2>/dev/null | - while read link ; do - if [[ "${file}" -ef "${link}" ]] ; then - rm -f "$link" "${link}.gz" - if [[ ${file%/*} = ${link%/*} ]]; then - ln -s -- "${file##*/}.gz" "${link}.gz" - else - ln -s -- "/${file}.gz" "${link}.gz" - fi - fi - done - if [[ -z ${files[$inode]} ]]; then - files[$inode]=$file - gzip -9 -n -f "$file" - else - rm -f "$file" - ln "${files[$inode]}.gz" "${file}.gz" - chmod 644 "${file}.gz" - fi - done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \ - -exec @INODECMD@ '{}' + 2>/dev/null) - fi - if check_option "strip" "y"; then msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")" # make sure library stripping variables are defined to prevent excess stripping @@ -1786,6 +1758,36 @@ create_package() { check_package cd_safe "$pkgdir" + + # compress manpages + if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then + msg2 "$(gettext "Compressing man and info pages...")" + local file files inode link + while read -rd ' ' inode; do + read file + find ${MAN_DIRS[@]} -type l 2>/dev/null | + while read link ; do + if [[ "${file}" -ef "${link}" ]] ; then + rm -f "$link" "${link}.gz" + if [[ ${file%/*} = ${link%/*} ]]; then + ln -s -- "${file##*/}.gz" "${link}.gz" + else + ln -s -- "/${file}.gz" "${link}.gz" + fi + fi + done + if [[ -z ${files[$inode]} ]]; then + files[$inode]=$file + gzip -9 -n -f "$file" + else + rm -f "$file" + ln "${files[$inode]}.gz" "${file}.gz" + chmod 644 "${file}.gz" + fi + done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \ + -exec @INODECMD@ '{}' + 2>/dev/null) + fi + msg "$(gettext "Creating package \"%s\"...")" "$pkgname" pkgarch=$(get_pkg_arch) -- 1.8.1
On 11/01/13 13:00, Chirantan Ekbote wrote:
Move the manpage compression code from tidy_install to create_package. Since tidy_install could remove a backup file, it should go before check_package. Alternatively, we could move all the code from tidy_install into create_package since those two are always called together.
Fixes FS#33318.
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> ---
I definitely do not want this in create_package. What I would like to see is tidy_install rearranged with check_install added in. So tidy_install should do: removal operations - docs - purge - libtool - emptydirs check for missing backup files grep for srcdir/pkgdir zipman strip upx Eventually we should just move this all into some sort of modular hooklike format like: 10-docs 20-purge ... but we need to be set-up for makepkg splitting first...
From: Chirantan Ekbote <chirantan.ekbote@gmail.com> Rearrange tidy_install so we first remove docs, unwanted files, libtool files, and empty directories. Then check for missing backup files and references to $srcdir and $pkgdir. Finally compress manpages, strip debug symbols, and compress executables with upx. Fixes FS33318 Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- scripts/makepkg.sh.in | 59 +++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dcd920d..bcc415b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1497,6 +1497,32 @@ tidy_install() { done fi + if check_option "libtool" "n"; then + msg2 "$(gettext "Removing "%s" files...")" "libtool" + find . ! -type d -name "*.la" -exec rm -f -- '{}' \; + fi + + if check_option "emptydirs" "n"; then + msg2 "$(gettext "Removing empty directories...")" + find . -depth -type d -exec rmdir '{}' + 2>/dev/null + fi + + # check existence of backup files + local file + for file in "${backup[@]}"; do + if [[ ! -f $file ]]; then + warning "$(gettext "%s entry file not in package : %s")" "backup" "$file" + fi + done + + # check for references to the build and package directory + if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then + warning "$(gettext "Package contains reference to %s")" "\$srcdir" + fi + if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdir}" ; then + warning "$(gettext "Package contains reference to %s")" "\$pkgdir" + fi + if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then msg2 "$(gettext "Compressing man and info pages...")" local file files inode link @@ -1552,16 +1578,6 @@ tidy_install() { done fi - if check_option "libtool" "n"; then - msg2 "$(gettext "Removing "%s" files...")" "libtool" - find . ! -type d -name "*.la" -exec rm -f -- '{}' \; - fi - - if check_option "emptydirs" "n"; then - msg2 "$(gettext "Removing empty directories...")" - find . -depth -type d -exec rmdir '{}' + 2>/dev/null - fi - if check_option "upx" "y"; then msg2 "$(gettext "Compressing binaries with %s...")" "UPX" local binary @@ -1753,27 +1769,6 @@ write_pkginfo() { check_license } -check_package() { - cd_safe "$pkgdir" - - # check existence of backup files - local file - for file in "${backup[@]}"; do - if [[ ! -f $file ]]; then - warning "$(gettext "%s entry file not in package : %s")" "backup" "$file" - fi - done - - # check for references to the build and package directory - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then - warning "$(gettext "Package contains reference to %s")" "\$srcdir" - fi - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdir}" ; then - warning "$(gettext "Package contains reference to %s")" "\$pkgdir" - fi - -} - create_package() { if [[ ! -d $pkgdir ]]; then error "$(gettext "Missing %s directory.")" "pkg/" @@ -1781,8 +1776,6 @@ create_package() { exit 1 # $E_MISSING_PKGDIR fi - check_package - cd_safe "$pkgdir" msg "$(gettext "Creating package \"%s\"...")" "$pkgname" -- 1.8.1.1
On 29/01/13 12:14, chirantan.ekbote@gmail.com wrote:
From: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Rearrange tidy_install so we first remove docs, unwanted files, libtool files, and empty directories. Then check for missing backup files and references to $srcdir and $pkgdir. Finally compress manpages, strip debug symbols, and compress executables with upx.
Fixes FS33318
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> ---
Looks good. Allan
On Mon, Jan 28, 2013 at 8:49 PM, Allan McRae <allan@archlinux.org> wrote:
On 29/01/13 12:14, chirantan.ekbote@gmail.com wrote:
From: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Rearrange tidy_install so we first remove docs, unwanted files, libtool files, and empty directories. Then check for missing backup files and references to $srcdir and $pkgdir. Finally compress manpages, strip debug symbols, and compress executables with upx.
Fixes FS33318
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> ---
Looks good.
FS#xxx would look better than FSxxx, but too late. No auto-linking in the commit message on cgit (https://projects.archlinux.org/pacman.git/commit/?id=266b3dd706) unless you prefix it like that. (For a good example, see https://projects.archlinux.org/pacman.git/commit/?id=27067b1372) -Dan
On Mon, Jan 28, 2013 at 10:46 PM, Dan McGee <dpmcgee@gmail.com> wrote:
On Mon, Jan 28, 2013 at 8:49 PM, Allan McRae <allan@archlinux.org> wrote:
On 29/01/13 12:14, chirantan.ekbote@gmail.com wrote:
From: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Rearrange tidy_install so we first remove docs, unwanted files, libtool files, and empty directories. Then check for missing backup files and references to $srcdir and $pkgdir. Finally compress manpages, strip debug symbols, and compress executables with upx.
Fixes FS33318
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> ---
Looks good.
FS#xxx would look better than FSxxx, but too late. No auto-linking in the commit message on cgit (https://projects.archlinux.org/pacman.git/commit/?id=266b3dd706) unless you prefix it like that. (For a good example, see https://projects.archlinux.org/pacman.git/commit/?id=27067b1372)
-Dan
Thanks, I'll remember that for the next one :-) +chirantan
participants (4)
-
Allan McRae
-
Chirantan Ekbote
-
chirantan.ekbote@gmail.com
-
Dan McGee