From b27597d40ab29bc880c8607858343f27e1dc8bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Thu, 16 Feb 2012 11:23:25 -0600 Subject: update-cleansystem: doesn't show erros of not avaliable db on tempdir --- update-cleansystem | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-cleansystem b/update-cleansystem index dd3ff6c..97c2922 100755 --- a/update-cleansystem +++ b/update-cleansystem @@ -15,7 +15,7 @@ tmpdir=/tmp/cleansystem.${RANDOM} mkdir -p ${tmpdir}/var/lib/pacman # We sync first because updating info gets printed to stdout too -pacman -r ${tmpdir} --config /etc/pacman.conf -Sy +pacman -r ${tmpdir} --config /etc/pacman.conf -Sy 2>/dev/null pacman -r ${tmpdir} \ --config /etc/pacman.conf \ -Sp --print-format "%n" \ -- cgit v1.2.3-2-g168b From b0f34edcb6a7ef1a6a96423b12994943b90af5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Thu, 16 Feb 2012 11:44:44 -0600 Subject: toru-utils: trap shows name of $0 --- fullpkg | 1 + toru-utils | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fullpkg b/fullpkg index bccd816..9a03b82 100755 --- a/fullpkg +++ b/fullpkg @@ -15,6 +15,7 @@ usage() { echo " -h : this message." echo "" echo "Wrapper for \`fullpkg-find' and \`fullpkg-build'" + echo "" exit 1 } diff --git a/toru-utils b/toru-utils index bb0aef4..7e6d62d 100755 --- a/toru-utils +++ b/toru-utils @@ -7,7 +7,7 @@ source /etc/libretools.conf if [ ! -w "$TORUPATH" ]; then error "Toru's path isn't writable. Please check $TORUPATH" - exit 1 + exit 1 fi LASTSYNCFILE=${TORUPATH}/lastsync @@ -81,6 +81,6 @@ trap_exit() { # Trap signals from makepkg set -E -trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "(prfullpkg:${level}) Aborted by user! Exiting..."' INT -trap 'trap_exit "(prfullpkg:${level}) An unknown error has occurred. Exiting..."' ERR +trap 'trap_exit "($(basename $0):${level}) TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "($(basename $0):${level}) Aborted by user! Exiting..."' INT +trap 'trap_exit "($(basename $0):${level}) An unknown error has occurred. Exiting..."' ERR -- cgit v1.2.3-2-g168b From ff089d0a64dbf280c73e2ad6b11f82d015e229bd Mon Sep 17 00:00:00 2001 From: "Joshua I. Haase H. (xihh)" Date: Mon, 4 Jun 2012 19:45:21 -0500 Subject: fix https://labs.parabola.nu/issues/30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fullpkg-find: - «copy_files» function added - removed «circular deps» unused code --- fullpkg-find | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/fullpkg-find b/fullpkg-find index 64c1790..2f3aaaa 100755 --- a/fullpkg-find +++ b/fullpkg-find @@ -31,6 +31,36 @@ get_fullver() { } +copy_files() { + + local copydir="$build_dir/${pkgbase:-${pkgname[0]}}" + mkdir -p "$copydir" + + # Copy PKGBUILD and sources + cp PKGBUILD "$copydir" + ( + source PKGBUILD + for file in "${source[@]}"; do + file="${file%%::*}" + file="${file##*://*/}" + if [[ -f $file ]]; then + cp "$file" "$copydir/" + elif [[ -f $SRCDEST/$file ]]; then + cp "$SRCDEST/$file" "$copydir/" + fi + done + + # Find all changelog and install files, even inside functions + for i in 'changelog' 'install'; do + while read -r file; do + # evaluate any bash variables used + eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\" + [[ -f $file ]] && cp "$file" "$copydir" + done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) + done + ) +} + # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. find_deps() { # Check this level @@ -63,7 +93,7 @@ find_deps() { exit 0 # Copy dir to build_dir else - cp -r ../${pkgbase}/ ${build_dir}/ + copy_files # to identify repo later echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" @@ -87,7 +117,7 @@ find_deps() { # TODO change for where_is or toru-path # May fail, e.g. since abslibre-mips64el doesn't include # arch=any packages. - local pkgdir=$(toru -p ${_dep}) || true + local pkgdir=$(where_is ${_dep}) || true if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then found=true @@ -133,7 +163,7 @@ usage() { echo "" echo "OPTIONS:" echo " -h : this message." -# echo " -A : use this ABSROOT." # Is it needed anymore? + echo " -A : use this ABSROOT." echo " -c : clean before working." echo " -m : check deps until this level" echo " -n : don't update pacman db." @@ -145,7 +175,7 @@ usage() { while getopts 'hA:l:cmn' arg; do case "$arg" in h) usage ;; -# A) ABSROOT="$OPTARG" ;; + A) ABSROOT="$OPTARG" ;; l) LEVEL="$OPTARG" ;; # hidden option to know dep level. c) CLEANFIRST='true' ;; m) MAXLEVEL="$OPTARG" ;; @@ -185,18 +215,7 @@ if [ "$LEVEL" -eq 0 ]; then msg "Checking dependencies" fi -# Probable circular deps -[ "$LEVEL" -gt "$MAXLEVEL" ] && exit 20 - # Find the dependencies on the ABS itself -find_deps || { - -# Probable circular deps - if [ "$?" -eq 20 -a "$LEVEL" -eq 0 ]; then - error "Check for circular deps on $build_dir/BUILDORDER"; - fi -# Pass message 20 - exit 20 -} +find_deps exit 0 -- cgit v1.2.3-2-g168b From ee40153178ec333278cc4aa422c5b237af6d858d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Thu, 7 Jun 2012 14:32:28 -0300 Subject: Get the last path, not the first one (fixes not found on repo change) --- treepkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/treepkg b/treepkg index d21377d..8dab83a 100755 --- a/treepkg +++ b/treepkg @@ -85,7 +85,8 @@ bury() { # Look in all caches but pick the first one # TODO move to a toru flag (-p?) where_is() { - grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ + grep "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ + tail -n1 2>/dev/null|\ cut -d: -f2 2>/dev/null } -- cgit v1.2.3-2-g168b From b612a89c220b722cfd8ac2e51be146eec94a20e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mas=C5=82owski?= Date: Fri, 8 Jun 2012 16:36:48 +0200 Subject: fullpkg-find: Use toru -p, fix not finding any dependencies. --- fullpkg-find | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fullpkg-find b/fullpkg-find index 2f3aaaa..e188ec8 100755 --- a/fullpkg-find +++ b/fullpkg-find @@ -11,14 +11,6 @@ guess_repo() { basename $(dirname $(pwd)) } -# Finds a PKGBUILD on toru's path cache -# Look in all caches but pick the first one -# TODO move to a toru flag (-p?) -where_is() { - grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ - cut -d: -f2 2>/dev/null -} - # return : full version spec, including epoch (if necessary), pkgver, pkgrel # usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) get_fullver() { @@ -114,10 +106,9 @@ find_deps() { for _dep in ${deps[@]}; do local found=false -# TODO change for where_is or toru-path # May fail, e.g. since abslibre-mips64el doesn't include # arch=any packages. - local pkgdir=$(where_is ${_dep}) || true + local pkgdir=$(toru -p ${_dep}) || true if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then found=true -- cgit v1.2.3-2-g168b From e45761f4049a7732242aa9572e3f6d87e60d391c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 4 Aug 2012 14:13:31 -0300 Subject: Be more helpful --- librerelease | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librerelease b/librerelease index c113572..a03ea98 100755 --- a/librerelease +++ b/librerelease @@ -116,7 +116,7 @@ clean_non_packages if [ ! -z "${SIGID}" ]; then sign_packages else - error "Package signing is *required*" + error "Package signing is *required*, please set SIGID on your libretools.conf" exit 1 fi -- cgit v1.2.3-2-g168b From 7e50ae7becc4ee9b89664a8ec4eca4193cc74482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 4 Aug 2012 14:16:53 -0300 Subject: Only remove synced files, avoids removing packages added by librestage during sync --- librerelease | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/librerelease b/librerelease index a03ea98..82a6ab4 100755 --- a/librerelease +++ b/librerelease @@ -91,7 +91,7 @@ function clean_non_packages { # Clean everything if not on dry-run mode function clean { [ -z ${dryrun} ] && \ - find ${WORKDIR}/staging/ -type f -delete + rm -f $@ } if [ -w / ]; then @@ -126,6 +126,9 @@ fi find ${WORKDIR}/staging -type f -exec chmod 644 {} \; find ${WORKDIR}/staging -type d -exec chmod 755 {} \; +# Get the synced files +SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) + msg "Uploading packages..." rsync --recursive \ ${dryrun} \ @@ -144,8 +147,8 @@ rsync --recursive \ exit 1 } -msg "Removing packages from local [staging]" -clean +msg "Removing ${#SYNCED_FILES[@]} packages from local [staging]" +clean ${SYNCED_FILES[@]} msg "Running db-update on repos" ssh ${PARABOLAHOST} dbscripts/db-update -- cgit v1.2.3-2-g168b From 660b32b7bb06d80e81ae7da41efde6f80fd073d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 4 Aug 2012 14:18:50 -0300 Subject: Actually resign when signature failed --- librerelease | 2 -- 1 file changed, 2 deletions(-) diff --git a/librerelease b/librerelease index 82a6ab4..3820a12 100755 --- a/librerelease +++ b/librerelease @@ -66,8 +66,6 @@ function sign_packages { if ! gpg --quiet --verify "${package}${SIGEXT}" >/dev/null 2>&1; then error "Failed! Resigning..." rm -f "${package}${SIGEXT}" - else - continue fi fi -- cgit v1.2.3-2-g168b From 0a7e0e2866dd5a3b8c794b1aefcec58c15cbe9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Fri, 10 Aug 2012 14:40:31 -0300 Subject: Not all removed files are packages --- librerelease | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librerelease b/librerelease index 3820a12..c4d97c1 100755 --- a/librerelease +++ b/librerelease @@ -145,7 +145,7 @@ rsync --recursive \ exit 1 } -msg "Removing ${#SYNCED_FILES[@]} packages from local [staging]" +msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" clean ${SYNCED_FILES[@]} msg "Running db-update on repos" -- cgit v1.2.3-2-g168b From fe138085ad889447942f03b969f1a3abb862cb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 15 Aug 2012 15:25:59 -0300 Subject: Toru-where is an utility to find PKGBUILD dirs on toru's path cache Use with toru-path --- toru-path | 5 +++++ toru-utils | 5 ----- toru-where | 11 +++++++++++ treepkg | 13 ++----------- 4 files changed, 18 insertions(+), 16 deletions(-) create mode 100755 toru-where diff --git a/toru-path b/toru-path index 5065a30..9bfc3ff 100755 --- a/toru-path +++ b/toru-path @@ -2,6 +2,11 @@ source $(dirname $(command -v $0))/toru-utils +if [ ! -w "$TORUPATH" ]; then + error "Toru's path isn't writable. Please check $TORUPATH" + exit 1 +fi + LASTSYNCFILE=${TORUPATH}/lastsync.paths # TODO pass other paths via flags diff --git a/toru-utils b/toru-utils index 0818aa6..c0918ae 100755 --- a/toru-utils +++ b/toru-utils @@ -5,11 +5,6 @@ source /etc/abs.conf source /etc/libretools.conf -if [ ! -w "$TORUPATH" ]; then - error "Toru's path isn't writable. Please check $TORUPATH" - exit 1 -fi - LASTSYNCFILE=${TORUPATH}/lastsync FORCE=false QUIET=false diff --git a/toru-where b/toru-where new file mode 100755 index 0000000..02a7a88 --- /dev/null +++ b/toru-where @@ -0,0 +1,11 @@ +#!/bin/bash +# Locates a PKGBUILD dir on toru's path cache + +source $(dirname $(command -v $0))/toru-utils + +# Look in all cached but pick the last one +grep "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ + tail -n1 2>/dev/null|\ + cut -d: -f2 2>/dev/null + +exit $? diff --git a/treepkg b/treepkg index 8dab83a..fcb9d29 100755 --- a/treepkg +++ b/treepkg @@ -81,17 +81,8 @@ bury() { } || return 1 } -# Finds a PKGBUILD on toru's path cache -# Look in all caches but pick the first one -# TODO move to a toru flag (-p?) -where_is() { - grep "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ - tail -n1 2>/dev/null|\ - cut -d: -f2 2>/dev/null -} - # Guess the repo from the pkgbase path -# $1 path, pwd or where_is +# $1 path, pwd or toru-where guess_repo() { basename "$(dirname "${1}")" } @@ -176,7 +167,7 @@ if ! ${BUILDNOW}; then egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} # Ask toru where's a PKGBUILD - depdir="$(where_is ${_dep})" + depdir="$(toru-where ${_dep})" if [ -z "${depdir}" -o ! -d "${depdir}" ]; then # We specify the pkgname because we can't source the dep PKGBUILD -- cgit v1.2.3-2-g168b From b3b52d5c4a3cbcdeb505b099230107b830290e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 15 Aug 2012 15:28:35 -0300 Subject: TODO was implemented already --- treepkg | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/treepkg b/treepkg index fcb9d29..00ec0e0 100755 --- a/treepkg +++ b/treepkg @@ -157,13 +157,10 @@ if ! ${BUILDNOW}; then # NOTE: getting depends from package() is a PITA for _dep in ${deps[@]}; do -# Ignore if already in build order -# TODO move deps deeper in the tree if +# Move deps deeper in the tree if # pkgbase - dep1 # \ dep2 - dep1 # dep1 should be depth + 1 -# probably sed -i buildorder and increase dep's dep depth :D -# remember to change dir name from xxx_pkgbase to xxx+1_pkgbase egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} # Ask toru where's a PKGBUILD -- cgit v1.2.3-2-g168b From f49a63724e56c11c5ee89561f573fff1b1d56506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 00:20:15 -0300 Subject: Skip already built packages --- treepkg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/treepkg b/treepkg index 00ec0e0..8a243e4 100755 --- a/treepkg +++ b/treepkg @@ -194,6 +194,8 @@ if [ ${DEPTH} -eq 0 ]; then for _pkg in $(ls -r "${BUILDDIR}"); do # Ignore if there's no PKGBUILD if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi +# Skip if already built (faster than calling is_build again) + if [ -f built_ok ]; then continue; fi ${VERBOSE} && msg "Building ${_pkg/_/ }" || true @@ -204,6 +206,8 @@ if [ ${DEPTH} -eq 0 ]; then ${FULLBUILDCMD} # Run local release hook with $1 = $repo ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) + + touch built_ok popd >/dev/null done -- cgit v1.2.3-2-g168b From d469036a9fe5a849060159383be2ff6249c51a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:21:42 -0300 Subject: Keep the synced database on a permanent dir --- update-cleansystem | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/update-cleansystem b/update-cleansystem index 97c2922..b55e882 100755 --- a/update-cleansystem +++ b/update-cleansystem @@ -3,20 +3,21 @@ # Creates a fake Parabola root and prints all packages installable from base # and base-devel plus extras -set -E +set -e if [ ! -w / ]; then echo "Run as root." exit 1 fi -tmpdir=/tmp/cleansystem.${RANDOM} +# Maintain a clean database in the system +db_dir="${DB:-/var/lib/libretools/clean}" -mkdir -p ${tmpdir}/var/lib/pacman +[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}" # We sync first because updating info gets printed to stdout too -pacman -r ${tmpdir} --config /etc/pacman.conf -Sy 2>/dev/null -pacman -r ${tmpdir} \ +pacman -b "${db_dir}" --config /etc/pacman.conf -Sy 2>/dev/null +pacman -b "${db_dir}" \ --config /etc/pacman.conf \ -Sp --print-format "%n" \ base base-devel sudo ${@} | sort > /etc/libretools.d/cleansystem -- cgit v1.2.3-2-g168b From 9ab4d557b3294c61bdee3978be50f59c63b71c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:26:38 -0300 Subject: Manage dependency installation and removal by tapping into makepkg --- clean-pacman | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 clean-pacman diff --git a/clean-pacman b/clean-pacman new file mode 100755 index 0000000..0c22ef0 --- /dev/null +++ b/clean-pacman @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright 2012 Nicolás Reynolds Licensed under GPLv3 +# +# Smart cleanup of the chroot, restores chroot to its original state but also +# leaves the dependencies needed by the current package. +# +# Useful when you're building a lot of packages one after another and they +# share some dependencies. +# +# Logic: tap into `makepkg -s` +# +# Use it as the PACMAN var for makepkg: `PACMAN=$0 makepkg` + +set -e +set -x + +cleanup_log=/tmp/libretools-cleanup.log +cmd="$1"; shift +# make -Rn respect PACMAN_OPTS +flags=($(echo "$@" | grep -o "\-\-no\(confirm\|progressbar\)" || true)) +args="$@" + +case $cmd in +# Collect the packages that are going to be installed, but use a clean database to +# get the full needed list +# See update-cleansystem + -T) +# Use sudo because $0 is run as normal user + sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy + sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ + -Sp \ + --print-format "%n" \ + ${args[@]} >>${cleanup_log} + ;; +# Diff against previously installed packages and remove the unneeded ones + -S) + cleanup=($(comm -23 \ + <(pacman -Qq | sort) \ + <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) + )) + + if [ ${#cleanup[@]} -gt 0 ]; then +# At this point $0 is run as root + pacman -Rn ${flags[@]} ${cleanup[@]} + fi + ;; +# Remove the cleanup log at the end + -R) rm ${cleanup_log} ;; +esac + +# Make makepkg dreams come true +pacman $cmd ${args[@]} -- cgit v1.2.3-2-g168b From 6279830c8b0647d88a25f70a1fa537f2a26037fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:29:07 -0300 Subject: Remove cleanup list right after cleanup --- clean-pacman | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/clean-pacman b/clean-pacman index 0c22ef0..160a0f5 100755 --- a/clean-pacman +++ b/clean-pacman @@ -2,12 +2,14 @@ # Copyright 2012 Nicolás Reynolds Licensed under GPLv3 # # Smart cleanup of the chroot, restores chroot to its original state but also -# leaves the dependencies needed by the current package. +# leaves the dependencies already installed that are needed by the current +# package. In other words, it removes everything that's left. # # Useful when you're building a lot of packages one after another and they # share some dependencies. # -# Logic: tap into `makepkg -s` +# Logic: tap into `makepkg -sr`, collect required packages and remove the +# leftovers # # Use it as the PACMAN var for makepkg: `PACMAN=$0 makepkg` @@ -43,9 +45,10 @@ case $cmd in # At this point $0 is run as root pacman -Rn ${flags[@]} ${cleanup[@]} fi - ;; + # Remove the cleanup log at the end - -R) rm ${cleanup_log} ;; + rm ${cleanup_log} + ;; esac # Make makepkg dreams come true -- cgit v1.2.3-2-g168b From 02099c8d855fc8a77075409f96e097ce9aa09af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:29:34 -0300 Subject: Take -r away from makepkg --- clean-pacman | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clean-pacman b/clean-pacman index 160a0f5..96de5b1 100755 --- a/clean-pacman +++ b/clean-pacman @@ -49,6 +49,8 @@ case $cmd in # Remove the cleanup log at the end rm ${cleanup_log} ;; +# DON'T LET MAKEPKG DO REMOVALS OF ITS OWN + -R) exit 0;; esac # Make makepkg dreams come true -- cgit v1.2.3-2-g168b From bdc72cb35e90e0d2e795a928de658c9d71b0feac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:33:59 -0300 Subject: Clarifications --- clean-pacman | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clean-pacman b/clean-pacman index 96de5b1..6b34874 100755 --- a/clean-pacman +++ b/clean-pacman @@ -23,18 +23,24 @@ flags=($(echo "$@" | grep -o "\-\-no\(confirm\|progressbar\)" || true)) args="$@" case $cmd in -# Collect the packages that are going to be installed, but use a clean database to -# get the full needed list + +# Collect the packages that are going to be installed, but use a clean database +# to get the full needed list. # See update-cleansystem -T) # Use sudo because $0 is run as normal user +# TODO -Sy only once sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ -Sp \ --print-format "%n" \ ${args[@]} >>${cleanup_log} ;; + # Diff against previously installed packages and remove the unneeded ones +# +# We don't collect during -S because we never get here if depencies are met +# during -T -S) cleanup=($(comm -23 \ <(pacman -Qq | sort) \ -- cgit v1.2.3-2-g168b From 8f76df557d92ef978743097a9e88a15ffdee1b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 04:42:40 -0300 Subject: Bogus output was captured --- clean-pacman | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clean-pacman b/clean-pacman index 6b34874..9ef4a46 100755 --- a/clean-pacman +++ b/clean-pacman @@ -30,11 +30,11 @@ case $cmd in -T) # Use sudo because $0 is run as normal user # TODO -Sy only once - sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy + sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy >/dev/null 2>&1 sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ -Sp \ --print-format "%n" \ - ${args[@]} >>${cleanup_log} + ${args[@]} >>${cleanup_log} 2>/dev/null ;; # Diff against previously installed packages and remove the unneeded ones -- cgit v1.2.3-2-g168b From 7c02d4480f87936ba1351299072704a3744ede1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 05:07:54 -0300 Subject: Use PACMAN on FULLBUILDCMD --- treepkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/treepkg b/treepkg index 8a243e4..5a8eae2 100755 --- a/treepkg +++ b/treepkg @@ -203,7 +203,8 @@ if [ ${DEPTH} -eq 0 ]; then pushd "${BUILDDIR}/${_pkg}" >/dev/null sudo pacman -Syu --noconfirm - ${FULLBUILDCMD} +# Pass the PACMAN env var to makepkg + PACMAN=$(dirname $0)/clean-pacman ${FULLBUILDCMD} # Run local release hook with $1 = $repo ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) -- cgit v1.2.3-2-g168b From 379cb6eb270b0b26ddddb9170c6dcd0f756d1de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 05:08:26 -0300 Subject: Fix skip on built_ok --- treepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/treepkg b/treepkg index 5a8eae2..8ba2add 100755 --- a/treepkg +++ b/treepkg @@ -195,7 +195,7 @@ if [ ${DEPTH} -eq 0 ]; then # Ignore if there's no PKGBUILD if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi # Skip if already built (faster than calling is_build again) - if [ -f built_ok ]; then continue; fi + if [ -f "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi ${VERBOSE} && msg "Building ${_pkg/_/ }" || true -- cgit v1.2.3-2-g168b From cddf27b728fd46157685b3791245fed53393cb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 18:38:29 -0300 Subject: Last commit before deprecation Reason: Too complex, makepkg runs three times and removes packages previously installed --- clean-pacman | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/clean-pacman b/clean-pacman index 9ef4a46..2bfa225 100755 --- a/clean-pacman +++ b/clean-pacman @@ -12,15 +12,24 @@ # leftovers # # Use it as the PACMAN var for makepkg: `PACMAN=$0 makepkg` +# +# Notes +# makepkg runs the following flags three times (depends, makedepends, checkdepends) +# -T check deps (collect here) +# -S install missing deps (remove leftovers here) +# -T check if installed correctly (ignore) +# -R remove installed deps (skip) set -e set -x -cleanup_log=/tmp/libretools-cleanup.log -cmd="$1"; shift -# make -Rn respect PACMAN_OPTS -flags=($(echo "$@" | grep -o "\-\-no\(confirm\|progressbar\)" || true)) -args="$@" +makepid=$(ps --no-header -o pid -C makepkg | head -n1 | tr -d " ") +cleanup_log=/tmp/libretools-cleanup-${makepid}.log +checkdep=/tmp/libretools-dep-check-${makepid} + +cmd="$(echo "$@" | grep -o "\-\(T\|S\|R\|Q\)[^ ]*")" +# remove all flags +args="$(echo " $@" | sed "s/ \-[^ ]\+//g")" case $cmd in @@ -28,36 +37,38 @@ case $cmd in # to get the full needed list. # See update-cleansystem -T) -# Use sudo because $0 is run as normal user + if [ ! -f "${checkdep}" ]; then +# Use sudo because $0 is run as normal user on -T # TODO -Sy only once sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy >/dev/null 2>&1 sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ -Sp \ --print-format "%n" \ - ${args[@]} >>${cleanup_log} 2>/dev/null - ;; + ${args[@]} >${cleanup_log} 2>/dev/null +# Deps are collected, so skip next time + touch "${checkdep}" # Diff against previously installed packages and remove the unneeded ones # # We don't collect during -S because we never get here if depencies are met # during -T - -S) cleanup=($(comm -23 \ <(pacman -Qq | sort) \ <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) )) if [ ${#cleanup[@]} -gt 0 ]; then -# At this point $0 is run as root - pacman -Rn ${flags[@]} ${cleanup[@]} + sudo pacman -Rn --noconfirm ${cleanup[@]} 1>&2 fi - +# This is the second -T run + else # Remove the cleanup log at the end - rm ${cleanup_log} + rm "${cleanup_log}" "${checkdep}" + fi ;; # DON'T LET MAKEPKG DO REMOVALS OF ITS OWN -R) exit 0;; esac # Make makepkg dreams come true -pacman $cmd ${args[@]} +pacman $@ -- cgit v1.2.3-2-g168b From a323ff09d756dd06a559586467c84dbe78069060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 18:47:21 -0300 Subject: Deprecate clean-pacman in favor of smart chcleanup Chcleanup compares the currently installed packages with a clean system list of packages + the package dependencies and removes the leftovers. Treepkg runs it as pre-build hook, so FULLBUILDCMD finds only the needed dependencies. --- chcleanup | 44 +++++++++++++++++++++++++++++++--- clean-pacman | 74 --------------------------------------------------------- libretools.conf | 17 ++++++++++--- treepkg | 5 ++-- 4 files changed, 58 insertions(+), 82 deletions(-) delete mode 100755 clean-pacman diff --git a/chcleanup b/chcleanup index 7074b84..e689a4b 100755 --- a/chcleanup +++ b/chcleanup @@ -1,11 +1,49 @@ #!/bin/bash +# (c) Nicolás Reynolds +# Released under GPLv3 +# +# Performs chroot cleanup smartly, it only removes the unneeded packages or +# leaves you with a cleansystem +# +# See: HOOKPREBUILD + +set -e [ ! -f /etc/libretools.d/cleansystem ] && exit 1 +[ ! -d "${DB:-/var/lib/libretools/clean}"/sync ] && exit 1 + +source $(dirname $0)/libremessages + +msg "Cleaning chroot..." + +cleanup_log=/tmp/libretools-cleanup.log +touch ${cleanup_log} + +# If we're running makepkg +if [ -f PKGBUILD ]; then + source PKGBUILD || true + +# Update the cleansystem database + sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy +# Get the full list of packages needed by dependencies + sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ + -Sp \ + --print-format "%n" \ + ${depends[@]} ${makedepends[@]} ${checkdepends[@]} \ + >${cleanup_log} +fi + +# Diff installed packages against a clean chroot and needed packages, +# then remove leftovers +packages=($(comm -23 <(pacman -Qq | sort) \ + <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) + )) -packages=($(comm -23 <(pacman -Qq | sort) <(sort /etc/libretools.d/cleansystem))) +[ ${#packages[@]} -eq 0 ] && exit 0 -echo "Removing: ${packages[@]}" +msg2 "Removing ${#packages[@]} packages: ${packages[@]}" -sudo pacman --noconfirm -Rcs ${packages[@]} +# Only remove leftovers, -Rcs removes too much +sudo pacman --noconfirm -Rn ${packages[@]} exit $? diff --git a/clean-pacman b/clean-pacman deleted file mode 100755 index 2bfa225..0000000 --- a/clean-pacman +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# Copyright 2012 Nicolás Reynolds Licensed under GPLv3 -# -# Smart cleanup of the chroot, restores chroot to its original state but also -# leaves the dependencies already installed that are needed by the current -# package. In other words, it removes everything that's left. -# -# Useful when you're building a lot of packages one after another and they -# share some dependencies. -# -# Logic: tap into `makepkg -sr`, collect required packages and remove the -# leftovers -# -# Use it as the PACMAN var for makepkg: `PACMAN=$0 makepkg` -# -# Notes -# makepkg runs the following flags three times (depends, makedepends, checkdepends) -# -T check deps (collect here) -# -S install missing deps (remove leftovers here) -# -T check if installed correctly (ignore) -# -R remove installed deps (skip) - -set -e -set -x - -makepid=$(ps --no-header -o pid -C makepkg | head -n1 | tr -d " ") -cleanup_log=/tmp/libretools-cleanup-${makepid}.log -checkdep=/tmp/libretools-dep-check-${makepid} - -cmd="$(echo "$@" | grep -o "\-\(T\|S\|R\|Q\)[^ ]*")" -# remove all flags -args="$(echo " $@" | sed "s/ \-[^ ]\+//g")" - -case $cmd in - -# Collect the packages that are going to be installed, but use a clean database -# to get the full needed list. -# See update-cleansystem - -T) - if [ ! -f "${checkdep}" ]; then -# Use sudo because $0 is run as normal user on -T -# TODO -Sy only once - sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy >/dev/null 2>&1 - sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ - -Sp \ - --print-format "%n" \ - ${args[@]} >${cleanup_log} 2>/dev/null -# Deps are collected, so skip next time - touch "${checkdep}" - -# Diff against previously installed packages and remove the unneeded ones -# -# We don't collect during -S because we never get here if depencies are met -# during -T - cleanup=($(comm -23 \ - <(pacman -Qq | sort) \ - <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) - )) - - if [ ${#cleanup[@]} -gt 0 ]; then - sudo pacman -Rn --noconfirm ${cleanup[@]} 1>&2 - fi -# This is the second -T run - else -# Remove the cleanup log at the end - rm "${cleanup_log}" "${checkdep}" - fi - ;; -# DON'T LET MAKEPKG DO REMOVALS OF ITS OWN - -R) exit 0;; -esac - -# Make makepkg dreams come true -pacman $@ diff --git a/libretools.conf b/libretools.conf index 514c37d..40f92dc 100644 --- a/libretools.conf +++ b/libretools.conf @@ -30,9 +30,6 @@ CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` ## Parabola hostname (should be the same used on ssh_config PARABOLAHOST=parabola -## Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.) -HOOKPRERELEASE="ssh -fN parabola" - ## Server destination of libre packages # Don't change unless you know what you're doing and you won't screw # anything ;) @@ -52,6 +49,20 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git FULLBUILDCMD="sudo libremakepkg -cuN" # Cross compiling fullkpg # FULLBUILDCMD="sudo libremakepkg -cuN -d '/path/to/cross-compiling/chroot'" +# Build from within the chroot (or host system) +# FULLBUILDCMD="makepkg -sL --noconfirm" + +# Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.) +HOOKPRERELEASE="ssh -fN parabola" + +# Run a command before running FULLBUILDCMD, usually to cleanup uneeded packages +# Note! chcleanup *is not* chroot aware, if you run it as it is it will cleanup +# your system +# HOOKPREBUILD="chcleanup" + +# Locally release the package or any other action after running FULLBUILDCMD +# succesfully +# HOOKLOCALRELEASE="" ## Toru # Section for toru's vars diff --git a/treepkg b/treepkg index 8ba2add..a22df71 100755 --- a/treepkg +++ b/treepkg @@ -203,8 +203,9 @@ if [ ${DEPTH} -eq 0 ]; then pushd "${BUILDDIR}/${_pkg}" >/dev/null sudo pacman -Syu --noconfirm -# Pass the PACMAN env var to makepkg - PACMAN=$(dirname $0)/clean-pacman ${FULLBUILDCMD} + ${HOOKPREBUILD} + + ${FULLBUILDCMD} # Run local release hook with $1 = $repo ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) -- cgit v1.2.3-2-g168b From df6d6b26c13ab6645e1f3bf683cc4537f1a18211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 20:17:02 -0300 Subject: Issue #195 - Install missing packages --- update-cleansystem | 2 ++ 1 file changed, 2 insertions(+) diff --git a/update-cleansystem b/update-cleansystem index b55e882..98eb0dc 100755 --- a/update-cleansystem +++ b/update-cleansystem @@ -22,4 +22,6 @@ pacman -b "${db_dir}" \ -Sp --print-format "%n" \ base base-devel sudo ${@} | sort > /etc/libretools.d/cleansystem +pacman -Sy --needed --noconfirm base base-devel sudo $@ + exit $? -- cgit v1.2.3-2-g168b From 08f13bd1f0a0d0e742f2a6e3816d878f2a23da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 22 Sep 2012 20:20:27 -0300 Subject: Remove temp file --- chcleanup | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chcleanup b/chcleanup index e689a4b..1252e66 100755 --- a/chcleanup +++ b/chcleanup @@ -46,4 +46,7 @@ msg2 "Removing ${#packages[@]} packages: ${packages[@]}" # Only remove leftovers, -Rcs removes too much sudo pacman --noconfirm -Rn ${packages[@]} +# Cleanup +rm -f ${cleanup_log} + exit $? -- cgit v1.2.3-2-g168b From 6c95ce9aedf6b1e9353e48f1e52e9989a563980b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 1 Oct 2012 11:56:51 -0300 Subject: Correctly set CARCH --- chcleanup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chcleanup b/chcleanup index 1252e66..9a27d49 100755 --- a/chcleanup +++ b/chcleanup @@ -13,6 +13,8 @@ set -e [ ! -d "${DB:-/var/lib/libretools/clean}"/sync ] && exit 1 source $(dirname $0)/libremessages +source /etc/makepkg.conf +source ${HOME}/.makepkg.conf 2>/dev/null|| true msg "Cleaning chroot..." -- cgit v1.2.3-2-g168b From eda9bd59c2d8919f90aa72cf6cffd545d7bd2295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 17 Oct 2012 22:39:27 -0300 Subject: Don't fail if depends are empty --- chcleanup | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/chcleanup b/chcleanup index 9a27d49..5fdbc58 100755 --- a/chcleanup +++ b/chcleanup @@ -25,14 +25,19 @@ touch ${cleanup_log} if [ -f PKGBUILD ]; then source PKGBUILD || true + check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) + + if [ ${#check[@]} -ne 0 ]; then + # Update the cleansystem database - sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy + sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy # Get the full list of packages needed by dependencies - sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ - -Sp \ - --print-format "%n" \ - ${depends[@]} ${makedepends[@]} ${checkdepends[@]} \ - >${cleanup_log} + sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ + -Sp \ + --print-format "%n" \ + ${check[@]} \ + >${cleanup_log} + fi fi # Diff installed packages against a clean chroot and needed packages, @@ -43,7 +48,7 @@ packages=($(comm -23 <(pacman -Qq | sort) \ [ ${#packages[@]} -eq 0 ] && exit 0 -msg2 "Removing ${#packages[@]} packages: ${packages[@]}" +msg2 "Removing %d packages: %s" ${#packages[@]} "${packages[@]}" # Only remove leftovers, -Rcs removes too much sudo pacman --noconfirm -Rn ${packages[@]} -- cgit v1.2.3-2-g168b From 434c2b7a7117fa52e3e087395c4042d6def904f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 17 Oct 2012 22:40:29 -0300 Subject: Removed commented lines --- mips64el/mipsrelease | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mips64el/mipsrelease b/mips64el/mipsrelease index f245c47..4d7a7de 100755 --- a/mips64el/mipsrelease +++ b/mips64el/mipsrelease @@ -43,7 +43,7 @@ fi source PKGBUILD fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) pkgs=() -makepkg --source -f +makepkg --source -f --skippgpcheck msg "Adding packages to [stage3]..." for name in ${pkgname[@]}; do @@ -53,7 +53,6 @@ done repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]} -#sudo pacman -Sy librestage ${repo} @@ -63,6 +62,4 @@ pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT} popd >/dev/null -$libretoolsdir/chcleanup || true - exit $? -- cgit v1.2.3-2-g168b From b4c8f17a6d97b63589b624d726e10d64cbd743ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 17 Oct 2012 22:59:52 -0300 Subject: fix printf --- chcleanup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chcleanup b/chcleanup index 5fdbc58..b5f631c 100755 --- a/chcleanup +++ b/chcleanup @@ -48,7 +48,7 @@ packages=($(comm -23 <(pacman -Qq | sort) \ [ ${#packages[@]} -eq 0 ] && exit 0 -msg2 "Removing %d packages: %s" ${#packages[@]} "${packages[@]}" +msg2 "Removing %d packages" ${#packages[@]} # Only remove leftovers, -Rcs removes too much sudo pacman --noconfirm -Rn ${packages[@]} -- cgit v1.2.3-2-g168b From ac5ec444b089a1242650c29b9ef6dad1c5b182ec Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 11 Mar 2012 23:56:59 -0400 Subject: Use arrays to better handle whitepsace in libremkchroot --- libremkchroot | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libremkchroot b/libremkchroot index c1f2072..b576209 100755 --- a/libremkchroot +++ b/libremkchroot @@ -2,7 +2,7 @@ # LibreMkChroot # Creates a chroot -# Copyright 2011 Luke Shumaker +# Copyright 2011, 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -27,10 +27,7 @@ if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then source "$XDG_CONFIG_HOME/libretools/libretools.conf" fi -#CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" - cmd=${0##*/} - function usage { echo "Usage: $cmd [OPTIONS]" echo 'This script will create a chroot to build packages in.' @@ -47,12 +44,12 @@ function usage { echo ' -M Location of makepkg config file.' } -mkchroot_args=''; +mkchroot_args=(); while getopts 'hfd:c:C:M:' arg; do case "$arg" in h) usage; exit 0 ;; - f) mkchroot_args="$mkchroot_args -$arg" ;; - c|C|M) mkchroot_args="$mkchroot_args -$arg $OPTARG" ;; + f) mkchroot_args+=("-$arg");; + c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; d) CHROOTDIR=$OPTARG ;; ?) usage; exit 1 ;; esac @@ -64,4 +61,4 @@ if (( EUID )); then fi mkdir -p "${CHROOTDIR}" -xargs -d'\n' mkarchroot $mkchroot_args "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem +xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem -- cgit v1.2.3-2-g168b From 5ae7257fca114a6174c070556745a40fe0ca4ff5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 18 Jun 2012 01:56:55 -0400 Subject: Improve update-cleansystem --- update-cleansystem | 66 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/update-cleansystem b/update-cleansystem index 97c2922..4ea6a24 100755 --- a/update-cleansystem +++ b/update-cleansystem @@ -1,24 +1,62 @@ #!/bin/bash # Updates the cleansystem file -# Creates a fake Parabola root and prints all packages installable from base -# and base-devel plus extras +# Creates a fake Parabola root and writes to cleansystem all +# packages installable from base and base-devel plus extras. -set -E +# Copyright 2012 Nicolás Reynolds, Luke Shumaker -if [ ! -w / ]; then - echo "Run as root." - exit 1 +# ---------- GNU General Public License 3 ---------- + +# This file is part of Parabola. + +# Parabola is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# Parabola is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Parabola. If not, see . + +source /etc/libretools.conf + +cleansystem=/etc/libretools.d/cleansystem + +cmd=${0##*/} +usage() { + echo "Usage: $cmd []" + echo " $cmd -h" + echo "Creates a fake Parabola root and writes to \`$cleansystem' all" + echo "packages installable from base and base-devel plus extras." + echo '' + echo 'Options:' + echo ' -h Show this message' +} + +if [ "$1" == '-h' ]; then + usage + exit 0 fi -tmpdir=/tmp/cleansystem.${RANDOM} +if [ ! -w "$cleansystem" ]; then + error 'This script must be run as root' + exit 1 +fi -mkdir -p ${tmpdir}/var/lib/pacman +tmpdir="`mktemp -d --tmpdir cleansystem.XXXXXXXXXX`" +mkdir -p "${tmpdir}"/var/lib/pacman # We sync first because updating info gets printed to stdout too -pacman -r ${tmpdir} --config /etc/pacman.conf -Sy 2>/dev/null -pacman -r ${tmpdir} \ - --config /etc/pacman.conf \ - -Sp --print-format "%n" \ - base base-devel sudo ${@} | sort > /etc/libretools.d/cleansystem +pacman -r "${tmpdir}" --config /etc/pacman.conf -Sy 2>/dev/null +pacman -r "${tmpdir}" --config /etc/pacman.conf \ + -Sp --print-format "%n" \ + base base-devel sudo "$@" | sort > "$cleansystem" +exitcode=$? + +rm -rf "$tmpdir" -exit $? +exit $exitcode -- cgit v1.2.3-2-g168b From 12377d79078170ec47c1fa5fb56b12ecb13367e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 20 Oct 2012 16:04:17 -0300 Subject: Use TokyoCabinet to store the PKGBUILD path cache --- toru-path | 23 +++++++++++++---------- toru-utils | 2 -- toru-where | 9 ++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/toru-path b/toru-path index 9bfc3ff..7f1d599 100755 --- a/toru-path +++ b/toru-path @@ -2,22 +2,30 @@ source $(dirname $(command -v $0))/toru-utils +TORUPATH=${T:-${TORUPATH}} + if [ ! -w "$TORUPATH" ]; then error "Toru's path isn't writable. Please check $TORUPATH" exit 1 fi LASTSYNCFILE=${TORUPATH}/lastsync.paths +PATHFILE=${TORUPATH}/paths.tch + +if [ ! -e "${PATHFILE}" ]; then + tcamgr create "${PATHFILE}" +fi # TODO pass other paths via flags -pkgbuilds=($(get_pkgbuilds ${ABSROOT})) -paths=() +# ABSROOT has trailing slash +fullrepos=($(for _repo in ${REPOS[@]}; do echo "${ABSROOT}${_repo}"; done)) +pkgbuilds=($(get_pkgbuilds ${fullrepos[@]})) msg "Updating path cache" msg2 "${#pkgbuilds[@]} PKGBUILDs to update" for _pkgbuild in ${pkgbuilds[@]}; do - $DEBUG && plain "$_pkgbuild" - source ${_pkgbuild} || { +# plain "$_pkgbuild" + source ${_pkgbuild} >/dev/null 2>&1 || { error "${_pkgbuild} contains errors, skipping" continue } @@ -25,15 +33,10 @@ for _pkgbuild in ${pkgbuilds[@]}; do fullpath=$(dirname ${_pkgbuild}) for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do - paths+=(${_pkg/[<>=]*}:${fullpath}) + tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath} done unset pkgbase pkgname provides done - -# TODO remove old paths -# by joining new paths to old paths and exclude the joining points from the -# cache (sort of a sql join) -echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths lastsync ${LASTSYNCFILE} diff --git a/toru-utils b/toru-utils index c0918ae..316e6b8 100755 --- a/toru-utils +++ b/toru-utils @@ -1,6 +1,4 @@ #!/bin/bash -#!/bin/bash - source /etc/abs.conf source /etc/libretools.conf diff --git a/toru-where b/toru-where index 02a7a88..f732dc0 100755 --- a/toru-where +++ b/toru-where @@ -1,11 +1,10 @@ #!/bin/bash # Locates a PKGBUILD dir on toru's path cache -source $(dirname $(command -v $0))/toru-utils +source /etc/libretools.conf -# Look in all cached but pick the last one -grep "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ - tail -n1 2>/dev/null|\ - cut -d: -f2 2>/dev/null +PATHFILE=${TORUPATH}/paths.tch + +exec tcamgr get ${PATHFILE} $1 exit $? -- cgit v1.2.3-2-g168b From 7389eee3207cf2e06b6392cac3cdbe622d284df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 29 Oct 2012 15:55:54 -0300 Subject: Return nothing when missing --- toru-where | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/toru-where b/toru-where index f732dc0..e9ab29d 100755 --- a/toru-where +++ b/toru-where @@ -1,10 +1,7 @@ #!/bin/bash # Locates a PKGBUILD dir on toru's path cache - source /etc/libretools.conf PATHFILE=${TORUPATH}/paths.tch -exec tcamgr get ${PATHFILE} $1 - -exit $? +tcamgr get ${PATHFILE} $1 2>/dev/null || echo "" -- cgit v1.2.3-2-g168b From fd0ffed60b3b3ed1a138e516b166884dbe12c9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 29 Oct 2012 15:56:14 -0300 Subject: Print information about packages --- toru-info | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 toru-info diff --git a/toru-info b/toru-info new file mode 100755 index 0000000..523f682 --- /dev/null +++ b/toru-info @@ -0,0 +1,28 @@ +#!/bin/bash +# Prints info about a given pkgname +source /etc/libretools.conf + +for _pkg in $@; do + _pkgbuild="$(toru-where $_pkg)" + + if [ -f "$_pkgbuild/PKGBUILD" ]; then + source "$_pkgbuild/PKGBUILD" 2>/dev/null || { + warning "Errors on %s" $_pkg + continue + } + + deps="${depends[@]} ${makedepends[@]} ${checkdepends[@]}" + repo="$(basename $(dirname "$_pkgbuild"))" + + unset build package depends makedepends checkdepends optdepends source md5sums + + msg "%s/%s %s-%s" $repo $_pkg $pkgver $pkgrel + msg2 "$pkgdesc" + msg2 "$url" + msg2 "Depends: ${deps}" + else + warning "%s doesn't exist" $_pkg + fi + + unset pkgname pkgver pkgrel pkgdesc url +done -- cgit v1.2.3-2-g168b From 38eefb72969f3f703fb8009ea46444bff40edf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 29 Oct 2012 16:25:03 -0300 Subject: Run is_built against pkgname[@] Sometimes pkgbase isn't a valid pkgname, so treepkg believes the package isn't built and makepkg fails later if packages are cached ("Part of this group has already been built") or builds anyway and db-update fails because someone else released it before. --- treepkg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/treepkg b/treepkg index a22df71..fb7eed1 100755 --- a/treepkg +++ b/treepkg @@ -134,10 +134,12 @@ if ! ${BUILDNOW}; then touch "${BUILDORDER}" # If this package is already built quit silently - if is_built "${pkgbase}" "${fullver}"; then - add_order "ignore" - exit 0 - fi + for _pkg in ${pkgname[@]}; do + if is_built "${_pkg}" "${fullver}"; then + add_order "ignore" + exit 0 + fi + done # Ignore if already in build order egrep -q ";${pkgbase};" "${BUILDORDER}" && exit 0 -- cgit v1.2.3-2-g168b From 5863c70d969c4654e0ea99f7b68876bc4aa5770b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 29 Oct 2012 16:34:57 -0300 Subject: Run is_built against pkgnames When pkgbase isn't a valid pkgname, treepkg ended up deciding to build this non-existant package, regardless of packages already built. This commit fixes that by checking is_built against pkgnames instead. --- treepkg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/treepkg b/treepkg index a22df71..fb7eed1 100755 --- a/treepkg +++ b/treepkg @@ -134,10 +134,12 @@ if ! ${BUILDNOW}; then touch "${BUILDORDER}" # If this package is already built quit silently - if is_built "${pkgbase}" "${fullver}"; then - add_order "ignore" - exit 0 - fi + for _pkg in ${pkgname[@]}; do + if is_built "${_pkg}" "${fullver}"; then + add_order "ignore" + exit 0 + fi + done # Ignore if already in build order egrep -q ";${pkgbase};" "${BUILDORDER}" && exit 0 -- cgit v1.2.3-2-g168b From 121e9ebb3caa4f6259960fb66c6ede0bbc875666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 3 Nov 2012 13:23:05 -0300 Subject: Set terminal title with libremessages' term_title() Useful for showing progress --- libremessages | 6 ++++++ treepkg | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/libremessages b/libremessages index 5d817dd..68badb8 100755 --- a/libremessages +++ b/libremessages @@ -86,6 +86,12 @@ stat_done() { printf "${BOLD}done${ALL_OFF}\n" >&2 } +# Set the terminal title +# TODO test on several terms - it works on screen/tmux +term_title() { + printf "\033k%s\033\\" "$@" +} + # usage : in_array( $needle, $haystack ) in_array() { [[ $2 ]] || return 1 # Not found diff --git a/treepkg b/treepkg index fb7eed1..8c4cc8e 100755 --- a/treepkg +++ b/treepkg @@ -18,12 +18,15 @@ source /etc/libretools.conf source $XDG_CONFIG_HOME/libretools/libretools.conf >/dev/null 2>&1|| true +term_title "$(basename $0)" + # Get system variables source /etc/makepkg.conf source $HOME/makepkg.conf >/dev/null 2>&1|| true # End inmediately but print an useful message trap_exit() { + term_title "error!" error "($(basename $0)) $@ (leftovers on ${BUILDDIR})" exit 1 } @@ -201,6 +204,9 @@ if [ ${DEPTH} -eq 0 ]; then ${VERBOSE} && msg "Building ${_pkg/_/ }" || true +# Remove leading zeros and space if any + term_title "$(echo ${_pkg/_/ } | sed "s/^0\+ \?//")" + # Run build command pushd "${BUILDDIR}/${_pkg}" >/dev/null sudo pacman -Syu --noconfirm @@ -227,4 +233,5 @@ fi fi +term_title "done" exit $? -- cgit v1.2.3-2-g168b From 04af64022ed0a0bf618e23c0ed7512c168d479c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 3 Nov 2012 13:29:38 -0300 Subject: Traverse REPOS backwards This ensures packages in stable repos are added last to the path cache --- libretools.conf | 6 ++++-- toru-path | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libretools.conf b/libretools.conf index 40f92dc..88ba515 100644 --- a/libretools.conf +++ b/libretools.conf @@ -7,10 +7,12 @@ DIFFTOOL=vimdiff # The dir where you work on WORKDIR=/home/$USER/packages # The repos you'll be packaging for +# # Tip: As early repos take precedence on $REPOS loops, you can use this as # inverted order of precedence. Put testing repos first so fullpkg find new -# PKGBUILDs first, for instance. -REPOS=('core' 'extra' 'community' 'libre' 'libre-testing' 'social' 'sugar') +# PKGBUILDs first, for instance. Toru-path uses reverse order to enforce repo +# precedence on the path cache (the last path added replaces the rest) +REPOS=('core' 'libre' 'extra' 'community' 'libre-testing' 'social' 'sugar') # The architectures ARCHES=('i686' 'x86_64' 'mips64el' 'any') diff --git a/toru-path b/toru-path index 7f1d599..957f49b 100755 --- a/toru-path +++ b/toru-path @@ -3,6 +3,7 @@ source $(dirname $(command -v $0))/toru-utils TORUPATH=${T:-${TORUPATH}} +VERBOSE=${V:-false} if [ ! -w "$TORUPATH" ]; then error "Toru's path isn't writable. Please check $TORUPATH" @@ -18,7 +19,11 @@ fi # TODO pass other paths via flags # ABSROOT has trailing slash -fullrepos=($(for _repo in ${REPOS[@]}; do echo "${ABSROOT}${_repo}"; done)) +fullrepos=() +for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do + ${VERBOSE} && msg "Processing [%s]" ${REPOS[$i]} + fullrepos+=("${ABSROOT}${REPOS[$i]}") +done pkgbuilds=($(get_pkgbuilds ${fullrepos[@]})) msg "Updating path cache" @@ -33,6 +38,7 @@ for _pkgbuild in ${pkgbuilds[@]}; do fullpath=$(dirname ${_pkgbuild}) for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do + $VERBOSE && msg2 "${_pkg} -> ${fullpath}" tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath} done -- cgit v1.2.3-2-g168b