Last email of the day, hopefully. Here is my current diff on makepkg, not really meant to be applied in its current state but at least letting you know what I am working on and hopefully I can get some feedback out of it. I'll make a cleaner diff in a few days and hopefully this script will start to look a little better. 1. Adds --repackage option and $REPKG variable, should be noted by a comment in the code. The diff does some weird things where I had to indent a whole big block of code, so I'd recommend just trying to look at it as a whole at that part (basically the whole 'build' section). 2. Adds and removes blank lines to be more consistent, or maybe just more for my own readability. Also adds a description of makepkg. 3. Removes keepdocs and nostrip options (on the command line). 4. Removes hardcoded references to /var/cache/pacman/src. 5. Fixes a syntax warning in the architecture detection. 6. Adds a missing / in the cp statement for source file copying. 7. Lets you see my scattered/random TODOs throughout the code. -Dan --- pacman-lib.orig/scripts/makepkg 2006-12-20 21:30:06.000000000 -0500 +++ pacman-lib/scripts/makepkg 2006-12-20 22:19:46.000000000 -0500 @@ -1,6 +1,6 @@ #!/bin/bash # -# makepkg +# makepkg - make packages compatable for use with pacman # # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> # Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> @@ -44,19 +44,21 @@ FORCE=0 GENINTEG=0 INSTALL=0 -DOWNLOAD="" NOBUILD=0 NODEPS=0 NOEXTRACT=0 RMDEPS=0 +REPKG=0 LOGGING=0 PACMAN_OPTS= -INFAKEROOT= +# determine if we are running with fakeroot if [ "$1" = "-F" ]; then INFAKEROOT=1 shift +else + INFAKEROOT=0 fi ### SUBROUTINES ### @@ -68,6 +70,7 @@ echo " $1" >&2 fi } + msg() { if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2 @@ -91,6 +94,7 @@ echo "==> WARNING: $1" >&2 fi } + error() { if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2 @@ -239,6 +243,7 @@ fi missingdeps=1 fi + # rerun any additional sh scripts found in /etc/profile.d/ for i in /etc/profile.d/*.sh do @@ -246,8 +251,6 @@ . $i &>/dev/null fi done - # some applications (eg, blackbox) will not build with some languages - unset LC_ALL LANG return $missingdeps } @@ -269,18 +272,15 @@ echo " -h, --help This help" echo " -i, --install Install package after successful build" echo " -j <jobs> Set MAKEFLAGS to \"-j<jobs>\" before building" - echo " -k, --keepdocs Keep doc and info directories" echo " -L, --log Log package build process" echo " -m, --nocolor Disable colorized output messages" - echo " -n, --nostrip Do not strip symbols from binaries/libraries" echo " -o, --nobuild Download and extract files only" echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')" echo " -r, --rmdeps Remove installed dependencies after a successful build" + # fix flyspray feature request #2978 + echo " -R, --repackage Repackage contents of $startdir/pkg without building" echo " -s, --syncdeps Install missing dependencies with pacman" echo " -S, --sudosync Install missing dependencies with pacman and sudo" - # fix flyspray feature request #5223 - Dan McGee <dpmcgee@gmail.com> - echo " -t <sourcedir> Cache source files in <sourcedir>" - echo " -w <destdir> Write package to <destdir> instead of the working dir" echo echo "These options can be passed to pacman:" echo @@ -294,15 +294,12 @@ ARGLIST=$@ if [ -f /etc/makepkg.conf ]; then - source /etc/makepkg.conf + source /etc/makepkg3.conf else - error "/etc/makepkg.conf not found. cannot continue" + error "/etc/makepkg3.conf not found. Cannot continue." exit 1 fi -#Let's be courteous and support frugalware's extensions -[ -e /usr/lib/frugalware/fwmakepkg ] && . /usr/lib/frugalware/fwmakepkg - while [ "$#" -ne "0" ]; do case $1 in # pacman @@ -319,12 +316,11 @@ --noextract) NOEXTRACT=1 ;; --install) INSTALL=1 ;; --force) FORCE=1 ;; - --keepdocs) KEEPDOCS=1 ;; - --nostrip) NOSTRIP=1 ;; --nobuild) NOBUILD=1 ;; --nocolor) USE_COLOR="n" ;; --geninteg) GENINTEG=1 ;; --rmdeps) RMDEPS=1 ;; + --repackage) REPKG=1 ;; --log) LOGGING=1 ;; --help) usage @@ -335,7 +331,7 @@ exit 1 ;; -*) - while getopts "bBcCdefghij:kLmnop:rsSt:w:-" opt; do + while getopts "bBcCdefghij:Lmop:rRsS-" opt; do case $opt in b) DEP_SRC=1 ;; B) USE_CCACHE=0 ;; @@ -346,30 +342,27 @@ f) FORCE=1 ;; g) GENINTEG=1 ;; h) - usage - exit 0 - ;; + usage + exit 0 + ;; i) INSTALL=1 ;; j) export MAKEFLAGS="-j$OPTARG" ;; - k) KEEPDOCS=1 ;; L) LOGGING=1 ;; m) USE_COLOR="n" ;; - n) NOSTRIP=1 ;; o) NOBUILD=1 ;; p) BUILDSCRIPT=$OPTARG ;; r) RMDEPS=1 ;; + R) REPKG=1 ;; s) DEP_BIN=1 ;; S) DEP_SUDO=1 ;; - t) SRCDEST=$OPTARG ;; - w) PKGDEST=$OPTARG ;; -) - OPTIND=0 - break - ;; + OPTIND=0 + break + ;; *) - usage - exit 1 - ;; + usage + exit 1 + ;; esac done ;; @@ -386,6 +379,7 @@ exit 1 fi +#TODO: is this necessary? # convert a (possibly) relative path to absolute cd $PKGDEST 2>/dev/null if [ $? -ne 0 ]; then @@ -396,20 +390,18 @@ cd $OLDPWD if [ "$CLEANCACHE" = "1" ]; then + # fix flyspray feature request #5223 if [ -n "$SRCDEST" ]; then msg "Cleaning up source files from the cache." - rm -rf /var/cache/pacman/src/* - rm -rf "${SRCDEST}"/* - exit 0 - else - if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then - msg "Cleaning up source files from the cache." - rm -rf /var/cache/pacman/src/* - exit 0 - else - error "You must be root to clean the cache." + rm -rf "$SRCDEST"/* + if [ $? -ne 0 ]; then + error "Problem removing files; you may not have correct permissions in $SRCDEST" exit 1 + else + exit 0 fi + else + error "Source destination must be defined in makepkg.conf." fi fi @@ -452,7 +444,7 @@ error "pkgrel is not allowed to contain hyphens." exit 1 fi -if ! in_array $CARCH ${arch[@]}; then +if [ ! "in_array $CARCH ${arch[@]}" ]; then error "$pkgname is not available for the '$CARCH' architecture." plain "Note that many packages may need a line added to their $BUILDSCRIPT" plain "such as arch=('$CARCH')." @@ -504,7 +496,7 @@ msg "Making package: $pkgname $pkgver-$pkgrel ($(date))" unset deplist makedeplist -# fix flyspray bug #5973 - Dan McGee <dpmcgee@gmail.com> +# fix flyspray bug #5973 if [ $(type -p pacman) -a "$NODEPS" = "0" -a "$GENINTEG" = "0" -a "$NOBUILD" = "0" ]; then msg "Checking Runtime Dependencies..." deplist=$(checkdeps ${depends[@]}) @@ -524,7 +516,9 @@ if [ $? -gt 0 ]; then exit 1 fi -elif [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" ]; then +elif [ "$GENINTEG" = "1" -o "$NOBUILD" = "1" ]; then + msg "skipping dependency checks." +elif [ "$NODEPS" = "1" ]; then warning "skipping dependency checks." else warning "pacman was not found in PATH. skipping dependency checks." @@ -537,16 +531,13 @@ mkdir -p src cd $startdir/src for netfile in ${source[@]}; do - file=$(strip_url $netfile) + file=$(strip_url "$netfile") if [ -f "../$file" ]; then - msg " Found $file in build dir" + msg2 "Found $file in build dir" cp "../$file" . elif [ -f "$SRCDEST/$file" ]; then - msg " Using cached copy of $file" - cp "$SRCDEST$file" . - elif [ -f "/var/cache/pacman/src/$file" ]; then - msg " Using cached copy of $file" - cp "/var/cache/pacman/src/$file" . + msg2 "Using cached copy of $file" + cp "$SRCDEST/$file" . else # check for a download utility if [ -z "$FTPAGENT" ]; then @@ -566,33 +557,28 @@ msg "Aborting..." exit 1 fi - msg " Downloading $file" + msg2 "Downloading $file" $FTPAGENT "$netfile" 2>&1 # fix flyspray bug #3289 ftpret=$? if [ $ftpret -gt 0 ]; then error "Failure while downloading $file" msg "Aborting..." - rm "$file" - exit 1 + #rm "$file" exit 1 fi - if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then - mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src - if [ -n "$SRCDEST" ]; then - mkdir -p $SRCDEST && cp "$file" $SRCDEST - elif [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then - mkdir -p /var/cache/pacman/src && cp "$file" /var/cache/pacman/src - else + if [ -n "$SRCDEST" ]; then + mkdir -p $SRCDEST && cp "$file" $SRCDEST + if [ $? -ne 0 ]; then + warning "You do not have correct permissions to cache source in $SRCDEST" cp "$file" .. - fi + else + cp "$file" .. fi fi done - - -if [ "$NOEXTRACT" = "1" ]; then +if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then warning "Skipping source integrity checks -- using existing src/ tree" else for integ in ${INTEGRITY_CHECK[@]}; do @@ -635,7 +621,7 @@ fi done plain "" - #Validate integrity checks + #Validate integrity checks else integrity_sums=($(eval echo \${${integrity_name}s[@]})) @@ -645,6 +631,7 @@ idx=0 for netfile in "${source[@]}"; do file=$(strip_url "$netfile") + #TODO is there a reason this is echo and not msg/msg2? echo -n " $file ... " >&2 echo "${integrity_sums[$idx]} $file" | $integrity_name -c -
/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -671,8 +658,8 @@ fi
#Extract sources -if [ "$NOEXTRACT" = "1" ]; then - warning "Skipping source extraction -- using existing src/ tree" +if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then + warning "Skipping source extraction -- using existing src/ tree" else msg "Extracting Sources..." for netfile in "${source[@]}"; do @@ -699,7 +686,7 @@ cmd="bunzip2 -f $file" ;; esac if [ "$cmd" != "" ]; then - msg " $cmd" + msg2 "$cmd" $cmd if [ $? -ne 0 ]; then # unzip will return a 1 as a warning, it is not an error @@ -713,71 +700,73 @@ done fi -if [ "$EUID" = "0" ]; then - # chown all source files to root.root - chown -R root.root $startdir/src -fi - -# check for existing pkg directory -if [ -d $startdir/pkg ]; then - msg "Removing existing pkg/ directory..." - rm -rf $startdir/pkg -fi -mkdir -p $startdir/pkg - -if [ "$NOBUILD" = "1" ]; then - msg "Sources are ready." - exit 0 -fi - -# use distcc if requested -if [ "$USE_DISTCC" = "y" ]; then - [ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH -fi - -# use ccache if it's available -if [ "$USE_CCACHE" = "1" ]; then - [ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH -fi - -# build -msg "Starting build()..." +if [ "$REPKG" = "0" ]; then + if [ "$EUID" = "0" ]; then + # chown all source files to root.root + chown -R root.root $startdir/src + fi -#check for "exit on syntax error" shell option -echo $SHELLOPTS | grep errexit 2>&1 >/dev/null -set_e=$? + # check for existing pkg directory + if [ -d $startdir/pkg ]; then + msg "Removing existing pkg/ directory..." + rm -rf $startdir/pkg + fi + mkdir -p $startdir/pkg -if [ "$LOGGING" = "1" ]; then - BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log" - if [ -f "$BUILDLOG" ]; then - i=1 - while true; do - if [ -f "$BUILDLOG.$i" ]; then - i=$(($i +1)) - else - break - fi - done - mv "$BUILDLOG" "$BUILDLOG.$i" + if [ "$NOBUILD" = "1" ]; then + msg "Sources are ready." + exit 0 fi - #use 'errexit' to bail on syntax error - [ $set_e -eq 1 ] && set -e - build 2>&1 | tee "$BUILDLOG" - [ $set_e -eq 1 ] && set +e + # use distcc if requested + if [ "$USE_DISTCC" = "y" ]; then + [ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH + fi + + # use ccache if it's available + if [ "x$USE_CCACHE" = "1" ]; then + [ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH + fi + + # build + msg "Starting build()..." + + #check for "exit on syntax error" shell option + echo $SHELLOPTS | grep errexit 2>&1 >/dev/null + set_e=$? + + if [ "x$LOGGING" = "1" ]; then + BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log" + if [ -f "$BUILDLOG" ]; then + i=1 + while true; do + if [ -f "$BUILDLOG.$i" ]; then + i=$( ($i +1)) + else + break + fi + done + mv "$BUILDLOG" "$BUILDLOG.$i" + fi - if [ ${PIPESTATUS[0]} -gt 0 ]; then - error "Build Failed. Aborting..." - exit 2 - fi -else - #use 'errexit' to bail on syntax error - [ $set_e -eq 1 ] && set -e - build 2>&1 - [ $set_e -eq 1 ] && set +e - if [ $? -gt 0 ]; then - error "Build Failed. Aborting..." - exit 2 + #use 'errexit' to bail on syntax error + [ $set_e -eq 1 ] && set -e + build 2>&1 | tee "$BUILDLOG" + [ $set_e -eq 1 ] && set +e + + if [ ${PIPESTATUS[0]} -gt 0 ]; then + error "Build Failed. Aborting..." + exit 2 + fi + else + #use 'errexit' to bail on syntax error + [ $set_e -eq 1 ] && set -e + build 2>&1 + [ $set_e -eq 1 ] && set +e + if [ $? -gt 0 ]; then + error "Build Failed. Aborting..." + exit 2 + fi fi fi @@ -788,6 +777,8 @@ rm -rf pkg/usr/info pkg/usr/share/info rm -rf pkg/usr/doc pkg/usr/share/doc rm -rf pkg/{usr,opt/gnome}/share/gtk-doc + # fix flyspray bug #5021 + #rm -rf ${DOC_DIRS[@]} fi # move /usr/share/man files to /usr/man