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.1-4-g5e80 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.1-4-g5e80 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.1-4-g5e80 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.1-4-g5e80 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.1-4-g5e80 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.1-4-g5e80 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.1-4-g5e80