From ec244eb8edbb741014701fa6459a4ce66c9120ae Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 05:47:11 -0500 Subject: [PATCH 1/6] Add the --noinstall and --repo flags --- packer | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packer b/packer index e35f87b..1b67a48 100644 --- a/packer +++ b/packer @@ -7,6 +7,9 @@ tmpdir="${TMPDIR:-/tmp}/packertmp-$UID" rm -rf "$tmpdir" &>/dev/null mkdir -p "$tmpdir" +# save current dir for built packages +outdir=$(pwd) + makepkgconf='/etc/makepkg.conf' usermakepkgconf="$HOME/.makepkg.conf" pacmanconf='/etc/pacman.conf' @@ -54,6 +57,8 @@ usage() { echo ' --auronly - only do actions for aur' echo ' --devel - update devel packages during -Su' echo ' --skipinteg - when using makepkg, do not check md5s' + echo ' --noinstall - build but do not install any aur packages' + echo ' --repo - takes the filename of a local repository to update' echo ' -h - outputs this message' exit } @@ -287,15 +292,20 @@ aurinstall() { . PKGBUILD confirm_edit "${COLOR6}Edit $install with \$EDITOR? [Y/n]${ENDCOLOR} " "$install" - # Installation (makepkg and pacman) + # Build if [[ $UID -eq 0 ]]; then makepkg $MAKEPKGOPTS --asroot -f else makepkg $MAKEPKGOPTS -f fi - [[ $? -ne 0 ]] && echo "The build failed." && return 1 - if [[ $2 = dependency ]]; then + + # Install + if [[ $noinstall ]]; then + cp $pkgname-*$PKGEXT "$outdir" + elif [[ $repofile ]]; then + repo-add "$repofile" $pkgname-*$PKGEXT + elif [[ $2 = dependency ]]; then runasroot pacman ${PACOPTS[@]} --asdeps -U $pkgname-*$PKGEXT elif [[ $2 = explicit ]]; then runasroot pacman ${PACOPTS[@]} -U $pkgname-*$PKGEXT @@ -401,7 +411,7 @@ installhandling() { fi # Install aur dependencies - if [[ $aurdepends ]]; then + if [[ $aurdepends && ! $noinstall ]]; then for dep in "${aurdepends[@]}"; do aurinstall "$dep" "dependency" done @@ -454,6 +464,8 @@ while [[ $1 ]]; do '--auronly') auronly='1' ;; '--devel') devel='1' ;; '--skipinteg') MAKEPKGOPTS="--skipinteg" ;; + '--noinstall') noinstall='1' ;; + '--repo') repofile=$(readlink -m "$2") ; shift ;; '--') shift ; packageargs+=("$@") ; break ;; -*) echo "packer: Option \`$1' is not valid." ; exit 5 ;; *) packageargs+=("$1") ;; @@ -483,7 +495,17 @@ if [[ $option = update ]]; then # Aur update echo -e "${COLOR5}:: ${COLOR1}Synchronizing aur database...${ENDCOLOR}" IFS=$'\n' - packages=( $(pacman -Qm) ) + packages=() + if [[ $repofile ]]; then + repodescs=( $(tar tzf $repofile | grep -e "/desc$") ) + for repodesc in "${repodescs[@]}"; do + pkg=$(tar xzOf "$repofile" "$repodesc" | awk '/^%NAME%$/ { getline; print $0 }') + ver=$(tar xzOf "$repofile" "$repodesc" | awk '/^%VERSION%$/ { getline; print $0 }') + packages+=( "$pkg $ver" ) + done + else + packages+=( $(pacman -Qm) ) + fi newpackages=() checkignores=() total="${#packages[@]}" From a70fae09d2bfa2e3245303c1e71c0002c5c43d1a Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 06:21:03 -0500 Subject: [PATCH 2/6] Don't warn about up to date packages when using a local repo --- packer | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packer b/packer index 1b67a48..f9439a4 100644 --- a/packer +++ b/packer @@ -367,14 +367,16 @@ installhandling() { exit fi # Test if aurpackages are already installed; echo warning if so - for pkg in "${aurtargets[@]}"; do - if existsinlocal "$pkg"; then - localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)" - if ! aurversionisnewer "$pkg" "$localversion"; then - echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling" + if ! [[ $repofile ]]; then + for pkg in "${aurtargets[@]}"; do + if existsinlocal "$pkg"; then + localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)" + if ! aurversionisnewer "$pkg" "$localversion"; then + echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling" + fi fi - fi - done + done + fi # Echo warning if packages are out of date for pkg in "${aurtargets[@]}" "${aurdepends[@]}"; do From e2b5c0b994c26a04055de6f34f2f58651231ced9 Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 06:27:35 -0500 Subject: [PATCH 3/6] Oops, copy packages to the directory alongside local repos --- packer | 1 + 1 file changed, 1 insertion(+) diff --git a/packer b/packer index f9439a4..34b05ac 100644 --- a/packer +++ b/packer @@ -305,6 +305,7 @@ aurinstall() { cp $pkgname-*$PKGEXT "$outdir" elif [[ $repofile ]]; then repo-add "$repofile" $pkgname-*$PKGEXT + cp $pkgname-*$PKGEXT "$(dirname '$repofile')" elif [[ $2 = dependency ]]; then runasroot pacman ${PACOPTS[@]} --asdeps -U $pkgname-*$PKGEXT elif [[ $2 = explicit ]]; then From 80010a57925ded7f23a7e9a3ec769b5d694e8e84 Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 06:32:24 -0500 Subject: [PATCH 4/6] --repo should imply --auronly --- packer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packer b/packer index 34b05ac..0fc8b2e 100644 --- a/packer +++ b/packer @@ -305,7 +305,7 @@ aurinstall() { cp $pkgname-*$PKGEXT "$outdir" elif [[ $repofile ]]; then repo-add "$repofile" $pkgname-*$PKGEXT - cp $pkgname-*$PKGEXT "$(dirname '$repofile')" + cp $pkgname-*$PKGEXT "$(dirname "$repofile")" elif [[ $2 = dependency ]]; then runasroot pacman ${PACOPTS[@]} --asdeps -U $pkgname-*$PKGEXT elif [[ $2 = explicit ]]; then @@ -468,7 +468,7 @@ while [[ $1 ]]; do '--devel') devel='1' ;; '--skipinteg') MAKEPKGOPTS="--skipinteg" ;; '--noinstall') noinstall='1' ;; - '--repo') repofile=$(readlink -m "$2") ; shift ;; + '--repo') repofile=$(readlink -m "$2") ; auronly='1' ; shift ;; '--') shift ; packageargs+=("$@") ; break ;; -*) echo "packer: Option \`$1' is not valid." ; exit 5 ;; *) packageargs+=("$1") ;; From 33f932c8cb969adb83b7e7b88c393458488c5ca1 Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 06:47:46 -0500 Subject: [PATCH 5/6] Remove the --noinstall flag --- packer | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packer b/packer index 0fc8b2e..07adcc8 100644 --- a/packer +++ b/packer @@ -7,9 +7,6 @@ tmpdir="${TMPDIR:-/tmp}/packertmp-$UID" rm -rf "$tmpdir" &>/dev/null mkdir -p "$tmpdir" -# save current dir for built packages -outdir=$(pwd) - makepkgconf='/etc/makepkg.conf' usermakepkgconf="$HOME/.makepkg.conf" pacmanconf='/etc/pacman.conf' @@ -57,8 +54,7 @@ usage() { echo ' --auronly - only do actions for aur' echo ' --devel - update devel packages during -Su' echo ' --skipinteg - when using makepkg, do not check md5s' - echo ' --noinstall - build but do not install any aur packages' - echo ' --repo - takes the filename of a local repository to update' + echo ' --repo - specify a local repository to update' echo ' -h - outputs this message' exit } @@ -301,9 +297,7 @@ aurinstall() { [[ $? -ne 0 ]] && echo "The build failed." && return 1 # Install - if [[ $noinstall ]]; then - cp $pkgname-*$PKGEXT "$outdir" - elif [[ $repofile ]]; then + if [[ $repofile ]]; then repo-add "$repofile" $pkgname-*$PKGEXT cp $pkgname-*$PKGEXT "$(dirname "$repofile")" elif [[ $2 = dependency ]]; then @@ -414,7 +408,7 @@ installhandling() { fi # Install aur dependencies - if [[ $aurdepends && ! $noinstall ]]; then + if [[ $aurdepends ]]; then for dep in "${aurdepends[@]}"; do aurinstall "$dep" "dependency" done @@ -467,7 +461,6 @@ while [[ $1 ]]; do '--auronly') auronly='1' ;; '--devel') devel='1' ;; '--skipinteg') MAKEPKGOPTS="--skipinteg" ;; - '--noinstall') noinstall='1' ;; '--repo') repofile=$(readlink -m "$2") ; auronly='1' ; shift ;; '--') shift ; packageargs+=("$@") ; break ;; -*) echo "packer: Option \`$1' is not valid." ; exit 5 ;; From 9b9284d74dad5a71be3fcfb7797b7cc5dafc5d20 Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Mon, 30 Jan 2012 08:13:00 -0500 Subject: [PATCH 6/6] Don't create files where directories should be with cp --- packer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer b/packer index 07adcc8..665c2fe 100644 --- a/packer +++ b/packer @@ -298,8 +298,8 @@ aurinstall() { # Install if [[ $repofile ]]; then + cp -t "$(dirname "$repofile")" $pkgname-*$PKGEXT repo-add "$repofile" $pkgname-*$PKGEXT - cp $pkgname-*$PKGEXT "$(dirname "$repofile")" elif [[ $2 = dependency ]]; then runasroot pacman ${PACOPTS[@]} --asdeps -U $pkgname-*$PKGEXT elif [[ $2 = explicit ]]; then