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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 From 3d3156b97f679a84210c08ca7e7563691d988a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Thu, 13 Sep 2012 19:56:46 -0300 Subject: Export the CARCH correctly --- librerepkg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/librerepkg b/librerepkg index d506003..5cb0fa3 100755 --- a/librerepkg +++ b/librerepkg @@ -60,11 +60,11 @@ for _arch in ${arch[@]}; do stdnull pushd ${tempdir} + echo "export CARCH=${_arch}" >> PKGBUILD + msg2 "Updating md5sums" makepkg -gp rePKGBUILD >> rePKGBUILD - echo "export CARCH=${_arch}" >> rePKGBUILD - msg "Repackaging using makepkg" makepkg -Lcdp rePKGBUILD ${makepkgflags} -- cgit v1.2.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 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.2 From a164826eef907c27c60936c01c72ff96005af9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sat, 3 Nov 2012 17:23:11 -0300 Subject: Inform the upload size --- librerelease | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/librerelease b/librerelease index c4d97c1..efb698e 100755 --- a/librerelease +++ b/librerelease @@ -118,7 +118,7 @@ else exit 1 fi -# Make the permissions of the packages 644 otherwize the user will get access +# Make the permissions of the packages 644 otherwise the user will get access # denied error when they try to download (rsync --no-perms doesn't seem to # work). find ${WORKDIR}/staging -type f -exec chmod 644 {} \; @@ -127,6 +127,7 @@ find ${WORKDIR}/staging -type d -exec chmod 755 {} \; # Get the synced files SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) +msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) msg "Uploading packages..." rsync --recursive \ ${dryrun} \ -- cgit v1.2.2 From d9efdb903fcd4d3242918910e7d6c00d2e17975d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 15:38:49 -0300 Subject: Updated treepkg docs --- doc/treepkg.markdown | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/treepkg.markdown b/doc/treepkg.markdown index 2808599..7f7ece1 100644 --- a/doc/treepkg.markdown +++ b/doc/treepkg.markdown @@ -13,9 +13,9 @@ some design issues that made fullpkg miss some packages sometimes. ## Requirements `treepkg` needs the help of `toru-path` for "indexing" an ABS tree. `toru-path` -stores a plain text database of "pkgname:path" pairs, where pkgname is replaced -by the "pkgbase", "pkgname", and "provides" fields of a PKGBUILD, followed by -the path of the current PKGBUILD. +stores a tokyocabinet database of "pkgname" => "path" pairs, where pkgname is +replaced by the "pkgbase", "pkgname", and "provides" fields of a PKGBUILD, +followed by the path of the current PKGBUILD. This information is then used by `treepkg` to know where to find the PKGBUILD of a package. The fullpkg family needed to guess this by traversing the full @@ -24,9 +24,9 @@ pkgbase. So, to use `treepkg` you need to run `toru-path` after the ABS tree update. -> Currently `toru-path` doesn't remove duplicated or updated pairs, but it -> picks the last ones and only processes new PKGBUILDs. This means `toru-path` -> works correctly but it's database will grow up slowly. +> Split PKGBUILDs make it difficult to extract metadata if it's stored inside +> package() functions. This will happen with the provides field and `treepkg` +> won't find that linux-libre-headers provides linux-headers, for instance. ## How does it work @@ -105,6 +105,9 @@ current one. Thus this will become the build path: ghostscript (0) - fontconfig (buried) \ cups (1) - fontconfig (2) +> Note: currently, `treepkg` doesn't perform recursive burying, so if you hit +> a really long build tree with some circular dependencies you may find +> packages buried several times and queued to build before their actuals deps. ## Tips @@ -114,13 +117,14 @@ to pass this arguments when running it manually, they're used internally to automatically construct the build path. But if a build failed, `treepkg` will cancel itself immediately informing you -where the leftovers files where left. If you pass this path to `treepkg` as the +where the leftovers files were left. If you pass this path to `treepkg` as the first argument, it will resume the build, skipping to the last package being packaged. You can take the opportunity given by this to modify the build path or the -PKGBUILDs, without having to re-run `treepkg` twice. For instance you can -remove a package from the build order, or move it manually, or update the -PKGBUILD that made `treepkg` fail in the first place. +PKGBUILDs, without having to run `treepkg` twice. For instance you can remove +a package from the build order, or move it manually, or update the PKGBUILD +that made `treepkg` fail in the first place. You can force a skipped package +(after building it manually) by using `touch built_ok` on the PKGBUILD dir. You don't probably want to mess with the second argument though. -- cgit v1.2.2 From 362ec9e880e784ec9bc2858c635b0279e52af82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:02:07 -0300 Subject: Be even smarter Only use one pacman call by getting repo.db files from the local cache. Adds a new libretools.conf array for getting extra packages (other than the base system): CHROOTEXTRAPKGS. --- chcleanup | 37 +++++++++++++++++-------------------- libretools.conf | 2 ++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/chcleanup b/chcleanup index b5f631c..e732b8c 100755 --- a/chcleanup +++ b/chcleanup @@ -9,16 +9,17 @@ set -e -[ ! -f /etc/libretools.d/cleansystem ] && exit 1 -[ ! -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..." -cleanup_log=/tmp/libretools-cleanup.log + +TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" +cleanup_log="${TMPDIR}"/libretools-cleanup.log + +cp -a /var/lib/pacman/sync "${TMPDIR}/" touch ${cleanup_log} # If we're running makepkg @@ -27,24 +28,20 @@ if [ -f PKGBUILD ]; then check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) - if [ ${#check[@]} -ne 0 ]; then - -# 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" \ - ${check[@]} \ - >${cleanup_log} - fi fi -# Diff installed packages against a clean chroot and needed packages, -# then remove leftovers +# Get the full list of packages needed by dependencies, including the base system +sudo pacman -b "${TMPDIR}" \ + -Sp \ + --print-format "%n" \ + base base-devel sudo \ + ${CHROOTEXTRAPKG[@]} \ + ${check[@]} \ + >${cleanup_log} + +# Diff installed packages against a clean chroot then remove leftovers packages=($(comm -23 <(pacman -Qq | sort) \ - <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) - )) + <(sort -u ${cleanup_log}))) [ ${#packages[@]} -eq 0 ] && exit 0 @@ -54,6 +51,6 @@ msg2 "Removing %d packages" ${#packages[@]} sudo pacman --noconfirm -Rn ${packages[@]} # Cleanup -rm -f ${cleanup_log} +rm -fr ${TMPDIR} exit $? diff --git a/libretools.conf b/libretools.conf index 88ba515..8032397 100644 --- a/libretools.conf +++ b/libretools.conf @@ -19,6 +19,8 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any') ## The directory where the chroots are stored CHROOTDIR=/home/chroot +# Extra packages to have installed on the chroot (besides base base-devel and sudo) +CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet) ## The working chroot ## A chroot is useful to build packages isolated from the current system and avoid -- cgit v1.2.2 From 61ca876072f8e7a5a6ab90974db895c57434ae9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:13:14 -0300 Subject: Added DRYRUN mode and use libretools.conf --- chcleanup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chcleanup b/chcleanup index e732b8c..26c1a27 100755 --- a/chcleanup +++ b/chcleanup @@ -9,13 +9,12 @@ set -e -source $(dirname $0)/libremessages source /etc/makepkg.conf +source /etc/libretools.conf source ${HOME}/.makepkg.conf 2>/dev/null|| true msg "Cleaning chroot..." - TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" cleanup_log="${TMPDIR}"/libretools-cleanup.log @@ -48,9 +47,10 @@ packages=($(comm -23 <(pacman -Qq | sort) \ msg2 "Removing %d packages" ${#packages[@]} # Only remove leftovers, -Rcs removes too much -sudo pacman --noconfirm -Rn ${packages[@]} +${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} +${DRYRUN} && echo ${packages[@]} # Cleanup -rm -fr ${TMPDIR} +${DRYRUN} || rm -fr ${TMPDIR} exit $? -- cgit v1.2.2 From 83dd1498e580510023b63611bb25feedd3699b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:30:55 -0300 Subject: Make librechroot use chcleanup --- librechroot | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/librechroot b/librechroot index 9e292f5..b4766e6 100755 --- a/librechroot +++ b/librechroot @@ -44,39 +44,9 @@ function usage { } function clean_chroot { # Clean packages with pacman - msg "Cleaning chroot: ${CHROOTDIR}/${CHROOTNAME}" - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/cleansystem" - (cat < "${CHROOTDIR}/${CHROOTNAME}/clean" - - chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" + cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" - rm "${CHROOTDIR}/${CHROOTNAME}/clean" - rm "${CHROOTDIR}/${CHROOTNAME}/cleansystem" + mkarchroot -r "/clean" } function clean_repo { -- cgit v1.2.2 From 78a5a4d9c6b6010d4064614e5d5a095bf54fddee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:39:24 -0300 Subject: Follow new tarball placement --- aur | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aur b/aur index b96cb20..24d4317 100755 --- a/aur +++ b/aur @@ -56,7 +56,7 @@ for _pkg in ${@}; do fi msg "Downloading $_pkg..." - wget -O - -q https://aur.archlinux.org/packages/$_pkg/$_pkg.tar.gz | \ + wget -O - -q https://aur.archlinux.org/packages/$(echo $_pkg | sed "s/^../&\/&/")/$_pkg.tar.gz | \ tar xzf - >/dev/null 2>&1 if [ $? -ne 0 ]; then -- cgit v1.2.2 From 48ca24dd22a16fb584b4bbe9684a87a44d4deb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:43:12 -0300 Subject: Run chcleanup correctly --- librechroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librechroot b/librechroot index b4766e6..c8e02b0 100755 --- a/librechroot +++ b/librechroot @@ -46,7 +46,7 @@ function usage { function clean_chroot { # Clean packages with pacman cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "/clean" + mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" } function clean_repo { -- cgit v1.2.2 From 4e5c5c74108718b08a021991b314d6a68d829544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:48:14 -0300 Subject: Note on aur usage --- aur | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aur b/aur index b96cb20..6ffb2b9 100755 --- a/aur +++ b/aur @@ -26,6 +26,9 @@ function usage { echo echo "This script will download packages from aur to the current dir" echo "and check their license for nonfree issues." + echo + echo "Note: it depends on abs to be updated." + echo "Install 'abs-libre' and run \`abs\` as root before working with $0" } while getopts 'h' arg; do -- cgit v1.2.2 From 48696038cec8f4cef0152d356b05d40c585a20b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Mon, 5 Nov 2012 16:48:28 -0300 Subject: Skip unexistent repos --- toru-path | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toru-path b/toru-path index 957f49b..baeaeb5 100755 --- a/toru-path +++ b/toru-path @@ -22,6 +22,8 @@ fi fullrepos=() for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do ${VERBOSE} && msg "Processing [%s]" ${REPOS[$i]} + + [ -d "${ABSROOT}${REPOS[$i]}" ] && \ fullrepos+=("${ABSROOT}${REPOS[$i]}") done pkgbuilds=($(get_pkgbuilds ${fullrepos[@]})) -- cgit v1.2.2 From c74d072dc83c5e3b3d9462678884cd0411a7d1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Tue, 6 Nov 2012 15:29:09 -0300 Subject: Default DRYRUN to false --- chcleanup | 1 + 1 file changed, 1 insertion(+) diff --git a/chcleanup b/chcleanup index 26c1a27..17c1f02 100755 --- a/chcleanup +++ b/chcleanup @@ -8,6 +8,7 @@ # See: HOOKPREBUILD set -e +DRYRUN=${DRYRUN:-false} source /etc/makepkg.conf source /etc/libretools.conf -- cgit v1.2.2 From e9bc885c355babf7851de31db8e1920dde752993 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 00:17:08 -0500 Subject: organize the files --- abslibre-commit | 36 ---- add-mips64el | 6 - aur | 123 ----------- buildenv | 28 --- chcleanup | 57 ------ createworkdir | 63 ------ diff-unfree | 85 -------- fullpkg | 34 --- fullpkg-build | 211 ------------------- fullpkg-find | 212 ------------------- is_built | 36 ---- is_unfree | 11 - lb | 16 -- libreaddiff | 97 --------- librebasebuilder | 84 -------- librechroot | 108 ---------- librecommit | 65 ------ librediff | 65 ------ libremakepkg | 126 ------------ libremessages | 107 ---------- libremkchroot | 64 ------ librerelease | 155 -------------- librerepkg | 72 ------- librestage | 138 ------------- mips64el/mips-add | 7 - mips64el/mips64el.conf | 12 -- mips64el/mipsrelease | 65 ------ pkgbuild-check-nonfree | 205 ------------------- prtools/prfullpkg | 398 ------------------------------------ prtools/prmipsrelease | 98 --------- prtools/prtools.conf | 4 - prtools/prtoru | 173 ---------------- src/abslibre-tools/abslibre-commit | 36 ++++ src/abslibre-tools/createworkdir | 63 ++++++ src/abslibre-tools/libreaddiff | 97 +++++++++ src/abslibre-tools/librecommit | 65 ++++++ src/abslibre-tools/librerelease | 155 ++++++++++++++ src/abslibre-tools/librestage | 138 +++++++++++++ src/abslibre-tools/updateabslibre | 39 ++++ src/aur | 123 +++++++++++ src/chroot-tools/buildenv | 28 +++ src/chroot-tools/chcleanup | 57 ++++++ src/chroot-tools/librechroot | 108 ++++++++++ src/chroot-tools/libremakepkg | 126 ++++++++++++ src/chroot-tools/libremkchroot | 64 ++++++ src/diff-unfree | 85 ++++++++ src/fullpkg/fullpkg | 34 +++ src/fullpkg/fullpkg-build | 211 +++++++++++++++++++ src/fullpkg/fullpkg-find | 212 +++++++++++++++++++ src/is_built | 36 ++++ src/is_unfree | 11 + src/librediff | 65 ++++++ src/libremessages | 107 ++++++++++ src/librerepkg | 72 +++++++ src/mips64el-tools/add-mips64el | 6 + src/mips64el-tools/librebasebuilder | 84 ++++++++ src/mips64el-tools/mips-add | 7 + src/mips64el-tools/mips64el.conf | 12 ++ src/mips64el-tools/mipsrelease | 65 ++++++ src/pkgbuild-check-nonfree | 205 +++++++++++++++++++ src/prtools/prfullpkg | 398 ++++++++++++++++++++++++++++++++++++ src/prtools/prmipsrelease | 98 +++++++++ src/prtools/prtools.conf | 4 + src/prtools/prtoru | 173 ++++++++++++++++ src/toru/toru | 314 ++++++++++++++++++++++++++++ src/toru/toru-info | 28 +++ src/toru/toru-path | 48 +++++ src/toru/toru-utils | 76 +++++++ src/toru/toru-where | 7 + src/treepkg | 237 +++++++++++++++++++++ src/update-cleansystem | 68 ++++++ toru | 314 ---------------------------- toru-info | 28 --- toru-path | 48 ----- toru-utils | 76 ------- toru-where | 7 - treepkg | 237 --------------------- update-cleansystem | 68 ------ updateabslibre | 39 ---- 79 files changed, 3762 insertions(+), 3778 deletions(-) delete mode 100755 abslibre-commit delete mode 100755 add-mips64el delete mode 100755 aur delete mode 100755 buildenv delete mode 100755 chcleanup delete mode 100755 createworkdir delete mode 100755 diff-unfree delete mode 100755 fullpkg delete mode 100755 fullpkg-build delete mode 100755 fullpkg-find delete mode 100755 is_built delete mode 100755 is_unfree delete mode 100755 lb delete mode 100755 libreaddiff delete mode 100755 librebasebuilder delete mode 100755 librechroot delete mode 100755 librecommit delete mode 100755 librediff delete mode 100755 libremakepkg delete mode 100755 libremessages delete mode 100755 libremkchroot delete mode 100755 librerelease delete mode 100755 librerepkg delete mode 100755 librestage delete mode 100644 mips64el/mips-add delete mode 100644 mips64el/mips64el.conf delete mode 100755 mips64el/mipsrelease delete mode 100755 pkgbuild-check-nonfree delete mode 100755 prtools/prfullpkg delete mode 100755 prtools/prmipsrelease delete mode 100644 prtools/prtools.conf delete mode 100644 prtools/prtoru create mode 100755 src/abslibre-tools/abslibre-commit create mode 100755 src/abslibre-tools/createworkdir create mode 100755 src/abslibre-tools/libreaddiff create mode 100755 src/abslibre-tools/librecommit create mode 100755 src/abslibre-tools/librerelease create mode 100755 src/abslibre-tools/librestage create mode 100755 src/abslibre-tools/updateabslibre create mode 100755 src/aur create mode 100755 src/chroot-tools/buildenv create mode 100755 src/chroot-tools/chcleanup create mode 100755 src/chroot-tools/librechroot create mode 100755 src/chroot-tools/libremakepkg create mode 100755 src/chroot-tools/libremkchroot create mode 100755 src/diff-unfree create mode 100755 src/fullpkg/fullpkg create mode 100755 src/fullpkg/fullpkg-build create mode 100755 src/fullpkg/fullpkg-find create mode 100755 src/is_built create mode 100755 src/is_unfree create mode 100755 src/librediff create mode 100755 src/libremessages create mode 100755 src/librerepkg create mode 100755 src/mips64el-tools/add-mips64el create mode 100755 src/mips64el-tools/librebasebuilder create mode 100644 src/mips64el-tools/mips-add create mode 100644 src/mips64el-tools/mips64el.conf create mode 100755 src/mips64el-tools/mipsrelease create mode 100755 src/pkgbuild-check-nonfree create mode 100755 src/prtools/prfullpkg create mode 100755 src/prtools/prmipsrelease create mode 100644 src/prtools/prtools.conf create mode 100644 src/prtools/prtoru create mode 100755 src/toru/toru create mode 100755 src/toru/toru-info create mode 100755 src/toru/toru-path create mode 100755 src/toru/toru-utils create mode 100755 src/toru/toru-where create mode 100755 src/treepkg create mode 100755 src/update-cleansystem delete mode 100755 toru delete mode 100755 toru-info delete mode 100755 toru-path delete mode 100755 toru-utils delete mode 100755 toru-where delete mode 100755 treepkg delete mode 100755 update-cleansystem delete mode 100755 updateabslibre diff --git a/abslibre-commit b/abslibre-commit deleted file mode 100755 index e906fbd..0000000 --- a/abslibre-commit +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# ABSLibreCommit -# Commits a PKGBUILD to ABSLibre.git - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 . - -for _pkg in ${@}; do - [[ ! -e ${_pkg}/PKGBUILD ]] && continue - - unset pkgbase pkgname - source ${_pkg}/PKGBUILD - -# use . instead of * will use .gitignore - git stage ${_pkg}/. - - git commit -m "${pkgbase:-$pkgname}-${pkgver}-${pkgrel}" -done - -exit 0 diff --git a/add-mips64el b/add-mips64el deleted file mode 100755 index e06d857..0000000 --- a/add-mips64el +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Change all arch array that aren't any or mips64el already - -find -name 'PKGBUILD' -exec sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" '{}' \; - -exit $? diff --git a/aur b/aur deleted file mode 100755 index 24d4317..0000000 --- a/aur +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# Copyright 2010 Nicolás Reynolds, Joshua Ismael - -# ---------- 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 -source /etc/abs.conf - -function usage { - echo "Usage: $0 pkgname-from-aur1 [pkgname-from-aur2 ...]" - echo - echo "This script will download packages from aur to the current dir" - echo "and check their license for nonfree issues." -} - -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - *) usage; exit 1 ;; - esac -done - -missing_deps=() -for _pkg in ${@}; do - -# Remove the version - _pkg="${_pkg%%[<>=]*}" - - if [ -f "${_pkg}/PKGBUILD" ]; then - warning "${_pkg} already existed." - -# Check if we want to diff - if [ -z "${DIFFTOOL}" ]; then - continue - else -# Store our copy of the PKGBUILD dir - _diff="${PWD}/${_pkg}" - stdnull "pushd $(mktemp -d /tmp/${_pkg}.XXXX)" - msg2 "Downloading PKGBUILD into ${PWD} for diff" - fi - fi - - msg "Downloading $_pkg..." - wget -O - -q https://aur.archlinux.org/packages/$(echo $_pkg | sed "s/^../&\/&/")/$_pkg.tar.gz | \ - tar xzf - >/dev/null 2>&1 - - if [ $? -ne 0 ]; then - error "Couldn't get $_pkg" - continue - fi - - stdnull "pushd $_pkg" - - if [ ! -z "$_diff" ]; then - msg2 "Diffing files" -# Diff all files with our difftool - for file in *; do - ${DIFFTOOL} ${_diff}/${file} ${file} - done - -# Go back to our copy to continue working - stdnull "pushd ${_diff}" - fi - - source PKGBUILD - - if ! pkgbuild-check-nonfree; then - if [ $? -eq 15 ]; then - warning "This PKGBUILD links to known unfree packages" - fi - fi - - msg2 "Checking license..." - free=0 - for _license in ${license[@]}; do - if [ ! -d /usr/share/licenses/common/$_license ]; then - warning "License $_license is not a common license" - free=1 - fi - done - - if [ $free -eq 1 ]; then - plain "Please check that the license is included in the package and - *specially* that it respects your freedom." - fi - - for _dep in ${depends[@]} ${makedepends[@]}; do - _dep=${_dep/[<>=]*/} - if ! is_built $_dep; then - if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then - msg2 "$_dep will be get from AUR" - missing_deps+=($_dep) - fi - else - msg2 "$_dep is on repos" - fi - done - - stdnull popd - -done - -[[ ${#missing_deps[*]} -gt 0 ]] && { - msg2 "Retrieving missing deps: ${missing_deps[@]}" - $0 ${missing_deps[@]} -} - -exit 0 diff --git a/buildenv b/buildenv deleted file mode 100755 index 84a1fc2..0000000 --- a/buildenv +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -trap "umount_all" 0 ERR TERM KILL - -user=${SUDO_USER:-${1}} - -umount_all() { - for mp in home/pkgdest home/srcdest home/${user}; do - msg "Umounting /$mp" - umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount" - done -} - -source /etc/libretools.conf - -for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do - msg "Binding /$mp" - mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1 -done - -for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do - msg "Copying config /$etc" - cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1 -done - -$(dirname $0)/librechroot $CHROOT - -exit $? diff --git a/chcleanup b/chcleanup deleted file mode 100755 index 17c1f02..0000000 --- a/chcleanup +++ /dev/null @@ -1,57 +0,0 @@ -#!/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 -DRYRUN=${DRYRUN:-false} - -source /etc/makepkg.conf -source /etc/libretools.conf -source ${HOME}/.makepkg.conf 2>/dev/null|| true - -msg "Cleaning chroot..." - -TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" -cleanup_log="${TMPDIR}"/libretools-cleanup.log - -cp -a /var/lib/pacman/sync "${TMPDIR}/" -touch ${cleanup_log} - -# If we're running makepkg -if [ -f PKGBUILD ]; then - source PKGBUILD || true - - check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) - -fi - -# Get the full list of packages needed by dependencies, including the base system -sudo pacman -b "${TMPDIR}" \ - -Sp \ - --print-format "%n" \ - base base-devel sudo \ - ${CHROOTEXTRAPKG[@]} \ - ${check[@]} \ - >${cleanup_log} - -# Diff installed packages against a clean chroot then remove leftovers -packages=($(comm -23 <(pacman -Qq | sort) \ - <(sort -u ${cleanup_log}))) - -[ ${#packages[@]} -eq 0 ] && exit 0 - -msg2 "Removing %d packages" ${#packages[@]} - -# Only remove leftovers, -Rcs removes too much -${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} -${DRYRUN} && echo ${packages[@]} - -# Cleanup -${DRYRUN} || rm -fr ${TMPDIR} - -exit $? diff --git a/createworkdir b/createworkdir deleted file mode 100755 index b443c08..0000000 --- a/createworkdir +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# CreateWorkDir -# Creates a dir structure for working with Parabola packages - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -[[ -e $custom_config ]] && source $custom_config - -[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR - - msg "Creating WORKDIR on ${WORKDIR}" - mkdir -p ${WORKDIR} ||{ - error "Could not create ${WORKDIR}"; exit 1 - } - -} - -for _repo in ${REPOS[@]}; do # Create the staging dirs - - [[ ! -d ${WORKDIR}/staging/${_repo} ]] && { - mkdir -p ${WORKDIR}/staging/${_repo} || { - error "Can't create ${WORKDIR}/staging/${_repo}" - exit 1 - } - } - -done - -[[ ! -d ${WORKDIR}/abslibre/.git ]] && { - msg "Cloning into ABSLibre" - CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre" - ${CMD} || { - error "Could not clone ABSLibre" - plain "Try running this command:" - echo - plain "${CMD}" - exit 1 - } -} - -msg "Finished, your packaging dir tree looks like this now:" -ls --color=always ${WORKDIR}/*/* - -exit 0 diff --git a/diff-unfree b/diff-unfree deleted file mode 100755 index a0a8d63..0000000 --- a/diff-unfree +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# This script will help you diff a *-libre PKGBUILD against the unfree one -# to check for updates. -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf - -[[ "$1" == "--help" ]] && { - msg "Diff-Unfree helps you diff build scripts from ABSLibre against - (Unfree) ABS. Package name and repo will we guessed if you don't - specify them." - msg2 "Usage: $0 [community|packages] [unfree-package] [repo]" - exit 0 -} - -[[ ! -r PKGBUILD ]] && { - error "This is not a build dir." - exit 1 -} - -package_guess=$(basename $PWD) - -repo=${1:-$(basename $(dirname $PWD))} -package=${2:-${package_guess/-libre}} -trunk=${3:-trunk} - -tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) - -svnrepo="packages" -case $repo in - community*) - svnrepo="community" - ;; - multilib*) - svnrepo="community" - ;; - *) - ;; -esac - -unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" - -[[ ! -d "${tmp_dir}" ]] && { - error "Can't create temp dir" - exit 1 -} - -stdnull 'pushd "${tmp_dir}"' - -msg "Getting diff from $repo/$package..." - -stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' - -cd ${svnrepo} -svn update ${package} - -# Back to start dir -stdnull popd - -msg "Diffing files" - -for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" - ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" -done - -exit $? diff --git a/fullpkg b/fullpkg deleted file mode 100755 index 9a03b82..0000000 --- a/fullpkg +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# set -x # uncomment for debug -# Builds packages from ABS recursively. It tries to find dependencies that -# aren't built or need update and then makepkg them in order. - -usage() { - - echo "cd to a dir containing a PKGBUILD and run:" - echo "$0 [build_dir]" - echo "" - echo "This script will check dependencies, build them if possible " - echo "and stage the packages on it's repo." - echo "" - echo "OPTIONS:" - echo " -h : this message." - echo "" - echo "Wrapper for \`fullpkg-find' and \`fullpkg-build'" - echo "" - exit 1 - -} - -while getopts 'haA:l:nm:' arg; do - case "$arg" in - h) usage ;; - esac -done - -shift $(( OPTIND - 1 )) - -build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}" -fullpkg-find "$build_dir" && fullpkg-build -N "$build_dir" - -exit 0 diff --git a/fullpkg-build b/fullpkg-build deleted file mode 100755 index b497db5..0000000 --- a/fullpkg-build +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash -# set -x # uncomment for debug -# Builds packages from ABS recursively. It tries to find dependencies that -# aren't built or need update and then makepkg them in order. - -# TODO move __build to chroot - -source /etc/makepkg.conf -source /etc/libretools.conf - -if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then - source $XDG_CONFIG_HOME/libretools/libretools.conf -fi - - -## List packages on log that are on status -## usage: list_pkgs -# -## status: nonfree, built, failed, unstaged -list_pkgs() { - msg="$2" - local pkgs=($(grep "$1:" $build_dir/log)) && { - msg "$2" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } -} - -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) -get_fullver() { - if [[ $1 -eq 0 ]]; then -# zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -## Check all build_dir, fails if one PKGBUILD is nonfree -check_nonfree() { - find "$build_dir" -name PKGBUILD \ - -exec pkgbuild-check-nonfree {} + - if [ "$?" -eq 15 ]; then - error "Some PKGBUILD have nonfree problems" - exit 15 - fi - -} - -# Removes a package from the buildorder -# $1 package name -# $2 buildorder file -remove_buildorder() { - grep -Evw "${1}" ${2} > ${2}2 - mv -f ${2}2 ${2} - - return $? -} - -succesfull_build() { - - if [ "$RUN" != "$FULLBUILDCMD" ]; then - return 0 # Custom command or download sources - fi - - if source .INFO && [ -n "$repo" ]; then - - if [ ! -z "$HOOKLOCALRELEASE" ]; then - find -name "*.pkg.tar.?z" -print0 | xargs -0 "$HOOKLOCALRELEASE" "$repo" - fi - - librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log - - msg "Updating pacman db and packages" - sudo pacman -Sy || true - - fi - - echo "built:$(basename $PWD)" >>$build_dir/log -} - -build_description() { - list_pkgs "nonfree" "Those packages contain nonfree deps:" - list_pkgs "built" "Those packages were built and staged:" - list_pkgs "failed" "Those packages failed to build:" - list_pkgs "unstaged" "Those packages couldn't be staged (missing reponame):" -} - -__build() { - pushd ${build_dir} >/dev/null - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first - - while [ ${#build_packages[@]} -ge 1 ]; do - - pushd "$build_dir/${build_packages[0]}" >/dev/null - - if [ -n "${HOOKPKGBUILDMOD}" ]; then - ${HOOKPKGBUILDMOD} || true - fi - - eval "$RUN"; r=$? - - case $r in - - 0) succesfull_build ;; - - *) error "There were errors while trying to build the package." - echo "failed:$(basename $PWD)" >>$build_dir/log - ;; - esac - - remove_buildorder "${build_packages[0]}" $buildorder || true - -# which is next package? - build_packages=($(sort -gr $buildorder | cut -d: -f2)) - popd > /dev/null - done - - popd >/dev/null -} - -# End inmediately but print a useful message -trap_exit() { - error "$@" - warning "Leftover files left on $build_dir" - mv .BUILDORDER BUILDORDER - exit 1 -} - -# Trap signals from makepkg -set -E -trap 'trap_exit "(fullpkg-build) TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "(fullpkg-build) Aborted by user! Exiting..."' INT -trap 'trap_exit "(fullpkg-build) An unknown error has occurred. Exiting..."' ERR - -CLEANUP="false" -CHECKNONFREE="true" -RUN="$FULLBUILDCMD" -MESSAGE="Building packages" - -usage() { - - echo "" - echo "$(basename $0) [options] " - echo "" - echo "Builds packages from build_dir, create a build_dir using:" - echo "'fullpkg-find '" - echo "" - echo "If no is specified, it uses the current directory." - echo "" - echo "OPTIONS:" - echo " -h : this message." - echo " -c : clean on succesfull build" - echo " -N : don't check for freedom issues." #Also made by fullpkg-find - echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"." - echo " -g : get sources for building packages on build_dir." - echo "" - exit 1 - -} - -while getopts 'hNr:g' arg; do - case $arg in - h) usage ;; - c) CLEAN ;; - N) CHECKNONFREE="false" ;; - r) RUN="$OPTARG" - MESSAGE="Executing custom action";; - g) RUN='makepkg -g > /dev/null' - MESSAGE="Downloading packages";; - esac -done - -shift $(( OPTIND - 1 )) -build_dir="${1:-`pwd`}" -buildorder="${build_dir}/BUILDORDER" - -if [ ! -e "$buildorder" ]; then - error "This is not a build_dir. Make one using fullpkg." - usage -else -# backup BUILDORDER - cp "$buildorder" "$build_dir/.BUILDORDER" -fi - -if "$CHECKNONFREE"; then - check_nonfree -fi - -if [ -z "$FULLBUILDCMD" ]; then - error "Set your FULLBUILDCMD on libretools.conf" -fi - -msg "$MESSAGE" -__build - -if [ "$RUN" != "$FULLBUILDCMD" ]; then - # Used for downloading or custom command - mv "$build_dir/.BUILDORDER" "$buildorder" - exit 0 -elif "$CLEANUP"; then - find "$build_dir" -mindepth 1 -delete -fi - -build_description - -plain "Test packages on and if they work fine librerelease." - -exit 0 diff --git a/fullpkg-find b/fullpkg-find deleted file mode 100755 index e188ec8..0000000 --- a/fullpkg-find +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/bash -# set -x # uncomment for debug -# Builds packages from ABS recursively. It tries to find dependencies that -# aren't built or need update and then makepkg them in order. - -# TODO: fullpkg-find should find packages wich depend on the -# package to be build, so we can avoid "missing $name.so errors" - -# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD -guess_repo() { - basename $(dirname $(pwd)) -} - -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) -get_fullver() { - if [[ $1 -eq 0 ]]; then -# zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -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 - source /etc/makepkg.conf - source PKGBUILD - - local repo="${repo:-$(guess_repo)}" - local pkgbase="${pkgbase:-${pkgname[0]}}" - local fullver="$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel})" - - if ! pkgbuild-check-nonfree > /dev/null 2> /dev/null; then - if [ "$?" -eq 15 ]; then - error "pkgbase" has nonfree issues - return 15 - fi - fi - - # Checking any package built, since otherwise e.g. kdebase would - # be always considered outdated: there is no package built named kdebase. - # TODO: maybe check for the package requested in case of recursive calls, - # instead of the first one listed? - if is_built "${pkgname[0]}" "${fullver}"; then - exit 0 # pkg is built and updated - fi - -# greater levels are built first - echo "${LEVEL}:${pkgbase}" >>"$build_dir/BUILDORDER" -# PKGBUILD is already there - if [ -d "${build_dir}/${pkgbase}" ]; then - exit 0 -# Copy dir to build_dir - else - copy_files - -# to identify repo later - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" - fi - -# current package plus a space for every level - msg2 "%${LEVEL}s${pkgbase}-${fullver}" - -## Check next levels - declare -i next_level=$LEVEL+1 - -# All deps in separate line, only once, without version. - deps=($(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u)) - - for _dep in ${deps[@]}; do - - local found=false - # May fail, e.g. since abslibre-mips64el doesn't include - # arch=any packages. - local pkgdir=$(toru -p ${_dep}) || true - - if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then - found=true - - pushd "${pkgdir}" > /dev/null -# runs itself on dep's PKGBUILD dir - $0 -l ${next_level} ${build_dir} || return $? - popd > /dev/null - fi - - if ! (( found )); then - echo "dep_not_found:$_dep" >>$build_dir/log - fi - - done - -## End variable block - - unset next_level dir -} - -source /etc/libretools.conf - -if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then - source $XDG_CONFIG_HOME/libretools/libretools.conf -fi - -LEVEL=0 -MAXLEVEL=20 -CLEANFIRST='false' -UPDATEDB='true' - -usage() { - - echo "" - echo "cd to a dir containing a PKGBUILD and run:" - echo "$(basename $0) [options] " - echo "" - echo "This script will create a build_dir for recursive building" - echo "it tries to find dependencies that aren't built or need update." - echo "" - echo "If no is specified, the script works on a tempdir" - echo "" - echo "OPTIONS:" - echo " -h : this message." - echo " -A : use this ABSROOT." - echo " -c : clean before working." - echo " -m : check deps until this level" - echo " -n : don't update pacman db." - echo "" - exit 1 - -} - -while getopts 'hA:l:cmn' arg; do - case "$arg" in - h) usage ;; - A) ABSROOT="$OPTARG" ;; - l) LEVEL="$OPTARG" ;; # hidden option to know dep level. - c) CLEANFIRST='true' ;; - m) MAXLEVEL="$OPTARG" ;; - n) UPDATEDB='false' ;; - esac -done - -if [ ! -r PKGBUILD ]; then - error "This directory doesnt contain a PKGBUILD" - usage -fi - -shift $(( OPTIND - 1 )) -build_dir="${1}" - -if [ "$LEVEL" -eq 0 ]; then - - build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}" - - if [ ! -d "$build_dir" ]; then - mkdir -p "$build_dir" - elif "$CLEANFIRST"; then - # Erase files already in dir - msg "Cleaning up files in dir" - find "$build_dir" -mindepth 1 -delete - fi - - if "$UPDATEDB"; then - msg "Updating pacman db" - sudo pacman -Sy --noconfirm || true - fi - -# make files for log and buildorder - touch "${build_dir}"/{log,BUILDORDER} - buildorder="${build_dir}/BUILDORDER" - - msg "Checking dependencies" -fi - -# Find the dependencies on the ABS itself -find_deps - -exit 0 diff --git a/is_built b/is_built deleted file mode 100755 index 1fa79d2..0000000 --- a/is_built +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -usage() { - echo "$0 " - echo - echo "Detect if a given package version is already in repos" - echo "Assuming you want greater or equal" - echo - echo "Example usage: is_built 'pcre' '20'" -} - -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - *) usage; exit 1 ;; - esac -done - -ver=${2} -pkg=${1} -pver=$(LC_ALL=C pacman -Sddp --print-format "%v" "${pkg}" 2>/dev/null) - -# if pacman fails or returns nothing -r=$? -[ "${pver}" = " there is nothing to do" ] && r=1 - -result=$(vercmp "${pver}" "${ver}") - -# if vercmp > 1 means our version is bigger -if [ ${result} -ge 0 -a ${r} -eq 0 ]; then - exit 0 -else - exit 1 -fi - -# just in case -exit 1 diff --git a/is_unfree b/is_unfree deleted file mode 100755 index f32c193..0000000 --- a/is_unfree +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Checks if a package is on blacklist - -# fail immediately on error -set -E - -blacklist="$XDG_CONFIG_HOME/libretools/blacklist.txt" - -egrep -q "^${1}:" "${blacklist}" - -exit $? diff --git a/lb b/lb deleted file mode 100755 index 85fb4df..0000000 --- a/lb +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# LibreTools wrapper -# License: GPLv3 - -source /etc/libretools.conf - -command=$1; shift - -[[ ! -x ~/l/libre"${command}" ]] && { - error "Command not found" - exit 1 -} - -~/l/libre${command} "$@" - -exit $? diff --git a/libreaddiff b/libreaddiff deleted file mode 100755 index 98646a2..0000000 --- a/libreaddiff +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# Copyright (C) 2011, 2012 Michał Masłowski -# -# This program 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. -# -# This program 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -set -e - -. /etc/libretools.conf -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -[ -e $custom_config ] && . $custom_config - -for arg in "$@" ; do - case "$arg" in - -h|--h|--he|--hel|--help|-\?) - echo 'Usage: libreaddiff repo [arch] - -This script outputs a diff of package names and versions in repo -between pacman'\''s sync db and abslibre checkout.' >&2 - exit 0 - ;; - esac -done - -# The repo to find missing packages in. -repo=$1 -# The arch to check in Arch repos, other will have all arches checked. -arch=${2:-mips64el} -# A Python tuple of repos which don't have arch=any packages. -archrepos='("core", "extra", "community")' - -diff -U0 \ - <( ( - cd /var/lib/pacman/sync - for f in $repo.db ; do - tar xOf $f | python -c 'import sys -arch = None -name = None -version = None -it = iter(sys.stdin) -try: - while True: - line = next(it) - if line == "%ARCH%\n": - arch = next(it) - if arch == "'"$arch"'\n" or "'$repo'" not in '"$archrepos"': - print("%s-%s" % (name.strip(), version.strip())) - if line == "%NAME%\n": - name = next(it) - if line == "%VERSION%\n": - version = next(it) -except StopIteration: - pass -' - done - ) | sort ) \ - <( ( - cd "${WORKDIR}/abslibre" - # Needed to not include pkgnames specific to other arches. - CARCH=$arch - for f in $repo/* ; do - unset pkgname - unset epoch - unset pkgver - unset pkgrel - unset arch - . $f/PKGBUILD || continue - is_here=false - for arc in ${arch[@]} ; do - if [ "$arc" = "any" -o "$arc" = "$CARCH" ] ; then - is_here=true - break - fi - done - if [ "$is_here" = "true" ] ; then - for name in ${pkgname[@]} ; do - if [ -z "$epoch" ] ; then - echo $name-$pkgver-$pkgrel - else - echo $name-$epoch:$pkgver-$pkgrel - fi - done - fi - done - ) | sort ) | sed -rn 's/^[+-][^+-].+$/&/p' diff --git a/librebasebuilder b/librebasebuilder deleted file mode 100755 index f7d3a25..0000000 --- a/librebasebuilder +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# Copyright (C) 2012 Michał Masłowski -# -# This program 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. -# -# This program 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -set -e - -# TODO: - -# - make it more configurable - -# - compare the result with previous base images - -for arg in "$@" ; do - case "$arg" in - -h|--h|--he|--hel|--help|-\?) - echo 'Usage: librebasebuilder - -Make a base tarball named parabola-mips64el-DATE.tar.bz2. - -This script must be run as root.' >&2 - exit 0 - ;; - esac -done - -[[ "$UID" != "0" ]] && { - echo "This script must be run as root." >&2 - exit 1 -} - -tempdir=/home/chroot/base -outdir=$(pwd) - -mkarchroot -n $tempdir mkinitcpio base sudo parted nano zile vi ed openssh - -cd $tempdir - -# Don't list mtjm's DNS servers. -cat > etc/resolv.conf < -#nameserver - -# End of file -EOF - -# From pacman-mirrorlist-libre-20120307-1. Remember to escape dollars. -cat > etc/pacman.d/mirrorlist <. - -function usage { - - echo "" - echo "Usage: $0 [options] [chrootname]" - echo "Use it as root." - echo "" - echo "Default chroot name: $CHROOT" - echo "Default chrootdir: $CHROOTDIR" - echo "" - echo "OPTIONS:" - echo "" - echo " -c : clean the chroot using pacman" - echo " only 'base', 'base-devel' and 'sudo' on chroot" - echo " -d : use instead of default" - echo " -r : clean /repo on the chroot" - echo " -h : this message" - echo " -u : update the chroot" - echo "" - -} - -function clean_chroot { # Clean packages with pacman - cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" - - mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" -} - -function clean_repo { - msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}" - if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then - find "${CHROOTDIR}/${CHROOTNAME}/repo/" -mindepth 1 -delete - else - mkdir -p "${CHROOTDIR}/${CHROOTNAME}/repo" - fi - bsdtar -czf "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db" -} -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -CLEANCHROOT='false' -UPDATE='false' -CLEANREPO='false' -CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" - -while getopts 'hrcud:' arg; do - case $arg in - h) usage; exit 0 ;; - c) CLEANCHROOT='true' ;; - u) UPDATE='true' ;; - r) CLEANREPO='true' ;; - d) CHROOTDIR="$(readlink -e $OPTARG)" ;; - esac -done - -[[ "$UID" != "0" ]] && { - error "This script must be run as root." - exit 1 -} - -shift $(($OPTIND - 1)) - -if [ $# -eq 1 ]; then - CHROOTNAME="$1" -fi - -if "$CLEANREPO"; then - clean_repo -fi - -if "$CLEANCHROOT"; then - clean_chroot -elif "$UPDATE"; then - msg "Updating chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -u "${CHROOTDIR}/${CHROOTNAME}" -else - msg "Entering chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -r "bash" "${CHROOTDIR}/${CHROOTNAME}" -fi - -exit 0 diff --git a/librecommit b/librecommit deleted file mode 100755 index 1698bed..0000000 --- a/librecommit +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 - -usage () { - echo "cd to the dir with the PKGBUILD you are commiting and" - echo - echo "$0 [optionally files to commit]" - echo - echo "This script commits the package using name, pkgver and pkgrel" - echo - exit 1 -} - -msg="Commiting libre package \"\$pkg-\$pkgver-\$pkgrel\"" - -for opt in $@ ; do - case ${opt} in - -h) usage ;; - -m) shift; msg=${1}; shift ;; - *) files+="${1} " ; shift ;; - esac -done - -if [ ! -e PKGBUILD -o -z "$files" ]; then usage; fi - -source PKGBUILD - -pkg=${pkgbase:-${pkgname}} - -msg=$(eval echo $msg) - -if [ "$COMMITCMD" = 'git' ]; then - - ${COMMITCMD} add ${files} && ${COMMITCMD} commit -m "$(echo $msg)" - -elif [ "$COMMITCMD" = 'hg' ]; then - - ${COMMITCMD} commit ${files} -m "$msg" -v || exit 1 - -else - - error "COMMITCMD is not correctly set on libretools.conf" - -fi - -exit 0 diff --git a/librediff b/librediff deleted file mode 100755 index 1f39eb9..0000000 --- a/librediff +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Generates a patch for a nonfree PKGBUILD -# -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 . - -usage() { - echo "Usage: $0 [ ...]" - echo "Requirements:" - echo "* Have a / directory with nonfree build scripts inside" - echo "* Have a -libre/ directory with libre build scripts inside" -} - -# Load custom config or system-wide config -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -if [ -e $custom_config ]; then - source $custom_config -else - source /etc/libretools.conf -fi - -# Print usage if no package has been given -[[ -z "$@" ]] && { - usage - exit 1 -} - - -for package in $@; do -# Continue on errors - [[ ! -d ./${package} || ! -d ./${package}-libre ]] && { - error "no matching ${package} and ${package}-libre found" - continue - } - - [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] && { - error "no matching PKGBUILDs found for ${package}-libre" - continue - } - - source ./${package}-libre/PKGBUILD - [[ -z ${pkgbase} ]] && pkgbase=${pkgname} - -# Generate a diff file, no -r since we don't want to patch src/ nor pkg/ - diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch - -done - -exit 0 diff --git a/libremakepkg b/libremakepkg deleted file mode 100755 index f7924f6..0000000 --- a/libremakepkg +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# Copyright 2010 - 2011 Nicolás Reynolds -# Copyright 2011 Joshua Ismael Haase Hernández - -# ---------- 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 . - - -# set -x # uncomment for debug - -function copy_log { # copy logs if they exist - - find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; - -} - - -function trap_exit { # End inmediately but print a useful message - - copy_log - error "$@" - exit 1 - -} - -# Trap signals from makepkg -set -E -trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT -trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR - -source /etc/libretools.conf - -CLEANFIRST="false" -UPDATEFIRST="false" -CHECKNONFREE="true" -LIBRECHROOT_ARGS="" -MAKEPKG_ARGS="" - -function usage { - - echo '' - echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' - echo 'This script will build your package on a chroot.' - echo '' - echo 'OPTIONS:' - echo '' - echo ' -h : show this message.' - echo ' -c : clean the chroot before building.' - echo ' -u : update the chroot before building.' - echo ' -d : use this dir instead of "$CHROOTDIR"' - echo ' -n : use this dir instead of "$CHROOT".' - echo ' -N : do not check freedom issues' # As fullpkg-check will do that before - echo '' - exit 1 - -} - -while getopts 'hcud:n:N' arg ; do - case "${arg}" in - h) usage ;; - c) CLEANFIRST="true" ;; - u) UPDATEFIRST="true" ;; - d) CHROOTDIR="$OPTARG" - LIBRECHROOT_ARGS='-d "$OPTARG"' ;; - n) CHROOT="$OPTARG" ;; - N) CHECKNONFREE="false" ;; - esac -done - -# Pass all arguments after -- right to makechrootpkg -MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}" - -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi - -if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory"; usage -fi - -msg "Checking PKGBUILD for non-free issues" -if "$CHECKNONFREE"; then - if ! pkgbuild-check-nonfree; then - - if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - warning "PKGBUILD couldn't be check aganist non-free issues" - fi - fi -fi - -if "$CLEANFIRST"; then - librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -if "$UPDATEFIRST"; then - librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS - -makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS -ev="$?" # exit value - -copy_log - -exit $ev diff --git a/libremessages b/libremessages deleted file mode 100755 index 68badb8..0000000 --- a/libremessages +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright (c) 2006-2010 Pacman Development Team -# Copyright (c) 2002-2006 by Judd Vinet -# Copyright (c) 2005 by Aurelien Foret -# Copyright (c) 2006 by Miklos Vajna -# Copyright (c) 2005 by Christian Hamar -# Copyright (c) 2006 by Alex Smith -# Copyright (c) 2006 by Andras Voroskoi -# Copyright (c) 2011 by Joshua Haase -# -# This program 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. -# -# This program 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 this program. If not, see . - -# gettext initialization -export TEXTDOMAIN='libretools' -export TEXTDOMAINDIR='/usr/share/locale' - -# check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW -if [[ -t 2 ]]; then - # prefer terminal safe colored and bold text when tput is supported - if tput setaf 0 &>/dev/null; then - ALL_OFF="$(tput sgr0)" - BOLD="$(tput bold)" - PURPLE="${ALL_OFF}$(tput setaf 5)" - BLUE="${BOLD}$(tput setaf 4)" - GREEN="${BOLD}$(tput setaf 2)" - RED="${BOLD}$(tput setaf 1)" - YELLOW="${BOLD}$(tput setaf 3)" - else - ALL_OFF="\e[1;0m" - BOLD="\e[1;1m" - BLUE="${BOLD}\e[1;34m" - GREEN="${BOLD}\e[1;32m" - RED="${BOLD}\e[1;31m" - YELLOW="${BOLD}\e[1;33m" - PURPLE="${BOLD}\033[1;30;40m" - fi -fi -readonly ALL_OFF BOLD BLUE GREEN RED YELLOW PURPLE - -stdnull() { - eval "$@ >/dev/null 2>&1" -} - -plain() { - local mesg=$1; shift - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg() { - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg2() { - local mesg=$1; shift - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -warning() { - local mesg=$1; shift - printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -error() { - local mesg=$1; shift - printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -stat_busy() { - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2 -} - -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 - - local needle=$1; shift - local item - - for item in "$@"; do - [[ ${item#@} = $needle ]] && return 0 # Found - done - - return 1 # Not Found -} diff --git a/libremkchroot b/libremkchroot deleted file mode 100755 index b576209..0000000 --- a/libremkchroot +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# LibreMkChroot -# Creates a chroot - -# Copyright 2011, 2012 Luke Shumaker - -# ---------- 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 - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -cmd=${0##*/} -function usage { - echo "Usage: $cmd [OPTIONS]" - echo 'This script will create a chroot to build packages in.' - echo "Use \`librechroot' to interact with the chroot after it is created." - echo '' - echo 'Options:' - echo ' -h Show this message' - echo '' - echo ' -f Force overwrite of files in the working-dir' - echo '' - echo ' -d Use this dir instead of "$CHROOTDIR".' - echo " -c Location of pacman cache. Default: \`/var/cache/pacman/pkg'." - echo ' -C Location of pacman config file.' - echo ' -M Location of makepkg config file.' -} - -mkchroot_args=(); -while getopts 'hfd:c:C:M:' arg; do - case "$arg" in - h) usage; exit 0 ;; - f) mkchroot_args+=("-$arg");; - c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG ;; - ?) usage; exit 1 ;; - esac -done - -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi - -mkdir -p "${CHROOTDIR}" -xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem diff --git a/librerelease b/librerelease deleted file mode 100755 index efb698e..0000000 --- a/librerelease +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/bash -# Librerelease -# Uploads packages into [staging] - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf - -function usage { - echo "$(gettext "Usage: $0")" - echo - echo "$(gettext "This script uploads packages on $WORKDIR/stagging")" - echo "$(gettext "to parabola server.")" - echo - echo "$(gettext "OPTIONS:")" - echo "$(gettext " -h this message.")" - echo "$(gettext " -l only list packages but not upload them.")" - echo "$(gettext " -c clean packages on $WORKDIR/staging.")" - echo "$(gettext " -n dry-run")" -} - -function list_packages { - repos=($(find "$WORKDIR/staging/" -mindepth 1 -type d \! -empty -printf '%f ' 2>/dev/null)) - for _repo in ${repos[@]}; do - msg2 "$_repo" - find ${WORKDIR}/staging/${_repo} -type f -printf "%f\n" - done - unset repos -} - -function sign_packages { - if [ -z "${SIGEXT}" ]; then - SIGEXT=.sig - warning "Empty SIGEXT var, using default .sig" - fi - - if [ -z "${GPG_AGENT_INFO}" ]; then - warning "It's better to use gpg-agent to sign packages in batches" - fi - - packages=($(find "${WORKDIR}/staging/" -type f -iname '*.pkg.tar.?z')) - for package in ${packages[@]}; do - if [ -f "${package}${SIGEXT}" ]; then - - warning "Package signature found, verifying..." - -# Verify that the signature is correct, else remove for re-signing - if ! gpg --quiet --verify "${package}${SIGEXT}" >/dev/null 2>&1; then - error "Failed! Resigning..." - rm -f "${package}${SIGEXT}" - fi - fi - - msg2 "Signing ${package}..." - gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" \ - --detach-sig "${package}" || { - error "Signing failed" - exit 2 - } - - done -} - -# Remove everything that's not a package or a signature -function clean_non_packages { - find $WORKDIR/staging/ -type f \ - \! -iname "*.pkg.tar.?z" -a \! -iname "*.pkg.tar.?z.sig" \ - -delete -} - -# Clean everything if not on dry-run mode -function clean { - [ -z ${dryrun} ] && \ - rm -f $@ -} - -if [ -w / ]; then - error "Run $0 as normal user" - exit 1 -fi - -while getopts 'hlcn' arg; do - case $arg in - h) usage; exit 0 ;; - l) list_packages; exit 0 ;; - c) clean; exit $? ;; - n) dryrun="--dry-run" ;; - esac -done - -[[ -e $custom_config ]] && source $custom_config - -[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" - -clean_non_packages -if [ ! -z "${SIGID}" ]; then - sign_packages -else - error "Package signing is *required*, please set SIGID on your libretools.conf" - exit 1 -fi - -# Make the permissions of the packages 644 otherwise the user will get access -# denied error when they try to download (rsync --no-perms doesn't seem to -# work). -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 "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) -msg "Uploading packages..." -rsync --recursive \ - ${dryrun} \ - --no-group \ - --no-perms \ - --copy-links \ - --hard-links \ - --partial \ - --prune-empty-dirs \ - --human-readable \ - --progress \ - -e "ssh " \ - ${WORKDIR}/staging \ - ${PARABOLAHOST}:${LIBREDESTDIR}/ || { - error "Sync failed, try again" - exit 1 - } - -msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" -clean ${SYNCED_FILES[@]} - -msg "Running db-update on repos" -ssh ${PARABOLAHOST} dbscripts/db-update - -exit 0 diff --git a/librerepkg b/librerepkg deleted file mode 100755 index d506003..0000000 --- a/librerepkg +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# Copyright 2011 Joshua Ismael Haase Hernandez - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -if [ -x $custom_config ]; then - source $custom_config; - unset $custom_config -fi - -[[ ! -r rePKGBUILD ]] && { - error "This build does not contains a rePKGBUILD." - exit 1 -} - -source /etc/makepkg.conf -source /etc/abs.conf -source rePKGBUILD - -usage() { - echo "cd to a dir with a rePKGBUILD and other file info and run" - echo "$0 [makepkg flags]" - echo - echo "This script will repackage an arch package without compiling" -} - -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - esac -done - -makepkgflags=$@ - -tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX) - -msg "Copying files" -cp ./* ${tempdir}/ - -for _arch in ${arch[@]}; do - - msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))" - - stdnull pushd ${tempdir} - - msg2 "Updating md5sums" - makepkg -gp rePKGBUILD >> rePKGBUILD - - echo "export CARCH=${_arch}" >> rePKGBUILD - - msg "Repackaging using makepkg" - makepkg -Lcdp rePKGBUILD ${makepkgflags} - - stdnull popd ${tempdir} -done diff --git a/librestage b/librestage deleted file mode 100755 index b474bb1..0000000 --- a/librestage +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# LibreStage -# Prepares packages for upload into [staging] - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -[[ -e $custom_config ]] && source $custom_config - -if [ -w / ]; then - error "This script should be run as regular user" - exit 1 -fi - - -# End Config - -usage() { - cat < [ ... ] - -LibreRelease will stage for upload the package(s) built by the PKGBUILD on -the current directory to the specified repo(s). -EOU -} - -repos=$@ - -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - esac -done - -if [ ${#repos} -eq 0 ]; then - usage - exit 1; -fi - -[[ ! -e ./PKGBUILD ]] && { - error "PKGBUILD not found" - exit 1 -} - -# Source the needed files -source /etc/makepkg.conf -[[ -e ~/.makepkg.conf ]] && source ~/.makepkg.conf -source ./PKGBUILD -[[ -e ./rePKGBUILD ]] && source ./rePKGBUILD - -# Default package location -PKGDEST=${PKGDEST:-.} -SRCPKGDEST=${SRCPKGDEST:-.} - -PKGEXT=".pkg.tar.?z" - -staged=false -# Copies the packages to the specified repos inside staging -for _arch in ${ARCHES[@]}; do - for pkg in ${pkgname[@]}; do - - pkgpath=$(find ${PKGDEST}/ -type f \ - -name "${pkg}-${pkgver}-${pkgrel}-${_arch}${PKGEXT}" -or \ - -name "${pkg}-${epoch}:${pkgver}-${pkgrel}-${_arch}${PKGEXT}") - - [[ -z ${pkgpath} ]] && continue - - pkgfile=$(basename ${pkgpath}) - -# TODO refactor this - if [ -e "${pkgpath}" ]; then - msg "Found ${pkgfile}" - - canonical="" - for _repo in ${repos[@]}; do - - if [ ! -d "${WORKDIR}/staging/${_repo}" ]; then - warning "[${_repo}] didn't exist, creating..." - mkdir -p "${WORKDIR}/staging/${_repo}" - fi - - if [ -z "$canonical" ]; then - canonical="${WORKDIR}/staging/${_repo}/${pkgfile}" - - cp "${pkgpath}" "${WORKDIR}/staging/${_repo}/" || { - error "Can't put ${pkgfile} on [staging]" - exit 1 - } && { - msg2 "${pkg} staged on [${_repo}]" - staged=true - } - - else - ln "${canonical}" "${WORKDIR}/staging/${_repo}/${pkgfile}" || { - error "Can't put ${pkgfile} on [staging]" - exit 1 - } && { - msg2 "${pkg} staged on [${_repo}]" - staged=true - } - - fi - done - fi - done -done - -if ! $staged ; then - error "No package was staged" - exit 1 -fi - -exit 0 diff --git a/mips64el/mips-add b/mips64el/mips-add deleted file mode 100644 index da9b431..0000000 --- a/mips64el/mips-add +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -source /etc/libretools.conf -if ! grep mips64el PKGBUILD >/dev/null; then # Add mips64el in ${arch} array if it isn't 'any' - warning "Adding mips64el arch" - sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" - librecommit PKGBUILD -fi diff --git a/mips64el/mips64el.conf b/mips64el/mips64el.conf deleted file mode 100644 index 836b407..0000000 --- a/mips64el/mips64el.conf +++ /dev/null @@ -1,12 +0,0 @@ -## Arquitecture specific commands - -## Run a command for PKGBUILD modifications before building -## Like adding 'mips64el' to arch if it's not there -# HOOKPKGBUILDMOD="mips-add" - -## Run a command for local releasing of packages -# Useful for mass packaging (ie. mips port) -# Must accept the following parameters even if the command won't use them: -# $1 repo name -# $2+ packages -# HOOKLOCALRELEASE="mipsrelease" diff --git a/mips64el/mipsrelease b/mips64el/mipsrelease deleted file mode 100755 index 4d7a7de..0000000 --- a/mips64el/mipsrelease +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Lic: GPLv3+ -# Author: Nicolas Reynolds -# Local release of mips64el packages + clean ABS sync -# Called by HOOKLOCALRELEASE - -# $1 repo -# $2+ packages - -source /etc/makepkg.conf -source /etc/libretools.conf - -libretoolsdir="$(dirname $0)/../" - -usage() { - echo "$0 repo package1 [ package2 ... packageN ]" - echo - echo " release packages locally on ${PKGDEST}/stage3." - echo " and make a clean ABS sync " -} - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - -repo=$1; shift - -if [ -z "${repo}" ]; then - error "Empty repo" - exit 1 -fi - -# Get all needed sources -source PKGBUILD -fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) -pkgs=() -makepkg --source -f --skippgpcheck - -msg "Adding packages to [stage3]..." -for name in ${pkgname[@]}; do - msg2 "${name} ${fullver}" - pkgs+=("${PKGDEST}/${name}-${fullver}-*.pkg.tar.*") -done - -repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]} - -librestage ${repo} - - -mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null - -pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null - tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT} -popd >/dev/null - -exit $? diff --git a/pkgbuild-check-nonfree b/pkgbuild-check-nonfree deleted file mode 100755 index df0ff36..0000000 --- a/pkgbuild-check-nonfree +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash -# pkgbuild-check-nonfree -# Copyright 2010 Joshua Ismael Haase Hernández, Joseph Graham - -# ---------- 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 . - -# function log_end { -# kill "$teepid" -# rm "$logpipe" -# } - -# function log { -# LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log" -# # ensure overridden package variables survive tee with split packages -# logpipe="$(mktemp -u "$startdir/logpipe.XXXXXXXX")" -# mkfifo "$logpipe" -# tee "$LOG" < "$logpipe" & -# teepid=$! -# trap log_end ERR EXIT -# } - - -function unset_pkgbuild { - - unset 'pkgbase' 'pkgname' 'pkgver' 'pkgrel' 'epoch' 'pkgdesc' \ - 'arch' 'url' 'license' 'groups' 'optdepends' 'provides' \ - 'conflicts' 'replaces' 'backup' 'options' 'install' \ - 'changelog' 'source' 'noextract' 'md5sums' 'build' \ - 'check' 'package' 'depends' 'makedepends' 'checkdepends' - -} - -function assert_pkgbuild { - - if [ -e "$1" ]; then - - source "$1" - if [ -n "${pkgname[0]}" ]; then - return 0 # valid PKGBUILD - fi - - fi - - error "$1 is not a valid PKGBUILD" - return 1 -} - -function check_replacement { - - [ $2 ] || return 0 # Free (not found) - local needle=$1; shift - local item - local rep - for line in $@; do - - item="$(echo "$line" | cut -d':' -f1)" - rep="$(echo "$line" | cut -s -d':' -f2)" - - if [ "$item" == "$needle" ]; then - if [ -z "$rep" ]; then - return 15 # Nonfree (found) - else - echo "$rep" - return 0 # Free (has replacement) - fi - fi - - done - return 0 # Free (not found) -} - -function get_blacklist { # Download the blacklist. - - pushd "$XDG_CONFIG_HOME/libretools" >/dev/null - - msg "Downloading the blacklist of proprietary software packages." - - if ! wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null; then - - if [ -e "$XDG_CONFIG_HOME/libretools/blacklist.txt" ]; then - warning "Using local copy of blacklist" - else - error "Download failed, exiting" - fi - - fi - - popd > /dev/null -} - -function check_deps { # Check wheter a package depends on non-free - - unset_pkgbuild - - if ! assert_pkgbuild "$1"; then - return 1 # not PKGBUILD - fi - - msg2 "${pkgbase:-${pkgname[0]}} $pkgver $pkgrel ${epoch:-""}" # > "$logpipe" - - for pkg in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ${checkdepends[@]}; do - - lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_")) - - rep="$(check_replacement $pkg ${lines[@]})" - freedom=$? - - if [ "$freedom" -eq 15 ]; then - warning "found $pkg" # > "$logpipe" - ev=15 - continue - - elif [ -n "$rep" ]; then - - if [ "$rep" = "$pkg" ]; then - plain "$pkg is repackaged with the same name." # > "$logpipe" - continue - else - plain "$pkg -> $rep" # > "$logpipe" - continue - fi - - fi - - done - -} - -function usage { - # TODO: implement PKGBUILD arguments - echo "" - echo "$(basename $0) [options] [PKGBUILD1 PKGBUILD2 ...]" - echo "" - echo "OPTIONS" - echo "" - echo " -h : this message" - echo "" - echo "If no PKGBUILD is specified, one is searched on current directory" - - exit 1 -} - -while getopts 'h' arg; do - case "$arg" in - h) usage ;; - esac -done - -if [ -w / ]; then - error "Run as normal user" -fi - -source /etc/libretools.conf -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -if [ -z "${BLACKLIST}" ]; then - error "BLACKLIST variable is not set your libretools.conf file" - exit 1 -fi - -if [ ! -d "$XDG_CONFIG_HOME/libretools" ]; then - mkdir -p "$XDG_CONFIG_HOME/libretools" -fi - -startdir=`pwd` - -get_blacklist -# log - -shift $(( OPTIND - 1)) - -msg "Looking for unfree dependencies" - -if [ $# -ge 1 ]; then - - for p in $@; do - if [ -n "$p" ]; then - check_deps "$p" - fi - done - -else - - check_deps "`pwd`/PKGBUILD" - -fi - -exit $ev diff --git a/prtools/prfullpkg b/prtools/prfullpkg deleted file mode 100755 index bbb8d73..0000000 --- a/prtools/prfullpkg +++ /dev/null @@ -1,398 +0,0 @@ -#!/bin/bash - -source /etc/makepkg.conf -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.conf - -if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors - - error "There's no XDG_CONFIG_HOME var set"; exit 1 - -elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then - - source $XDG_CONFIG_HOME/libretools/libretools.conf - -fi - - -function usage { - - echo "cd to a dir containing a PKGBUILD and run:" - echo "$0 [options]" - printf "This script will check dependencies, build them if possible " - printf "and stage the packages on it's repo." - echo - echo "OPTIONS:" - echo " -h : this message." - echo " -a absdir : set absdir as ABSROOT." - echo " -b build_dir : use a fullpkg build_dir and only build." - echo " -c : check deps only, do not build." - echo " -d build_dir : use this dir to build. Defaults to mktemp." - echo " -n : don't update pacman db." - echo " -m max_level : check deps until this level" - echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" - echo - exit 1 - -} - -function remove_buildorder { # Removes a package from the buildorder -# $1 package name -# $2 buildorder file - - grep -Evw "${1}" ${2} > ${2}2 - mv -f ${2}2 ${2} - -} - -function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD - - basename $(pwd) - -} - -function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel - -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) - - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -function cleanup { # Cleans the build_dir. - - [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. - - - if [ $level -eq 0 ]; then # Only do cleanup on level 0. - msg "Cleaning up ${build_dir}" - rm -rf "$build_dir/*" - fi -} - -function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. - - source PKGBUILD ## Check this level. - - local repo=${repo:-$(guess_repo)} - local pkgbase=${pkgbase:-${pkgname[0]}} - local epoch=${epoch:-0} - local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) - - if is_built "${pkgbase}" "${fullver}"; then - exit 0 # pkg is built and updated - fi - - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first - - if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there - - exit 0 - - else # Copy dir to build_dir - - mkdir ${build_dir}/${pkgbase} - cp -r $(pwd)/* ${build_dir}/${pkgbase} - - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later - fi - - msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level - - declare -i next_level=$level+1 ## Check next deps level. - - deps=$(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u) # All deps in separate line, only once, without version. - - for _dep in ${deps[@]}; do - - local found=false - - if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo - - for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order - - if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then - - pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular deps - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - else # pkgsplit, needs guess - - for _repo in ${REPOS[@]}; do - - if _dir=($(find "$ABSROOT/" -type f \ - -wholename "*/${_repo}/PKGBUILD" -print0 2>/dev/null | \ - "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ - grep -w "$_dep" 2>&1)) ; - - then - - _dir=$(dirname $(echo $_dir | cut -d: -f1)) - plain "guess for $_dep -> $_dir" - - pushd "$_dir" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular dep - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - fi - - if ( ${found} ); then - continue 1 # go to next dep - else - echo "dep_not_found:$_dep" >> $build_dir/log - fi - - done - - unset next_level dir - # unset PKGBUILD variables - unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ - makedepens checkdepends optdepends provides conflicts replaces backup \ - options install changelog source noextract md5sums build check package -} - -function __build () { - pushd ${build_dir} > /dev/null - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first - - while [ ${#build_packages[@]} -ge 1 ]; do - pushd $build_dir/${build_packages[0]} > /dev/null - source PKGBUILD - - msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" - - msg2 "Checking for non free deps" - pkgbuild-check-nonfree || { - if [ $? -eq 15 ]; then # this error means nonfree others means fail. - - echo "nonfree:$(basename $PWD)" >> $build_dir/log - - remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder - - continue # build next package - fi - } - - msg2 "Building $(basename $PWD)" - - $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf - - case $r in - - 0) ## Succesfull build - - plain "The build was succesful." - if source .INFO && [ -n $repo ]; then - - if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used - find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo - fi - - librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log - - msg "Updating pacman db and packages" - sudo pacman -Sy || true - - fi - - echo "built:$(basename $PWD)" >> $build_dir/log - ;; - - *) ## Build failed - error "There were errors while trying to build the package." - echo "failed:$(basename $PWD)" >> $build_dir/log - ;; - esac - - remove_buildorder "${build_packages[0]}" $buildorder || true - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? - popd > /dev/null - done - - pkgs=($(grep "nonfree:" $build_dir/log)) && { - error "Those packages contain nonfree deps:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "built:" $build_dir/log)) && { - msg "Those packages were built and staged:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "failed:" $build_dir/log)) && { - error "Those packages failed to build:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "unstaged:" $build_dir/log)) && { - error "Those packages couldn't be staged because of missing reponame:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - popd > /dev/null -} - -function trap_exit { # End inmediately but print a useful message - - error "$@" - warning "Leftover files left on $build_dir" - - exit 1 -} - -# 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 - -ban_file=$XDG_CONFIG_HOME/libretools/ban -force_build="" -level=0 -noupdate='n' -build_only='n' -check_deps_only='n' -max_level=21 - -while getopts 'ha:b:cd:l:nm:r:' arg; do - case $arg in - h) usage ;; - a) ABSROOT="$OPTARG" ;; - b) build_only='y' - build_dir="$OPTARG" - if [ -z ${build_dir} ]; then - usage - fi - if [ ! -r ${build_dir}/BUILDORDER ] ; then - error "${build_dir}/BUILDORDER doesn't exist." - exit 1 - fi;; - c) check_deps_only='y' ;; - d) build_dir="$OPTARG" ;; - l) level=$OPTARG ;; # hidden option to know dep level. - n) noupdate='y';; - m) max_level=$OPTARG ;; - r) FULLBUILDCMD="$OPTARG" ;; - esac -done - -if [ ${build_only} == 'n' ]; then - - [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory" - usage - } - - if [ ! -z "$HOOKPKGBUILDMOD" ]; then - "$HOOKPKGBUILDMOD" - fi - -fi - -if [ $level -eq 0 ]; then - - if [ ! -d ${build_dir} ]; then # in case of custom -d option - mkdir -p ${build_dir} - else - cleanup # files already there can screw find_deps - fi - - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp - - touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder - buildorder=${build_dir}/BUILDORDER - - if [ ${noupdate} = 'n' ]; then - - msg "Updating pacman db and packages" - sudo pacman -Syu --noconfirm || true - - fi - - if [ ${build_only} == 'y' ]; then - - msg "Build Packages" - - __build - - exit 0 - - fi - - msg "Checking dependencies" -fi - -[ $level -ge $max_level ] && exit 20 # Probable circular deps - -find_deps || { - - if [ $? -eq 20 ]; then # Probable circular deps - - if [ $level -eq 0 ]; then # Show error only on level 0 - error "Check for circular deps on $build_dir/BUILDORDER"; - fi - - fi - exit 20 # Pass message 20 -} - -[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 - -if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check - - if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions - - chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" - - else - - rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { - - warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist - - search=$(cat ${ban_file} | tr "\n" "|") - - egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files - - egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder - - mv -f ${buildorder}2 ${buildorder} - - unset search - } - } - fi -fi - -msg "Building packages:" - -__build # Build the packages - -echo -msg2 "Check if your system works fine and librerelease if it does" - -exit 0 diff --git a/prtools/prmipsrelease b/prtools/prmipsrelease deleted file mode 100755 index 1fbd696..0000000 --- a/prtools/prmipsrelease +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# Lic: GPLv3+ -# Author: Nicolas Reynolds -# Local release of mips64el packages + clean ABS sync -# Called by HOOKLOCALRELEASE - -# $1 repo -# $2+ packages - - source /etc/makepkg.conf - source /etc/libretools.conf - source /etc/libretools.d/prtools.conf - - usage() { - echo "$0 repo package1 [ package2 ... packageN ]" - echo - echo " release packages locally on ${PKGDEST}/stage3." - echo " and make a clean ABS sync " - } - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## - get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - } - - repo=$1; shift - repo-add "${PKGDEST}/stage3.db.tar.gz" $@ - -# Get all needed sources - source PKGBUILD - fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-$pkgname} - - msg "Adding packages to [stage3]..." - repo-add $@ - for name in ${pkgname[@]}; do - msg2 "${name} ${fullver}" - repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* - done - -# Copy PKGBUILD and sources - - msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase" - dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase" - mkdir -p ${dest_dir} >/dev/null - rm -rf ${dest_dir}/* # if package existed already there - - eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources. - export CARCH - source=($(. "PKGBUILD"; echo ${source[@]})) - cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1" - for f in ${source[@]}; do - basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g') - if [ -f "$basef" ]; then - cp --remove-destination "$basef" "${dest_dir}" - fi - done - - ( . PKGBUILD - for i in 'changelog' 'install'; do - filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) - for file in $filelist; do - # evaluate any bash variables used - eval file=${file} - if [ -f "$file" ]; then - cp --remove-destination "$file" "${dest_dir}" - fi - done - done - ) -# END add clean abs - -# Commit the changes - - pushd "$dest_dir" >/dev/null - - source "${dest_dir}/PKGBUILD" - epoch=${epoch:-0} - fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-${pkgname[0]}} - - git add "${dest_dir}/." # add using .gitignore - - git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}" - - popd >/dev/null - -# END commit - - exit $? diff --git a/prtools/prtools.conf b/prtools/prtools.conf deleted file mode 100644 index 5b41216..0000000 --- a/prtools/prtools.conf +++ /dev/null @@ -1,4 +0,0 @@ - -# Absroot for libretools-pr -ABSROOT=$WORKDIR/prabs -HOOKLOCALRELEASE="prmipsrelease" \ No newline at end of file diff --git a/prtools/prtoru b/prtools/prtoru deleted file mode 100644 index 2898b66..0000000 --- a/prtools/prtoru +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash -# Queries the ABS -# License: GPL3 - -## TODO -# * Add license text -# * Create symlinks from pkgbase to pkgname[@] for easy package finding -# * Use lastsync to store processed packages - -## GOALS -# * Have a searchable database of PKGBUILD metadata -# * Have an interface for source-only builds -# * Possibility to hook up ABS dirs besides ABSROOT (low priority) -# * Tell updates and non available binary packages (working on this) - -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.conf - -# Stores the lastsync date -lastsync() { - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } - - date +%s > "$lastsyncfile" - touch "$lastsyncfile" -} - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - -# Outputs an ordered package-fullpkgver array -print_package_array() { - echo "$@" | tr " " "\n" | sort -V -u -} - - -# Gets repo.db contents -# $1 repo -get_db_contents() { - [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 - - bsdtar -tf /var/lib/pacman/sync/$1.db | \ - cut -d'/' -f1 | \ - sort -V -u -} - - -extract_pkgname() { - echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" -} - -extract_fullpkgver() { - echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" -} - - -# Updates the database by finding all PKGBUILDS -# Workflow: -# * Find all PKGBUILDs on the ABS repo specified -# * Get all packages already on package repos -# * Compare them -# Args: -update() { -# The PKGBUILDs found - local pkgbuilds=() -# The list of pkgname-fullpkgver - local packages_to_sync=() - local packages_in_sync=() - local needed_updates=() - local old_versions=() - -# Find all the PKGBUILDs newer than the last update -# Update newer, otherwise everything - if [ $force ] || [ ! -e ${lastsyncfile} ]; then - $quiet || msg "Forcing upgrade" - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) - else - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) - fi - -# Inform how many PKGBUILDS were found and quit immediately if none - $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" - [ ${#pkgbuilds[*]} -eq 1 ] && { - $quiet || msg2 "There's nothing to be done. Phew!" - exit 0 - } - - for _pkgbuild in ${pkgbuilds[@]}; do - -# The repo name is guessed -# You *must* use repo/pkgbase structure - _pkgpath=$(dirname "${_pkgbuild}") - _pkgbase=$(basename "${_pkgpath}") - _pkgrepo=$(basename $(dirname "${_pkgpath}")) - - source ${_pkgbuild} - - for _pkg in ${pkgname[@]}; do -# Fill the list of packages to find - packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) - done - - unset pkgbase pkgname pkgver pkgrel source epoch - done - -# Get repo database contents - packages_in_sync=($(get_db_contents ${_pkgrepo})) - print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync - print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync - -# We've orderer the files! - needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - - $quiet || msg "This packages are available to update" - for _update in ${needed_updates[@]}; do - pkg=$(extract_pkgname $_update) - - $quiet && echo $pkg - $quiet || { - ver=$(extract_fullpkgver $_update) - oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) - - msg2 "$pkg $oldver => $ver" - } - - done - -# lastsync - -} - -## MAIN -commands=() -repos=() -quiet=false -force=false -while getopts 'hqfu' arg; do - case $arg in - h) usage; exit 0 ;; - q) quiet=true ;; - f) force=true ;; - u) commands+=(update);; - esac - - shift $((OPTIND-1)) -done - -# This is the syncfile, stores the last date as content and mtime -lastsyncfile=${ABSROOT}/toru.lastsync - -TMPDIR=$(mktemp -d) - -[[ -z ${TMPDIR} ]] && exit 1 - -${commands[0]} ${@} - -rm -rf ${TMPDIR} - -exit $? diff --git a/src/abslibre-tools/abslibre-commit b/src/abslibre-tools/abslibre-commit new file mode 100755 index 0000000..e906fbd --- /dev/null +++ b/src/abslibre-tools/abslibre-commit @@ -0,0 +1,36 @@ +#!/bin/bash +# ABSLibreCommit +# Commits a PKGBUILD to ABSLibre.git + +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 . + +for _pkg in ${@}; do + [[ ! -e ${_pkg}/PKGBUILD ]] && continue + + unset pkgbase pkgname + source ${_pkg}/PKGBUILD + +# use . instead of * will use .gitignore + git stage ${_pkg}/. + + git commit -m "${pkgbase:-$pkgname}-${pkgver}-${pkgrel}" +done + +exit 0 diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir new file mode 100755 index 0000000..b443c08 --- /dev/null +++ b/src/abslibre-tools/createworkdir @@ -0,0 +1,63 @@ +#!/bin/bash +# CreateWorkDir +# Creates a dir structure for working with Parabola packages + +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +[[ -e $custom_config ]] && source $custom_config + +[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR + + msg "Creating WORKDIR on ${WORKDIR}" + mkdir -p ${WORKDIR} ||{ + error "Could not create ${WORKDIR}"; exit 1 + } + +} + +for _repo in ${REPOS[@]}; do # Create the staging dirs + + [[ ! -d ${WORKDIR}/staging/${_repo} ]] && { + mkdir -p ${WORKDIR}/staging/${_repo} || { + error "Can't create ${WORKDIR}/staging/${_repo}" + exit 1 + } + } + +done + +[[ ! -d ${WORKDIR}/abslibre/.git ]] && { + msg "Cloning into ABSLibre" + CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre" + ${CMD} || { + error "Could not clone ABSLibre" + plain "Try running this command:" + echo + plain "${CMD}" + exit 1 + } +} + +msg "Finished, your packaging dir tree looks like this now:" +ls --color=always ${WORKDIR}/*/* + +exit 0 diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff new file mode 100755 index 0000000..98646a2 --- /dev/null +++ b/src/abslibre-tools/libreaddiff @@ -0,0 +1,97 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# Copyright (C) 2011, 2012 Michał Masłowski +# +# This program 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. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +set -e + +. /etc/libretools.conf +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +[ -e $custom_config ] && . $custom_config + +for arg in "$@" ; do + case "$arg" in + -h|--h|--he|--hel|--help|-\?) + echo 'Usage: libreaddiff repo [arch] + +This script outputs a diff of package names and versions in repo +between pacman'\''s sync db and abslibre checkout.' >&2 + exit 0 + ;; + esac +done + +# The repo to find missing packages in. +repo=$1 +# The arch to check in Arch repos, other will have all arches checked. +arch=${2:-mips64el} +# A Python tuple of repos which don't have arch=any packages. +archrepos='("core", "extra", "community")' + +diff -U0 \ + <( ( + cd /var/lib/pacman/sync + for f in $repo.db ; do + tar xOf $f | python -c 'import sys +arch = None +name = None +version = None +it = iter(sys.stdin) +try: + while True: + line = next(it) + if line == "%ARCH%\n": + arch = next(it) + if arch == "'"$arch"'\n" or "'$repo'" not in '"$archrepos"': + print("%s-%s" % (name.strip(), version.strip())) + if line == "%NAME%\n": + name = next(it) + if line == "%VERSION%\n": + version = next(it) +except StopIteration: + pass +' + done + ) | sort ) \ + <( ( + cd "${WORKDIR}/abslibre" + # Needed to not include pkgnames specific to other arches. + CARCH=$arch + for f in $repo/* ; do + unset pkgname + unset epoch + unset pkgver + unset pkgrel + unset arch + . $f/PKGBUILD || continue + is_here=false + for arc in ${arch[@]} ; do + if [ "$arc" = "any" -o "$arc" = "$CARCH" ] ; then + is_here=true + break + fi + done + if [ "$is_here" = "true" ] ; then + for name in ${pkgname[@]} ; do + if [ -z "$epoch" ] ; then + echo $name-$pkgver-$pkgrel + else + echo $name-$epoch:$pkgver-$pkgrel + fi + done + fi + done + ) | sort ) | sed -rn 's/^[+-][^+-].+$/&/p' diff --git a/src/abslibre-tools/librecommit b/src/abslibre-tools/librecommit new file mode 100755 index 0000000..1698bed --- /dev/null +++ b/src/abslibre-tools/librecommit @@ -0,0 +1,65 @@ +#!/bin/bash +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 + +usage () { + echo "cd to the dir with the PKGBUILD you are commiting and" + echo + echo "$0 [optionally files to commit]" + echo + echo "This script commits the package using name, pkgver and pkgrel" + echo + exit 1 +} + +msg="Commiting libre package \"\$pkg-\$pkgver-\$pkgrel\"" + +for opt in $@ ; do + case ${opt} in + -h) usage ;; + -m) shift; msg=${1}; shift ;; + *) files+="${1} " ; shift ;; + esac +done + +if [ ! -e PKGBUILD -o -z "$files" ]; then usage; fi + +source PKGBUILD + +pkg=${pkgbase:-${pkgname}} + +msg=$(eval echo $msg) + +if [ "$COMMITCMD" = 'git' ]; then + + ${COMMITCMD} add ${files} && ${COMMITCMD} commit -m "$(echo $msg)" + +elif [ "$COMMITCMD" = 'hg' ]; then + + ${COMMITCMD} commit ${files} -m "$msg" -v || exit 1 + +else + + error "COMMITCMD is not correctly set on libretools.conf" + +fi + +exit 0 diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease new file mode 100755 index 0000000..efb698e --- /dev/null +++ b/src/abslibre-tools/librerelease @@ -0,0 +1,155 @@ +#!/bin/bash +# Librerelease +# Uploads packages into [staging] + +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf + +function usage { + echo "$(gettext "Usage: $0")" + echo + echo "$(gettext "This script uploads packages on $WORKDIR/stagging")" + echo "$(gettext "to parabola server.")" + echo + echo "$(gettext "OPTIONS:")" + echo "$(gettext " -h this message.")" + echo "$(gettext " -l only list packages but not upload them.")" + echo "$(gettext " -c clean packages on $WORKDIR/staging.")" + echo "$(gettext " -n dry-run")" +} + +function list_packages { + repos=($(find "$WORKDIR/staging/" -mindepth 1 -type d \! -empty -printf '%f ' 2>/dev/null)) + for _repo in ${repos[@]}; do + msg2 "$_repo" + find ${WORKDIR}/staging/${_repo} -type f -printf "%f\n" + done + unset repos +} + +function sign_packages { + if [ -z "${SIGEXT}" ]; then + SIGEXT=.sig + warning "Empty SIGEXT var, using default .sig" + fi + + if [ -z "${GPG_AGENT_INFO}" ]; then + warning "It's better to use gpg-agent to sign packages in batches" + fi + + packages=($(find "${WORKDIR}/staging/" -type f -iname '*.pkg.tar.?z')) + for package in ${packages[@]}; do + if [ -f "${package}${SIGEXT}" ]; then + + warning "Package signature found, verifying..." + +# Verify that the signature is correct, else remove for re-signing + if ! gpg --quiet --verify "${package}${SIGEXT}" >/dev/null 2>&1; then + error "Failed! Resigning..." + rm -f "${package}${SIGEXT}" + fi + fi + + msg2 "Signing ${package}..." + gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" \ + --detach-sig "${package}" || { + error "Signing failed" + exit 2 + } + + done +} + +# Remove everything that's not a package or a signature +function clean_non_packages { + find $WORKDIR/staging/ -type f \ + \! -iname "*.pkg.tar.?z" -a \! -iname "*.pkg.tar.?z.sig" \ + -delete +} + +# Clean everything if not on dry-run mode +function clean { + [ -z ${dryrun} ] && \ + rm -f $@ +} + +if [ -w / ]; then + error "Run $0 as normal user" + exit 1 +fi + +while getopts 'hlcn' arg; do + case $arg in + h) usage; exit 0 ;; + l) list_packages; exit 0 ;; + c) clean; exit $? ;; + n) dryrun="--dry-run" ;; + esac +done + +[[ -e $custom_config ]] && source $custom_config + +[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" + +clean_non_packages +if [ ! -z "${SIGID}" ]; then + sign_packages +else + error "Package signing is *required*, please set SIGID on your libretools.conf" + exit 1 +fi + +# Make the permissions of the packages 644 otherwise the user will get access +# denied error when they try to download (rsync --no-perms doesn't seem to +# work). +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 "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) +msg "Uploading packages..." +rsync --recursive \ + ${dryrun} \ + --no-group \ + --no-perms \ + --copy-links \ + --hard-links \ + --partial \ + --prune-empty-dirs \ + --human-readable \ + --progress \ + -e "ssh " \ + ${WORKDIR}/staging \ + ${PARABOLAHOST}:${LIBREDESTDIR}/ || { + error "Sync failed, try again" + exit 1 + } + +msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" +clean ${SYNCED_FILES[@]} + +msg "Running db-update on repos" +ssh ${PARABOLAHOST} dbscripts/db-update + +exit 0 diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage new file mode 100755 index 0000000..b474bb1 --- /dev/null +++ b/src/abslibre-tools/librestage @@ -0,0 +1,138 @@ +#!/bin/bash +# LibreStage +# Prepares packages for upload into [staging] + +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +[[ -e $custom_config ]] && source $custom_config + +if [ -w / ]; then + error "This script should be run as regular user" + exit 1 +fi + + +# End Config + +usage() { + cat < [ ... ] + +LibreRelease will stage for upload the package(s) built by the PKGBUILD on +the current directory to the specified repo(s). +EOU +} + +repos=$@ + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + esac +done + +if [ ${#repos} -eq 0 ]; then + usage + exit 1; +fi + +[[ ! -e ./PKGBUILD ]] && { + error "PKGBUILD not found" + exit 1 +} + +# Source the needed files +source /etc/makepkg.conf +[[ -e ~/.makepkg.conf ]] && source ~/.makepkg.conf +source ./PKGBUILD +[[ -e ./rePKGBUILD ]] && source ./rePKGBUILD + +# Default package location +PKGDEST=${PKGDEST:-.} +SRCPKGDEST=${SRCPKGDEST:-.} + +PKGEXT=".pkg.tar.?z" + +staged=false +# Copies the packages to the specified repos inside staging +for _arch in ${ARCHES[@]}; do + for pkg in ${pkgname[@]}; do + + pkgpath=$(find ${PKGDEST}/ -type f \ + -name "${pkg}-${pkgver}-${pkgrel}-${_arch}${PKGEXT}" -or \ + -name "${pkg}-${epoch}:${pkgver}-${pkgrel}-${_arch}${PKGEXT}") + + [[ -z ${pkgpath} ]] && continue + + pkgfile=$(basename ${pkgpath}) + +# TODO refactor this + if [ -e "${pkgpath}" ]; then + msg "Found ${pkgfile}" + + canonical="" + for _repo in ${repos[@]}; do + + if [ ! -d "${WORKDIR}/staging/${_repo}" ]; then + warning "[${_repo}] didn't exist, creating..." + mkdir -p "${WORKDIR}/staging/${_repo}" + fi + + if [ -z "$canonical" ]; then + canonical="${WORKDIR}/staging/${_repo}/${pkgfile}" + + cp "${pkgpath}" "${WORKDIR}/staging/${_repo}/" || { + error "Can't put ${pkgfile} on [staging]" + exit 1 + } && { + msg2 "${pkg} staged on [${_repo}]" + staged=true + } + + else + ln "${canonical}" "${WORKDIR}/staging/${_repo}/${pkgfile}" || { + error "Can't put ${pkgfile} on [staging]" + exit 1 + } && { + msg2 "${pkg} staged on [${_repo}]" + staged=true + } + + fi + done + fi + done +done + +if ! $staged ; then + error "No package was staged" + exit 1 +fi + +exit 0 diff --git a/src/abslibre-tools/updateabslibre b/src/abslibre-tools/updateabslibre new file mode 100755 index 0000000..76f964a --- /dev/null +++ b/src/abslibre-tools/updateabslibre @@ -0,0 +1,39 @@ +#!/bin/bash +# UpdateABSLibre +# Updates the ABSLibre git repo + +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +[[ -e $custom_config ]] && source $custom_config + +# Send every output to /dev/null + +msg "Updating ABSLibre..." + +pushd ${WORKDIR}/abslibre ${stdnull} + git pull ${ABSLIBREGIT} || { + error "Failed pull" + exit 1 +} +stdnull "popd" + +exit 0 diff --git a/src/aur b/src/aur new file mode 100755 index 0000000..24d4317 --- /dev/null +++ b/src/aur @@ -0,0 +1,123 @@ +#!/bin/bash +# Copyright 2010 Nicolás Reynolds, Joshua Ismael + +# ---------- 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 +source /etc/abs.conf + +function usage { + echo "Usage: $0 pkgname-from-aur1 [pkgname-from-aur2 ...]" + echo + echo "This script will download packages from aur to the current dir" + echo "and check their license for nonfree issues." +} + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + *) usage; exit 1 ;; + esac +done + +missing_deps=() +for _pkg in ${@}; do + +# Remove the version + _pkg="${_pkg%%[<>=]*}" + + if [ -f "${_pkg}/PKGBUILD" ]; then + warning "${_pkg} already existed." + +# Check if we want to diff + if [ -z "${DIFFTOOL}" ]; then + continue + else +# Store our copy of the PKGBUILD dir + _diff="${PWD}/${_pkg}" + stdnull "pushd $(mktemp -d /tmp/${_pkg}.XXXX)" + msg2 "Downloading PKGBUILD into ${PWD} for diff" + fi + fi + + msg "Downloading $_pkg..." + wget -O - -q https://aur.archlinux.org/packages/$(echo $_pkg | sed "s/^../&\/&/")/$_pkg.tar.gz | \ + tar xzf - >/dev/null 2>&1 + + if [ $? -ne 0 ]; then + error "Couldn't get $_pkg" + continue + fi + + stdnull "pushd $_pkg" + + if [ ! -z "$_diff" ]; then + msg2 "Diffing files" +# Diff all files with our difftool + for file in *; do + ${DIFFTOOL} ${_diff}/${file} ${file} + done + +# Go back to our copy to continue working + stdnull "pushd ${_diff}" + fi + + source PKGBUILD + + if ! pkgbuild-check-nonfree; then + if [ $? -eq 15 ]; then + warning "This PKGBUILD links to known unfree packages" + fi + fi + + msg2 "Checking license..." + free=0 + for _license in ${license[@]}; do + if [ ! -d /usr/share/licenses/common/$_license ]; then + warning "License $_license is not a common license" + free=1 + fi + done + + if [ $free -eq 1 ]; then + plain "Please check that the license is included in the package and + *specially* that it respects your freedom." + fi + + for _dep in ${depends[@]} ${makedepends[@]}; do + _dep=${_dep/[<>=]*/} + if ! is_built $_dep; then + if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then + msg2 "$_dep will be get from AUR" + missing_deps+=($_dep) + fi + else + msg2 "$_dep is on repos" + fi + done + + stdnull popd + +done + +[[ ${#missing_deps[*]} -gt 0 ]] && { + msg2 "Retrieving missing deps: ${missing_deps[@]}" + $0 ${missing_deps[@]} +} + +exit 0 diff --git a/src/chroot-tools/buildenv b/src/chroot-tools/buildenv new file mode 100755 index 0000000..84a1fc2 --- /dev/null +++ b/src/chroot-tools/buildenv @@ -0,0 +1,28 @@ +#!/bin/bash + +trap "umount_all" 0 ERR TERM KILL + +user=${SUDO_USER:-${1}} + +umount_all() { + for mp in home/pkgdest home/srcdest home/${user}; do + msg "Umounting /$mp" + umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount" + done +} + +source /etc/libretools.conf + +for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do + msg "Binding /$mp" + mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1 +done + +for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do + msg "Copying config /$etc" + cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1 +done + +$(dirname $0)/librechroot $CHROOT + +exit $? diff --git a/src/chroot-tools/chcleanup b/src/chroot-tools/chcleanup new file mode 100755 index 0000000..17c1f02 --- /dev/null +++ b/src/chroot-tools/chcleanup @@ -0,0 +1,57 @@ +#!/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 +DRYRUN=${DRYRUN:-false} + +source /etc/makepkg.conf +source /etc/libretools.conf +source ${HOME}/.makepkg.conf 2>/dev/null|| true + +msg "Cleaning chroot..." + +TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" +cleanup_log="${TMPDIR}"/libretools-cleanup.log + +cp -a /var/lib/pacman/sync "${TMPDIR}/" +touch ${cleanup_log} + +# If we're running makepkg +if [ -f PKGBUILD ]; then + source PKGBUILD || true + + check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) + +fi + +# Get the full list of packages needed by dependencies, including the base system +sudo pacman -b "${TMPDIR}" \ + -Sp \ + --print-format "%n" \ + base base-devel sudo \ + ${CHROOTEXTRAPKG[@]} \ + ${check[@]} \ + >${cleanup_log} + +# Diff installed packages against a clean chroot then remove leftovers +packages=($(comm -23 <(pacman -Qq | sort) \ + <(sort -u ${cleanup_log}))) + +[ ${#packages[@]} -eq 0 ] && exit 0 + +msg2 "Removing %d packages" ${#packages[@]} + +# Only remove leftovers, -Rcs removes too much +${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} +${DRYRUN} && echo ${packages[@]} + +# Cleanup +${DRYRUN} || rm -fr ${TMPDIR} + +exit $? diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot new file mode 100755 index 0000000..c8e02b0 --- /dev/null +++ b/src/chroot-tools/librechroot @@ -0,0 +1,108 @@ +#!/bin/bash +# LibreChRoot +# Enters a chroot + +# Copyright 2010 Nicolás Reynolds +# Copyright 2011 Joshua Haase + +# ---------- 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 . + +function usage { + + echo "" + echo "Usage: $0 [options] [chrootname]" + echo "Use it as root." + echo "" + echo "Default chroot name: $CHROOT" + echo "Default chrootdir: $CHROOTDIR" + echo "" + echo "OPTIONS:" + echo "" + echo " -c : clean the chroot using pacman" + echo " only 'base', 'base-devel' and 'sudo' on chroot" + echo " -d : use instead of default" + echo " -r : clean /repo on the chroot" + echo " -h : this message" + echo " -u : update the chroot" + echo "" + +} + +function clean_chroot { # Clean packages with pacman + cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" + + mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" +} + +function clean_repo { + msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}" + if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then + find "${CHROOTDIR}/${CHROOTNAME}/repo/" -mindepth 1 -delete + else + mkdir -p "${CHROOTDIR}/${CHROOTNAME}/repo" + fi + bsdtar -czf "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db" +} +source /etc/libretools.conf + +if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then + source "$XDG_CONFIG_HOME/libretools/libretools.conf" +fi + +CLEANCHROOT='false' +UPDATE='false' +CLEANREPO='false' +CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" + +while getopts 'hrcud:' arg; do + case $arg in + h) usage; exit 0 ;; + c) CLEANCHROOT='true' ;; + u) UPDATE='true' ;; + r) CLEANREPO='true' ;; + d) CHROOTDIR="$(readlink -e $OPTARG)" ;; + esac +done + +[[ "$UID" != "0" ]] && { + error "This script must be run as root." + exit 1 +} + +shift $(($OPTIND - 1)) + +if [ $# -eq 1 ]; then + CHROOTNAME="$1" +fi + +if "$CLEANREPO"; then + clean_repo +fi + +if "$CLEANCHROOT"; then + clean_chroot +elif "$UPDATE"; then + msg "Updating chroot: ${CHROOTDIR}/${CHROOTNAME}" + mkarchroot -u "${CHROOTDIR}/${CHROOTNAME}" +else + msg "Entering chroot: ${CHROOTDIR}/${CHROOTNAME}" + mkarchroot -r "bash" "${CHROOTDIR}/${CHROOTNAME}" +fi + +exit 0 diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg new file mode 100755 index 0000000..f7924f6 --- /dev/null +++ b/src/chroot-tools/libremakepkg @@ -0,0 +1,126 @@ +#!/bin/bash +# Copyright 2010 - 2011 Nicolás Reynolds +# Copyright 2011 Joshua Ismael Haase Hernández + +# ---------- 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 . + + +# set -x # uncomment for debug + +function copy_log { # copy logs if they exist + + find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; + +} + + +function trap_exit { # End inmediately but print a useful message + + copy_log + error "$@" + exit 1 + +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT +trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR + +source /etc/libretools.conf + +CLEANFIRST="false" +UPDATEFIRST="false" +CHECKNONFREE="true" +LIBRECHROOT_ARGS="" +MAKEPKG_ARGS="" + +function usage { + + echo '' + echo 'cd to a dir containing a PKGBUILD and run:' + echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' + echo 'This script will build your package on a chroot.' + echo '' + echo 'OPTIONS:' + echo '' + echo ' -h : show this message.' + echo ' -c : clean the chroot before building.' + echo ' -u : update the chroot before building.' + echo ' -d : use this dir instead of "$CHROOTDIR"' + echo ' -n : use this dir instead of "$CHROOT".' + echo ' -N : do not check freedom issues' # As fullpkg-check will do that before + echo '' + exit 1 + +} + +while getopts 'hcud:n:N' arg ; do + case "${arg}" in + h) usage ;; + c) CLEANFIRST="true" ;; + u) UPDATEFIRST="true" ;; + d) CHROOTDIR="$OPTARG" + LIBRECHROOT_ARGS='-d "$OPTARG"' ;; + n) CHROOT="$OPTARG" ;; + N) CHECKNONFREE="false" ;; + esac +done + +# Pass all arguments after -- right to makechrootpkg +MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}" + +if (( EUID )); then + error "This script must be run as root" + exit 1 +fi + +if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. + error "This isn't a build directory"; usage +fi + +msg "Checking PKGBUILD for non-free issues" +if "$CHECKNONFREE"; then + if ! pkgbuild-check-nonfree; then + + if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi +fi + +if "$CLEANFIRST"; then + librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" +fi + +if "$UPDATEFIRST"; then + librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" +fi + +unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS + +makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS +ev="$?" # exit value + +copy_log + +exit $ev diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot new file mode 100755 index 0000000..b576209 --- /dev/null +++ b/src/chroot-tools/libremkchroot @@ -0,0 +1,64 @@ +#!/bin/bash +# LibreMkChroot +# Creates a chroot + +# Copyright 2011, 2012 Luke Shumaker + +# ---------- 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 + +if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then + source "$XDG_CONFIG_HOME/libretools/libretools.conf" +fi + +cmd=${0##*/} +function usage { + echo "Usage: $cmd [OPTIONS]" + echo 'This script will create a chroot to build packages in.' + echo "Use \`librechroot' to interact with the chroot after it is created." + echo '' + echo 'Options:' + echo ' -h Show this message' + echo '' + echo ' -f Force overwrite of files in the working-dir' + echo '' + echo ' -d Use this dir instead of "$CHROOTDIR".' + echo " -c Location of pacman cache. Default: \`/var/cache/pacman/pkg'." + echo ' -C Location of pacman config file.' + echo ' -M Location of makepkg config file.' +} + +mkchroot_args=(); +while getopts 'hfd:c:C:M:' arg; do + case "$arg" in + h) usage; exit 0 ;; + f) mkchroot_args+=("-$arg");; + c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; + d) CHROOTDIR=$OPTARG ;; + ?) usage; exit 1 ;; + esac +done + +if (( EUID )); then + error "This script must be run as root" + exit 1 +fi + +mkdir -p "${CHROOTDIR}" +xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem diff --git a/src/diff-unfree b/src/diff-unfree new file mode 100755 index 0000000..a0a8d63 --- /dev/null +++ b/src/diff-unfree @@ -0,0 +1,85 @@ +#!/bin/bash +# This script will help you diff a *-libre PKGBUILD against the unfree one +# to check for updates. +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf + +[[ "$1" == "--help" ]] && { + msg "Diff-Unfree helps you diff build scripts from ABSLibre against + (Unfree) ABS. Package name and repo will we guessed if you don't + specify them." + msg2 "Usage: $0 [community|packages] [unfree-package] [repo]" + exit 0 +} + +[[ ! -r PKGBUILD ]] && { + error "This is not a build dir." + exit 1 +} + +package_guess=$(basename $PWD) + +repo=${1:-$(basename $(dirname $PWD))} +package=${2:-${package_guess/-libre}} +trunk=${3:-trunk} + +tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) + +svnrepo="packages" +case $repo in + community*) + svnrepo="community" + ;; + multilib*) + svnrepo="community" + ;; + *) + ;; +esac + +unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" + +[[ ! -d "${tmp_dir}" ]] && { + error "Can't create temp dir" + exit 1 +} + +stdnull 'pushd "${tmp_dir}"' + +msg "Getting diff from $repo/$package..." + +stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' + +cd ${svnrepo} +svn update ${package} + +# Back to start dir +stdnull popd + +msg "Diffing files" + +for _file in ${unfree_dir}/*; do + msg2 "$(basename "${_file}")" + ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" +done + +exit $? diff --git a/src/fullpkg/fullpkg b/src/fullpkg/fullpkg new file mode 100755 index 0000000..9a03b82 --- /dev/null +++ b/src/fullpkg/fullpkg @@ -0,0 +1,34 @@ +#!/bin/bash +# set -x # uncomment for debug +# Builds packages from ABS recursively. It tries to find dependencies that +# aren't built or need update and then makepkg them in order. + +usage() { + + echo "cd to a dir containing a PKGBUILD and run:" + echo "$0 [build_dir]" + echo "" + echo "This script will check dependencies, build them if possible " + echo "and stage the packages on it's repo." + echo "" + echo "OPTIONS:" + echo " -h : this message." + echo "" + echo "Wrapper for \`fullpkg-find' and \`fullpkg-build'" + echo "" + exit 1 + +} + +while getopts 'haA:l:nm:' arg; do + case "$arg" in + h) usage ;; + esac +done + +shift $(( OPTIND - 1 )) + +build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}" +fullpkg-find "$build_dir" && fullpkg-build -N "$build_dir" + +exit 0 diff --git a/src/fullpkg/fullpkg-build b/src/fullpkg/fullpkg-build new file mode 100755 index 0000000..b497db5 --- /dev/null +++ b/src/fullpkg/fullpkg-build @@ -0,0 +1,211 @@ +#!/bin/bash +# set -x # uncomment for debug +# Builds packages from ABS recursively. It tries to find dependencies that +# aren't built or need update and then makepkg them in order. + +# TODO move __build to chroot + +source /etc/makepkg.conf +source /etc/libretools.conf + +if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then + source $XDG_CONFIG_HOME/libretools/libretools.conf +fi + + +## List packages on log that are on status +## usage: list_pkgs +# +## status: nonfree, built, failed, unstaged +list_pkgs() { + msg="$2" + local pkgs=($(grep "$1:" $build_dir/log)) && { + msg "$2" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } +} + +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) +get_fullver() { + if [[ $1 -eq 0 ]]; then +# zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + +} + +## Check all build_dir, fails if one PKGBUILD is nonfree +check_nonfree() { + find "$build_dir" -name PKGBUILD \ + -exec pkgbuild-check-nonfree {} + + if [ "$?" -eq 15 ]; then + error "Some PKGBUILD have nonfree problems" + exit 15 + fi + +} + +# Removes a package from the buildorder +# $1 package name +# $2 buildorder file +remove_buildorder() { + grep -Evw "${1}" ${2} > ${2}2 + mv -f ${2}2 ${2} + + return $? +} + +succesfull_build() { + + if [ "$RUN" != "$FULLBUILDCMD" ]; then + return 0 # Custom command or download sources + fi + + if source .INFO && [ -n "$repo" ]; then + + if [ ! -z "$HOOKLOCALRELEASE" ]; then + find -name "*.pkg.tar.?z" -print0 | xargs -0 "$HOOKLOCALRELEASE" "$repo" + fi + + librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log + + msg "Updating pacman db and packages" + sudo pacman -Sy || true + + fi + + echo "built:$(basename $PWD)" >>$build_dir/log +} + +build_description() { + list_pkgs "nonfree" "Those packages contain nonfree deps:" + list_pkgs "built" "Those packages were built and staged:" + list_pkgs "failed" "Those packages failed to build:" + list_pkgs "unstaged" "Those packages couldn't be staged (missing reponame):" +} + +__build() { + pushd ${build_dir} >/dev/null + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first + + while [ ${#build_packages[@]} -ge 1 ]; do + + pushd "$build_dir/${build_packages[0]}" >/dev/null + + if [ -n "${HOOKPKGBUILDMOD}" ]; then + ${HOOKPKGBUILDMOD} || true + fi + + eval "$RUN"; r=$? + + case $r in + + 0) succesfull_build ;; + + *) error "There were errors while trying to build the package." + echo "failed:$(basename $PWD)" >>$build_dir/log + ;; + esac + + remove_buildorder "${build_packages[0]}" $buildorder || true + +# which is next package? + build_packages=($(sort -gr $buildorder | cut -d: -f2)) + popd > /dev/null + done + + popd >/dev/null +} + +# End inmediately but print a useful message +trap_exit() { + error "$@" + warning "Leftover files left on $build_dir" + mv .BUILDORDER BUILDORDER + exit 1 +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "(fullpkg-build) TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "(fullpkg-build) Aborted by user! Exiting..."' INT +trap 'trap_exit "(fullpkg-build) An unknown error has occurred. Exiting..."' ERR + +CLEANUP="false" +CHECKNONFREE="true" +RUN="$FULLBUILDCMD" +MESSAGE="Building packages" + +usage() { + + echo "" + echo "$(basename $0) [options] " + echo "" + echo "Builds packages from build_dir, create a build_dir using:" + echo "'fullpkg-find '" + echo "" + echo "If no is specified, it uses the current directory." + echo "" + echo "OPTIONS:" + echo " -h : this message." + echo " -c : clean on succesfull build" + echo " -N : don't check for freedom issues." #Also made by fullpkg-find + echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"." + echo " -g : get sources for building packages on build_dir." + echo "" + exit 1 + +} + +while getopts 'hNr:g' arg; do + case $arg in + h) usage ;; + c) CLEAN ;; + N) CHECKNONFREE="false" ;; + r) RUN="$OPTARG" + MESSAGE="Executing custom action";; + g) RUN='makepkg -g > /dev/null' + MESSAGE="Downloading packages";; + esac +done + +shift $(( OPTIND - 1 )) +build_dir="${1:-`pwd`}" +buildorder="${build_dir}/BUILDORDER" + +if [ ! -e "$buildorder" ]; then + error "This is not a build_dir. Make one using fullpkg." + usage +else +# backup BUILDORDER + cp "$buildorder" "$build_dir/.BUILDORDER" +fi + +if "$CHECKNONFREE"; then + check_nonfree +fi + +if [ -z "$FULLBUILDCMD" ]; then + error "Set your FULLBUILDCMD on libretools.conf" +fi + +msg "$MESSAGE" +__build + +if [ "$RUN" != "$FULLBUILDCMD" ]; then + # Used for downloading or custom command + mv "$build_dir/.BUILDORDER" "$buildorder" + exit 0 +elif "$CLEANUP"; then + find "$build_dir" -mindepth 1 -delete +fi + +build_description + +plain "Test packages on and if they work fine librerelease." + +exit 0 diff --git a/src/fullpkg/fullpkg-find b/src/fullpkg/fullpkg-find new file mode 100755 index 0000000..e188ec8 --- /dev/null +++ b/src/fullpkg/fullpkg-find @@ -0,0 +1,212 @@ +#!/bin/bash +# set -x # uncomment for debug +# Builds packages from ABS recursively. It tries to find dependencies that +# aren't built or need update and then makepkg them in order. + +# TODO: fullpkg-find should find packages wich depend on the +# package to be build, so we can avoid "missing $name.so errors" + +# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD +guess_repo() { + basename $(dirname $(pwd)) +} + +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) +get_fullver() { + if [[ $1 -eq 0 ]]; then +# zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + +} + +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 + source /etc/makepkg.conf + source PKGBUILD + + local repo="${repo:-$(guess_repo)}" + local pkgbase="${pkgbase:-${pkgname[0]}}" + local fullver="$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel})" + + if ! pkgbuild-check-nonfree > /dev/null 2> /dev/null; then + if [ "$?" -eq 15 ]; then + error "pkgbase" has nonfree issues + return 15 + fi + fi + + # Checking any package built, since otherwise e.g. kdebase would + # be always considered outdated: there is no package built named kdebase. + # TODO: maybe check for the package requested in case of recursive calls, + # instead of the first one listed? + if is_built "${pkgname[0]}" "${fullver}"; then + exit 0 # pkg is built and updated + fi + +# greater levels are built first + echo "${LEVEL}:${pkgbase}" >>"$build_dir/BUILDORDER" +# PKGBUILD is already there + if [ -d "${build_dir}/${pkgbase}" ]; then + exit 0 +# Copy dir to build_dir + else + copy_files + +# to identify repo later + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" + fi + +# current package plus a space for every level + msg2 "%${LEVEL}s${pkgbase}-${fullver}" + +## Check next levels + declare -i next_level=$LEVEL+1 + +# All deps in separate line, only once, without version. + deps=($(echo "${depends[@]} ${makedepends[@]}" | \ + sed "s/[=<>]\+[^ ]\+//g" | \ + tr ' ' "\n" | \ + sort -u)) + + for _dep in ${deps[@]}; do + + local found=false + # May fail, e.g. since abslibre-mips64el doesn't include + # arch=any packages. + local pkgdir=$(toru -p ${_dep}) || true + + if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then + found=true + + pushd "${pkgdir}" > /dev/null +# runs itself on dep's PKGBUILD dir + $0 -l ${next_level} ${build_dir} || return $? + popd > /dev/null + fi + + if ! (( found )); then + echo "dep_not_found:$_dep" >>$build_dir/log + fi + + done + +## End variable block + + unset next_level dir +} + +source /etc/libretools.conf + +if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then + source $XDG_CONFIG_HOME/libretools/libretools.conf +fi + +LEVEL=0 +MAXLEVEL=20 +CLEANFIRST='false' +UPDATEDB='true' + +usage() { + + echo "" + echo "cd to a dir containing a PKGBUILD and run:" + echo "$(basename $0) [options] " + echo "" + echo "This script will create a build_dir for recursive building" + echo "it tries to find dependencies that aren't built or need update." + echo "" + echo "If no is specified, the script works on a tempdir" + echo "" + echo "OPTIONS:" + echo " -h : this message." + echo " -A : use this ABSROOT." + echo " -c : clean before working." + echo " -m : check deps until this level" + echo " -n : don't update pacman db." + echo "" + exit 1 + +} + +while getopts 'hA:l:cmn' arg; do + case "$arg" in + h) usage ;; + A) ABSROOT="$OPTARG" ;; + l) LEVEL="$OPTARG" ;; # hidden option to know dep level. + c) CLEANFIRST='true' ;; + m) MAXLEVEL="$OPTARG" ;; + n) UPDATEDB='false' ;; + esac +done + +if [ ! -r PKGBUILD ]; then + error "This directory doesnt contain a PKGBUILD" + usage +fi + +shift $(( OPTIND - 1 )) +build_dir="${1}" + +if [ "$LEVEL" -eq 0 ]; then + + build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}" + + if [ ! -d "$build_dir" ]; then + mkdir -p "$build_dir" + elif "$CLEANFIRST"; then + # Erase files already in dir + msg "Cleaning up files in dir" + find "$build_dir" -mindepth 1 -delete + fi + + if "$UPDATEDB"; then + msg "Updating pacman db" + sudo pacman -Sy --noconfirm || true + fi + +# make files for log and buildorder + touch "${build_dir}"/{log,BUILDORDER} + buildorder="${build_dir}/BUILDORDER" + + msg "Checking dependencies" +fi + +# Find the dependencies on the ABS itself +find_deps + +exit 0 diff --git a/src/is_built b/src/is_built new file mode 100755 index 0000000..1fa79d2 --- /dev/null +++ b/src/is_built @@ -0,0 +1,36 @@ +#!/bin/bash +usage() { + echo "$0 " + echo + echo "Detect if a given package version is already in repos" + echo "Assuming you want greater or equal" + echo + echo "Example usage: is_built 'pcre' '20'" +} + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + *) usage; exit 1 ;; + esac +done + +ver=${2} +pkg=${1} +pver=$(LC_ALL=C pacman -Sddp --print-format "%v" "${pkg}" 2>/dev/null) + +# if pacman fails or returns nothing +r=$? +[ "${pver}" = " there is nothing to do" ] && r=1 + +result=$(vercmp "${pver}" "${ver}") + +# if vercmp > 1 means our version is bigger +if [ ${result} -ge 0 -a ${r} -eq 0 ]; then + exit 0 +else + exit 1 +fi + +# just in case +exit 1 diff --git a/src/is_unfree b/src/is_unfree new file mode 100755 index 0000000..f32c193 --- /dev/null +++ b/src/is_unfree @@ -0,0 +1,11 @@ +#!/bin/bash +# Checks if a package is on blacklist + +# fail immediately on error +set -E + +blacklist="$XDG_CONFIG_HOME/libretools/blacklist.txt" + +egrep -q "^${1}:" "${blacklist}" + +exit $? diff --git a/src/librediff b/src/librediff new file mode 100755 index 0000000..1f39eb9 --- /dev/null +++ b/src/librediff @@ -0,0 +1,65 @@ +#!/bin/bash +# Generates a patch for a nonfree PKGBUILD +# +# Copyright 2010 Nicolás Reynolds + +# ---------- 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 . + +usage() { + echo "Usage: $0 [ ...]" + echo "Requirements:" + echo "* Have a / directory with nonfree build scripts inside" + echo "* Have a -libre/ directory with libre build scripts inside" +} + +# Load custom config or system-wide config +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +if [ -e $custom_config ]; then + source $custom_config +else + source /etc/libretools.conf +fi + +# Print usage if no package has been given +[[ -z "$@" ]] && { + usage + exit 1 +} + + +for package in $@; do +# Continue on errors + [[ ! -d ./${package} || ! -d ./${package}-libre ]] && { + error "no matching ${package} and ${package}-libre found" + continue + } + + [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] && { + error "no matching PKGBUILDs found for ${package}-libre" + continue + } + + source ./${package}-libre/PKGBUILD + [[ -z ${pkgbase} ]] && pkgbase=${pkgname} + +# Generate a diff file, no -r since we don't want to patch src/ nor pkg/ + diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch + +done + +exit 0 diff --git a/src/libremessages b/src/libremessages new file mode 100755 index 0000000..68badb8 --- /dev/null +++ b/src/libremessages @@ -0,0 +1,107 @@ +# Copyright (c) 2006-2010 Pacman Development Team +# Copyright (c) 2002-2006 by Judd Vinet +# Copyright (c) 2005 by Aurelien Foret +# Copyright (c) 2006 by Miklos Vajna +# Copyright (c) 2005 by Christian Hamar +# Copyright (c) 2006 by Alex Smith +# Copyright (c) 2006 by Andras Voroskoi +# Copyright (c) 2011 by Joshua Haase +# +# This program 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. +# +# This program 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 this program. If not, see . + +# gettext initialization +export TEXTDOMAIN='libretools' +export TEXTDOMAINDIR='/usr/share/locale' + +# check if messages are to be printed using color +unset ALL_OFF BOLD BLUE GREEN RED YELLOW +if [[ -t 2 ]]; then + # prefer terminal safe colored and bold text when tput is supported + if tput setaf 0 &>/dev/null; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + PURPLE="${ALL_OFF}$(tput setaf 5)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" + else + ALL_OFF="\e[1;0m" + BOLD="\e[1;1m" + BLUE="${BOLD}\e[1;34m" + GREEN="${BOLD}\e[1;32m" + RED="${BOLD}\e[1;31m" + YELLOW="${BOLD}\e[1;33m" + PURPLE="${BOLD}\033[1;30;40m" + fi +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW PURPLE + +stdnull() { + eval "$@ >/dev/null 2>&1" +} + +plain() { + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +msg() { + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +msg2() { + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +stat_busy() { + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2 +} + +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 + + local needle=$1; shift + local item + + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 # Found + done + + return 1 # Not Found +} diff --git a/src/librerepkg b/src/librerepkg new file mode 100755 index 0000000..d506003 --- /dev/null +++ b/src/librerepkg @@ -0,0 +1,72 @@ +#!/bin/bash +# Copyright 2011 Joshua Ismael Haase Hernandez + +# ---------- 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 +custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf +if [ -x $custom_config ]; then + source $custom_config; + unset $custom_config +fi + +[[ ! -r rePKGBUILD ]] && { + error "This build does not contains a rePKGBUILD." + exit 1 +} + +source /etc/makepkg.conf +source /etc/abs.conf +source rePKGBUILD + +usage() { + echo "cd to a dir with a rePKGBUILD and other file info and run" + echo "$0 [makepkg flags]" + echo + echo "This script will repackage an arch package without compiling" +} + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + esac +done + +makepkgflags=$@ + +tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX) + +msg "Copying files" +cp ./* ${tempdir}/ + +for _arch in ${arch[@]}; do + + msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))" + + stdnull pushd ${tempdir} + + msg2 "Updating md5sums" + makepkg -gp rePKGBUILD >> rePKGBUILD + + echo "export CARCH=${_arch}" >> rePKGBUILD + + msg "Repackaging using makepkg" + makepkg -Lcdp rePKGBUILD ${makepkgflags} + + stdnull popd ${tempdir} +done diff --git a/src/mips64el-tools/add-mips64el b/src/mips64el-tools/add-mips64el new file mode 100755 index 0000000..e06d857 --- /dev/null +++ b/src/mips64el-tools/add-mips64el @@ -0,0 +1,6 @@ +#!/bin/bash +# Change all arch array that aren't any or mips64el already + +find -name 'PKGBUILD' -exec sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" '{}' \; + +exit $? diff --git a/src/mips64el-tools/librebasebuilder b/src/mips64el-tools/librebasebuilder new file mode 100755 index 0000000..f7d3a25 --- /dev/null +++ b/src/mips64el-tools/librebasebuilder @@ -0,0 +1,84 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# Copyright (C) 2012 Michał Masłowski +# +# This program 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. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +set -e + +# TODO: + +# - make it more configurable + +# - compare the result with previous base images + +for arg in "$@" ; do + case "$arg" in + -h|--h|--he|--hel|--help|-\?) + echo 'Usage: librebasebuilder + +Make a base tarball named parabola-mips64el-DATE.tar.bz2. + +This script must be run as root.' >&2 + exit 0 + ;; + esac +done + +[[ "$UID" != "0" ]] && { + echo "This script must be run as root." >&2 + exit 1 +} + +tempdir=/home/chroot/base +outdir=$(pwd) + +mkarchroot -n $tempdir mkinitcpio base sudo parted nano zile vi ed openssh + +cd $tempdir + +# Don't list mtjm's DNS servers. +cat > etc/resolv.conf < +#nameserver + +# End of file +EOF + +# From pacman-mirrorlist-libre-20120307-1. Remember to escape dollars. +cat > etc/pacman.d/mirrorlist </dev/null; then # Add mips64el in ${arch} array if it isn't 'any' + warning "Adding mips64el arch" + sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" + librecommit PKGBUILD +fi diff --git a/src/mips64el-tools/mips64el.conf b/src/mips64el-tools/mips64el.conf new file mode 100644 index 0000000..836b407 --- /dev/null +++ b/src/mips64el-tools/mips64el.conf @@ -0,0 +1,12 @@ +## Arquitecture specific commands + +## Run a command for PKGBUILD modifications before building +## Like adding 'mips64el' to arch if it's not there +# HOOKPKGBUILDMOD="mips-add" + +## Run a command for local releasing of packages +# Useful for mass packaging (ie. mips port) +# Must accept the following parameters even if the command won't use them: +# $1 repo name +# $2+ packages +# HOOKLOCALRELEASE="mipsrelease" diff --git a/src/mips64el-tools/mipsrelease b/src/mips64el-tools/mipsrelease new file mode 100755 index 0000000..4d7a7de --- /dev/null +++ b/src/mips64el-tools/mipsrelease @@ -0,0 +1,65 @@ +#!/bin/bash +# Lic: GPLv3+ +# Author: Nicolas Reynolds +# Local release of mips64el packages + clean ABS sync +# Called by HOOKLOCALRELEASE + +# $1 repo +# $2+ packages + +source /etc/makepkg.conf +source /etc/libretools.conf + +libretoolsdir="$(dirname $0)/../" + +usage() { + echo "$0 repo package1 [ package2 ... packageN ]" + echo + echo " release packages locally on ${PKGDEST}/stage3." + echo " and make a clean ABS sync " +} + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## +get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi +} + +repo=$1; shift + +if [ -z "${repo}" ]; then + error "Empty repo" + exit 1 +fi + +# Get all needed sources +source PKGBUILD +fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) +pkgs=() +makepkg --source -f --skippgpcheck + +msg "Adding packages to [stage3]..." +for name in ${pkgname[@]}; do + msg2 "${name} ${fullver}" + pkgs+=("${PKGDEST}/${name}-${fullver}-*.pkg.tar.*") +done + +repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]} + +librestage ${repo} + + +mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null + +pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null + tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT} +popd >/dev/null + +exit $? diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree new file mode 100755 index 0000000..df0ff36 --- /dev/null +++ b/src/pkgbuild-check-nonfree @@ -0,0 +1,205 @@ +#!/bin/bash +# pkgbuild-check-nonfree +# Copyright 2010 Joshua Ismael Haase Hernández, Joseph Graham + +# ---------- 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 . + +# function log_end { +# kill "$teepid" +# rm "$logpipe" +# } + +# function log { +# LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log" +# # ensure overridden package variables survive tee with split packages +# logpipe="$(mktemp -u "$startdir/logpipe.XXXXXXXX")" +# mkfifo "$logpipe" +# tee "$LOG" < "$logpipe" & +# teepid=$! +# trap log_end ERR EXIT +# } + + +function unset_pkgbuild { + + unset 'pkgbase' 'pkgname' 'pkgver' 'pkgrel' 'epoch' 'pkgdesc' \ + 'arch' 'url' 'license' 'groups' 'optdepends' 'provides' \ + 'conflicts' 'replaces' 'backup' 'options' 'install' \ + 'changelog' 'source' 'noextract' 'md5sums' 'build' \ + 'check' 'package' 'depends' 'makedepends' 'checkdepends' + +} + +function assert_pkgbuild { + + if [ -e "$1" ]; then + + source "$1" + if [ -n "${pkgname[0]}" ]; then + return 0 # valid PKGBUILD + fi + + fi + + error "$1 is not a valid PKGBUILD" + return 1 +} + +function check_replacement { + + [ $2 ] || return 0 # Free (not found) + local needle=$1; shift + local item + local rep + for line in $@; do + + item="$(echo "$line" | cut -d':' -f1)" + rep="$(echo "$line" | cut -s -d':' -f2)" + + if [ "$item" == "$needle" ]; then + if [ -z "$rep" ]; then + return 15 # Nonfree (found) + else + echo "$rep" + return 0 # Free (has replacement) + fi + fi + + done + return 0 # Free (not found) +} + +function get_blacklist { # Download the blacklist. + + pushd "$XDG_CONFIG_HOME/libretools" >/dev/null + + msg "Downloading the blacklist of proprietary software packages." + + if ! wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null; then + + if [ -e "$XDG_CONFIG_HOME/libretools/blacklist.txt" ]; then + warning "Using local copy of blacklist" + else + error "Download failed, exiting" + fi + + fi + + popd > /dev/null +} + +function check_deps { # Check wheter a package depends on non-free + + unset_pkgbuild + + if ! assert_pkgbuild "$1"; then + return 1 # not PKGBUILD + fi + + msg2 "${pkgbase:-${pkgname[0]}} $pkgver $pkgrel ${epoch:-""}" # > "$logpipe" + + for pkg in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ${checkdepends[@]}; do + + lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_")) + + rep="$(check_replacement $pkg ${lines[@]})" + freedom=$? + + if [ "$freedom" -eq 15 ]; then + warning "found $pkg" # > "$logpipe" + ev=15 + continue + + elif [ -n "$rep" ]; then + + if [ "$rep" = "$pkg" ]; then + plain "$pkg is repackaged with the same name." # > "$logpipe" + continue + else + plain "$pkg -> $rep" # > "$logpipe" + continue + fi + + fi + + done + +} + +function usage { + # TODO: implement PKGBUILD arguments + echo "" + echo "$(basename $0) [options] [PKGBUILD1 PKGBUILD2 ...]" + echo "" + echo "OPTIONS" + echo "" + echo " -h : this message" + echo "" + echo "If no PKGBUILD is specified, one is searched on current directory" + + exit 1 +} + +while getopts 'h' arg; do + case "$arg" in + h) usage ;; + esac +done + +if [ -w / ]; then + error "Run as normal user" +fi + +source /etc/libretools.conf +if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then + source "$XDG_CONFIG_HOME/libretools/libretools.conf" +fi + +if [ -z "${BLACKLIST}" ]; then + error "BLACKLIST variable is not set your libretools.conf file" + exit 1 +fi + +if [ ! -d "$XDG_CONFIG_HOME/libretools" ]; then + mkdir -p "$XDG_CONFIG_HOME/libretools" +fi + +startdir=`pwd` + +get_blacklist +# log + +shift $(( OPTIND - 1)) + +msg "Looking for unfree dependencies" + +if [ $# -ge 1 ]; then + + for p in $@; do + if [ -n "$p" ]; then + check_deps "$p" + fi + done + +else + + check_deps "`pwd`/PKGBUILD" + +fi + +exit $ev diff --git a/src/prtools/prfullpkg b/src/prtools/prfullpkg new file mode 100755 index 0000000..bbb8d73 --- /dev/null +++ b/src/prtools/prfullpkg @@ -0,0 +1,398 @@ +#!/bin/bash + +source /etc/makepkg.conf +source /etc/abs.conf +source /etc/libretools.conf +source /etc/libretools.d/prtools.conf + +if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors + + error "There's no XDG_CONFIG_HOME var set"; exit 1 + +elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then + + source $XDG_CONFIG_HOME/libretools/libretools.conf + +fi + + +function usage { + + echo "cd to a dir containing a PKGBUILD and run:" + echo "$0 [options]" + printf "This script will check dependencies, build them if possible " + printf "and stage the packages on it's repo." + echo + echo "OPTIONS:" + echo " -h : this message." + echo " -a absdir : set absdir as ABSROOT." + echo " -b build_dir : use a fullpkg build_dir and only build." + echo " -c : check deps only, do not build." + echo " -d build_dir : use this dir to build. Defaults to mktemp." + echo " -n : don't update pacman db." + echo " -m max_level : check deps until this level" + echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" + echo + exit 1 + +} + +function remove_buildorder { # Removes a package from the buildorder +# $1 package name +# $2 buildorder file + + grep -Evw "${1}" ${2} > ${2}2 + mv -f ${2}2 ${2} + +} + +function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD + + basename $(pwd) + +} + +function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel + +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) + + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + +} + +function cleanup { # Cleans the build_dir. + + [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. + + + if [ $level -eq 0 ]; then # Only do cleanup on level 0. + msg "Cleaning up ${build_dir}" + rm -rf "$build_dir/*" + fi +} + +function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. + + source PKGBUILD ## Check this level. + + local repo=${repo:-$(guess_repo)} + local pkgbase=${pkgbase:-${pkgname[0]}} + local epoch=${epoch:-0} + local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) + + if is_built "${pkgbase}" "${fullver}"; then + exit 0 # pkg is built and updated + fi + + echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first + + if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there + + exit 0 + + else # Copy dir to build_dir + + mkdir ${build_dir}/${pkgbase} + cp -r $(pwd)/* ${build_dir}/${pkgbase} + + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later + fi + + msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level + + declare -i next_level=$level+1 ## Check next deps level. + + deps=$(echo "${depends[@]} ${makedepends[@]}" | \ + sed "s/[=<>]\+[^ ]\+//g" | \ + tr ' ' "\n" | \ + sort -u) # All deps in separate line, only once, without version. + + for _dep in ${deps[@]}; do + + local found=false + + if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo + + for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order + + if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then + + pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular deps + popd > /dev/null + local found=true + break 1 # found, go to next dep + fi + + done + + else # pkgsplit, needs guess + + for _repo in ${REPOS[@]}; do + + if _dir=($(find "$ABSROOT/" -type f \ + -wholename "*/${_repo}/PKGBUILD" -print0 2>/dev/null | \ + "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ + grep -w "$_dep" 2>&1)) ; + + then + + _dir=$(dirname $(echo $_dir | cut -d: -f1)) + plain "guess for $_dep -> $_dir" + + pushd "$_dir" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular dep + popd > /dev/null + local found=true + break 1 # found, go to next dep + fi + + done + + fi + + if ( ${found} ); then + continue 1 # go to next dep + else + echo "dep_not_found:$_dep" >> $build_dir/log + fi + + done + + unset next_level dir + # unset PKGBUILD variables + unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ + makedepens checkdepends optdepends provides conflicts replaces backup \ + options install changelog source noextract md5sums build check package +} + +function __build () { + pushd ${build_dir} > /dev/null + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first + + while [ ${#build_packages[@]} -ge 1 ]; do + pushd $build_dir/${build_packages[0]} > /dev/null + source PKGBUILD + + msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" + + msg2 "Checking for non free deps" + pkgbuild-check-nonfree || { + if [ $? -eq 15 ]; then # this error means nonfree others means fail. + + echo "nonfree:$(basename $PWD)" >> $build_dir/log + + remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder + + continue # build next package + fi + } + + msg2 "Building $(basename $PWD)" + + $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf + + case $r in + + 0) ## Succesfull build + + plain "The build was succesful." + if source .INFO && [ -n $repo ]; then + + if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used + find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo + fi + + librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log + + msg "Updating pacman db and packages" + sudo pacman -Sy || true + + fi + + echo "built:$(basename $PWD)" >> $build_dir/log + ;; + + *) ## Build failed + error "There were errors while trying to build the package." + echo "failed:$(basename $PWD)" >> $build_dir/log + ;; + esac + + remove_buildorder "${build_packages[0]}" $buildorder || true + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? + popd > /dev/null + done + + pkgs=($(grep "nonfree:" $build_dir/log)) && { + error "Those packages contain nonfree deps:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "built:" $build_dir/log)) && { + msg "Those packages were built and staged:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "failed:" $build_dir/log)) && { + error "Those packages failed to build:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "unstaged:" $build_dir/log)) && { + error "Those packages couldn't be staged because of missing reponame:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + popd > /dev/null +} + +function trap_exit { # End inmediately but print a useful message + + error "$@" + warning "Leftover files left on $build_dir" + + exit 1 +} + +# 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 + +ban_file=$XDG_CONFIG_HOME/libretools/ban +force_build="" +level=0 +noupdate='n' +build_only='n' +check_deps_only='n' +max_level=21 + +while getopts 'ha:b:cd:l:nm:r:' arg; do + case $arg in + h) usage ;; + a) ABSROOT="$OPTARG" ;; + b) build_only='y' + build_dir="$OPTARG" + if [ -z ${build_dir} ]; then + usage + fi + if [ ! -r ${build_dir}/BUILDORDER ] ; then + error "${build_dir}/BUILDORDER doesn't exist." + exit 1 + fi;; + c) check_deps_only='y' ;; + d) build_dir="$OPTARG" ;; + l) level=$OPTARG ;; # hidden option to know dep level. + n) noupdate='y';; + m) max_level=$OPTARG ;; + r) FULLBUILDCMD="$OPTARG" ;; + esac +done + +if [ ${build_only} == 'n' ]; then + + [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. + error "This isn't a build directory" + usage + } + + if [ ! -z "$HOOKPKGBUILDMOD" ]; then + "$HOOKPKGBUILDMOD" + fi + +fi + +if [ $level -eq 0 ]; then + + if [ ! -d ${build_dir} ]; then # in case of custom -d option + mkdir -p ${build_dir} + else + cleanup # files already there can screw find_deps + fi + + build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp + + touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder + buildorder=${build_dir}/BUILDORDER + + if [ ${noupdate} = 'n' ]; then + + msg "Updating pacman db and packages" + sudo pacman -Syu --noconfirm || true + + fi + + if [ ${build_only} == 'y' ]; then + + msg "Build Packages" + + __build + + exit 0 + + fi + + msg "Checking dependencies" +fi + +[ $level -ge $max_level ] && exit 20 # Probable circular deps + +find_deps || { + + if [ $? -eq 20 ]; then # Probable circular deps + + if [ $level -eq 0 ]; then # Show error only on level 0 + error "Check for circular deps on $build_dir/BUILDORDER"; + fi + + fi + exit 20 # Pass message 20 +} + +[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 + +if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check + + if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions + + chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" + + else + + rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { + + warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist + + search=$(cat ${ban_file} | tr "\n" "|") + + egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files + + egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder + + mv -f ${buildorder}2 ${buildorder} + + unset search + } + } + fi +fi + +msg "Building packages:" + +__build # Build the packages + +echo +msg2 "Check if your system works fine and librerelease if it does" + +exit 0 diff --git a/src/prtools/prmipsrelease b/src/prtools/prmipsrelease new file mode 100755 index 0000000..1fbd696 --- /dev/null +++ b/src/prtools/prmipsrelease @@ -0,0 +1,98 @@ +#!/bin/bash +# Lic: GPLv3+ +# Author: Nicolas Reynolds +# Local release of mips64el packages + clean ABS sync +# Called by HOOKLOCALRELEASE + +# $1 repo +# $2+ packages + + source /etc/makepkg.conf + source /etc/libretools.conf + source /etc/libretools.d/prtools.conf + + usage() { + echo "$0 repo package1 [ package2 ... packageN ]" + echo + echo " release packages locally on ${PKGDEST}/stage3." + echo " and make a clean ABS sync " + } + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## + get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + } + + repo=$1; shift + repo-add "${PKGDEST}/stage3.db.tar.gz" $@ + +# Get all needed sources + source PKGBUILD + fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) + pkgbase=${pkgbase:-$pkgname} + + msg "Adding packages to [stage3]..." + repo-add $@ + for name in ${pkgname[@]}; do + msg2 "${name} ${fullver}" + repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* + done + +# Copy PKGBUILD and sources + + msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase" + dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase" + mkdir -p ${dest_dir} >/dev/null + rm -rf ${dest_dir}/* # if package existed already there + + eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources. + export CARCH + source=($(. "PKGBUILD"; echo ${source[@]})) + cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1" + for f in ${source[@]}; do + basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g') + if [ -f "$basef" ]; then + cp --remove-destination "$basef" "${dest_dir}" + fi + done + + ( . PKGBUILD + for i in 'changelog' 'install'; do + filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) + for file in $filelist; do + # evaluate any bash variables used + eval file=${file} + if [ -f "$file" ]; then + cp --remove-destination "$file" "${dest_dir}" + fi + done + done + ) +# END add clean abs + +# Commit the changes + + pushd "$dest_dir" >/dev/null + + source "${dest_dir}/PKGBUILD" + epoch=${epoch:-0} + fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) + pkgbase=${pkgbase:-${pkgname[0]}} + + git add "${dest_dir}/." # add using .gitignore + + git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}" + + popd >/dev/null + +# END commit + + exit $? diff --git a/src/prtools/prtools.conf b/src/prtools/prtools.conf new file mode 100644 index 0000000..5b41216 --- /dev/null +++ b/src/prtools/prtools.conf @@ -0,0 +1,4 @@ + +# Absroot for libretools-pr +ABSROOT=$WORKDIR/prabs +HOOKLOCALRELEASE="prmipsrelease" \ No newline at end of file diff --git a/src/prtools/prtoru b/src/prtools/prtoru new file mode 100644 index 0000000..2898b66 --- /dev/null +++ b/src/prtools/prtoru @@ -0,0 +1,173 @@ +#!/bin/bash +# Queries the ABS +# License: GPL3 + +## TODO +# * Add license text +# * Create symlinks from pkgbase to pkgname[@] for easy package finding +# * Use lastsync to store processed packages + +## GOALS +# * Have a searchable database of PKGBUILD metadata +# * Have an interface for source-only builds +# * Possibility to hook up ABS dirs besides ABSROOT (low priority) +# * Tell updates and non available binary packages (working on this) + +source /etc/abs.conf +source /etc/libretools.conf +source /etc/libretools.d/prtools.conf + +# Stores the lastsync date +lastsync() { + [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { + error "The sync date can't be saved. ${lastsyncfile} isn't writable." + return 1 + } + + date +%s > "$lastsyncfile" + touch "$lastsyncfile" +} + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## +get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi +} + +# Outputs an ordered package-fullpkgver array +print_package_array() { + echo "$@" | tr " " "\n" | sort -V -u +} + + +# Gets repo.db contents +# $1 repo +get_db_contents() { + [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 + + bsdtar -tf /var/lib/pacman/sync/$1.db | \ + cut -d'/' -f1 | \ + sort -V -u +} + + +extract_pkgname() { + echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" +} + +extract_fullpkgver() { + echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" +} + + +# Updates the database by finding all PKGBUILDS +# Workflow: +# * Find all PKGBUILDs on the ABS repo specified +# * Get all packages already on package repos +# * Compare them +# Args: +update() { +# The PKGBUILDs found + local pkgbuilds=() +# The list of pkgname-fullpkgver + local packages_to_sync=() + local packages_in_sync=() + local needed_updates=() + local old_versions=() + +# Find all the PKGBUILDs newer than the last update +# Update newer, otherwise everything + if [ $force ] || [ ! -e ${lastsyncfile} ]; then + $quiet || msg "Forcing upgrade" + pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) + else + pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) + fi + +# Inform how many PKGBUILDS were found and quit immediately if none + $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" + [ ${#pkgbuilds[*]} -eq 1 ] && { + $quiet || msg2 "There's nothing to be done. Phew!" + exit 0 + } + + for _pkgbuild in ${pkgbuilds[@]}; do + +# The repo name is guessed +# You *must* use repo/pkgbase structure + _pkgpath=$(dirname "${_pkgbuild}") + _pkgbase=$(basename "${_pkgpath}") + _pkgrepo=$(basename $(dirname "${_pkgpath}")) + + source ${_pkgbuild} + + for _pkg in ${pkgname[@]}; do +# Fill the list of packages to find + packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) + done + + unset pkgbase pkgname pkgver pkgrel source epoch + done + +# Get repo database contents + packages_in_sync=($(get_db_contents ${_pkgrepo})) + print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync + print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync + +# We've orderer the files! + needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + + $quiet || msg "This packages are available to update" + for _update in ${needed_updates[@]}; do + pkg=$(extract_pkgname $_update) + + $quiet && echo $pkg + $quiet || { + ver=$(extract_fullpkgver $_update) + oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) + + msg2 "$pkg $oldver => $ver" + } + + done + +# lastsync + +} + +## MAIN +commands=() +repos=() +quiet=false +force=false +while getopts 'hqfu' arg; do + case $arg in + h) usage; exit 0 ;; + q) quiet=true ;; + f) force=true ;; + u) commands+=(update);; + esac + + shift $((OPTIND-1)) +done + +# This is the syncfile, stores the last date as content and mtime +lastsyncfile=${ABSROOT}/toru.lastsync + +TMPDIR=$(mktemp -d) + +[[ -z ${TMPDIR} ]] && exit 1 + +${commands[0]} ${@} + +rm -rf ${TMPDIR} + +exit $? diff --git a/src/toru/toru b/src/toru/toru new file mode 100755 index 0000000..28f0b8a --- /dev/null +++ b/src/toru/toru @@ -0,0 +1,314 @@ +#!/bin/bash +# Queries the ABS +# License: GPL3 + +## TODO +# * Add license text +# * Create symlinks from pkgbase to pkgname[@] for easy package finding + +## GOALS +# * Have a searchable database of PKGBUILD metadata +# * Have an interface for source-only builds +# * Possibility to hook up ABS dirs besides ABSROOT (low priority) +# * Tell updates and non available binary packages (working on this) + +source $(dirname $(command -v $0))/toru-utils + +# Saves contents on a named cache +# $1 cache name (repo) +# $2+ contents +function store_cache { + cache=$1; shift + + [ -z "$cache" ] && return 1 + + cat $@ > ${TORUPATH}/${cache}.cache + + return $? +} + +# Return cache contents +# $1 cache name +read_cache() { + cat ${TORUPATH}/${1}.cache 2>/dev/null + + return $? +} + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## +get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi +} + +# Outputs an ordered package-fullpkgver array +print_package_array() { + echo "$@" | tr " " "\n" | sort -u +} + + +# Gets repo.db contents (unordered) +# $1 repo +get_db_contents() { + [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 + + bsdtar -tf /var/lib/pacman/sync/$1.db | cut -d'/' -f1 | sort -u +} + +# Get the pkgname +# pkgname from pkgver separator can be either '-' or ' ' +extract_pkgname() { + echo "$@" | tr " " "\n" | sed "s/^\(.\+\)[- ][^-]\+-[^-]\+$/\1/" +} + +# Get all the pkgnames from a file +# pkgname from pkgver separator can be either '-' or ' ' +extract_pkgname_from_file() { + sed "s/^\(.\+\)[- ][^-]\+-[^-]\+$/\1/" $1 +} + +# Split pkgnames from pkgvers +split_pkgname_from_pkgver() { + sed "s/^\(.\+\)-\([^-]\+-[^-]\+\)$/\1 \2/" $1 +} + +# Get the fullpkgver +# pkgname from pkgver separator can be either '-' or ' ' +extract_fullpkgver() { + echo "$@" | tr " " "\n" | sed "s/^.\+[ -]\([^-]\+-[^-]\+\)$/\1/" +} + +# Checks if $1 is a valid repo +is_repo() { + if ! in_array ${1} ${REPOS[@]}; then + $quiet || warning "${1} is not a valid repo (check REPOS array at libretools.conf)" + return 1 + fi +} + +# Updates the database by finding all PKGBUILDS +# Workflow: +# * Find all PKGBUILDs on the ABS repo specified +# * Get all packages already on package repos +# * Compare them +# Args: +update() { + local update_sync_file=false +# The PKGBUILDs found + local -a pkgbuilds=() +# The list of pkgname-fullpkgver + local -a packages_in_abs=() + local -a pkg_updates=() + local -a package_paths=() + +# Traverse all specified repos + for __repo in $@; do +# Check if the repo is set as such, otherwise skip + is_repo ${__repo} || continue + +# Fullpath of the repo + _repopath=$(readlink -f ${__repo}) + +# This is the syncfile, stores the last date as content and mtime + local lastsyncfile=${TORUPATH}/${__repo}.lastsync + +# Find all the PKGBUILDs newer than the last update +# Update newer, otherwise everything + if [[ $force = true || ! -e ${lastsyncfile} ]]; then + + $quiet || warning "Forcing upgrade" +# Get all PKGBUILDs + pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD')) + + else + +# Only find newer than lastsyncfile and read everything else from cache + pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) + packages_in_abs=($(read_cache ${__repo})) + + $quiet || msg2 "Getting ${#packages_in_abs[@]} packages from cache" + + fi + + package_paths=($(read_cache ${__repo}.paths || true)) + +# Inform how many PKGBUILDS were found and quit immediately if none + $quiet || msg "Found $((${#pkgbuilds[*]}-1)) PKGBUILDs to update" + +# Traverse all found PKGBUILDs + for _pkgbuild in ${pkgbuilds[@]}; do +# Update the sync file because there are pkgbuilds to update + update_sync_file=true + +# Load PKGBUILD's metadata + source ${_pkgbuild} || continue + +# Guess pkgbase from PKGBUILD's basedir + _pkgpath=$(dirname "${_pkgbuild}") + _pkgbase=${pkgbase:-${pkgname[0]}} + +# We won't need this (all unsets are for memory efficiency) + unset build package url md5sums install pkgdesc backup options +# TODO fill a license list + unset license +# TODO create source tarballs? + unset mksource +# TODO solve dependency tree? + unset depends makedepends + + for _pkg in ${pkgname[@]}; do +# Keep removing unneeded stuff + unset package_${_pkg} >/dev/null 2>&1 || true +# Fill the list of packages to find + packages_in_abs+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) + package_paths+=($_pkg:$_pkgpath) + done # end pkgnames + + unset pkgbase pkgname pkgver pkgrel source epoch + done # end pkgbuilds + +# Sync! (Only if there was an actual sync) + ${update_sync_file} && lastsync ${lastsyncfile} + + if [ "${lastsyncfile}" -nt "${TORUPATH}/${__repo}.paths.cache" ]; then + print_package_array "${package_paths[@]}" > $TMPDIR/paths + store_cache ${__repo}.paths $TMPDIR/paths + fi + +# If there isn't an update cache or it's older than the last update, we check + if [ "${lastsyncfile}" -nt "${TORUPATH}/${__repo}.updates.cache" ]; then + +# Get repo database contents + packages_in_sync=($(get_db_contents ${__repo})) +# Drops arrays into files + print_package_array "${packages_in_abs[@]}" > ${TMPDIR}/packages_in_abs + print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync + +# Work with files + unset packages_in_abs package_in_sync + +# Use a different separator for pkgnames and pkgvers +# so we can join them by pkgname (first field) + split_pkgname_from_pkgver ${TMPDIR}/packages_in_abs | sort -k1b,1 > ${TMPDIR}/in_abs + split_pkgname_from_pkgver ${TMPDIR}/packages_in_sync | sort -k1b,1 > ${TMPDIR}/in_sync + + $quiet || msg "These packages are available to update" +# Join both files by pkgname, the end result is: +# pkgname syncver absver + join ${TMPDIR}/in_sync ${TMPDIR}/in_abs | \ + while read need_line; do + _pkg=$(echo "${need_line}" | cut -d' ' -f1) + _syncver=$(echo "${need_line}" | cut -d' ' -f2) + _absver=$(echo "${need_line}" | cut -d' ' -f3) + +# If the versions differ we need an update +# TODO move this to update query + if [ "${_syncver}" != "${_absver}" ]; then + $quiet || msg2 "$_pkg update from $_syncver to $_absver" + $quiet && echo "$_pkg" + +# FIXME this works all right but it's unset once the while ends + #pkg_updates+=("$_pkg") + +# Fix for the above problem, but it access the file every time instead of +# puting all packages together once + echo $_pkg >> ${TMPDIR}/updates + + fi + done # end need_line + + unset _pkg _syncver _absver need_line + +# Save the cache + store_cache ${__repo} ${TMPDIR}/packages_in_abs + +# See above FIXME + # print_package_array "${updates[@]}" > ${TMPDIR}/updates + if [ -r ${TMPDIR}/updates ]; then + store_cache ${__repo}.updates ${TMPDIR}/updates + fi + + else + $quiet || msg "Reading updates from cache..." + read_cache ${__repo}.updates + fi + + done # end repos +} + +# Find all the packages that are missing from the repo dbs (aka not built) +missing() { + true +} + +## Finds a PKGBUILD on toru's path cache +## usage: where_is +# Look in all caches but pick the first one +where_is() { + local __repo + local _path + for __repo in ${REPOS[@]}; do + _path=$(grep "^${1}:" "${TORUPATH}/${__repo}.paths.cache" 2>/dev/null | + cut -d: -f2) + + [ -n "${_path}" ] && break + done + + [ -z "$_path" ] && return 1 + + echo ${_path} +} + +# TODO: clean usage instructions +function usage { + echo "" + echo "$0 [options] repo1 ... repon" + echo "" + echo "Make a db containing PKGBUILD metadata." + echo "" + echo "-h : this message" +# echo "-a : update all repos at once" + echo "-u : update repo information" + echo "-q : quiet" + echo "-f : rebuild the db even if it is updated" + echo "-p : return the path for pkgname" + echo "" + exit 1 +} + +## MAIN +commands=() +repos=() +quiet=false +force=false +while getopts 'haqfpum' arg; do + case $arg in + h) usage; exit 0 ;; +# TODO: Update all repos on $REPOS array +# a) update_all_repos ;; + q) quiet=true ;; + f) force=true ;; + u) commands+=(update);; + p) shift $(( OPTIND - 1 )) + where_is "$1" || exit 1;; + m) commands+=(missing);; + esac + + shift $(( OPTIND - 1 )) +done + + +TMPDIR=$(mktemp -d) + +[[ -z ${TMPDIR} ]] && exit 1 + +${commands[0]} ${@} + +exit $? diff --git a/src/toru/toru-info b/src/toru/toru-info new file mode 100755 index 0000000..523f682 --- /dev/null +++ b/src/toru/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 diff --git a/src/toru/toru-path b/src/toru/toru-path new file mode 100755 index 0000000..957f49b --- /dev/null +++ b/src/toru/toru-path @@ -0,0 +1,48 @@ +#!/bin/bash + +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" + 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 +# ABSROOT has trailing slash +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" +msg2 "${#pkgbuilds[@]} PKGBUILDs to update" +for _pkgbuild in ${pkgbuilds[@]}; do +# plain "$_pkgbuild" + source ${_pkgbuild} >/dev/null 2>&1 || { + error "${_pkgbuild} contains errors, skipping" + continue + } + + fullpath=$(dirname ${_pkgbuild}) + + for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do + $VERBOSE && msg2 "${_pkg} -> ${fullpath}" + tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath} + done + + unset pkgbase pkgname provides +done + +lastsync ${LASTSYNCFILE} diff --git a/src/toru/toru-utils b/src/toru/toru-utils new file mode 100755 index 0000000..316e6b8 --- /dev/null +++ b/src/toru/toru-utils @@ -0,0 +1,76 @@ +#!/bin/bash + +source /etc/abs.conf +source /etc/libretools.conf + +LASTSYNCFILE=${TORUPATH}/lastsync +FORCE=false +QUIET=false +DEBUG=false + +# usage : in_array( $needle, $haystack ) +function in_array { + [[ $2 ]] || return 1 # Not found + + local needle=$1; shift + local item + + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 # Found + done + + return 1 # Not Found +} + +# Stores the lastsync date +lastsync() { + local lastsyncfile + + lastsyncfile=$1 + + [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { + error "The sync date can't be saved. ${lastsyncfile} isn't writable." + return 1 + } + + date +%s > ${lastsyncfile} + touch ${lastsyncfile} +} + +get_dbs() { + local _db + for _db in /var/lib/pacman/sync/*.db; do + bsdtar tf ${_db} | cut -d'/' -f1 | sort -u + done +} + +# repo paths +get_pkgbuilds() { + pkgbuilds=() + + if [[ $FORCE = true || ! -e ${LASTSYNCFILE} ]]; then + + $QUIET || warning "Forcing upgrade" +# Get all PKGBUILDs + extra="" + else +# Only find newer than lastsyncfile and read everything else from cache + extra=" -newer ${LASTSYNCFILE}" + fi + +# Return all PKGBUILDs found + find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD' ${extra} +} + +# End inmediately but print a useful message +trap_exit() { + error "$@" + + exit 1 +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "Aborted by user! Exiting..."' INT +trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR diff --git a/src/toru/toru-where b/src/toru/toru-where new file mode 100755 index 0000000..e9ab29d --- /dev/null +++ b/src/toru/toru-where @@ -0,0 +1,7 @@ +#!/bin/bash +# Locates a PKGBUILD dir on toru's path cache +source /etc/libretools.conf + +PATHFILE=${TORUPATH}/paths.tch + +tcamgr get ${PATHFILE} $1 2>/dev/null || echo "" diff --git a/src/treepkg b/src/treepkg new file mode 100755 index 0000000..8c4cc8e --- /dev/null +++ b/src/treepkg @@ -0,0 +1,237 @@ +#!/bin/bash +#set -x +# (c) 2012 Nicolás Reynolds +# +# This program 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. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +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 +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "Aborted by user! Exiting..."' INT +trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR + +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) +get_fullver() { + if [ $1 -eq 0 ]; then +# zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + +} + +# Add line to build order cache in CSV format +# *must* be run from the PKGBUILD path +# status;depth;pkgbase;[epoch:]pkgver-pkgrel;path;repo +# $1 status +# $2 pkgname +add_order() { + echo "${1};${DEPTH};${2:-${pkgbase}};${fullver};${PWD};$(guess_repo "$PWD")" >> "${BUILDORDER}" + ${VERBOSE} && msg2 "%${DEPTH}s${2:-${pkgbase}} [${1}]" || true +} + +# Bury a package deeper in the tree +# $1 pkgbase +# $2 nextdepth +bury() { +# Bury only if we are going to build the dep +# Get it's current depth and dir name + local current_depth=$(grep "build;[0-9]\+;${1};" "${BUILDORDER}" | cut -d ';' -f 2) + local current_name="$(printf "%03d" ${current_depth})_${1}" + +# If there's a depth or the package is not the root of the build tree (which +# can lead to funny chicken-and-egg problems), update the depth to the current +# package next-depth and rename the dir too + if [ -z "${current_depth}" ]; then return; fi + if [ -z "${current_name}" ]; then return; fi + if [ ${current_depth} -eq 0 ]; then return; fi + if [ ${current_depth} -ge $2 ]; then return; fi + + ${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}" + + { + sed -i "s|^\(build;\)\([0-9]\+\)\(;${1};.*\)$|\1${2}\3|" "${BUILDORDER}" && \ + mv "${BUILDDIR}/${current_name}" "${BUILDDIR}/$(printf "%03d" ${2})_${1}" + } || return 1 +} + +# Guess the repo from the pkgbase path +# $1 path, pwd or toru-where +guess_repo() { + basename "$(dirname "${1}")" +} + +if [ ! -f PKGBUILD ]; then + error "Missing PKGBUILD ($PWD)" + exit 1 +fi + +if ! source PKGBUILD ; then + error "Can't source PKGBUILD" + exit 1 +fi + +# Save resources +unset pkgdesc arch license groups backup install md5sums sha1sums \ + sha256sums source options >/dev/null 2>&1 + +unset build package >/dev/null 2>&1 + +for _pkg in ${pkgname[@]}; do + unset package_${_pkg} >/dev/null 2>&1 || true +done +## + +# Get useful values +pkgbase="${pkgbase:-${pkgname[0]}}" +fullver=$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel}) + +# Get or set the work dir +BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}" +BUILDORDER="${BUILDDIR}/BUILDORDER" +DEPTH=${2:-0} +NEXTDEPTH=$((${DEPTH} + 1)) +# This can be set as env vars (ie: $ V=false B=false treepkg) +# TODO Turn into flags? +VERBOSE=${V:-true} +BUILD=${B:-true} +CLEANUP=${C:-true} +# Skip BUILDORDER creation and build anything on BUILDDIR +BUILDNOW=${N:-false} + +if [ ! -z "${1}" -a ${DEPTH} -eq 0 ]; then + BUILDNOW=true +fi + +if ! ${BUILDNOW}; then +# ensure it exists + touch "${BUILDORDER}" + +# If this package is already built quit silently + 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 + +# Add pkgbase to build order + add_order "build" + +# Copy the directory to the build dir +# TODO run makepkg --source to avoid moving garbage around? + cp -r "${PWD}" "${BUILDDIR}/$(printf "%03d" ${DEPTH})_${pkgbase}" + +# Cleanup dep versioning + deps=($(echo "${depends[@]} ${makedepends[@]}" | \ + sed "s/[=<>]\+[^ ]\+//g" | \ + tr ' ' "\n" | \ + sort -u)) + +# NOTE: getting depends from package() is a PITA + for _dep in ${deps[@]}; do +# Move deps deeper in the tree if +# pkgbase - dep1 +# \ dep2 - dep1 +# dep1 should be depth + 1 + egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} + +# Ask toru where's a PKGBUILD + depdir="$(toru-where ${_dep})" + + if [ -z "${depdir}" -o ! -d "${depdir}" ]; then +# We specify the pkgname because we can't source the dep PKGBUILD +# Normally 'any' packages are missing from our work ABS + add_order "missing" "${_dep}" + continue + fi + + pushd "${depdir}" >/dev/null + +# Run itself over dependencies + $0 "${BUILDDIR}" ${NEXTDEPTH} + + done +# End BUILD now +fi + +# Only build at the end +if [ ${DEPTH} -eq 0 ]; then + ${VERBOSE} && msg "Starting build" || true + + if ${BUILD}; then + ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true + +# Build everything sorting the build dir +# The reverse order ensures we start by the deepest packages + 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 "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi + + ${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 + + ${HOOKPREBUILD} + + ${FULLBUILDCMD} +# Run local release hook with $1 = $repo + ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) + + touch built_ok + popd >/dev/null + done + + else +# Just print the working dir + ${VERBOSE} || echo "${BUILDORDER}" || true + fi + +if ${CLEANUP} ; then + msg2 "Removing ${BUILDDIR}" + rm -rf "${BUILDDIR}" +fi + +fi + +term_title "done" +exit $? diff --git a/src/update-cleansystem b/src/update-cleansystem new file mode 100755 index 0000000..6bec742 --- /dev/null +++ b/src/update-cleansystem @@ -0,0 +1,68 @@ +#!/bin/bash +# Updates the cleansystem file +# 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 + +# ---------- 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 . + +set -e + +# libretools.conf gives us libremessages +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 + +if [ ! -w "$cleansystem" ]; then + error 'This script must be run as root' + exit 1 +fi + +# Maintain a clean database in the system +db_dir="${DB:-/var/lib/libretools/clean}" +[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}" + +# We sync first because updating info gets printed to stdout too +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 > "$cleansystem" + +# Ensures everything's installed +pacman -Sy --needed --noconfirm base base-devel sudo $@ + +exit $? diff --git a/toru b/toru deleted file mode 100755 index 28f0b8a..0000000 --- a/toru +++ /dev/null @@ -1,314 +0,0 @@ -#!/bin/bash -# Queries the ABS -# License: GPL3 - -## TODO -# * Add license text -# * Create symlinks from pkgbase to pkgname[@] for easy package finding - -## GOALS -# * Have a searchable database of PKGBUILD metadata -# * Have an interface for source-only builds -# * Possibility to hook up ABS dirs besides ABSROOT (low priority) -# * Tell updates and non available binary packages (working on this) - -source $(dirname $(command -v $0))/toru-utils - -# Saves contents on a named cache -# $1 cache name (repo) -# $2+ contents -function store_cache { - cache=$1; shift - - [ -z "$cache" ] && return 1 - - cat $@ > ${TORUPATH}/${cache}.cache - - return $? -} - -# Return cache contents -# $1 cache name -read_cache() { - cat ${TORUPATH}/${1}.cache 2>/dev/null - - return $? -} - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - -# Outputs an ordered package-fullpkgver array -print_package_array() { - echo "$@" | tr " " "\n" | sort -u -} - - -# Gets repo.db contents (unordered) -# $1 repo -get_db_contents() { - [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 - - bsdtar -tf /var/lib/pacman/sync/$1.db | cut -d'/' -f1 | sort -u -} - -# Get the pkgname -# pkgname from pkgver separator can be either '-' or ' ' -extract_pkgname() { - echo "$@" | tr " " "\n" | sed "s/^\(.\+\)[- ][^-]\+-[^-]\+$/\1/" -} - -# Get all the pkgnames from a file -# pkgname from pkgver separator can be either '-' or ' ' -extract_pkgname_from_file() { - sed "s/^\(.\+\)[- ][^-]\+-[^-]\+$/\1/" $1 -} - -# Split pkgnames from pkgvers -split_pkgname_from_pkgver() { - sed "s/^\(.\+\)-\([^-]\+-[^-]\+\)$/\1 \2/" $1 -} - -# Get the fullpkgver -# pkgname from pkgver separator can be either '-' or ' ' -extract_fullpkgver() { - echo "$@" | tr " " "\n" | sed "s/^.\+[ -]\([^-]\+-[^-]\+\)$/\1/" -} - -# Checks if $1 is a valid repo -is_repo() { - if ! in_array ${1} ${REPOS[@]}; then - $quiet || warning "${1} is not a valid repo (check REPOS array at libretools.conf)" - return 1 - fi -} - -# Updates the database by finding all PKGBUILDS -# Workflow: -# * Find all PKGBUILDs on the ABS repo specified -# * Get all packages already on package repos -# * Compare them -# Args: -update() { - local update_sync_file=false -# The PKGBUILDs found - local -a pkgbuilds=() -# The list of pkgname-fullpkgver - local -a packages_in_abs=() - local -a pkg_updates=() - local -a package_paths=() - -# Traverse all specified repos - for __repo in $@; do -# Check if the repo is set as such, otherwise skip - is_repo ${__repo} || continue - -# Fullpath of the repo - _repopath=$(readlink -f ${__repo}) - -# This is the syncfile, stores the last date as content and mtime - local lastsyncfile=${TORUPATH}/${__repo}.lastsync - -# Find all the PKGBUILDs newer than the last update -# Update newer, otherwise everything - if [[ $force = true || ! -e ${lastsyncfile} ]]; then - - $quiet || warning "Forcing upgrade" -# Get all PKGBUILDs - pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD')) - - else - -# Only find newer than lastsyncfile and read everything else from cache - pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) - packages_in_abs=($(read_cache ${__repo})) - - $quiet || msg2 "Getting ${#packages_in_abs[@]} packages from cache" - - fi - - package_paths=($(read_cache ${__repo}.paths || true)) - -# Inform how many PKGBUILDS were found and quit immediately if none - $quiet || msg "Found $((${#pkgbuilds[*]}-1)) PKGBUILDs to update" - -# Traverse all found PKGBUILDs - for _pkgbuild in ${pkgbuilds[@]}; do -# Update the sync file because there are pkgbuilds to update - update_sync_file=true - -# Load PKGBUILD's metadata - source ${_pkgbuild} || continue - -# Guess pkgbase from PKGBUILD's basedir - _pkgpath=$(dirname "${_pkgbuild}") - _pkgbase=${pkgbase:-${pkgname[0]}} - -# We won't need this (all unsets are for memory efficiency) - unset build package url md5sums install pkgdesc backup options -# TODO fill a license list - unset license -# TODO create source tarballs? - unset mksource -# TODO solve dependency tree? - unset depends makedepends - - for _pkg in ${pkgname[@]}; do -# Keep removing unneeded stuff - unset package_${_pkg} >/dev/null 2>&1 || true -# Fill the list of packages to find - packages_in_abs+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) - package_paths+=($_pkg:$_pkgpath) - done # end pkgnames - - unset pkgbase pkgname pkgver pkgrel source epoch - done # end pkgbuilds - -# Sync! (Only if there was an actual sync) - ${update_sync_file} && lastsync ${lastsyncfile} - - if [ "${lastsyncfile}" -nt "${TORUPATH}/${__repo}.paths.cache" ]; then - print_package_array "${package_paths[@]}" > $TMPDIR/paths - store_cache ${__repo}.paths $TMPDIR/paths - fi - -# If there isn't an update cache or it's older than the last update, we check - if [ "${lastsyncfile}" -nt "${TORUPATH}/${__repo}.updates.cache" ]; then - -# Get repo database contents - packages_in_sync=($(get_db_contents ${__repo})) -# Drops arrays into files - print_package_array "${packages_in_abs[@]}" > ${TMPDIR}/packages_in_abs - print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync - -# Work with files - unset packages_in_abs package_in_sync - -# Use a different separator for pkgnames and pkgvers -# so we can join them by pkgname (first field) - split_pkgname_from_pkgver ${TMPDIR}/packages_in_abs | sort -k1b,1 > ${TMPDIR}/in_abs - split_pkgname_from_pkgver ${TMPDIR}/packages_in_sync | sort -k1b,1 > ${TMPDIR}/in_sync - - $quiet || msg "These packages are available to update" -# Join both files by pkgname, the end result is: -# pkgname syncver absver - join ${TMPDIR}/in_sync ${TMPDIR}/in_abs | \ - while read need_line; do - _pkg=$(echo "${need_line}" | cut -d' ' -f1) - _syncver=$(echo "${need_line}" | cut -d' ' -f2) - _absver=$(echo "${need_line}" | cut -d' ' -f3) - -# If the versions differ we need an update -# TODO move this to update query - if [ "${_syncver}" != "${_absver}" ]; then - $quiet || msg2 "$_pkg update from $_syncver to $_absver" - $quiet && echo "$_pkg" - -# FIXME this works all right but it's unset once the while ends - #pkg_updates+=("$_pkg") - -# Fix for the above problem, but it access the file every time instead of -# puting all packages together once - echo $_pkg >> ${TMPDIR}/updates - - fi - done # end need_line - - unset _pkg _syncver _absver need_line - -# Save the cache - store_cache ${__repo} ${TMPDIR}/packages_in_abs - -# See above FIXME - # print_package_array "${updates[@]}" > ${TMPDIR}/updates - if [ -r ${TMPDIR}/updates ]; then - store_cache ${__repo}.updates ${TMPDIR}/updates - fi - - else - $quiet || msg "Reading updates from cache..." - read_cache ${__repo}.updates - fi - - done # end repos -} - -# Find all the packages that are missing from the repo dbs (aka not built) -missing() { - true -} - -## Finds a PKGBUILD on toru's path cache -## usage: where_is -# Look in all caches but pick the first one -where_is() { - local __repo - local _path - for __repo in ${REPOS[@]}; do - _path=$(grep "^${1}:" "${TORUPATH}/${__repo}.paths.cache" 2>/dev/null | - cut -d: -f2) - - [ -n "${_path}" ] && break - done - - [ -z "$_path" ] && return 1 - - echo ${_path} -} - -# TODO: clean usage instructions -function usage { - echo "" - echo "$0 [options] repo1 ... repon" - echo "" - echo "Make a db containing PKGBUILD metadata." - echo "" - echo "-h : this message" -# echo "-a : update all repos at once" - echo "-u : update repo information" - echo "-q : quiet" - echo "-f : rebuild the db even if it is updated" - echo "-p : return the path for pkgname" - echo "" - exit 1 -} - -## MAIN -commands=() -repos=() -quiet=false -force=false -while getopts 'haqfpum' arg; do - case $arg in - h) usage; exit 0 ;; -# TODO: Update all repos on $REPOS array -# a) update_all_repos ;; - q) quiet=true ;; - f) force=true ;; - u) commands+=(update);; - p) shift $(( OPTIND - 1 )) - where_is "$1" || exit 1;; - m) commands+=(missing);; - esac - - shift $(( OPTIND - 1 )) -done - - -TMPDIR=$(mktemp -d) - -[[ -z ${TMPDIR} ]] && exit 1 - -${commands[0]} ${@} - -exit $? diff --git a/toru-info b/toru-info deleted file mode 100755 index 523f682..0000000 --- a/toru-info +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 diff --git a/toru-path b/toru-path deleted file mode 100755 index 957f49b..0000000 --- a/toru-path +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -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" - 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 -# ABSROOT has trailing slash -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" -msg2 "${#pkgbuilds[@]} PKGBUILDs to update" -for _pkgbuild in ${pkgbuilds[@]}; do -# plain "$_pkgbuild" - source ${_pkgbuild} >/dev/null 2>&1 || { - error "${_pkgbuild} contains errors, skipping" - continue - } - - fullpath=$(dirname ${_pkgbuild}) - - for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do - $VERBOSE && msg2 "${_pkg} -> ${fullpath}" - tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath} - done - - unset pkgbase pkgname provides -done - -lastsync ${LASTSYNCFILE} diff --git a/toru-utils b/toru-utils deleted file mode 100755 index 316e6b8..0000000 --- a/toru-utils +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -source /etc/abs.conf -source /etc/libretools.conf - -LASTSYNCFILE=${TORUPATH}/lastsync -FORCE=false -QUIET=false -DEBUG=false - -# usage : in_array( $needle, $haystack ) -function in_array { - [[ $2 ]] || return 1 # Not found - - local needle=$1; shift - local item - - for item in "$@"; do - [[ ${item#@} = $needle ]] && return 0 # Found - done - - return 1 # Not Found -} - -# Stores the lastsync date -lastsync() { - local lastsyncfile - - lastsyncfile=$1 - - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } - - date +%s > ${lastsyncfile} - touch ${lastsyncfile} -} - -get_dbs() { - local _db - for _db in /var/lib/pacman/sync/*.db; do - bsdtar tf ${_db} | cut -d'/' -f1 | sort -u - done -} - -# repo paths -get_pkgbuilds() { - pkgbuilds=() - - if [[ $FORCE = true || ! -e ${LASTSYNCFILE} ]]; then - - $QUIET || warning "Forcing upgrade" -# Get all PKGBUILDs - extra="" - else -# Only find newer than lastsyncfile and read everything else from cache - extra=" -newer ${LASTSYNCFILE}" - fi - -# Return all PKGBUILDs found - find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD' ${extra} -} - -# End inmediately but print a useful message -trap_exit() { - error "$@" - - exit 1 -} - -# Trap signals from makepkg -set -E -trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "Aborted by user! Exiting..."' INT -trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR diff --git a/toru-where b/toru-where deleted file mode 100755 index e9ab29d..0000000 --- a/toru-where +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# Locates a PKGBUILD dir on toru's path cache -source /etc/libretools.conf - -PATHFILE=${TORUPATH}/paths.tch - -tcamgr get ${PATHFILE} $1 2>/dev/null || echo "" diff --git a/treepkg b/treepkg deleted file mode 100755 index 8c4cc8e..0000000 --- a/treepkg +++ /dev/null @@ -1,237 +0,0 @@ -#!/bin/bash -#set -x -# (c) 2012 Nicolás Reynolds -# -# This program 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. -# -# This program 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -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 -} - -# Trap signals from makepkg -set -E -trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "Aborted by user! Exiting..."' INT -trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR - -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) -get_fullver() { - if [ $1 -eq 0 ]; then -# zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -# Add line to build order cache in CSV format -# *must* be run from the PKGBUILD path -# status;depth;pkgbase;[epoch:]pkgver-pkgrel;path;repo -# $1 status -# $2 pkgname -add_order() { - echo "${1};${DEPTH};${2:-${pkgbase}};${fullver};${PWD};$(guess_repo "$PWD")" >> "${BUILDORDER}" - ${VERBOSE} && msg2 "%${DEPTH}s${2:-${pkgbase}} [${1}]" || true -} - -# Bury a package deeper in the tree -# $1 pkgbase -# $2 nextdepth -bury() { -# Bury only if we are going to build the dep -# Get it's current depth and dir name - local current_depth=$(grep "build;[0-9]\+;${1};" "${BUILDORDER}" | cut -d ';' -f 2) - local current_name="$(printf "%03d" ${current_depth})_${1}" - -# If there's a depth or the package is not the root of the build tree (which -# can lead to funny chicken-and-egg problems), update the depth to the current -# package next-depth and rename the dir too - if [ -z "${current_depth}" ]; then return; fi - if [ -z "${current_name}" ]; then return; fi - if [ ${current_depth} -eq 0 ]; then return; fi - if [ ${current_depth} -ge $2 ]; then return; fi - - ${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}" - - { - sed -i "s|^\(build;\)\([0-9]\+\)\(;${1};.*\)$|\1${2}\3|" "${BUILDORDER}" && \ - mv "${BUILDDIR}/${current_name}" "${BUILDDIR}/$(printf "%03d" ${2})_${1}" - } || return 1 -} - -# Guess the repo from the pkgbase path -# $1 path, pwd or toru-where -guess_repo() { - basename "$(dirname "${1}")" -} - -if [ ! -f PKGBUILD ]; then - error "Missing PKGBUILD ($PWD)" - exit 1 -fi - -if ! source PKGBUILD ; then - error "Can't source PKGBUILD" - exit 1 -fi - -# Save resources -unset pkgdesc arch license groups backup install md5sums sha1sums \ - sha256sums source options >/dev/null 2>&1 - -unset build package >/dev/null 2>&1 - -for _pkg in ${pkgname[@]}; do - unset package_${_pkg} >/dev/null 2>&1 || true -done -## - -# Get useful values -pkgbase="${pkgbase:-${pkgname[0]}}" -fullver=$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel}) - -# Get or set the work dir -BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}" -BUILDORDER="${BUILDDIR}/BUILDORDER" -DEPTH=${2:-0} -NEXTDEPTH=$((${DEPTH} + 1)) -# This can be set as env vars (ie: $ V=false B=false treepkg) -# TODO Turn into flags? -VERBOSE=${V:-true} -BUILD=${B:-true} -CLEANUP=${C:-true} -# Skip BUILDORDER creation and build anything on BUILDDIR -BUILDNOW=${N:-false} - -if [ ! -z "${1}" -a ${DEPTH} -eq 0 ]; then - BUILDNOW=true -fi - -if ! ${BUILDNOW}; then -# ensure it exists - touch "${BUILDORDER}" - -# If this package is already built quit silently - 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 - -# Add pkgbase to build order - add_order "build" - -# Copy the directory to the build dir -# TODO run makepkg --source to avoid moving garbage around? - cp -r "${PWD}" "${BUILDDIR}/$(printf "%03d" ${DEPTH})_${pkgbase}" - -# Cleanup dep versioning - deps=($(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u)) - -# NOTE: getting depends from package() is a PITA - for _dep in ${deps[@]}; do -# Move deps deeper in the tree if -# pkgbase - dep1 -# \ dep2 - dep1 -# dep1 should be depth + 1 - egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} - -# Ask toru where's a PKGBUILD - depdir="$(toru-where ${_dep})" - - if [ -z "${depdir}" -o ! -d "${depdir}" ]; then -# We specify the pkgname because we can't source the dep PKGBUILD -# Normally 'any' packages are missing from our work ABS - add_order "missing" "${_dep}" - continue - fi - - pushd "${depdir}" >/dev/null - -# Run itself over dependencies - $0 "${BUILDDIR}" ${NEXTDEPTH} - - done -# End BUILD now -fi - -# Only build at the end -if [ ${DEPTH} -eq 0 ]; then - ${VERBOSE} && msg "Starting build" || true - - if ${BUILD}; then - ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true - -# Build everything sorting the build dir -# The reverse order ensures we start by the deepest packages - 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 "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi - - ${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 - - ${HOOKPREBUILD} - - ${FULLBUILDCMD} -# Run local release hook with $1 = $repo - ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) - - touch built_ok - popd >/dev/null - done - - else -# Just print the working dir - ${VERBOSE} || echo "${BUILDORDER}" || true - fi - -if ${CLEANUP} ; then - msg2 "Removing ${BUILDDIR}" - rm -rf "${BUILDDIR}" -fi - -fi - -term_title "done" -exit $? diff --git a/update-cleansystem b/update-cleansystem deleted file mode 100755 index 6bec742..0000000 --- a/update-cleansystem +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# Updates the cleansystem file -# 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 - -# ---------- 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 . - -set -e - -# libretools.conf gives us libremessages -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 - -if [ ! -w "$cleansystem" ]; then - error 'This script must be run as root' - exit 1 -fi - -# Maintain a clean database in the system -db_dir="${DB:-/var/lib/libretools/clean}" -[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}" - -# We sync first because updating info gets printed to stdout too -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 > "$cleansystem" - -# Ensures everything's installed -pacman -Sy --needed --noconfirm base base-devel sudo $@ - -exit $? diff --git a/updateabslibre b/updateabslibre deleted file mode 100755 index 76f964a..0000000 --- a/updateabslibre +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# UpdateABSLibre -# Updates the ABSLibre git repo - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -[[ -e $custom_config ]] && source $custom_config - -# Send every output to /dev/null - -msg "Updating ABSLibre..." - -pushd ${WORKDIR}/abslibre ${stdnull} - git pull ${ABSLIBREGIT} || { - error "Failed pull" - exit 1 -} -stdnull "popd" - -exit 0 -- cgit v1.2.2 From fa8e8a2a9770391530134272bd4da3ec0ecb6b9e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 11:09:56 -0500 Subject: mv src/pr{,-}tools --- src/pr-tools/prfullpkg | 398 +++++++++++++++++++++++++++++++++++++++++++++ src/pr-tools/prmipsrelease | 98 +++++++++++ src/pr-tools/prtools.conf | 4 + src/pr-tools/prtoru | 173 ++++++++++++++++++++ src/prtools/prfullpkg | 398 --------------------------------------------- src/prtools/prmipsrelease | 98 ----------- src/prtools/prtools.conf | 4 - src/prtools/prtoru | 173 -------------------- 8 files changed, 673 insertions(+), 673 deletions(-) create mode 100755 src/pr-tools/prfullpkg create mode 100755 src/pr-tools/prmipsrelease create mode 100644 src/pr-tools/prtools.conf create mode 100755 src/pr-tools/prtoru delete mode 100755 src/prtools/prfullpkg delete mode 100755 src/prtools/prmipsrelease delete mode 100644 src/prtools/prtools.conf delete mode 100644 src/prtools/prtoru diff --git a/src/pr-tools/prfullpkg b/src/pr-tools/prfullpkg new file mode 100755 index 0000000..bbb8d73 --- /dev/null +++ b/src/pr-tools/prfullpkg @@ -0,0 +1,398 @@ +#!/bin/bash + +source /etc/makepkg.conf +source /etc/abs.conf +source /etc/libretools.conf +source /etc/libretools.d/prtools.conf + +if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors + + error "There's no XDG_CONFIG_HOME var set"; exit 1 + +elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then + + source $XDG_CONFIG_HOME/libretools/libretools.conf + +fi + + +function usage { + + echo "cd to a dir containing a PKGBUILD and run:" + echo "$0 [options]" + printf "This script will check dependencies, build them if possible " + printf "and stage the packages on it's repo." + echo + echo "OPTIONS:" + echo " -h : this message." + echo " -a absdir : set absdir as ABSROOT." + echo " -b build_dir : use a fullpkg build_dir and only build." + echo " -c : check deps only, do not build." + echo " -d build_dir : use this dir to build. Defaults to mktemp." + echo " -n : don't update pacman db." + echo " -m max_level : check deps until this level" + echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" + echo + exit 1 + +} + +function remove_buildorder { # Removes a package from the buildorder +# $1 package name +# $2 buildorder file + + grep -Evw "${1}" ${2} > ${2}2 + mv -f ${2}2 ${2} + +} + +function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD + + basename $(pwd) + +} + +function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel + +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) + + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + +} + +function cleanup { # Cleans the build_dir. + + [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. + + + if [ $level -eq 0 ]; then # Only do cleanup on level 0. + msg "Cleaning up ${build_dir}" + rm -rf "$build_dir/*" + fi +} + +function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. + + source PKGBUILD ## Check this level. + + local repo=${repo:-$(guess_repo)} + local pkgbase=${pkgbase:-${pkgname[0]}} + local epoch=${epoch:-0} + local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) + + if is_built "${pkgbase}" "${fullver}"; then + exit 0 # pkg is built and updated + fi + + echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first + + if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there + + exit 0 + + else # Copy dir to build_dir + + mkdir ${build_dir}/${pkgbase} + cp -r $(pwd)/* ${build_dir}/${pkgbase} + + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later + fi + + msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level + + declare -i next_level=$level+1 ## Check next deps level. + + deps=$(echo "${depends[@]} ${makedepends[@]}" | \ + sed "s/[=<>]\+[^ ]\+//g" | \ + tr ' ' "\n" | \ + sort -u) # All deps in separate line, only once, without version. + + for _dep in ${deps[@]}; do + + local found=false + + if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo + + for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order + + if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then + + pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular deps + popd > /dev/null + local found=true + break 1 # found, go to next dep + fi + + done + + else # pkgsplit, needs guess + + for _repo in ${REPOS[@]}; do + + if _dir=($(find "$ABSROOT/" -type f \ + -wholename "*/${_repo}/PKGBUILD" -print0 2>/dev/null | \ + "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ + grep -w "$_dep" 2>&1)) ; + + then + + _dir=$(dirname $(echo $_dir | cut -d: -f1)) + plain "guess for $_dep -> $_dir" + + pushd "$_dir" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular dep + popd > /dev/null + local found=true + break 1 # found, go to next dep + fi + + done + + fi + + if ( ${found} ); then + continue 1 # go to next dep + else + echo "dep_not_found:$_dep" >> $build_dir/log + fi + + done + + unset next_level dir + # unset PKGBUILD variables + unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ + makedepens checkdepends optdepends provides conflicts replaces backup \ + options install changelog source noextract md5sums build check package +} + +function __build () { + pushd ${build_dir} > /dev/null + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first + + while [ ${#build_packages[@]} -ge 1 ]; do + pushd $build_dir/${build_packages[0]} > /dev/null + source PKGBUILD + + msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" + + msg2 "Checking for non free deps" + pkgbuild-check-nonfree || { + if [ $? -eq 15 ]; then # this error means nonfree others means fail. + + echo "nonfree:$(basename $PWD)" >> $build_dir/log + + remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder + + continue # build next package + fi + } + + msg2 "Building $(basename $PWD)" + + $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf + + case $r in + + 0) ## Succesfull build + + plain "The build was succesful." + if source .INFO && [ -n $repo ]; then + + if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used + find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo + fi + + librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log + + msg "Updating pacman db and packages" + sudo pacman -Sy || true + + fi + + echo "built:$(basename $PWD)" >> $build_dir/log + ;; + + *) ## Build failed + error "There were errors while trying to build the package." + echo "failed:$(basename $PWD)" >> $build_dir/log + ;; + esac + + remove_buildorder "${build_packages[0]}" $buildorder || true + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? + popd > /dev/null + done + + pkgs=($(grep "nonfree:" $build_dir/log)) && { + error "Those packages contain nonfree deps:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "built:" $build_dir/log)) && { + msg "Those packages were built and staged:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "failed:" $build_dir/log)) && { + error "Those packages failed to build:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + pkgs=($(grep "unstaged:" $build_dir/log)) && { + error "Those packages couldn't be staged because of missing reponame:" + echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 + } + + popd > /dev/null +} + +function trap_exit { # End inmediately but print a useful message + + error "$@" + warning "Leftover files left on $build_dir" + + exit 1 +} + +# 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 + +ban_file=$XDG_CONFIG_HOME/libretools/ban +force_build="" +level=0 +noupdate='n' +build_only='n' +check_deps_only='n' +max_level=21 + +while getopts 'ha:b:cd:l:nm:r:' arg; do + case $arg in + h) usage ;; + a) ABSROOT="$OPTARG" ;; + b) build_only='y' + build_dir="$OPTARG" + if [ -z ${build_dir} ]; then + usage + fi + if [ ! -r ${build_dir}/BUILDORDER ] ; then + error "${build_dir}/BUILDORDER doesn't exist." + exit 1 + fi;; + c) check_deps_only='y' ;; + d) build_dir="$OPTARG" ;; + l) level=$OPTARG ;; # hidden option to know dep level. + n) noupdate='y';; + m) max_level=$OPTARG ;; + r) FULLBUILDCMD="$OPTARG" ;; + esac +done + +if [ ${build_only} == 'n' ]; then + + [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. + error "This isn't a build directory" + usage + } + + if [ ! -z "$HOOKPKGBUILDMOD" ]; then + "$HOOKPKGBUILDMOD" + fi + +fi + +if [ $level -eq 0 ]; then + + if [ ! -d ${build_dir} ]; then # in case of custom -d option + mkdir -p ${build_dir} + else + cleanup # files already there can screw find_deps + fi + + build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp + + touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder + buildorder=${build_dir}/BUILDORDER + + if [ ${noupdate} = 'n' ]; then + + msg "Updating pacman db and packages" + sudo pacman -Syu --noconfirm || true + + fi + + if [ ${build_only} == 'y' ]; then + + msg "Build Packages" + + __build + + exit 0 + + fi + + msg "Checking dependencies" +fi + +[ $level -ge $max_level ] && exit 20 # Probable circular deps + +find_deps || { + + if [ $? -eq 20 ]; then # Probable circular deps + + if [ $level -eq 0 ]; then # Show error only on level 0 + error "Check for circular deps on $build_dir/BUILDORDER"; + fi + + fi + exit 20 # Pass message 20 +} + +[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 + +if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check + + if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions + + chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" + + else + + rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { + + warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist + + search=$(cat ${ban_file} | tr "\n" "|") + + egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files + + egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder + + mv -f ${buildorder}2 ${buildorder} + + unset search + } + } + fi +fi + +msg "Building packages:" + +__build # Build the packages + +echo +msg2 "Check if your system works fine and librerelease if it does" + +exit 0 diff --git a/src/pr-tools/prmipsrelease b/src/pr-tools/prmipsrelease new file mode 100755 index 0000000..1fbd696 --- /dev/null +++ b/src/pr-tools/prmipsrelease @@ -0,0 +1,98 @@ +#!/bin/bash +# Lic: GPLv3+ +# Author: Nicolas Reynolds +# Local release of mips64el packages + clean ABS sync +# Called by HOOKLOCALRELEASE + +# $1 repo +# $2+ packages + + source /etc/makepkg.conf + source /etc/libretools.conf + source /etc/libretools.d/prtools.conf + + usage() { + echo "$0 repo package1 [ package2 ... packageN ]" + echo + echo " release packages locally on ${PKGDEST}/stage3." + echo " and make a clean ABS sync " + } + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## + get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + } + + repo=$1; shift + repo-add "${PKGDEST}/stage3.db.tar.gz" $@ + +# Get all needed sources + source PKGBUILD + fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) + pkgbase=${pkgbase:-$pkgname} + + msg "Adding packages to [stage3]..." + repo-add $@ + for name in ${pkgname[@]}; do + msg2 "${name} ${fullver}" + repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* + done + +# Copy PKGBUILD and sources + + msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase" + dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase" + mkdir -p ${dest_dir} >/dev/null + rm -rf ${dest_dir}/* # if package existed already there + + eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources. + export CARCH + source=($(. "PKGBUILD"; echo ${source[@]})) + cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1" + for f in ${source[@]}; do + basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g') + if [ -f "$basef" ]; then + cp --remove-destination "$basef" "${dest_dir}" + fi + done + + ( . PKGBUILD + for i in 'changelog' 'install'; do + filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) + for file in $filelist; do + # evaluate any bash variables used + eval file=${file} + if [ -f "$file" ]; then + cp --remove-destination "$file" "${dest_dir}" + fi + done + done + ) +# END add clean abs + +# Commit the changes + + pushd "$dest_dir" >/dev/null + + source "${dest_dir}/PKGBUILD" + epoch=${epoch:-0} + fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) + pkgbase=${pkgbase:-${pkgname[0]}} + + git add "${dest_dir}/." # add using .gitignore + + git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}" + + popd >/dev/null + +# END commit + + exit $? diff --git a/src/pr-tools/prtools.conf b/src/pr-tools/prtools.conf new file mode 100644 index 0000000..5b41216 --- /dev/null +++ b/src/pr-tools/prtools.conf @@ -0,0 +1,4 @@ + +# Absroot for libretools-pr +ABSROOT=$WORKDIR/prabs +HOOKLOCALRELEASE="prmipsrelease" \ No newline at end of file diff --git a/src/pr-tools/prtoru b/src/pr-tools/prtoru new file mode 100755 index 0000000..2898b66 --- /dev/null +++ b/src/pr-tools/prtoru @@ -0,0 +1,173 @@ +#!/bin/bash +# Queries the ABS +# License: GPL3 + +## TODO +# * Add license text +# * Create symlinks from pkgbase to pkgname[@] for easy package finding +# * Use lastsync to store processed packages + +## GOALS +# * Have a searchable database of PKGBUILD metadata +# * Have an interface for source-only builds +# * Possibility to hook up ABS dirs besides ABSROOT (low priority) +# * Tell updates and non available binary packages (working on this) + +source /etc/abs.conf +source /etc/libretools.conf +source /etc/libretools.d/prtools.conf + +# Stores the lastsync date +lastsync() { + [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { + error "The sync date can't be saved. ${lastsyncfile} isn't writable." + return 1 + } + + date +%s > "$lastsyncfile" + touch "$lastsyncfile" +} + +## +# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel +## +get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi +} + +# Outputs an ordered package-fullpkgver array +print_package_array() { + echo "$@" | tr " " "\n" | sort -V -u +} + + +# Gets repo.db contents +# $1 repo +get_db_contents() { + [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 + + bsdtar -tf /var/lib/pacman/sync/$1.db | \ + cut -d'/' -f1 | \ + sort -V -u +} + + +extract_pkgname() { + echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" +} + +extract_fullpkgver() { + echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" +} + + +# Updates the database by finding all PKGBUILDS +# Workflow: +# * Find all PKGBUILDs on the ABS repo specified +# * Get all packages already on package repos +# * Compare them +# Args: +update() { +# The PKGBUILDs found + local pkgbuilds=() +# The list of pkgname-fullpkgver + local packages_to_sync=() + local packages_in_sync=() + local needed_updates=() + local old_versions=() + +# Find all the PKGBUILDs newer than the last update +# Update newer, otherwise everything + if [ $force ] || [ ! -e ${lastsyncfile} ]; then + $quiet || msg "Forcing upgrade" + pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) + else + pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) + fi + +# Inform how many PKGBUILDS were found and quit immediately if none + $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" + [ ${#pkgbuilds[*]} -eq 1 ] && { + $quiet || msg2 "There's nothing to be done. Phew!" + exit 0 + } + + for _pkgbuild in ${pkgbuilds[@]}; do + +# The repo name is guessed +# You *must* use repo/pkgbase structure + _pkgpath=$(dirname "${_pkgbuild}") + _pkgbase=$(basename "${_pkgpath}") + _pkgrepo=$(basename $(dirname "${_pkgpath}")) + + source ${_pkgbuild} + + for _pkg in ${pkgname[@]}; do +# Fill the list of packages to find + packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) + done + + unset pkgbase pkgname pkgver pkgrel source epoch + done + +# Get repo database contents + packages_in_sync=($(get_db_contents ${_pkgrepo})) + print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync + print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync + +# We've orderer the files! + needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + + $quiet || msg "This packages are available to update" + for _update in ${needed_updates[@]}; do + pkg=$(extract_pkgname $_update) + + $quiet && echo $pkg + $quiet || { + ver=$(extract_fullpkgver $_update) + oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) + + msg2 "$pkg $oldver => $ver" + } + + done + +# lastsync + +} + +## MAIN +commands=() +repos=() +quiet=false +force=false +while getopts 'hqfu' arg; do + case $arg in + h) usage; exit 0 ;; + q) quiet=true ;; + f) force=true ;; + u) commands+=(update);; + esac + + shift $((OPTIND-1)) +done + +# This is the syncfile, stores the last date as content and mtime +lastsyncfile=${ABSROOT}/toru.lastsync + +TMPDIR=$(mktemp -d) + +[[ -z ${TMPDIR} ]] && exit 1 + +${commands[0]} ${@} + +rm -rf ${TMPDIR} + +exit $? diff --git a/src/prtools/prfullpkg b/src/prtools/prfullpkg deleted file mode 100755 index bbb8d73..0000000 --- a/src/prtools/prfullpkg +++ /dev/null @@ -1,398 +0,0 @@ -#!/bin/bash - -source /etc/makepkg.conf -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.conf - -if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors - - error "There's no XDG_CONFIG_HOME var set"; exit 1 - -elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then - - source $XDG_CONFIG_HOME/libretools/libretools.conf - -fi - - -function usage { - - echo "cd to a dir containing a PKGBUILD and run:" - echo "$0 [options]" - printf "This script will check dependencies, build them if possible " - printf "and stage the packages on it's repo." - echo - echo "OPTIONS:" - echo " -h : this message." - echo " -a absdir : set absdir as ABSROOT." - echo " -b build_dir : use a fullpkg build_dir and only build." - echo " -c : check deps only, do not build." - echo " -d build_dir : use this dir to build. Defaults to mktemp." - echo " -n : don't update pacman db." - echo " -m max_level : check deps until this level" - echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" - echo - exit 1 - -} - -function remove_buildorder { # Removes a package from the buildorder -# $1 package name -# $2 buildorder file - - grep -Evw "${1}" ${2} > ${2}2 - mv -f ${2}2 ${2} - -} - -function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD - - basename $(pwd) - -} - -function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel - -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) - - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -function cleanup { # Cleans the build_dir. - - [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. - - - if [ $level -eq 0 ]; then # Only do cleanup on level 0. - msg "Cleaning up ${build_dir}" - rm -rf "$build_dir/*" - fi -} - -function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. - - source PKGBUILD ## Check this level. - - local repo=${repo:-$(guess_repo)} - local pkgbase=${pkgbase:-${pkgname[0]}} - local epoch=${epoch:-0} - local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) - - if is_built "${pkgbase}" "${fullver}"; then - exit 0 # pkg is built and updated - fi - - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first - - if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there - - exit 0 - - else # Copy dir to build_dir - - mkdir ${build_dir}/${pkgbase} - cp -r $(pwd)/* ${build_dir}/${pkgbase} - - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later - fi - - msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level - - declare -i next_level=$level+1 ## Check next deps level. - - deps=$(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u) # All deps in separate line, only once, without version. - - for _dep in ${deps[@]}; do - - local found=false - - if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo - - for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order - - if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then - - pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular deps - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - else # pkgsplit, needs guess - - for _repo in ${REPOS[@]}; do - - if _dir=($(find "$ABSROOT/" -type f \ - -wholename "*/${_repo}/PKGBUILD" -print0 2>/dev/null | \ - "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ - grep -w "$_dep" 2>&1)) ; - - then - - _dir=$(dirname $(echo $_dir | cut -d: -f1)) - plain "guess for $_dep -> $_dir" - - pushd "$_dir" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular dep - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - fi - - if ( ${found} ); then - continue 1 # go to next dep - else - echo "dep_not_found:$_dep" >> $build_dir/log - fi - - done - - unset next_level dir - # unset PKGBUILD variables - unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ - makedepens checkdepends optdepends provides conflicts replaces backup \ - options install changelog source noextract md5sums build check package -} - -function __build () { - pushd ${build_dir} > /dev/null - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first - - while [ ${#build_packages[@]} -ge 1 ]; do - pushd $build_dir/${build_packages[0]} > /dev/null - source PKGBUILD - - msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" - - msg2 "Checking for non free deps" - pkgbuild-check-nonfree || { - if [ $? -eq 15 ]; then # this error means nonfree others means fail. - - echo "nonfree:$(basename $PWD)" >> $build_dir/log - - remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder - - continue # build next package - fi - } - - msg2 "Building $(basename $PWD)" - - $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf - - case $r in - - 0) ## Succesfull build - - plain "The build was succesful." - if source .INFO && [ -n $repo ]; then - - if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used - find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo - fi - - librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log - - msg "Updating pacman db and packages" - sudo pacman -Sy || true - - fi - - echo "built:$(basename $PWD)" >> $build_dir/log - ;; - - *) ## Build failed - error "There were errors while trying to build the package." - echo "failed:$(basename $PWD)" >> $build_dir/log - ;; - esac - - remove_buildorder "${build_packages[0]}" $buildorder || true - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? - popd > /dev/null - done - - pkgs=($(grep "nonfree:" $build_dir/log)) && { - error "Those packages contain nonfree deps:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "built:" $build_dir/log)) && { - msg "Those packages were built and staged:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "failed:" $build_dir/log)) && { - error "Those packages failed to build:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - pkgs=($(grep "unstaged:" $build_dir/log)) && { - error "Those packages couldn't be staged because of missing reponame:" - echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 - } - - popd > /dev/null -} - -function trap_exit { # End inmediately but print a useful message - - error "$@" - warning "Leftover files left on $build_dir" - - exit 1 -} - -# 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 - -ban_file=$XDG_CONFIG_HOME/libretools/ban -force_build="" -level=0 -noupdate='n' -build_only='n' -check_deps_only='n' -max_level=21 - -while getopts 'ha:b:cd:l:nm:r:' arg; do - case $arg in - h) usage ;; - a) ABSROOT="$OPTARG" ;; - b) build_only='y' - build_dir="$OPTARG" - if [ -z ${build_dir} ]; then - usage - fi - if [ ! -r ${build_dir}/BUILDORDER ] ; then - error "${build_dir}/BUILDORDER doesn't exist." - exit 1 - fi;; - c) check_deps_only='y' ;; - d) build_dir="$OPTARG" ;; - l) level=$OPTARG ;; # hidden option to know dep level. - n) noupdate='y';; - m) max_level=$OPTARG ;; - r) FULLBUILDCMD="$OPTARG" ;; - esac -done - -if [ ${build_only} == 'n' ]; then - - [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory" - usage - } - - if [ ! -z "$HOOKPKGBUILDMOD" ]; then - "$HOOKPKGBUILDMOD" - fi - -fi - -if [ $level -eq 0 ]; then - - if [ ! -d ${build_dir} ]; then # in case of custom -d option - mkdir -p ${build_dir} - else - cleanup # files already there can screw find_deps - fi - - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp - - touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder - buildorder=${build_dir}/BUILDORDER - - if [ ${noupdate} = 'n' ]; then - - msg "Updating pacman db and packages" - sudo pacman -Syu --noconfirm || true - - fi - - if [ ${build_only} == 'y' ]; then - - msg "Build Packages" - - __build - - exit 0 - - fi - - msg "Checking dependencies" -fi - -[ $level -ge $max_level ] && exit 20 # Probable circular deps - -find_deps || { - - if [ $? -eq 20 ]; then # Probable circular deps - - if [ $level -eq 0 ]; then # Show error only on level 0 - error "Check for circular deps on $build_dir/BUILDORDER"; - fi - - fi - exit 20 # Pass message 20 -} - -[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 - -if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check - - if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions - - chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" - - else - - rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { - - warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist - - search=$(cat ${ban_file} | tr "\n" "|") - - egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files - - egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder - - mv -f ${buildorder}2 ${buildorder} - - unset search - } - } - fi -fi - -msg "Building packages:" - -__build # Build the packages - -echo -msg2 "Check if your system works fine and librerelease if it does" - -exit 0 diff --git a/src/prtools/prmipsrelease b/src/prtools/prmipsrelease deleted file mode 100755 index 1fbd696..0000000 --- a/src/prtools/prmipsrelease +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# Lic: GPLv3+ -# Author: Nicolas Reynolds -# Local release of mips64el packages + clean ABS sync -# Called by HOOKLOCALRELEASE - -# $1 repo -# $2+ packages - - source /etc/makepkg.conf - source /etc/libretools.conf - source /etc/libretools.d/prtools.conf - - usage() { - echo "$0 repo package1 [ package2 ... packageN ]" - echo - echo " release packages locally on ${PKGDEST}/stage3." - echo " and make a clean ABS sync " - } - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## - get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - } - - repo=$1; shift - repo-add "${PKGDEST}/stage3.db.tar.gz" $@ - -# Get all needed sources - source PKGBUILD - fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-$pkgname} - - msg "Adding packages to [stage3]..." - repo-add $@ - for name in ${pkgname[@]}; do - msg2 "${name} ${fullver}" - repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* - done - -# Copy PKGBUILD and sources - - msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase" - dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase" - mkdir -p ${dest_dir} >/dev/null - rm -rf ${dest_dir}/* # if package existed already there - - eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources. - export CARCH - source=($(. "PKGBUILD"; echo ${source[@]})) - cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1" - for f in ${source[@]}; do - basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g') - if [ -f "$basef" ]; then - cp --remove-destination "$basef" "${dest_dir}" - fi - done - - ( . PKGBUILD - for i in 'changelog' 'install'; do - filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) - for file in $filelist; do - # evaluate any bash variables used - eval file=${file} - if [ -f "$file" ]; then - cp --remove-destination "$file" "${dest_dir}" - fi - done - done - ) -# END add clean abs - -# Commit the changes - - pushd "$dest_dir" >/dev/null - - source "${dest_dir}/PKGBUILD" - epoch=${epoch:-0} - fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-${pkgname[0]}} - - git add "${dest_dir}/." # add using .gitignore - - git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}" - - popd >/dev/null - -# END commit - - exit $? diff --git a/src/prtools/prtools.conf b/src/prtools/prtools.conf deleted file mode 100644 index 5b41216..0000000 --- a/src/prtools/prtools.conf +++ /dev/null @@ -1,4 +0,0 @@ - -# Absroot for libretools-pr -ABSROOT=$WORKDIR/prabs -HOOKLOCALRELEASE="prmipsrelease" \ No newline at end of file diff --git a/src/prtools/prtoru b/src/prtools/prtoru deleted file mode 100644 index 2898b66..0000000 --- a/src/prtools/prtoru +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash -# Queries the ABS -# License: GPL3 - -## TODO -# * Add license text -# * Create symlinks from pkgbase to pkgname[@] for easy package finding -# * Use lastsync to store processed packages - -## GOALS -# * Have a searchable database of PKGBUILD metadata -# * Have an interface for source-only builds -# * Possibility to hook up ABS dirs besides ABSROOT (low priority) -# * Tell updates and non available binary packages (working on this) - -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.conf - -# Stores the lastsync date -lastsync() { - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } - - date +%s > "$lastsyncfile" - touch "$lastsyncfile" -} - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - -# Outputs an ordered package-fullpkgver array -print_package_array() { - echo "$@" | tr " " "\n" | sort -V -u -} - - -# Gets repo.db contents -# $1 repo -get_db_contents() { - [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 - - bsdtar -tf /var/lib/pacman/sync/$1.db | \ - cut -d'/' -f1 | \ - sort -V -u -} - - -extract_pkgname() { - echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" -} - -extract_fullpkgver() { - echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" -} - - -# Updates the database by finding all PKGBUILDS -# Workflow: -# * Find all PKGBUILDs on the ABS repo specified -# * Get all packages already on package repos -# * Compare them -# Args: -update() { -# The PKGBUILDs found - local pkgbuilds=() -# The list of pkgname-fullpkgver - local packages_to_sync=() - local packages_in_sync=() - local needed_updates=() - local old_versions=() - -# Find all the PKGBUILDs newer than the last update -# Update newer, otherwise everything - if [ $force ] || [ ! -e ${lastsyncfile} ]; then - $quiet || msg "Forcing upgrade" - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) - else - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) - fi - -# Inform how many PKGBUILDS were found and quit immediately if none - $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" - [ ${#pkgbuilds[*]} -eq 1 ] && { - $quiet || msg2 "There's nothing to be done. Phew!" - exit 0 - } - - for _pkgbuild in ${pkgbuilds[@]}; do - -# The repo name is guessed -# You *must* use repo/pkgbase structure - _pkgpath=$(dirname "${_pkgbuild}") - _pkgbase=$(basename "${_pkgpath}") - _pkgrepo=$(basename $(dirname "${_pkgpath}")) - - source ${_pkgbuild} - - for _pkg in ${pkgname[@]}; do -# Fill the list of packages to find - packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) - done - - unset pkgbase pkgname pkgver pkgrel source epoch - done - -# Get repo database contents - packages_in_sync=($(get_db_contents ${_pkgrepo})) - print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync - print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync - -# We've orderer the files! - needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - - $quiet || msg "This packages are available to update" - for _update in ${needed_updates[@]}; do - pkg=$(extract_pkgname $_update) - - $quiet && echo $pkg - $quiet || { - ver=$(extract_fullpkgver $_update) - oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) - - msg2 "$pkg $oldver => $ver" - } - - done - -# lastsync - -} - -## MAIN -commands=() -repos=() -quiet=false -force=false -while getopts 'hqfu' arg; do - case $arg in - h) usage; exit 0 ;; - q) quiet=true ;; - f) force=true ;; - u) commands+=(update);; - esac - - shift $((OPTIND-1)) -done - -# This is the syncfile, stores the last date as content and mtime -lastsyncfile=${ABSROOT}/toru.lastsync - -TMPDIR=$(mktemp -d) - -[[ -z ${TMPDIR} ]] && exit 1 - -${commands[0]} ${@} - -rm -rf ${TMPDIR} - -exit $? -- cgit v1.2.2 From 84442a551d28dc504b3b38e1dcfc99dd56c52dea Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 11:10:11 -0500 Subject: mv libretools.conf src/ --- libretools.conf | 122 ---------------------------------------------------- src/libretools.conf | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 122 deletions(-) delete mode 100644 libretools.conf create mode 100644 src/libretools.conf diff --git a/libretools.conf b/libretools.conf deleted file mode 100644 index 8032397..0000000 --- a/libretools.conf +++ /dev/null @@ -1,122 +0,0 @@ -## Blacklist URL -BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt - -# Diff tool (vimdiff, gvimdiff, meld, etc) -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. 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') - -## The directory where the chroots are stored -CHROOTDIR=/home/chroot -# Extra packages to have installed on the chroot (besides base base-devel and sudo) -CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet) - -## The working chroot -## A chroot is useful to build packages isolated from the current system and avoid -## unwanted (as in not in dependencies) automatic library linking -# CHROOT=$SUDO_USER -# CHROOT=root - -## Obtains CacheDir from pacman.conf -CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` - -## Parabola hostname (should be the same used on ssh_config -PARABOLAHOST=parabola - -## Server destination of libre packages -# Don't change unless you know what you're doing and you won't screw -# anything ;) -LIBREDESTDIR=/srv/http/repo/public - -## ABSLibre -ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git - -## Commit Command -## Should be git or hg -## Uncomment only one of those -#COMMITCMD=git -#COMMITCMD=hg - -## Uncomment one of those or make one of your choice -# Normal fullpkg -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 -TORUPATH=/var/lib/libretools/toru - -## Package signing -# Leave commented to disable signing -#SIGEXT=".sig" -#SIGID="0xYOURID" - -# Checks if vars aren't empty - -for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \ - BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ - COMMITCMD DIFFTOOL FULLBUILDCMD; do - - ret=0 - [[ -z ${!VAR} ]] && { - echo "Configure $VAR var in /etc/libretools.conf" - ret=1 - } - [ $ret -ne 0 ] && exit 1 -done - -source /usr/bin/libremessages - -## These are architecture specific files. -## Uncomment them if you installed libretools-mips64el -# source /etc/libretools.d/mips64el.conf - -## Recommended SSH Config follows -# SSH host, it's better if you have it configured on ~/.ssh/config -# with ControlMaster auto (and a shell opened somewhere else) -# -# Example: -# Host * -# Protocol 2 -# ControlMaster auto -# ControlPath /tmp/ssh-%r@%h:%p -# -## Repo server -# Host parabola -# Port 22 -# HostName repo.parabolagnulinux.org -# User parabolavnx -# IdentityFile ~/.ssh/id_rsa -# -## Git server -# Host vparabola -# Port 1863 -# HostName parabolagnulinux.org -# User parabola -# IdentityFile ~/.ssh/id_rsa diff --git a/src/libretools.conf b/src/libretools.conf new file mode 100644 index 0000000..8032397 --- /dev/null +++ b/src/libretools.conf @@ -0,0 +1,122 @@ +## Blacklist URL +BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt + +# Diff tool (vimdiff, gvimdiff, meld, etc) +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. 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') + +## The directory where the chroots are stored +CHROOTDIR=/home/chroot +# Extra packages to have installed on the chroot (besides base base-devel and sudo) +CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet) + +## The working chroot +## A chroot is useful to build packages isolated from the current system and avoid +## unwanted (as in not in dependencies) automatic library linking +# CHROOT=$SUDO_USER +# CHROOT=root + +## Obtains CacheDir from pacman.conf +CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` + +## Parabola hostname (should be the same used on ssh_config +PARABOLAHOST=parabola + +## Server destination of libre packages +# Don't change unless you know what you're doing and you won't screw +# anything ;) +LIBREDESTDIR=/srv/http/repo/public + +## ABSLibre +ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git + +## Commit Command +## Should be git or hg +## Uncomment only one of those +#COMMITCMD=git +#COMMITCMD=hg + +## Uncomment one of those or make one of your choice +# Normal fullpkg +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 +TORUPATH=/var/lib/libretools/toru + +## Package signing +# Leave commented to disable signing +#SIGEXT=".sig" +#SIGID="0xYOURID" + +# Checks if vars aren't empty + +for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \ + BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ + COMMITCMD DIFFTOOL FULLBUILDCMD; do + + ret=0 + [[ -z ${!VAR} ]] && { + echo "Configure $VAR var in /etc/libretools.conf" + ret=1 + } + [ $ret -ne 0 ] && exit 1 +done + +source /usr/bin/libremessages + +## These are architecture specific files. +## Uncomment them if you installed libretools-mips64el +# source /etc/libretools.d/mips64el.conf + +## Recommended SSH Config follows +# SSH host, it's better if you have it configured on ~/.ssh/config +# with ControlMaster auto (and a shell opened somewhere else) +# +# Example: +# Host * +# Protocol 2 +# ControlMaster auto +# ControlPath /tmp/ssh-%r@%h:%p +# +## Repo server +# Host parabola +# Port 22 +# HostName repo.parabolagnulinux.org +# User parabolavnx +# IdentityFile ~/.ssh/id_rsa +# +## Git server +# Host vparabola +# Port 1863 +# HostName parabolagnulinux.org +# User parabola +# IdentityFile ~/.ssh/id_rsa -- cgit v1.2.2 From d308ec64174aeeccd75a14df6b91c1a789fe7e5b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 11:10:34 -0500 Subject: chmod 755 src/mips64el-tools/mips-add --- src/mips64el-tools/mips-add | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/mips64el-tools/mips-add diff --git a/src/mips64el-tools/mips-add b/src/mips64el-tools/mips-add old mode 100644 new mode 100755 -- cgit v1.2.2 From 040111e9d8419456255816600784a496febd57b0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Nov 2012 11:17:49 -0500 Subject: add a Makefile to install everything --- Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..802117a --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +# Configuration +DESTDIR= + +#prefix=/usr/local +prefix=/usr +exec_prefix=$(prefix) +datarootdir=$(prefix)/share + +bindir=$(exec_prefix)/bin +sbindir=$(exec_prefix)/sbin +#sysconfdir=$(prefix)/etc +sysconfdir=/etc +datadir=$(datarootdir) +docdir=$(datarootdir)/doc + +################################################################################ + +pseudo-packages=abslibre-tools chroot-tools fullpkg mips64el-tools pr-tools toru +packages=libretools libretools-pr libretools-mips64el + +libretools=abslibre-tools chroot-tools fullpkg toru misc +libretools-pr=pr-tools +libretools-mips64el=mips64el-tools + +################################################################################ + +all: PHONY libretools +install: PHONY install-libretools install-doc + +install-doc: $(patsubst doc/%,$(DESTDIR)$(docdir)/libretools/%,$(wildcard doc/*)) + +$(DESTDIR)$(docdir)/libretools/%: doc/% + install -Dm644 '$<' '$@' + +$(DESTDIR)$(sysconfdir)/libretools.conf: src/libretools.conf + install -Dm644 '$<' '$@' + +$(foreach pkg,$(pseudo-packages) ., \ +$(eval \ +$(DESTDIR)$(bindir)/%: src/$(pkg)/%; \ + install -Dm755 '$$<' '$$@' \ +) \ +$(eval \ +$(DESTDIR)$(sysconfdir)/libretools.d/%: src/$(pkg)/%; \ + install -Dm644 '$$<' '$$@' \ +)) + +################################################################################ + +progs = $(shell find src/$1 -maxdepth 1 -type f -executable -printf '%f\n') +confs = $(shell find src/$1 -maxdepth 1 -type f -not -executable -printf '%f\n') +files = $(addprefix $(DESTDIR)$2/,$(call progs,$1)) \ + $(addprefix $(DESTDIR)$3/,$(call confs,$1)) + +.SECONDEXPANSION: +$(packages): %: PHONY $$($$*) +$(addprefix install-,$(packages)): install-%: PHONY $$(addprefix install-,$$($$*)) + +$(pseudo-packages) misc: %: PHONY +$(addprefix install-,$(pseudo-packages)): install-%: PHONY $$(call files,$$*,$(bindir),$(sysconfdir)/libretools.d) +# special cases +install-misc: PHONY $(call files,.,$(bindir),$(sysconfdir)) + +################################################################################ + +FORCE: PHONY +PHONY: +.PHONY: FORCE PHONY -- cgit v1.2.2 From 6c14fad1750b4342b5b283e0851c00e3c074a15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 7 Nov 2012 15:04:29 -0300 Subject: The dirtiest way of putting chcleanup to work on the chroot --- librechroot | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/librechroot b/librechroot index c8e02b0..158828b 100755 --- a/librechroot +++ b/librechroot @@ -46,7 +46,12 @@ function usage { function clean_chroot { # Clean packages with pacman cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" - mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" + libremessages="$(grep "libremessages" /etc/libretools.conf | cut -d" " -f2)" + + cat /etc/libretools.conf ${libremessages} | sed "/libremessages/d" > "${CHROOTDIR}/${CHROOTNAME}/etc/libretools.conf" + + + mkarchroot -r "sh -c 'cd /build; /clean'" "${CHROOTDIR}/${CHROOTNAME}" } function clean_repo { -- cgit v1.2.2 From de192642ea009e9b8e16f54209575536538869e2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 16:29:07 -0500 Subject: touch up libremessages --- src/libremessages | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libremessages b/src/libremessages index 68badb8..756e19a 100755 --- a/src/libremessages +++ b/src/libremessages @@ -1,3 +1,4 @@ +#!/bin/bash # Copyright (c) 2006-2010 Pacman Development Team # Copyright (c) 2002-2006 by Judd Vinet # Copyright (c) 2005 by Aurelien Foret @@ -105,3 +106,10 @@ in_array() { return 1 # Not Found } + +if [[ "${0##*/}" = libremessages ]]; then + _libremessages_cmd=$1 + shift + "$_libremessages_cmd" "$@" + unset _libremessages_cmd +fi -- cgit v1.2.2 From a7158a6772f830ae8b40430e3c974356384eb3a4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 16:43:36 -0500 Subject: libretools.conf: clean up .ssh/config recomendation --- src/libretools.conf | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index 8032397..d310776 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -33,6 +33,13 @@ CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` ## Parabola hostname (should be the same used on ssh_config PARABOLAHOST=parabola +## Assumes something similar in your .ssh/config: + +## Repo server +# Host parabola +# Port 1863 +# HostName repo.parabolagnulinux.org +# User repo ## Server destination of libre packages # Don't change unless you know what you're doing and you won't screw @@ -96,27 +103,3 @@ source /usr/bin/libremessages ## These are architecture specific files. ## Uncomment them if you installed libretools-mips64el # source /etc/libretools.d/mips64el.conf - -## Recommended SSH Config follows -# SSH host, it's better if you have it configured on ~/.ssh/config -# with ControlMaster auto (and a shell opened somewhere else) -# -# Example: -# Host * -# Protocol 2 -# ControlMaster auto -# ControlPath /tmp/ssh-%r@%h:%p -# -## Repo server -# Host parabola -# Port 22 -# HostName repo.parabolagnulinux.org -# User parabolavnx -# IdentityFile ~/.ssh/id_rsa -# -## Git server -# Host vparabola -# Port 1863 -# HostName parabolagnulinux.org -# User parabola -# IdentityFile ~/.ssh/id_rsa -- cgit v1.2.2 From 53da04831f410d86412361564b1018e9c72e4b66 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 16:54:55 -0500 Subject: libretools.conf: improve the "code" section at the end * verify that XDG_CONFIG_HOME is set; if not, then set it * warn about all unconfigured variables, not just the first one * source the user-specific libretools.conf, if it exists --- src/libretools.conf | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index d310776..cc8a8f1 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -84,22 +84,36 @@ TORUPATH=/var/lib/libretools/toru #SIGEXT=".sig" #SIGID="0xYOURID" -# Checks if vars aren't empty - +################################################################################ +# This probably shouldn't be in a .conf file... # +################################################################################ + +if [[ -z $XDG_CONFIG_HOME ]]; then + if [[ -n $SUDO_USER ]]; then + SUDO_HOME="$(eval echo ~$SUDO_USER)" + export XDG_CONFIG_HOME="${SUDO_HOME}/.config" + unset SUDO_HOME + else + export XDG_CONFIG_HOME="${HOME}/.config" + fi +fi +if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then + . "$XDG_CONFIG_HOME/libretools/libretools.conf" +fi + +ret=0 for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \ - BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ - COMMITCMD DIFFTOOL FULLBUILDCMD; do - - ret=0 - [[ -z ${!VAR} ]] && { - echo "Configure $VAR var in /etc/libretools.conf" - ret=1 - } - [ $ret -ne 0 ] && exit 1 -done + BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ + COMMITCMD DIFFTOOL FULLBUILDCMD; do -source /usr/bin/libremessages + if [[ -z ${!VAR} ]]; then + echo "Configure $VAR var in /etc/libretools.conf" + ret=1 + fi +done +if [[ $ret != 0 ]]; then + exit 1 +fi +unset ret -## These are architecture specific files. -## Uncomment them if you installed libretools-mips64el -# source /etc/libretools.d/mips64el.conf +. /usr/bin/libremessages -- cgit v1.2.2 From 803ec5f8b5f1450d0ecd6f52463bd3882f03c05c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 16:57:01 -0500 Subject: libretools.conf: remove CACHEDIR (grep confirms it is unused) --- src/libretools.conf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index cc8a8f1..01c93e6 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -28,9 +28,6 @@ CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet) # CHROOT=$SUDO_USER # CHROOT=root -## Obtains CacheDir from pacman.conf -CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` - ## Parabola hostname (should be the same used on ssh_config PARABOLAHOST=parabola ## Assumes something similar in your .ssh/config: @@ -102,7 +99,7 @@ if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then fi ret=0 -for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \ +for VAR in CHROOTDIR CHROOT PARABOLAHOST LIBREDESTDIR \ BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ COMMITCMD DIFFTOOL FULLBUILDCMD; do -- cgit v1.2.2 From a5f4fb2d351c2972daa6bffad4e74e0a49f5760b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:04:51 -0500 Subject: libretools.conf: add [prc] and [java] to REPOS --- src/libretools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretools.conf b/src/libretools.conf index 01c93e6..e62dd90 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -12,7 +12,7 @@ WORKDIR=/home/$USER/packages # inverted order of precedence. Put testing repos first so fullpkg find new # 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') +REPOS=('core' 'libre' 'extra' 'community' 'libre-testing' 'social' 'sugar' 'pcr' 'java') # The architectures ARCHES=('i686' 'x86_64' 'mips64el' 'any') -- cgit v1.2.2 From f607063e49984bfd5286001699ff101f0bf3663b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:05:37 -0500 Subject: libretools.conf: autodetect DIFFTOOL --- src/libretools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretools.conf b/src/libretools.conf index e62dd90..75d47fe 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -2,7 +2,7 @@ BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt # Diff tool (vimdiff, gvimdiff, meld, etc) -DIFFTOOL=vimdiff +DIFFTOOL=`which vimdiff gvimdiff meld colordiff 2>/dev/null|sed 's/\s.*//'` # The dir where you work on WORKDIR=/home/$USER/packages -- cgit v1.2.2 From 96ae7c177a39d09e5c1cd0116d7199259a20f239 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:06:09 -0500 Subject: libretools.conf: add a shebang to help editors out --- src/libretools.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libretools.conf b/src/libretools.conf index 75d47fe..f3e327a 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -1,3 +1,5 @@ +#!/bin/bash + ## Blacklist URL BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt -- cgit v1.2.2 From 7d455f70d317d36693e2d3d194b2bed299ad194e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:06:54 -0500 Subject: libretools.conf: set COMMITCMD=git by default --- src/libretools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretools.conf b/src/libretools.conf index f3e327a..4a69998 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -51,7 +51,7 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git ## Commit Command ## Should be git or hg ## Uncomment only one of those -#COMMITCMD=git +COMMITCMD=git #COMMITCMD=hg ## Uncomment one of those or make one of your choice -- cgit v1.2.2 From 027db84b180a16a17a9414a88e7a35a7669983fa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:10:23 -0500 Subject: libretools.conf: clean up CHROOT* settings: * CHROOTEXTRAPKG: add libretools, remove tokyocabinet (dep of libretools) * CHROOT=default new devtools does NOT like 'root' --- src/libretools.conf | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index 4a69998..70d2eca 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -21,14 +21,11 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any') ## The directory where the chroots are stored CHROOTDIR=/home/chroot -# Extra packages to have installed on the chroot (besides base base-devel and sudo) -CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet) - -## The working chroot -## A chroot is useful to build packages isolated from the current system and avoid -## unwanted (as in not in dependencies) automatic library linking -# CHROOT=$SUDO_USER -# CHROOT=root +## Extra packages to have installed on the chroot (besides base base-devel and sudo) +CHROOTEXTRAPKG=(distcc ccache tsocks libretools) +## The meaning of this changes based on the version of libretools+devtools +## do NOT set it to 'root' +CHROOT=default ## Parabola hostname (should be the same used on ssh_config PARABOLAHOST=parabola -- cgit v1.2.2 From 487602793c43a5858b734fde4bbb8d0fdb80e96b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:18:14 -0500 Subject: libretools.conf: organize into sections --- src/libretools.conf | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index 70d2eca..631ca89 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -1,24 +1,33 @@ #!/bin/bash +################################################################################ +# misc # +################################################################################ + ## Blacklist URL +## Used by `pkgbuild-check-nonfree` BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt -# Diff tool (vimdiff, gvimdiff, meld, etc) +## Diff tool (vimdiff, gvimdiff, meld, etc) +## Used by `aur`, `diff-unfree` DIFFTOOL=`which vimdiff gvimdiff meld colordiff 2>/dev/null|sed 's/\s.*//'` -# The dir where you work on -WORKDIR=/home/$USER/packages -# The repos you'll be packaging for -# +## The repos you'll be packaging for +## Used by `toru`, `createworkdir`, `prfullpkg` # 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. 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' 'pcr' 'java') -# The architectures +## The architectures +## Used by `librestage` ARCHES=('i686' 'x86_64' 'mips64el' 'any') +################################################################################ +# chroot # +################################################################################ + ## The directory where the chroots are stored CHROOTDIR=/home/chroot ## Extra packages to have installed on the chroot (besides base base-devel and sudo) @@ -27,7 +36,19 @@ CHROOTEXTRAPKG=(distcc ccache tsocks libretools) ## do NOT set it to 'root' CHROOT=default -## Parabola hostname (should be the same used on ssh_config +################################################################################ +# abslibre # +################################################################################ + +# The dir where you work on +WORKDIR=/home/$USER/packages + +## Package signing +# Leave commented to disable signing +#SIGEXT=".sig" +#SIGID="0xYOURID" + +## Parabola hostname PARABOLAHOST=parabola ## Assumes something similar in your .ssh/config: @@ -51,6 +72,10 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git COMMITCMD=git #COMMITCMD=hg +################################################################################ +# fullpkg # +################################################################################ + ## Uncomment one of those or make one of your choice # Normal fullpkg FULLBUILDCMD="sudo libremakepkg -cuN" @@ -71,15 +96,13 @@ HOOKPRERELEASE="ssh -fN parabola" # succesfully # HOOKLOCALRELEASE="" -## Toru +################################################################################ +# toru # +################################################################################ + # Section for toru's vars TORUPATH=/var/lib/libretools/toru -## Package signing -# Leave commented to disable signing -#SIGEXT=".sig" -#SIGID="0xYOURID" - ################################################################################ # This probably shouldn't be in a .conf file... # ################################################################################ -- cgit v1.2.2 From 16e41597e98333f6383a3cb9aa6e9371f64522bf Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 17:32:40 -0500 Subject: chroot-tools: clean up, make play nice with new devtools * buildenv: delete; this is done by `mkarchroot` * librechroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY * libremakepkg: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - add `-l` option to set the CHROOTCOPY - pass options to `makechrootpkg` and `makepkg` the way `-h` always said it did * libremkchroot: - adopt `archbuild`'s concept of CHROOT and CHROOTCOPY - remove `-c` option to set the pacman cache - remove `-f` option to force overwrite --- src/chroot-tools/buildenv | 28 ------ src/chroot-tools/librechroot | 160 ++++++++++++++++++--------------- src/chroot-tools/libremakepkg | 195 ++++++++++++++++++++++------------------- src/chroot-tools/libremkchroot | 56 ++++++------ 4 files changed, 222 insertions(+), 217 deletions(-) delete mode 100755 src/chroot-tools/buildenv diff --git a/src/chroot-tools/buildenv b/src/chroot-tools/buildenv deleted file mode 100755 index 84a1fc2..0000000 --- a/src/chroot-tools/buildenv +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -trap "umount_all" 0 ERR TERM KILL - -user=${SUDO_USER:-${1}} - -umount_all() { - for mp in home/pkgdest home/srcdest home/${user}; do - msg "Umounting /$mp" - umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount" - done -} - -source /etc/libretools.conf - -for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do - msg "Binding /$mp" - mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1 -done - -for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do - msg "Copying config /$etc" - cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1 -done - -$(dirname $0)/librechroot $CHROOT - -exit $? diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index c8e02b0..d53448a 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -4,6 +4,7 @@ # Copyright 2010 Nicolás Reynolds # Copyright 2011 Joshua Haase +# Copyright 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -22,87 +23,100 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -function usage { - - echo "" - echo "Usage: $0 [options] [chrootname]" - echo "Use it as root." - echo "" - echo "Default chroot name: $CHROOT" - echo "Default chrootdir: $CHROOTDIR" - echo "" - echo "OPTIONS:" - echo "" - echo " -c : clean the chroot using pacman" - echo " only 'base', 'base-devel' and 'sudo' on chroot" - echo " -d : use instead of default" - echo " -r : clean /repo on the chroot" - echo " -h : this message" - echo " -u : update the chroot" - echo "" +. /etc/libretools.conf -} +cmd=${0##*/} -function clean_chroot { # Clean packages with pacman - cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" +clean_chroot() { # Clean packages with pacman + msg "Cleaning chroot with pacman: ${chroot_path}" - mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" -} + cp -a "$(dirname $0)/chcleanup" "${chroot_path}/clean" + mkarchroot -r "cd /build; /clean" "${chroot_path}" -function clean_repo { - msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}" - if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then - find "${CHROOTDIR}/${CHROOTNAME}/repo/" -mindepth 1 -delete - else - mkdir -p "${CHROOTDIR}/${CHROOTNAME}/repo" - fi - bsdtar -czf "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db" + #mkarchroot "${chroot_path}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" } -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -CLEANCHROOT='false' -UPDATE='false' -CLEANREPO='false' -CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}" - -while getopts 'hrcud:' arg; do - case $arg in - h) usage; exit 0 ;; - c) CLEANCHROOT='true' ;; - u) UPDATE='true' ;; - r) CLEANREPO='true' ;; - d) CHROOTDIR="$(readlink -e $OPTARG)" ;; - esac -done - -[[ "$UID" != "0" ]] && { - error "This script must be run as root." - exit 1 + +clean_repo() { + msg "Cleaning repo for chroot: ${chroot_path}" + + if [ -d "${chroot_path}/repo" ]; then + find "${chroot_path}/repo/" -mindepth 1 -delete + else + mkdir -p "${chroot_path}/repo" + fi + bsdtar -czf "${chroot_path}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${chroot_path}/repo/repo.db" } -shift $(($OPTIND - 1)) +update() { + msg "Updating chroot: ${chroot_path}" + mkarchroot -u "${chroot_path}" +} -if [ $# -eq 1 ]; then - CHROOTNAME="$1" -fi +enter() { + msg "Entering chroot: ${chroot_path}" + mkarchroot -r "bash" "${chroot_path}" +} -if "$CLEANREPO"; then - clean_repo -fi +usage() { + echo "Usage: $cmd [OPTIONS] [CHROOT]" + echo 'Interacts with a chroot.' + echo '' + echo "The default CHROOT is \`${CHROOT}'." + echo '' + echo 'Options:' + echo ' Settings:' + echo " -d Use this dir instead of \`${CHROOTDIR}'" + echo ' -l Use this as the chroot copy instead of basing it' + echo ' on the username' + echo ' Modes:' + echo ' -h Show this message' + echo ' -c Clean the chroot using pacman' + echo ' -r Clean /repo in the chroot' + echo ' -u Update the chroot' +} -if "$CLEANCHROOT"; then - clean_chroot -elif "$UPDATE"; then - msg "Updating chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -u "${CHROOTDIR}/${CHROOTNAME}" -else - msg "Entering chroot: ${CHROOTDIR}/${CHROOTNAME}" - mkarchroot -r "bash" "${CHROOTDIR}/${CHROOTNAME}" -fi +main() { + # The logic for setting CHROOTCOPY is mirred from makechrootpkg + CHROOTCOPY=$USER + [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER + [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy + + local mode=enter + while getopts 'hrcud:l:' arg; do + case $arg in + d) CHROOTDIR=$OPTARG;; + l) CHROOTCOPY=$OPTARG;; + + c) mode=clean_chroot;; + r) mode=clean_repo;; + u) mode=update;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + case $# in + 0) :;; + 1) CHROOT="$1";; + *) usage; exit 1;; + esac + + # not local + chroot_path="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + + if (( EUID )); then + error "This script must be run as root." + exit 1 + fi + + case "$mode" in + clean_chroot) clean_chroot; exit $?;; + clean_repo) clean_repo; exit $?;; + update) update; exit $?;; + enter) enter; exit $?;; + esac +} -exit 0 +main "$@" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index f7924f6..69e8998 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -1,6 +1,10 @@ #!/bin/bash +# libremakepkg +# analogous to devtools' archbuild + # Copyright 2010 - 2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández +# Copyright 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -19,108 +23,117 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . +. /etc/libretools.conf -# set -x # uncomment for debug - -function copy_log { # copy logs if they exist - - find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; - +## +# copy logs if they exist +## +copy_log() { + find "${chroot_path}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; } - -function trap_exit { # End inmediately but print a useful message - - copy_log - error "$@" - exit 1 - +## +# End inmediately but print a useful message +## +trap_exit() { + copy_log + error "$@" + exit 1 } -# Trap signals from makepkg -set -E -trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT -trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR - -source /etc/libretools.conf - -CLEANFIRST="false" -UPDATEFIRST="false" -CHECKNONFREE="true" -LIBRECHROOT_ARGS="" -MAKEPKG_ARGS="" - -function usage { - - echo '' +usage() { echo 'cd to a dir containing a PKGBUILD and run:' echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' - echo 'This script will build your package on a chroot.' + echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' + echo ' -h Show this message' echo '' - echo ' -h : show this message.' - echo ' -c : clean the chroot before building.' - echo ' -u : update the chroot before building.' - echo ' -d : use this dir instead of "$CHROOTDIR"' - echo ' -n : use this dir instead of "$CHROOT".' - echo ' -N : do not check freedom issues' # As fullpkg-check will do that before + echo ' -c Clean the chroot before building' + echo ' -u Update the chroot before building' + echo ' -N Do not check freedom issues (for fullpkg)' echo '' - exit 1 + echo " -d Use this dir instead of \`$CHROOTDIR'" + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' +} +main() { + # The logic for setting CHROOTCOPY is mirred from makechrootpkg + CHROOTCOPY=$USER + [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER + [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy + + CLEANFIRST=false + UPDATEFIRST=false + CHECKNONFREE=true + + makechrootpkg_args=() + + while getopts 'hcuNd:n:l:' arg ; do + case "${arg}" in + c) CLEANFIRST=true;; + u) UPDATEFIRST=true;; + N) CHECKNONFREE=false;; + + d) CHROOTDIR=$OPTARG;; + n) CHROOT=$OPTARG;; + l) CHROOTCOPY=$OPTARG;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + # Pass all arguments after -- right to makechrootpkg + makechrootpkg_args+=("$@") + + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + if [[ ! -e PKGBUILD ]]; then + error "This isn't a build directory" + exit 1 + fi + + # OK, we're starting now ############################################### + + # Trap signals from makepkg + set -E + trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT + trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT + trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR + + if $CHECKNONFREE; then + msg "Checking PKGBUILD for non-free issues" + if ! pkgbuild-check-nonfree; then + if [[ $? -eq 15 ]]; then + # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi + fi + + if $CLEANFIRST; then + librechroot -c -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" + fi + + if $UPDATEFIRST; then + librechroot -u -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" + fi + + unset CLEANFIRST UPDATEFIRST librechroot_args + + makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/${CHROOT}" -l "$CHROOTCOPY" + ev=$? # exit value + copy_log + exit $ev } -while getopts 'hcud:n:N' arg ; do - case "${arg}" in - h) usage ;; - c) CLEANFIRST="true" ;; - u) UPDATEFIRST="true" ;; - d) CHROOTDIR="$OPTARG" - LIBRECHROOT_ARGS='-d "$OPTARG"' ;; - n) CHROOT="$OPTARG" ;; - N) CHECKNONFREE="false" ;; - esac -done - -# Pass all arguments after -- right to makechrootpkg -MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}" - -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi - -if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory"; usage -fi - -msg "Checking PKGBUILD for non-free issues" -if "$CHECKNONFREE"; then - if ! pkgbuild-check-nonfree; then - - if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - warning "PKGBUILD couldn't be check aganist non-free issues" - fi - fi -fi - -if "$CLEANFIRST"; then - librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -if "$UPDATEFIRST"; then - librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT" -fi - -unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS - -makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS -ev="$?" # exit value - -copy_log - -exit $ev +main "$@" diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index b576209..48b255a 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -21,44 +21,50 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf - -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi +. /etc/libretools.conf cmd=${0##*/} -function usage { - echo "Usage: $cmd [OPTIONS]" + +usage() { + echo "Usage: $cmd [OPTIONS] [CHROOT]" echo 'This script will create a chroot to build packages in.' echo "Use \`librechroot' to interact with the chroot after it is created." echo '' + echo "The default CHROOT is \`${CHROOT}'." + echo '' echo 'Options:' echo ' -h Show this message' echo '' - echo ' -f Force overwrite of files in the working-dir' - echo '' echo ' -d Use this dir instead of "$CHROOTDIR".' - echo " -c Location of pacman cache. Default: \`/var/cache/pacman/pkg'." echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } -mkchroot_args=(); -while getopts 'hfd:c:C:M:' arg; do - case "$arg" in - h) usage; exit 0 ;; - f) mkchroot_args+=("-$arg");; - c|C|M) mkchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG ;; - ?) usage; exit 1 ;; +main() { + mkarchroot_args=(); + while getopts 'hfd:C:M:' arg; do + case "$arg" in + C|M) mkarchroot_args+=("-$arg" "$OPTARG");; + d) CHROOTDIR=$OPTARG;; + + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + case $# in + 0) :;; + 1) CHROOT="$1";; + *) usage; exit 1;; esac -done -if (( EUID )); then - error "This script must be run as root" - exit 1 -fi + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + mkdir -p "${CHROOTDIR}/${CHROOT}" + xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" < /etc/libretools.d/cleansystem +} -mkdir -p "${CHROOTDIR}" -xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem +main "$@" -- cgit v1.2.2 From 749e8295844160ba96f0a67cab1a0799a5a81a24 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 18:54:52 -0500 Subject: libremakepkg: touch up brackets --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 69e8998..a146627 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -130,7 +130,7 @@ main() { unset CLEANFIRST UPDATEFIRST librechroot_args - makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/${CHROOT}" -l "$CHROOTCOPY" + makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/$CHROOT" -l "$CHROOTCOPY" ev=$? # exit value copy_log exit $ev -- cgit v1.2.2 From 8398652c850196d05e6ad9120d93993bebd6e918 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 18:55:23 -0500 Subject: libremkchroot: don't use cleansystem --- src/chroot-tools/libremkchroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 48b255a..cc5b431 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -64,7 +64,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" < /etc/libretools.d/cleansystem + mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" -- cgit v1.2.2 From e5c5ec7c6bf8d0460b870b1dacc5c928326fb81b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 18:56:53 -0500 Subject: librechroot: learn how to sync copies with root --- src/chroot-tools/librechroot | 119 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 101 insertions(+), 18 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index d53448a..1c9700c 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -27,35 +27,107 @@ cmd=${0##*/} -clean_chroot() { # Clean packages with pacman - msg "Cleaning chroot with pacman: ${chroot_path}" +lock_open_write() { + local fd=$1 + local path=$2 + local msg=$3 + + # Only reopen the FD if it wasn't handed to us + if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then + exec $fd>"${path}.lock" + fi + + if ! flock -n $fd; then + stat_busy "$msg" + flock $fd + stat_done + fi +} + +lock_open_read() { + local fd=$1 + local path=$2 + local msg=$3 + + # Only reopen the FD if it wasn't handed to us + if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then + exec $fd>"${path}.lock" + fi - cp -a "$(dirname $0)/chcleanup" "${chroot_path}/clean" - mkarchroot -r "cd /build; /clean" "${chroot_path}" + if ! flock -sn $fd; then + stat_busy "$msg" + flock -s $fd + stat_done + fi +} - #mkarchroot "${chroot_path}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" +lock_close() { + local fd=$1 + exec $fd>&- +} + +clean_pacman() { + msg "Cleaning chroot with pacman: ${copydir}" + + cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" + mkarchroot -r "cd /build; /clean" "${copydir}" + + #mkarchroot "${copydir}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" } clean_repo() { - msg "Cleaning repo for chroot: ${chroot_path}" + msg "Cleaning repo for chroot: ${copydir}" + + if [ -d "${copydir}/repo" ]; then + find "${copydir}/repo/" -mindepth 1 -delete + else + mkdir -p "${copydir}/repo" + fi + bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" +} + +## +# This function is almost verbatim from makechrootpkg +## +sync() { + if [[ $CHROOTCOPY = root ]]; then + error "Cannot sync the root copy with itself" + exit 1 + fi + + # Note that '9' is the same FD number as in mkarchroot + lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" + lock_open_read 8 "$rootdir" "Locking clean chroot" - if [ -d "${chroot_path}/repo" ]; then - find "${chroot_path}/repo/" -mindepth 1 -delete + stat_busy 'Creating clean working copy' + local use_rsync=false + if type -P btrfs >/dev/null; then + [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null + btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || + use_rsync=true else - mkdir -p "${chroot_path}/repo" + use_rsync=true fi - bsdtar -czf "${chroot_path}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${chroot_path}/repo/repo.db" + + if $use_rsync; then + mkdir -p "$copydir" + rsync -a --delete -q -W -x "$CHROOTDIR/$CHROOT/root/" "$copydir" + fi + stat_done + + lock_close 8 + lock_close 9 } update() { - msg "Updating chroot: ${chroot_path}" - mkarchroot -u "${chroot_path}" + msg "Updating chroot: ${copydir}" + mkarchroot -u "${copydir}" } enter() { - msg "Entering chroot: ${chroot_path}" - mkarchroot -r "bash" "${chroot_path}" + msg "Entering chroot: ${copydir}" + mkarchroot -r "bash" "${copydir}" } usage() { @@ -72,6 +144,7 @@ usage() { echo ' Modes:' echo ' -h Show this message' echo ' -c Clean the chroot using pacman' + echo " -C Clean the chroot by syncing it with 'root' copy" echo ' -r Clean /repo in the chroot' echo ' -u Update the chroot' } @@ -88,7 +161,8 @@ main() { d) CHROOTDIR=$OPTARG;; l) CHROOTCOPY=$OPTARG;; - c) mode=clean_chroot;; + c) mode=clean_pacman;; + C) mode=sync;; r) mode=clean_repo;; u) mode=update;; @@ -104,15 +178,24 @@ main() { esac # not local - chroot_path="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + rootdir="${CHROOTDIR}/${CHROOT}/root" + copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" if (( EUID )); then error "This script must be run as root." exit 1 fi + if [[ ! -d $rootdir ]]; then + libremkchroot -d "$CHROOTDIR" "$CHROOT" + fi + + if [[ ! -d $copydir ]] && [[ $mode != sync ]]; then + sync + fi + case "$mode" in - clean_chroot) clean_chroot; exit $?;; + clean_pacman) clean_pacman; exit $?;; clean_repo) clean_repo; exit $?;; update) update; exit $?;; enter) enter; exit $?;; -- cgit v1.2.2 From ec88851b92ead25bfdd1e29046c95e7dd4508f3f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 21:45:39 -0500 Subject: I'm embarrassed; I commited non-working file lock code --- src/chroot-tools/librechroot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 1c9700c..2c952cc 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -34,7 +34,7 @@ lock_open_write() { # Only reopen the FD if it wasn't handed to us if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - exec $fd>"${path}.lock" + eval "exec $fd>${path}.lock" fi if ! flock -n $fd; then @@ -51,7 +51,7 @@ lock_open_read() { # Only reopen the FD if it wasn't handed to us if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - exec $fd>"${path}.lock" + eval "exec $fd>${path}.lock" fi if ! flock -sn $fd; then @@ -63,7 +63,7 @@ lock_open_read() { lock_close() { local fd=$1 - exec $fd>&- + eval "exec $fd>&-" } clean_pacman() { -- cgit v1.2.2 From 80125fc674b087b42791d2bd48a74bfa7edb2fe0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 23:36:28 -0500 Subject: librechroot: fix a bug in clean_pacman --- src/chroot-tools/librechroot | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 2c952cc..07360d7 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -70,6 +70,7 @@ clean_pacman() { msg "Cleaning chroot with pacman: ${copydir}" cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" + mkdir -p "$copydir/build" mkarchroot -r "cd /build; /clean" "${copydir}" #mkarchroot "${copydir}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" -- cgit v1.2.2 From e17b270bbfa29160beb34266533f5b2e2120041f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 12 Nov 2012 23:37:29 -0500 Subject: librechroot: keep a lock on the CHROOTCOPY the whole time --- src/chroot-tools/librechroot | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 07360d7..a5c5728 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -97,8 +97,6 @@ sync() { exit 1 fi - # Note that '9' is the same FD number as in mkarchroot - lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" lock_open_read 8 "$rootdir" "Locking clean chroot" stat_busy 'Creating clean working copy' @@ -118,7 +116,6 @@ sync() { stat_done lock_close 8 - lock_close 9 } update() { @@ -187,6 +184,10 @@ main() { exit 1 fi + # Keep this lock as long as we are running + # Note that '9' is the same FD number as in mkarchroot + lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" + if [[ ! -d $rootdir ]]; then libremkchroot -d "$CHROOTDIR" "$CHROOT" fi -- cgit v1.2.2 From a7d0da3e7fd7009c28e09f73c32f0a355819f2e6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:07:15 -0500 Subject: libremakepkg: fix copy_log --- src/chroot-tools/libremakepkg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index a146627..3fa2f3d 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -29,7 +29,7 @@ # copy logs if they exist ## copy_log() { - find "${chroot_path}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; + find "${copydir}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; } ## @@ -89,6 +89,10 @@ main() { # Pass all arguments after -- right to makechrootpkg makechrootpkg_args+=("$@") + # not local + rootdir="${CHROOTDIR}/${CHROOT}/root" + copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + if (( EUID )); then error "This script must be run as root" exit 1 -- cgit v1.2.2 From c611090157e9c7d04e6f411c0c5f9ca5834835fd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:43:41 -0500 Subject: pkgbuild-check-nonfree: fix a few errors, clean up This includes the notorious command-not-found error triggered in libremakepkg --- src/pkgbuild-check-nonfree | 139 +++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 80 deletions(-) diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index df0ff36..fba4b7b 100755 --- a/src/pkgbuild-check-nonfree +++ b/src/pkgbuild-check-nonfree @@ -1,6 +1,7 @@ #!/bin/bash # pkgbuild-check-nonfree # Copyright 2010 Joshua Ismael Haase Hernández, Joseph Graham +# Copyright 2012 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -19,15 +20,20 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -# function log_end { +. /etc/libretools.conf + +cmd=${0##*/} +ev=0 + +# log_end() { # kill "$teepid" # rm "$logpipe" # } -# function log { -# LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log" +# log() { +# local LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log" # # ensure overridden package variables survive tee with split packages -# logpipe="$(mktemp -u "$startdir/logpipe.XXXXXXXX")" +# logpipe="$(mktemp)" # mkfifo "$logpipe" # tee "$LOG" < "$logpipe" & # teepid=$! @@ -35,18 +41,15 @@ # } -function unset_pkgbuild { - +unset_pkgbuild() { unset 'pkgbase' 'pkgname' 'pkgver' 'pkgrel' 'epoch' 'pkgdesc' \ 'arch' 'url' 'license' 'groups' 'optdepends' 'provides' \ 'conflicts' 'replaces' 'backup' 'options' 'install' \ 'changelog' 'source' 'noextract' 'md5sums' 'build' \ 'check' 'package' 'depends' 'makedepends' 'checkdepends' - } -function assert_pkgbuild { - +assert_pkgbuild() { if [ -e "$1" ]; then source "$1" @@ -60,16 +63,15 @@ function assert_pkgbuild { return 1 } -function check_replacement { - +check_replacement() { [ $2 ] || return 0 # Free (not found) local needle=$1; shift local item local rep for line in $@; do - item="$(echo "$line" | cut -d':' -f1)" - rep="$(echo "$line" | cut -s -d':' -f2)" + local item="$(echo "$line" | cut -d':' -f1)" + local rep="$(echo "$line" | cut -s -d':' -f2)" if [ "$item" == "$needle" ]; then if [ -z "$rep" ]; then @@ -84,8 +86,11 @@ function check_replacement { return 0 # Free (not found) } -function get_blacklist { # Download the blacklist. - +## +# Download the blacklist. +## +get_blacklist() { + mkdir -p "$XDG_CONFIG_HOME/libretools" pushd "$XDG_CONFIG_HOME/libretools" >/dev/null msg "Downloading the blacklist of proprietary software packages." @@ -103,103 +108,77 @@ function get_blacklist { # Download the blacklist. popd > /dev/null } -function check_deps { # Check wheter a package depends on non-free - +## +# Check wheter a package depends on non-free +## +check_deps() { unset_pkgbuild - if ! assert_pkgbuild "$1"; then - return 1 # not PKGBUILD + exit 1 # not PKGBUILD fi msg2 "${pkgbase:-${pkgname[0]}} $pkgver $pkgrel ${epoch:-""}" # > "$logpipe" - for pkg in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ${checkdepends[@]}; do + for pkg in "${pkgname[@]}" "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do - lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_")) + local lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_")) - rep="$(check_replacement $pkg ${lines[@]})" - freedom=$? + local rep="$(check_replacement $pkg ${lines[@]})" + local freedom=$? - if [ "$freedom" -eq 15 ]; then + if [[ $freedom = 15 ]]; then warning "found $pkg" # > "$logpipe" ev=15 - continue - elif [ -n "$rep" ]; then - if [ "$rep" = "$pkg" ]; then plain "$pkg is repackaged with the same name." # > "$logpipe" - continue else plain "$pkg -> $rep" # > "$logpipe" - continue fi - fi - done - } -function usage { +usage() { # TODO: implement PKGBUILD arguments + echo "Usage: $cmd [OPTIONS] [PKGBUILD1 PKGBUILD2 ...]" echo "" - echo "$(basename $0) [options] [PKGBUILD1 PKGBUILD2 ...]" - echo "" - echo "OPTIONS" + echo "If no PKGBUILD is specified, \`./PKGBUILD' is implied" echo "" - echo " -h : this message" - echo "" - echo "If no PKGBUILD is specified, one is searched on current directory" - - exit 1 + echo "Options:" + echo " -h Show this message" } -while getopts 'h' arg; do - case "$arg" in - h) usage ;; - esac -done - -if [ -w / ]; then - error "Run as normal user" -fi - -source /etc/libretools.conf -if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then - source "$XDG_CONFIG_HOME/libretools/libretools.conf" -fi - -if [ -z "${BLACKLIST}" ]; then - error "BLACKLIST variable is not set your libretools.conf file" - exit 1 -fi - -if [ ! -d "$XDG_CONFIG_HOME/libretools" ]; then - mkdir -p "$XDG_CONFIG_HOME/libretools" -fi - -startdir=`pwd` - -get_blacklist -# log +main() { + while getopts 'fh' arg; do + case "$arg" in + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + shift $(($OPTIND - 1)) + pkgbuilds=("$@") + if [[ $# < 1 ]]; then + pkgbuilds=("`pwd`/PKGBUILD") + fi -shift $(( OPTIND - 1)) + if [[ -w / ]]; then + error "Run as normal user" + exit 1 + fi -msg "Looking for unfree dependencies" + get_blacklist + # log -if [ $# -ge 1 ]; then + msg "Looking for unfree dependencies" - for p in $@; do - if [ -n "$p" ]; then + for p in "${pkgbuilds[@]}"; do + if [[ -n "$p" ]]; then check_deps "$p" fi done -else - - check_deps "`pwd`/PKGBUILD" - -fi + return $ev +} -exit $ev +main "$@" -- cgit v1.2.2 From 444cc22bc5cda7a4adc26982d3edbcfd1af426ed Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:44:38 -0500 Subject: add an '-f' flag to pkgbuild-check-nonfree to let libremakepkg run as root --- src/chroot-tools/libremakepkg | 2 +- src/pkgbuild-check-nonfree | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 3fa2f3d..4593121 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -113,7 +113,7 @@ main() { if $CHECKNONFREE; then msg "Checking PKGBUILD for non-free issues" - if ! pkgbuild-check-nonfree; then + if ! pkgbuild-check-nonfree -f; then if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree error "PKGBUILD contains non-free issues" diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index fba4b7b..0fd480c 100755 --- a/src/pkgbuild-check-nonfree +++ b/src/pkgbuild-check-nonfree @@ -146,12 +146,15 @@ usage() { echo "If no PKGBUILD is specified, \`./PKGBUILD' is implied" echo "" echo "Options:" + echo " -f Allow running as root user" echo " -h Show this message" } main() { + local asroot=false while getopts 'fh' arg; do case "$arg" in + f) asroot=true;; h) usage; exit 0;; *) usage; exit 1;; esac @@ -162,7 +165,7 @@ main() { pkgbuilds=("`pwd`/PKGBUILD") fi - if [[ -w / ]]; then + if [[ -w / ]] && ! $asroot; then error "Run as normal user" exit 1 fi -- cgit v1.2.2 From a07049cd10c57d0df4497e389dd5b08631a10049 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 00:47:49 -0500 Subject: aur: use bash builtins instead of sed --- src/aur | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aur b/src/aur index 24d4317..f90a776 100755 --- a/src/aur +++ b/src/aur @@ -56,7 +56,7 @@ for _pkg in ${@}; do fi msg "Downloading $_pkg..." - wget -O - -q https://aur.archlinux.org/packages/$(echo $_pkg | sed "s/^../&\/&/")/$_pkg.tar.gz | \ + wget -O - -q https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz | \ tar xzf - >/dev/null 2>&1 if [ $? -ne 0 ]; then -- cgit v1.2.2 From 27d4291f8404cfa8992492211df6ed7042f6036e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 12:28:21 -0500 Subject: rm src/update-cleansystem --- src/update-cleansystem | 68 -------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100755 src/update-cleansystem diff --git a/src/update-cleansystem b/src/update-cleansystem deleted file mode 100755 index 6bec742..0000000 --- a/src/update-cleansystem +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# Updates the cleansystem file -# 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 - -# ---------- 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 . - -set -e - -# libretools.conf gives us libremessages -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 - -if [ ! -w "$cleansystem" ]; then - error 'This script must be run as root' - exit 1 -fi - -# Maintain a clean database in the system -db_dir="${DB:-/var/lib/libretools/clean}" -[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}" - -# We sync first because updating info gets printed to stdout too -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 > "$cleansystem" - -# Ensures everything's installed -pacman -Sy --needed --noconfirm base base-devel sudo $@ - -exit $? -- cgit v1.2.2 From b72653f654882335026d04de5c25ea02c20e8412 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 14:19:36 -0500 Subject: clean up some misc scripts --- src/diff-unfree | 95 +++++++++++++++++++++++++++++---------------------------- src/is_unfree | 5 +-- src/librediff | 60 ++++++++++++++++-------------------- src/librerepkg | 73 +++++++++++++++++++++----------------------- 4 files changed, 110 insertions(+), 123 deletions(-) diff --git a/src/diff-unfree b/src/diff-unfree index a0a8d63..24ada67 100755 --- a/src/diff-unfree +++ b/src/diff-unfree @@ -20,66 +20,67 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf - -[[ "$1" == "--help" ]] && { - msg "Diff-Unfree helps you diff build scripts from ABSLibre against - (Unfree) ABS. Package name and repo will we guessed if you don't - specify them." - msg2 "Usage: $0 [community|packages] [unfree-package] [repo]" - exit 0 -} +. /etc/libretools.conf + +cmd=${0##*/} -[[ ! -r PKGBUILD ]] && { - error "This is not a build dir." - exit 1 +usage() { + echo "Usage: $cmd [community|packages] [unfree-package] [repo]" + echo "Usage: $cmd --help" + echo "Helps you diff build scripts from ABSLibre against (Unfree) ABS." + echo "" + echo "Package name and repo will we guessed if you don't specify them." } -package_guess=$(basename $PWD) +main() { + if [[ "$1" == "--help" ]]; then + usage + exit 0 + fi -repo=${1:-$(basename $(dirname $PWD))} -package=${2:-${package_guess/-libre}} -trunk=${3:-trunk} + local package_guess=${PWD##*/} + local repo=${1:-$(basename ${PWD%/*})} + local package=${2:-${package_guess%-libre}} + local trunk=${3:-trunk} -tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) + svnrepo="packages" + case $repo in + community*) svnrepo="community";; + multilib*) svnrepo="community";; + *) :;; + esac -svnrepo="packages" -case $repo in - community*) - svnrepo="community" - ;; - multilib*) - svnrepo="community" - ;; - *) - ;; -esac + if [[ ! -r PKGBUILD ]]; then + error "This is not a build dir." + exit 1 + fi -unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -[[ ! -d "${tmp_dir}" ]] && { - error "Can't create temp dir" - exit 1 -} + tmp_dir="$(mktemp --tmpdir -d ${package}.XXXXXX)" + if [[ ! -d "${tmp_dir}" ]]; then + error "Can't create temp dir" + exit 1 + fi + unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -stdnull 'pushd "${tmp_dir}"' + stdnull 'pushd "${tmp_dir}"' -msg "Getting diff from $repo/$package..." + msg "Getting diff from $repo/$package..." -stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' + stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' -cd ${svnrepo} -svn update ${package} + cd ${svnrepo} + svn update ${package} -# Back to start dir -stdnull popd + # Back to start dir + stdnull popd -msg "Diffing files" + msg "Diffing files" -for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" - ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" -done + for _file in ${unfree_dir}/*; do + msg2 "$(basename "${_file}")" + ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" + done +} -exit $? +main "$@" diff --git a/src/is_unfree b/src/is_unfree index f32c193..c2a37c9 100755 --- a/src/is_unfree +++ b/src/is_unfree @@ -1,11 +1,8 @@ #!/bin/bash # Checks if a package is on blacklist -# fail immediately on error -set -E +. /etc/libretools.conf blacklist="$XDG_CONFIG_HOME/libretools/blacklist.txt" - egrep -q "^${1}:" "${blacklist}" - exit $? diff --git a/src/librediff b/src/librediff index 1f39eb9..6dbe41b 100755 --- a/src/librediff +++ b/src/librediff @@ -20,46 +20,38 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -usage() { - echo "Usage: $0 [ ...]" - echo "Requirements:" - echo "* Have a / directory with nonfree build scripts inside" - echo "* Have a -libre/ directory with libre build scripts inside" -} +. /etc/libretools.conf -# Load custom config or system-wide config -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -if [ -e $custom_config ]; then - source $custom_config -else - source /etc/libretools.conf -fi +cmd=${0##*/} -# Print usage if no package has been given -[[ -z "$@" ]] && { - usage - exit 1 +usage() { + echo "Usage: $cmd [ ...]" + echo "Requirements:" + echo " * Have a / directory with nonfree build scripts inside" + echo " * Have a -libre/ directory with libre build scripts inside" } +main() { + local packages=("$@") + if [[ ${packages[#]} = 0 ]]; then + usage + exit 1 + fi -for package in $@; do -# Continue on errors - [[ ! -d ./${package} || ! -d ./${package}-libre ]] && { - error "no matching ${package} and ${package}-libre found" - continue - } - - [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] && { - error "no matching PKGBUILDs found for ${package}-libre" - continue - } + for package in "${packages[@]}"; do + if [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] + then + error "Build scripts not found for ${package}(-libre)" + else - source ./${package}-libre/PKGBUILD - [[ -z ${pkgbase} ]] && pkgbase=${pkgname} + . ./${package}-libre/PKGBUILD + [[ -z ${pkgbase} ]] && pkgbase=${pkgname} -# Generate a diff file, no -r since we don't want to patch src/ nor pkg/ - diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch + # Generate a diff file, no -r since we don't want to patch src/ nor pkg/ + diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch + done -done + exit 0 +} -exit 0 +main "$@" diff --git a/src/librerepkg b/src/librerepkg index d506003..85c58d9 100755 --- a/src/librerepkg +++ b/src/librerepkg @@ -18,55 +18,52 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -if [ -x $custom_config ]; then - source $custom_config; - unset $custom_config -fi - -[[ ! -r rePKGBUILD ]] && { - error "This build does not contains a rePKGBUILD." - exit 1 -} +. /etc/libretools.conf +. /etc/makepkg.conf +. /etc/abs.conf -source /etc/makepkg.conf -source /etc/abs.conf -source rePKGBUILD +cmd=${0##*/} usage() { - echo "cd to a dir with a rePKGBUILD and other file info and run" - echo "$0 [makepkg flags]" - echo - echo "This script will repackage an arch package without compiling" + echo "cd to a dir with a rePKGBUILD and other file info and run" + echo "$cmd [makepkg flags]" + echo "" + echo "This script will repackage an arch package without compiling" } -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - esac -done - -makepkgflags=$@ +main() { + while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + esac + done + makepkgflags=("$@") -tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX) + if [[ ! -r rePKGBUILD ]]; then + error "This build does not contains a rePKGBUILD." + exit 1 + fi + . rePKGBUILD -msg "Copying files" -cp ./* ${tempdir}/ + tempdir="$(mktemp --tmpdir -d ${PWD##*/}.XXXXX)" -for _arch in ${arch[@]}; do + msg "Copying files" + cp ./* "${tempdir}/" - msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))" + for _arch in "${arch[@]}"; do + msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))" + stdnull pushd "${tempdir}" - stdnull pushd ${tempdir} + msg2 "Updating md5sums" + makepkg -gp rePKGBUILD >> rePKGBUILD - msg2 "Updating md5sums" - makepkg -gp rePKGBUILD >> rePKGBUILD + echo "export CARCH=${_arch}" >> rePKGBUILD - echo "export CARCH=${_arch}" >> rePKGBUILD + msg "Repackaging using makepkg" + makepkg -Lcdp rePKGBUILD "${makepkgflags[@]}" - msg "Repackaging using makepkg" - makepkg -Lcdp rePKGBUILD ${makepkgflags} + stdnull popd "${tempdir}" + done +} - stdnull popd ${tempdir} -done +main "$@" -- cgit v1.2.2 From 066c7716e69817af9e08782a7fbfc3dc2eb6356b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 26 Nov 2012 01:30:54 -0500 Subject: libremessages: term_title: learn about xterm/rxvt --- src/libremessages | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libremessages b/src/libremessages index 756e19a..ff7476b 100755 --- a/src/libremessages +++ b/src/libremessages @@ -88,9 +88,13 @@ stat_done() { } # Set the terminal title -# TODO test on several terms - it works on screen/tmux term_title() { - printf "\033k%s\033\\" "$@" + local fmt='' + case "$TERM" in + screen|tmux) fmt='\ek%s\e\\';; + xterm*|rxvt*) fmt='\e]0;%s\a';; + esac + printf "$fmt" "$*" } # usage : in_array( $needle, $haystack ) -- cgit v1.2.2 From fd1e5a426713715d9c0e3fabbfe0d8a20b629bad Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:18:44 -0500 Subject: chroot-tools: disable overriding CHROOTDIR at the command line --- src/chroot-tools/librechroot | 2 -- src/chroot-tools/libremakepkg | 2 -- src/chroot-tools/libremkchroot | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index a5c5728..48e6cdc 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -136,7 +136,6 @@ usage() { echo '' echo 'Options:' echo ' Settings:' - echo " -d Use this dir instead of \`${CHROOTDIR}'" echo ' -l Use this as the chroot copy instead of basing it' echo ' on the username' echo ' Modes:' @@ -156,7 +155,6 @@ main() { local mode=enter while getopts 'hrcud:l:' arg; do case $arg in - d) CHROOTDIR=$OPTARG;; l) CHROOTCOPY=$OPTARG;; c) mode=clean_pacman;; diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 4593121..faa50be 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -53,7 +53,6 @@ usage() { echo ' -u Update the chroot before building' echo ' -N Do not check freedom issues (for fullpkg)' echo '' - echo " -d Use this dir instead of \`$CHROOTDIR'" echo " -n Use this chroot instead of \`$CHROOT'" echo ' -l Use this chroot copy instead of basing it' echo ' on the username' @@ -77,7 +76,6 @@ main() { u) UPDATEFIRST=true;; N) CHECKNONFREE=false;; - d) CHROOTDIR=$OPTARG;; n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index cc5b431..08f69b1 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -35,7 +35,6 @@ usage() { echo 'Options:' echo ' -h Show this message' echo '' - echo ' -d Use this dir instead of "$CHROOTDIR".' echo ' -C Location of pacman config file.' echo ' -M Location of makepkg config file.' } @@ -45,7 +44,6 @@ main() { while getopts 'hfd:C:M:' arg; do case "$arg" in C|M) mkarchroot_args+=("-$arg" "$OPTARG");; - d) CHROOTDIR=$OPTARG;; h) usage; exit 0;; *) usage; exit 1;; -- cgit v1.2.2 From 00d67a5051e5d4163acffa80b7ef85f81f7e548f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:20:59 -0500 Subject: take (some) advantage of chroottools, fix some compatability things mkarchroot/archroot's option parsing is a little less flexible (but a lot more understandable) than it was before. --- src/chroot-tools/librechroot | 51 +++------------------- src/chroot-tools/libremkchroot | 6 +-- src/libremessages | 96 ++++++++++++++---------------------------- 3 files changed, 39 insertions(+), 114 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 48e6cdc..8830c39 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -27,53 +27,12 @@ cmd=${0##*/} -lock_open_write() { - local fd=$1 - local path=$2 - local msg=$3 - - # Only reopen the FD if it wasn't handed to us - if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - eval "exec $fd>${path}.lock" - fi - - if ! flock -n $fd; then - stat_busy "$msg" - flock $fd - stat_done - fi -} - -lock_open_read() { - local fd=$1 - local path=$2 - local msg=$3 - - # Only reopen the FD if it wasn't handed to us - if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - eval "exec $fd>${path}.lock" - fi - - if ! flock -sn $fd; then - stat_busy "$msg" - flock -s $fd - stat_done - fi -} - -lock_close() { - local fd=$1 - eval "exec $fd>&-" -} - clean_pacman() { msg "Cleaning chroot with pacman: ${copydir}" cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" mkdir -p "$copydir/build" - mkarchroot -r "cd /build; /clean" "${copydir}" - - #mkarchroot "${copydir}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${copydir}" -r "cd /build; /clean" } clean_repo() { @@ -120,12 +79,12 @@ sync() { update() { msg "Updating chroot: ${copydir}" - mkarchroot -u "${copydir}" + archroot "${copydir}" -u } enter() { msg "Entering chroot: ${copydir}" - mkarchroot -r "bash" "${copydir}" + archroot "${copydir}" -r "bash" } usage() { @@ -183,11 +142,11 @@ main() { fi # Keep this lock as long as we are running - # Note that '9' is the same FD number as in mkarchroot + # Note that '9' is the same FD number as in (mk)archroot lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" if [[ ! -d $rootdir ]]; then - libremkchroot -d "$CHROOTDIR" "$CHROOT" + libremkchroot "$CHROOT" fi if [[ ! -d $copydir ]] && [[ $mode != sync ]]; then diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 08f69b1..3072b9e 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -40,10 +40,10 @@ usage() { } main() { - mkarchroot_args=(); + archroot_args=(); while getopts 'hfd:C:M:' arg; do case "$arg" in - C|M) mkarchroot_args+=("-$arg" "$OPTARG");; + C|M) archroot_args+=("-$arg" "$OPTARG");; h) usage; exit 0;; *) usage; exit 1;; @@ -62,7 +62,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" diff --git a/src/libremessages b/src/libremessages index ff7476b..ccb5fb4 100755 --- a/src/libremessages +++ b/src/libremessages @@ -1,11 +1,11 @@ #!/bin/bash -# Copyright (c) 2006-2010 Pacman Development Team # Copyright (c) 2002-2006 by Judd Vinet +# Copyright (c) 2006-2010 Pacman Development Team # Copyright (c) 2005 by Aurelien Foret -# Copyright (c) 2006 by Miklos Vajna # Copyright (c) 2005 by Christian Hamar # Copyright (c) 2006 by Alex Smith # Copyright (c) 2006 by Andras Voroskoi +# Copyright (c) 2006 by Miklos Vajna # Copyright (c) 2011 by Joshua Haase # # This program is free software; you can redistribute it and/or modify @@ -21,70 +21,46 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# gettext initialization -export TEXTDOMAIN='libretools' -export TEXTDOMAINDIR='/usr/share/locale' +################################################################################ +# Inherit most functions from devtools # +################################################################################ -# check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW -if [[ -t 2 ]]; then - # prefer terminal safe colored and bold text when tput is supported - if tput setaf 0 &>/dev/null; then - ALL_OFF="$(tput sgr0)" - BOLD="$(tput bold)" - PURPLE="${ALL_OFF}$(tput setaf 5)" - BLUE="${BOLD}$(tput setaf 4)" - GREEN="${BOLD}$(tput setaf 2)" - RED="${BOLD}$(tput setaf 1)" - YELLOW="${BOLD}$(tput setaf 3)" - else - ALL_OFF="\e[1;0m" - BOLD="\e[1;1m" - BLUE="${BOLD}\e[1;34m" - GREEN="${BOLD}\e[1;32m" - RED="${BOLD}\e[1;31m" - YELLOW="${BOLD}\e[1;33m" - PURPLE="${BOLD}\033[1;30;40m" - fi -fi -readonly ALL_OFF BOLD BLUE GREEN RED YELLOW PURPLE +# This is only installed in Parabola's distribution of devtools, not Arch's +. /usr/share/devtools/common.sh -stdnull() { - eval "$@ >/dev/null 2>&1" -} +################################################################################ +# gettext initialization # +################################################################################ -plain() { - local mesg=$1; shift - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} +export TEXTDOMAIN='libretools' +export TEXTDOMAINDIR='/usr/share/locale' -msg() { - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} +################################################################################ +# Devtools overrides # +################################################################################ -msg2() { - local mesg=$1; shift - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} +# Override several functions with built-in text to uses gettext warning() { - local mesg=$1; shift - printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { - local mesg=$1; shift - printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -stat_busy() { local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2 + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } stat_done() { - printf "${BOLD}done${ALL_OFF}\n" >&2 + printf "${BOLD}$(gettext "done")${ALL_OFF}\n" >&2 +} + +################################################################################ +# Own functions # +################################################################################ + +stdnull() { + eval "$@ >/dev/null 2>&1" } # Set the terminal title @@ -97,19 +73,9 @@ term_title() { printf "$fmt" "$*" } -# usage : in_array( $needle, $haystack ) -in_array() { - [[ $2 ]] || return 1 # Not found - - local needle=$1; shift - local item - - for item in "$@"; do - [[ ${item#@} = $needle ]] && return 0 # Found - done - - return 1 # Not Found -} +################################################################################ +# Run one of the defined functions if invoked directly # +################################################################################ if [[ "${0##*/}" = libremessages ]]; then _libremessages_cmd=$1 -- cgit v1.2.2 From 8eaf0770e396efa4bb254c7e62e4940682817589 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:21:18 -0500 Subject: libretools.conf: force CHROOT != root --- src/libretools.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libretools.conf b/src/libretools.conf index 631ca89..4157006 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -130,6 +130,10 @@ for VAR in CHROOTDIR CHROOT PARABOLAHOST LIBREDESTDIR \ ret=1 fi done +if [[ $CHROOT == root ]]; then + echo "Configured var CHROOT cannot equal 'root'" + ret=1 +fi if [[ $ret != 0 ]]; then exit 1 fi -- cgit v1.2.2 From 35a3071f5a06efaeab9d884fbce67426abbc010d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:21:47 -0500 Subject: libretools.conf: remove libretools from CHROOTEXTRAPKG, it is being added to base-devel --- src/libretools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretools.conf b/src/libretools.conf index 4157006..bef9fc4 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -31,7 +31,7 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any') ## The directory where the chroots are stored CHROOTDIR=/home/chroot ## Extra packages to have installed on the chroot (besides base base-devel and sudo) -CHROOTEXTRAPKG=(distcc ccache tsocks libretools) +CHROOTEXTRAPKG=(distcc ccache tsocks) ## The meaning of this changes based on the version of libretools+devtools ## do NOT set it to 'root' CHROOT=default -- cgit v1.2.2 From 4e5d7c05ada2181ce0aa3bed0ba734f4e1ae70cb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:23:43 -0500 Subject: clean up aur --- src/aur | 214 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 112 insertions(+), 102 deletions(-) diff --git a/src/aur b/src/aur index f90a776..12efb81 100755 --- a/src/aur +++ b/src/aur @@ -2,122 +2,132 @@ # Copyright 2010 Nicolás Reynolds, Joshua Ismael # ---------- 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 -source /etc/abs.conf +. /etc/libretools.conf +. /etc/abs.conf + +cmd=${0##*/} -function usage { - echo "Usage: $0 pkgname-from-aur1 [pkgname-from-aur2 ...]" - echo - echo "This script will download packages from aur to the current dir" - echo "and check their license for nonfree issues." +usage() { + echo "Usage: $cmd pkgname-from-aur1 [pkgname-from-aur2 ...]" + echo + echo "This script will download packages from aur to the current dir" + echo "and check their license for nonfree issues." } -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - *) usage; exit 1 ;; - esac -done - -missing_deps=() -for _pkg in ${@}; do - -# Remove the version - _pkg="${_pkg%%[<>=]*}" - - if [ -f "${_pkg}/PKGBUILD" ]; then - warning "${_pkg} already existed." - -# Check if we want to diff - if [ -z "${DIFFTOOL}" ]; then - continue - else -# Store our copy of the PKGBUILD dir - _diff="${PWD}/${_pkg}" - stdnull "pushd $(mktemp -d /tmp/${_pkg}.XXXX)" - msg2 "Downloading PKGBUILD into ${PWD} for diff" - fi - fi - - msg "Downloading $_pkg..." - wget -O - -q https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz | \ - tar xzf - >/dev/null 2>&1 - - if [ $? -ne 0 ]; then - error "Couldn't get $_pkg" - continue - fi - - stdnull "pushd $_pkg" - - if [ ! -z "$_diff" ]; then - msg2 "Diffing files" -# Diff all files with our difftool - for file in *; do - ${DIFFTOOL} ${_diff}/${file} ${file} - done - -# Go back to our copy to continue working - stdnull "pushd ${_diff}" - fi - - source PKGBUILD - - if ! pkgbuild-check-nonfree; then - if [ $? -eq 15 ]; then - warning "This PKGBUILD links to known unfree packages" - fi - fi - - msg2 "Checking license..." - free=0 - for _license in ${license[@]}; do - if [ ! -d /usr/share/licenses/common/$_license ]; then - warning "License $_license is not a common license" - free=1 - fi - done - - if [ $free -eq 1 ]; then - plain "Please check that the license is included in the package and - *specially* that it respects your freedom." - fi - - for _dep in ${depends[@]} ${makedepends[@]}; do - _dep=${_dep/[<>=]*/} - if ! is_built $_dep; then - if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then - msg2 "$_dep will be get from AUR" - missing_deps+=($_dep) - fi - else - msg2 "$_dep is on repos" - fi - done - - stdnull popd - -done - -[[ ${#missing_deps[*]} -gt 0 ]] && { - msg2 "Retrieving missing deps: ${missing_deps[@]}" - $0 ${missing_deps[@]} +main() { + while getopts 'h' arg; do + case $arg in + h) usage; exit 0;; + *) usage; exit 1;; + esac + done + + local missing_deps=() + for _pkg in "$@"; do + + # Remove the version + _pkg="${_pkg%%[<>=]*}" + + if [[ -f "${_pkg}/PKGBUILD" ]]; then + warning "${_pkg} already existed." + + # Check if we want to diff + if [[ -z "${DIFFTOOL}" ]]; then + continue + else + # Store our copy of the PKGBUILD dir + _diff="${PWD}/${_pkg}" + stdnull "pushd $(mktemp --tmpdir -d ${_pkg}.XXXX)" + msg2 "Downloading PKGBUILD into ${PWD} for diff" + fi + fi + + msg "Downloading $_pkg..." + local url=https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz + wget -O - -q "$url" | tar xzf - >/dev/null 2>&1 + + if [[ $? -ne 0 ]]; then + error "Couldn't get $_pkg" + continue + fi + + stdnull "pushd $_pkg" + + if [[ ! -z "$_diff" ]]; then + msg2 "Diffing files" + # Diff all files with our difftool + for file in *; do + "${DIFFTOOL}" "${_diff}/${file}" "${file}" + done + + # Go back to our copy to continue working + stdnull "pushd ${_diff}" + fi + + . PKGBUILD + + ################################################################ + + if ! pkgbuild-check-nonfree; then + if [[ $? = 15 ]]; then + warning "This PKGBUILD links to known unfree packages" + fi + fi + + ################################################################ + + msg2 "Checking license..." + local free=0 + for _license in ${license[@]}; do + if [[ ! -d /usr/share/licenses/common/$_license ]]; then + warning "License $_license is not a common license" + free=1 + fi + done + + if [[ $free -eq 1 ]]; then + plain "Please check that the license is included in the package and *specially* that it respects your freedom." + fi + + ################################################################ + + for _dep in "${depends[@]}" "${makedepends[@]}"; do + _dep=${_dep/[<>=]*/} + if ! is_built $_dep; then + if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then + msg2 "$_dep will be get from AUR" + missing_deps+=($_dep) + fi + else + msg2 "$_dep is on repos" + fi + done + + stdnull popd + done + + [[ ${#missing_deps[*]} -gt 0 ]] && { + msg2 "Retrieving missing deps: ${missing_deps[@]}" + $0 ${missing_deps[@]} + } + + exit 0 } -exit 0 +main "$@" -- cgit v1.2.2 From 144466aaa12ef0aed8a53767becae6033df9b3cf Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:17:00 -0500 Subject: libretools.conf: set LIBREUSER and LIBREHOME --- src/libretools.conf | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index bef9fc4..20c7d90 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -107,14 +107,10 @@ TORUPATH=/var/lib/libretools/toru # This probably shouldn't be in a .conf file... # ################################################################################ +LIBREUSER="${SUDO_USER:-$USER}" +LIBREHOME="$(eval echo ~$SUDO_USER)" if [[ -z $XDG_CONFIG_HOME ]]; then - if [[ -n $SUDO_USER ]]; then - SUDO_HOME="$(eval echo ~$SUDO_USER)" - export XDG_CONFIG_HOME="${SUDO_HOME}/.config" - unset SUDO_HOME - else - export XDG_CONFIG_HOME="${HOME}/.config" - fi + export XDG_CONFIG_HOME="${LIBREHOME}/.config" fi if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then . "$XDG_CONFIG_HOME/libretools/libretools.conf" -- cgit v1.2.2 From 56f394ecbe65b5aba13759237f8a6cbc645e5e3d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:17:19 -0500 Subject: fix getopts for libremkchroot --- src/chroot-tools/libremkchroot | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 3072b9e..992c6e5 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -1,23 +1,20 @@ #!/bin/bash -# LibreMkChroot -# Creates a chroot +# libremkchroot # Copyright 2011, 2012 Luke Shumaker - -# ---------- 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 . @@ -41,7 +38,7 @@ usage() { main() { archroot_args=(); - while getopts 'hfd:C:M:' arg; do + while getopts 'hC:M:' arg; do case "$arg" in C|M) archroot_args+=("-$arg" "$OPTARG");; -- cgit v1.2.2 From 2a86ab6a3575724412f32fdbd794b0fd2738eb91 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:17:54 -0500 Subject: reorganize, add a few features to librechroot --- src/chroot-tools/librechroot | 130 +++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 61 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 8830c39..c3c7374 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -1,52 +1,27 @@ -#!/bin/bash -# LibreChRoot -# Enters a chroot +#!/bin/bash -euE +# librechroot # Copyright 2010 Nicolás Reynolds # Copyright 2011 Joshua Haase # Copyright 2012 Luke Shumaker - -# ---------- 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 . . /etc/libretools.conf -cmd=${0##*/} - -clean_pacman() { - msg "Cleaning chroot with pacman: ${copydir}" - - cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" - mkdir -p "$copydir/build" - archroot "${copydir}" -r "cd /build; /clean" -} - -clean_repo() { - msg "Cleaning repo for chroot: ${copydir}" - - if [ -d "${copydir}/repo" ]; then - find "${copydir}/repo/" -mindepth 1 -delete - else - mkdir -p "${copydir}/repo" - fi - bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" -} - ## # This function is almost verbatim from makechrootpkg ## @@ -62,8 +37,7 @@ sync() { local use_rsync=false if type -P btrfs >/dev/null; then [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null - btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || - use_rsync=true + btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || use_rsync=true else use_rsync=true fi @@ -77,48 +51,49 @@ sync() { lock_close 8 } -update() { - msg "Updating chroot: ${copydir}" - archroot "${copydir}" -u -} - -enter() { - msg "Entering chroot: ${copydir}" - archroot "${copydir}" -r "bash" -} - usage() { - echo "Usage: $cmd [OPTIONS] [CHROOT]" + echo "Usage: $cmd [OPTIONS] [CHROOT] " echo 'Interacts with a chroot.' echo '' echo "The default CHROOT is \`${CHROOT}'." echo '' echo 'Options:' echo ' Settings:' - echo ' -l Use this as the chroot copy instead of basing it' + echo ' -l Use this as the chroot copy instead of basing it' echo ' on the username' - echo ' Modes:' - echo ' -h Show this message' - echo ' -c Clean the chroot using pacman' - echo " -C Clean the chroot by syncing it with 'root' copy" - echo ' -r Clean /repo in the chroot' + echo ' -N Disable networking in the chroot' + echo '' + echo ' Modes: (the last mode given will be used)' + echo ' -C Clean /repo in the chroot' + echo ' -c Clean the packages installed in the chroot' + echo ' -I Install the package FILE into the chroot' + echo ' -i Install the package PKG from repos into the chroot' + echo ' -n No-op, just make sure that the chroot exists' + echo ' -r Run CMD in the chroot' + echo " -s Sync the copy with the 'root' copy" echo ' -u Update the chroot' + echo ' -h Print this message' } main() { - # The logic for setting CHROOTCOPY is mirred from makechrootpkg - CHROOTCOPY=$USER - [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER - [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy + CHROOTCOPY=$LIBREUSER + [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy local mode=enter - while getopts 'hrcud:l:' arg; do + local archroot_args=() + local ARG='' + while getopts 'l:NCcI:i:nrsuh' arg; do case $arg in l) CHROOTCOPY=$OPTARG;; + N) archroot_args+=(-N);; + C) mode=clean_repo c) mode=clean_pacman;; - C) mode=sync;; - r) mode=clean_repo;; + I) mode=install_file; ARG=$OPTARG;; + I) mode=install_pkg; ARG=$OPTARG;; + n) mode=noop;; + r) mode=run; ARG=$OPTARG;; + s) mode=sync;; u) mode=update;; h) usage; exit 0;; @@ -154,10 +129,43 @@ main() { fi case "$mode" in - clean_pacman) clean_pacman; exit $?;; - clean_repo) clean_repo; exit $?;; - update) update; exit $?;; - enter) enter; exit $?;; + clean_repo) + msg "Cleaning local pacman repository" + rm -rf "${copydir}/repo" + mkdir "${copydir}/repo" + bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" + ;; + clean_pacman) + msg "Intelligently cleaning packages" + cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" + mkdir -p "$copydir/build" + archroot "${archroot_args[@]}" "${copydir}" -r "cd /build; /clean" + ;; + install_file) + msg "Installing package file: $ARG" + cp "$ARG" "$copydir/${ARG##*/}" + archroot "${archroot_args[@]}" "$copydir" -r "pacman -U /${ARG##*/} --noconfirm" + rm "$copydir/${ARG##*/}" + ;; + install_pkg) + msg "Installing package(s): $ARG" + archroot "${archroot_args[@]}" "$copydir" -i $ARG + ;; + noop) :;; + run) + msg "Running command" + archroot "${archroot_args[@]}" "${copydir}" -r "$ARG" + ;; + sync) sync;; + update) + msg "Updating chroot" + archroot "${archroot_args[@]}" "${copydir}" -u + ;; + enter) + msg "Entering chroot" + archroot "${archroot_args[@]}" "${copydir}" -r bash + ;; esac } -- cgit v1.2.2 From 259c05c47fc43875415d5ecab9666a46fb4b6d76 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:34:19 -0500 Subject: Rewrite libremakepkg to not use makechrootpkg --- src/chroot-tools/libremakepkg | 175 ++++++++++++++++++++++++------------- src/chroot-tools/libremakepkg.gpl2 | 102 +++++++++++++++++++++ 2 files changed, 214 insertions(+), 63 deletions(-) create mode 100755 src/chroot-tools/libremakepkg.gpl2 diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index faa50be..d661714 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -1,141 +1,190 @@ -#!/bin/bash +#!/bin/bash -euE # libremakepkg -# analogous to devtools' archbuild # Copyright 2010 - 2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández # Copyright 2012 Luke Shumaker - -# ---------- 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 . . /etc/libretools.conf +shopt -s nullglob + +# This file (libremakepkg) is GPLv3+, but I would like to use some code +# modified from devtools' "makechrootpkg", which is GPLv2. +. "$(dirname "$0")/libremakepkg.gpl2" +# This gives us the functions: +# - chroot_init +# - chroot_extract +# - chroot_build +# - copy_pkgs + +# Boring functions ############################################################# + ## # copy logs if they exist ## -copy_log() { - find "${copydir}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; +copy_logs() { + for l in "$copydir"/build/*.log; do + chown "$LIBREUSER" "$l" + mv "$l" . + done } ## # End inmediately but print a useful message ## trap_exit() { - copy_log - error "$@" + copy_logs + error "$*" exit 1 } +## +# Usage: makepkg_conf_get SETTING [DEFAULT] +## +makepkg_conf_get() { + local setting=$1 + if [[ -f $LIBREHOME/.makepkg.conf ]]; then + eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf") + fi + if [[ -z ${!setting} ]]; then + eval $(grep "^$setting=" "/etc/makepkg.conf") + fi + if [[ -z ${!setting} && -n ${2} ]]; then + eval "$setting='$2'" + fi +} + +chroot_makepkg_conf_get() { + local setting=$1 + eval $(grep "^$setting=" "$copydir/etc/makepkg.conf") +} + +chroot_makepkg_conf_set() { + local key=$1 + local val=$2 + sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf" + echo "$key='$val'" >> "$copydir/etc/makepkg.conf" +} + +# Functions that check for issues with the build ############################### + +libre_check_pkgbuild() { + msg "Checking PKGBUILD for issues" + # TODO + if ! pkgbuild-check-nonfree -f; then + if [[ $? -eq 15 ]]; then + # other errors mean fail, not nonfree + error "PKGBUILD contains non-free issues" + exit 15 + else + warning "PKGBUILD couldn't be check aganist non-free issues" + fi + fi +} + +libre_check_src() { + msg "Checking src directory for issues" + # TODO +} + +libre_check_pkg() { + msg "Checking final package for issues" + # TODO +} + + +# The main program ############################################################# + usage() { echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [-- makechrootpkg args [-- makepkg args]]' + echo '$0 [options] [-- makepkg args]' echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' echo ' -h Show this message' echo '' - echo ' -c Clean the chroot before building' - echo ' -u Update the chroot before building' - echo ' -N Do not check freedom issues (for fullpkg)' - echo '' + echo " -R Repackage" echo " -n Use this chroot instead of \`$CHROOT'" echo ' -l Use this chroot copy instead of basing it' echo ' on the username' } main() { - # The logic for setting CHROOTCOPY is mirred from makechrootpkg - CHROOTCOPY=$USER - [[ -n $SUDO_USER ]] && CHROOTCOPY=$SUDO_USER - [[ -z $CHROOTCOPY || $CHROOTCOPY = root ]] && CHROOTCOPY=copy - - CLEANFIRST=false - UPDATEFIRST=false - CHECKNONFREE=true + # Parse command line ################################################### - makechrootpkg_args=() + CHROOTCOPY=$LIBREUSER + [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy + makepkg_args=(-s --noconfirm -L) + REPACKAGE=false - while getopts 'hcuNd:n:l:' arg ; do + while getopts 'hRn:l:' arg ; do case "${arg}" in - c) CLEANFIRST=true;; - u) UPDATEFIRST=true;; - N) CHECKNONFREE=false;; - n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; - + R) REPACKAGE=true; makepkg_args+=(-R) ;; h) usage; exit 0;; *) usage; exit 1;; esac done shift $(($OPTIND - 1)) - # Pass all arguments after -- right to makechrootpkg - makechrootpkg_args+=("$@") + # Pass all arguments after -- right to makepkg + makepkg_args+=("$@") - # not local rootdir="${CHROOTDIR}/${CHROOT}/root" copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + # Init ################################################################# + if (( EUID )); then error "This script must be run as root" exit 1 fi - if [[ ! -e PKGBUILD ]]; then - error "This isn't a build directory" + if [[ ! -f PKGBUILD ]]; then + error "This must be run in a directory containing a PKGBUILD" exit 1 fi - # OK, we're starting now ############################################### - # Trap signals from makepkg - set -E trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR - if $CHECKNONFREE; then - msg "Checking PKGBUILD for non-free issues" - if ! pkgbuild-check-nonfree -f; then - if [[ $? -eq 15 ]]; then - # other errors mean fail, not nonfree - error "PKGBUILD contains non-free issues" - exit 15 - else - warning "PKGBUILD couldn't be check aganist non-free issues" - fi - fi - fi + makepkg_conf_get SRCDEST . + makepkg_conf_get PKGDEST . - if $CLEANFIRST; then - librechroot -c -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" - fi + # OK, we're starting now ############################################### - if $UPDATEFIRST; then - librechroot -u -d "$CHROOTDIR" -l "$CHROOTCOPY" "$CHROOT" - fi + lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'" - unset CLEANFIRST UPDATEFIRST librechroot_args + # Set target CARCH as it might be used within the PKGBUILD to select correct sources + chroot_makepkg_conf_get CARCH + export CARCH - makechrootpkg "${makechrootpkg_args[@]}" -d -r "$CHROOTDIR/$CHROOT" -l "$CHROOTCOPY" - ev=$? # exit value - copy_log - exit $ev + chroot_init + libre_check_pkgbuild + $REPACKAGE || chroot_extract + libre_check_src + chroot_build + libre_check_pkg + copy_pkgs + copy_logs } main "$@" diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 new file mode 100755 index 0000000..8ca60e0 --- /dev/null +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -0,0 +1,102 @@ +#!/bin/bash +# Contains code derived from devtools' "makechrootpkg" + +# Copyright 2011-2012 The Arch Linux Development Team +# Copyright 2012 Luke Shumaker +# +# This program 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; version 2 of the License. +# +# This program 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. + +chroot_init() { + # no-op; make sure the chroot exists + librechroot -n -l "$CHROOTCOPY" "$CHROOT" + + if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then + install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg" + fi + + mkdir -p "$copydir/pkgdest" + mkdir -p "$copydir/srcdest" + chroot_makepkg_conf_set PKGDEST /pkgdest + chroot_makepkg_conf_set SRCDEST /srcdest + + cat > "$copydir/etc/sudoers.d/nobody-pacman" < "$file" + echo '. /etc/profile' >> "$file" + echo 'export HOME=/build' >> "$file" + echo 'cd /build' >> "$file" + echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -o" >> "$file" + chmod 755 "$file" + archroot "$copydir" -r /chrootextract +} + +chroot_build() { + local file="$copydir/chrootbuild" + echo '#!/bin/bash' > "$file" + echo '. /etc/profile' >> "$file" + echo 'export HOME=/build' >> "$file" + echo 'cd /build' >> "$file" + echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -e" >> "$file" + chmod 755 "$file" + archroot -N "$copydir" -r /chrootbuild +} + +copy_pkgs() { + for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do + mkdir -p "$copydir/repo" + pushd "$copydir/repo" >/dev/null + cp "$pkgfile" . + repo-add repo.db.tar.gz "${pkgfile##*/}" + popd >/dev/null + + chown "$LIBREUSER" "$pkgfile" + mv "$pkgfile" "$PKGDEST" + if [[ $PKGDEST != . ]]; then + ln -s "$PKGDEST/${pkgfile##*/}" . + fi + done +} -- cgit v1.2.2 From 6dd807e109d491458b26d76602ad344b4c025475 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 19:42:08 -0500 Subject: teach libremakepkg "-m" to use a different command than "makepkg" --- src/chroot-tools/libremakepkg | 17 +++++++++++------ src/chroot-tools/libremakepkg.gpl2 | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index d661714..b6c84c1 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -117,12 +117,14 @@ usage() { echo 'This script will build your package in a chroot.' echo '' echo 'OPTIONS:' - echo ' -h Show this message' + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' echo '' + echo " -m Use the command MAKEPKG instead of 'makepkg'" echo " -R Repackage" - echo " -n Use this chroot instead of \`$CHROOT'" - echo ' -l Use this chroot copy instead of basing it' - echo ' on the username' + echo '' + echo ' -h Show this message' } main() { @@ -130,14 +132,17 @@ main() { CHROOTCOPY=$LIBREUSER [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy + makepkg_args=(-s --noconfirm -L) REPACKAGE=false + MAKEPKG=makepkg - while getopts 'hRn:l:' arg ; do + while getopts 'n:l:m:Rh' arg ; do case "${arg}" in n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=(-R) ;; + m) MAKEPKG=$OPTARG;; + R) REPACKAGE=true; makepkg_args+=(-R);; h) usage; exit 0;; *) usage; exit 1;; esac diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 8ca60e0..1f2d185 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -69,7 +69,7 @@ chroot_extract() { echo '. /etc/profile' >> "$file" echo 'export HOME=/build' >> "$file" echo 'cd /build' >> "$file" - echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -o" >> "$file" + echo "sudo -u nobody ${MAKEPKG} $makepkg_args -o" >> "$file" chmod 755 "$file" archroot "$copydir" -r /chrootextract } @@ -80,7 +80,7 @@ chroot_build() { echo '. /etc/profile' >> "$file" echo 'export HOME=/build' >> "$file" echo 'cd /build' >> "$file" - echo "sudo -u nobody ${MAKEPKG:-makepkg} $makepkg_args -e" >> "$file" + echo "sudo -u nobody ${MAKEPKG} $makepkg_args -e" >> "$file" chmod 755 "$file" archroot -N "$copydir" -r /chrootbuild } -- cgit v1.2.2 From ba312fb72ec0843297978796a20c6ffc1fe3ef6e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 20:14:44 -0500 Subject: fix a typo --- src/chroot-tools/librechroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index c3c7374..e39b105 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -87,7 +87,7 @@ main() { l) CHROOTCOPY=$OPTARG;; N) archroot_args+=(-N);; - C) mode=clean_repo + C) mode=clean_repo;; c) mode=clean_pacman;; I) mode=install_file; ARG=$OPTARG;; I) mode=install_pkg; ARG=$OPTARG;; -- cgit v1.2.2 From 01d928f223a23f28af04dc1cdfcfd62ed6cc3f61 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:08:56 -0500 Subject: improve libremakepkg's help message --- src/chroot-tools/libremakepkg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index b6c84c1..b9107d8 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -111,20 +111,20 @@ libre_check_pkg() { # The main program ############################################################# +cmd=${0##*/} usage() { - echo 'cd to a dir containing a PKGBUILD and run:' - echo '$0 [options] [-- makepkg args]' - echo 'This script will build your package in a chroot.' + echo "Usage: $cmd [options] [-- makepkg args]" + echo 'This program will build your package.' echo '' echo 'OPTIONS:' - echo " -n Use this chroot instead of \`$CHROOT'" - echo ' -l Use this chroot copy instead of basing it' - echo ' on the username' + echo " -n Use this chroot instead of \`$CHROOT'" + echo ' -l Use this chroot copy instead of basing it' + echo ' on the username' echo '' - echo " -m Use the command MAKEPKG instead of 'makepkg'" - echo " -R Repackage" + echo " -m Use the command MAKEPKG instead of 'makepkg'" + echo " -R Repackage" echo '' - echo ' -h Show this message' + echo ' -h Show this message' } main() { -- cgit v1.2.2 From 06f10b87d16d4c83016ff3ef21217494f921d93b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:10:26 -0500 Subject: many fixes --- src/chroot-tools/librechroot | 14 +++++++++----- src/chroot-tools/libremakepkg | 14 +++++++------- src/chroot-tools/libremakepkg.gpl2 | 1 + src/chroot-tools/libremkchroot | 6 +++--- src/libretools.conf | 4 ++-- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index e39b105..d43ea2f 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -51,6 +51,7 @@ sync() { lock_close 8 } +cmd=${0##*/} usage() { echo "Usage: $cmd [OPTIONS] [CHROOT] " echo 'Interacts with a chroot.' @@ -80,7 +81,7 @@ main() { [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy local mode=enter - local archroot_args=() + local archroot_args=(-f) local ARG='' while getopts 'l:NCcI:i:nrsuh' arg; do case $arg in @@ -90,7 +91,7 @@ main() { C) mode=clean_repo;; c) mode=clean_pacman;; I) mode=install_file; ARG=$OPTARG;; - I) mode=install_pkg; ARG=$OPTARG;; + i) mode=install_pkg; ARG=$OPTARG;; n) mode=noop;; r) mode=run; ARG=$OPTARG;; s) mode=sync;; @@ -118,7 +119,7 @@ main() { # Keep this lock as long as we are running # Note that '9' is the same FD number as in (mk)archroot - lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" + lock_open_write 9 "$copydir" "Locking chroot copy '$CHROOTCOPY'" if [[ ! -d $rootdir ]]; then libremkchroot "$CHROOT" @@ -139,8 +140,11 @@ main() { clean_pacman) msg "Intelligently cleaning packages" cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" - mkdir -p "$copydir/build" - archroot "${archroot_args[@]}" "${copydir}" -r "cd /build; /clean" + echo '#!/bin/bash' > "${copydir}/cleanstrap" + echo 'mkdir /build' >> "${copydir}/cleanstrap" + echo 'cd /build; /clean' >> "${copydir}/cleanstrap" + chmod 755 "${copydir}/cleanstrap" + archroot "${archroot_args[@]}" "${copydir}" -r /cleanstrap ;; install_file) msg "Installing package file: $ARG" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index b9107d8..f06bb17 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -62,10 +62,10 @@ makepkg_conf_get() { if [[ -f $LIBREHOME/.makepkg.conf ]]; then eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf") fi - if [[ -z ${!setting} ]]; then + if [[ -z ${!setting:-} ]]; then eval $(grep "^$setting=" "/etc/makepkg.conf") fi - if [[ -z ${!setting} && -n ${2} ]]; then + if [[ -z ${!setting:-} && -n ${2} ]]; then eval "$setting='$2'" fi } @@ -78,7 +78,7 @@ chroot_makepkg_conf_get() { chroot_makepkg_conf_set() { local key=$1 local val=$2 - sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf" + sed -i "/^$key=/d" "$copydir/etc/makepkg.conf" echo "$key='$val'" >> "$copydir/etc/makepkg.conf" } @@ -133,7 +133,7 @@ main() { CHROOTCOPY=$LIBREUSER [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy - makepkg_args=(-s --noconfirm -L) + makepkg_args='-s --noconfirm -L ' REPACKAGE=false MAKEPKG=makepkg @@ -142,14 +142,14 @@ main() { n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; m) MAKEPKG=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=(-R);; + R) REPACKAGE=true; makepkg_args+=' -R ';; h) usage; exit 0;; *) usage; exit 1;; esac done shift $(($OPTIND - 1)) # Pass all arguments after -- right to makepkg - makepkg_args+=("$@") + makepkg_args+=" $*" rootdir="${CHROOTDIR}/${CHROOT}/root" copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" @@ -176,7 +176,7 @@ main() { # OK, we're starting now ############################################### - lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'" + lock_open_write 9 "$copydir" "Locking chroot '$CHROOTCOPY'" # Set target CARCH as it might be used within the PKGBUILD to select correct sources chroot_makepkg_conf_get CARCH diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 1f2d185..cd279b8 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -37,6 +37,7 @@ chroot_extract() { rm -rf "$copydir"/build/* cp PKGBUILD "$copydir/build/" ( + set +euE source PKGBUILD # Copy source files diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot index 992c6e5..d3652a5 100755 --- a/src/chroot-tools/libremkchroot +++ b/src/chroot-tools/libremkchroot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -euE # libremkchroot # Copyright 2011, 2012 Luke Shumaker @@ -37,7 +37,7 @@ usage() { } main() { - archroot_args=(); + archroot_args=(-f); while getopts 'hC:M:' arg; do case "$arg" in C|M) archroot_args+=("-$arg" "$OPTARG");; @@ -59,7 +59,7 @@ main() { fi mkdir -p "${CHROOTDIR}/${CHROOT}" - archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${archroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}" } main "$@" diff --git a/src/libretools.conf b/src/libretools.conf index 20c7d90..91ec452 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -108,8 +108,8 @@ TORUPATH=/var/lib/libretools/toru ################################################################################ LIBREUSER="${SUDO_USER:-$USER}" -LIBREHOME="$(eval echo ~$SUDO_USER)" -if [[ -z $XDG_CONFIG_HOME ]]; then +LIBREHOME="$(eval echo ~$LIBREUSER)" +if [[ -z ${XDG_CONFIG_HOME:-} ]]; then export XDG_CONFIG_HOME="${LIBREHOME}/.config" fi if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then -- cgit v1.2.2 From 00c79846ae48dfbb08e7ecb1dfda9e16822a71ad Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 22:10:56 -0500 Subject: libretools.conf: change the default value of CHROOTDIR to match devtools --- src/libretools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretools.conf b/src/libretools.conf index 91ec452..37453e1 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -29,7 +29,7 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any') ################################################################################ ## The directory where the chroots are stored -CHROOTDIR=/home/chroot +CHROOTDIR=/var/lib/archbuild ## Extra packages to have installed on the chroot (besides base base-devel and sudo) CHROOTEXTRAPKG=(distcc ccache tsocks) ## The meaning of this changes based on the version of libretools+devtools -- cgit v1.2.2 From 09a60ac3ddb6763cbf1c9c783117c10bb1e1291e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Fri, 30 Nov 2012 02:31:34 -0300 Subject: Workflows documentation --- doc/workflows.markdown | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/workflows.markdown diff --git a/doc/workflows.markdown b/doc/workflows.markdown new file mode 100644 index 0000000..f55ae7e --- /dev/null +++ b/doc/workflows.markdown @@ -0,0 +1,60 @@ +# Workflows + +Describe your packaging workflow here! + + +## fauno's way + +During packaging, I don't usually restart a build from scratch if I have to +make changes to the PKGBUILD. I use a lot of commenting out commands already +ran, `makepkg -R`, etc. When I used `libremakepkg` I ended up using a lot more +`librechroot` and working from inside the unconfigured chroot, because +`makechrootpkg` (the underlying technology for `libremakepkg`) tries to be too +smart. + +When I started writing `treepkg` I found that mounting what I need directly on +the chroot and working from inside it was much more comfortable and simple than +having a makepkg wrapper doing funny stuff (for instance, mangling makepkg.conf +and breaking everything.) + +This is how the chroot is configured: + +* Create the same user (with same uid) on the chroot that the one I use regularly. + +* Give it password-less sudo on the chroot. + +* Bind mount /home to /chroot/home, where I have the abslibre-mips64el clone. + +* Bind mount /var/cache/pacman/pkg to /chroot/var/cache/pacman/pkg + +* Put these on system's fstab so I don't have to do it everytime + +* Configure makepkg.conf to PKGDEST=CacheDir and SRCDEST to something on my home. + +Workflow: + +* Enter the chroot with `systemd-nspawn -D/chroot` and `su - fauno`. + +* From another shell (I use tmux) edit the abslibre or search for updates with + `git log --no-merges --numstat`. + +* Pick a package and run `treepkg` from its dir on the chroot, or retake + a build with `treepkg /tmp/package-treepkg-xxxx`. (Refer to doc/treepkg + here). + +What this allows: + +* Not having to worry about the state of the chroot. `chcleanup` removes and + adds packages in a smart way so shared dependencies stay and others move + along (think of installing and removing qt for a complete kde rebuild). + +* Building many packages in a row without recreating a chroot for every one of + them. + +* Knowing that any change you made to the chroot stays as you want (no one + touches your makepkg.conf) + +* Hability to run regular commands, not through a chroot wrapper. I can `cd` to + a dir and use `makepkg -whatever` on it and nothing breaks. + +* No extra code spent on wrappers. -- cgit v1.2.2 From d602c1d5d462100313a2c6c47434c652444ba7fd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:07:48 -0500 Subject: move librechroot's sync into it's own file for licensing reasons --- src/chroot-tools/librechroot | 33 +++++--------------------------- src/chroot-tools/librechroot.gpl2 | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 src/chroot-tools/librechroot.gpl2 diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index d43ea2f..8e57004 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -22,34 +22,11 @@ . /etc/libretools.conf -## -# This function is almost verbatim from makechrootpkg -## -sync() { - if [[ $CHROOTCOPY = root ]]; then - error "Cannot sync the root copy with itself" - exit 1 - fi - - lock_open_read 8 "$rootdir" "Locking clean chroot" - - stat_busy 'Creating clean working copy' - local use_rsync=false - if type -P btrfs >/dev/null; then - [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null - btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || use_rsync=true - else - use_rsync=true - fi - - if $use_rsync; then - mkdir -p "$copydir" - rsync -a --delete -q -W -x "$CHROOTDIR/$CHROOT/root/" "$copydir" - fi - stat_done - - lock_close 8 -} +# This file (librechroot) is GPLv3+, but I would like to use some code +# modified from devtools' "makechrootpkg", which is GPLv2. +. "$(dirname "$0")/librechroot.gpl2" +# This gives us the functions: +# - sync cmd=${0##*/} usage() { diff --git a/src/chroot-tools/librechroot.gpl2 b/src/chroot-tools/librechroot.gpl2 new file mode 100644 index 0000000..6ba361f --- /dev/null +++ b/src/chroot-tools/librechroot.gpl2 @@ -0,0 +1,40 @@ +#!/bin/bash +# Contains code derived from devtools' "makechrootpkg" + +# Copyright 2011-2012 The Arch Linux Development Team +# Copyright 2012 Luke Shumaker +# +# This program 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; version 2 of the License. +# +# This program 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. + +sync() { + if [[ $CHROOTCOPY = root ]]; then + error "Cannot sync the root copy with itself" + exit 1 + fi + + lock_open_read 8 "$rootdir" "Locking clean chroot" + + stat_busy 'Creating clean working copy' + local use_rsync=false + if type -P btrfs >/dev/null; then + [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null + btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || use_rsync=true + else + use_rsync=true + fi + + if $use_rsync; then + mkdir -p "$copydir" + rsync -a --delete -q -W -x "$CHROOTDIR/$CHROOT/root/" "$copydir" + fi + stat_done + + lock_close 8 +} -- cgit v1.2.2 From 762e198c42dcd5b3da5c3a9dbe1006c7f85ec643 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:10:48 -0500 Subject: [librechroot] have -n set the CHROOT; rename the old -n to -m https://labs.parabola.nu/issues/252 --- src/chroot-tools/librechroot | 23 ++++++++++++++--------- src/chroot-tools/libremakepkg.gpl2 | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 8e57004..e93c57e 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -30,13 +30,14 @@ cmd=${0##*/} usage() { - echo "Usage: $cmd [OPTIONS] [CHROOT] " + echo "Usage: $cmd [OPTIONS] " echo 'Interacts with a chroot.' echo '' echo "The default CHROOT is \`${CHROOT}'." echo '' echo 'Options:' echo ' Settings:' + echo " -n Use this chroot instead of \`$CHROOT'" echo ' -l Use this as the chroot copy instead of basing it' echo ' on the username' echo ' -N Disable networking in the chroot' @@ -46,7 +47,7 @@ usage() { echo ' -c Clean the packages installed in the chroot' echo ' -I Install the package FILE into the chroot' echo ' -i Install the package PKG from repos into the chroot' - echo ' -n No-op, just make sure that the chroot exists' + echo ' -m Make sure the chroot exists; do nothing else' echo ' -r Run CMD in the chroot' echo " -s Sync the copy with the 'root' copy" echo ' -u Update the chroot' @@ -60,8 +61,9 @@ main() { local mode=enter local archroot_args=(-f) local ARG='' - while getopts 'l:NCcI:i:nrsuh' arg; do + while getopts 'n:l:NCcI:i:mrsuh' arg; do case $arg in + n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; N) archroot_args+=(-N);; @@ -69,7 +71,7 @@ main() { c) mode=clean_pacman;; I) mode=install_file; ARG=$OPTARG;; i) mode=install_pkg; ARG=$OPTARG;; - n) mode=noop;; + m) mode=noop;; r) mode=run; ARG=$OPTARG;; s) mode=sync;; u) mode=update;; @@ -79,16 +81,17 @@ main() { esac done shift $(($OPTIND - 1)) - case $# in - 0) :;; - 1) CHROOT="$1";; - *) usage; exit 1;; - esac + if [[ $# > 0 ]]; then + usage + exit 1 + fi # not local rootdir="${CHROOTDIR}/${CHROOT}/root" copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}" + ######################################################################## + if (( EUID )); then error "This script must be run as root." exit 1 @@ -106,6 +109,8 @@ main() { sync fi + ######################################################################## + case "$mode" in clean_repo) msg "Cleaning local pacman repository" diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index cd279b8..bc8a9be 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -14,8 +14,8 @@ # GNU General Public License for more details. chroot_init() { - # no-op; make sure the chroot exists - librechroot -n -l "$CHROOTCOPY" "$CHROOT" + # make sure the chroot exists + librechroot -n "$CHROOT" -l "$CHROOTCOPY" -m if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg" -- cgit v1.2.2 From a7b7e36af2ca02449770cb77c5f017d638872d8e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:11:38 -0500 Subject: libretools.conf: force SIGEXT and SIGID to be set https://labs.parabola.nu/issues/154 --- src/libretools.conf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index 37453e1..747d28c 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -44,8 +44,7 @@ CHROOT=default WORKDIR=/home/$USER/packages ## Package signing -# Leave commented to disable signing -#SIGEXT=".sig" +SIGEXT=".sig" #SIGID="0xYOURID" ## Parabola hostname @@ -119,7 +118,7 @@ fi ret=0 for VAR in CHROOTDIR CHROOT PARABOLAHOST LIBREDESTDIR \ BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \ - COMMITCMD DIFFTOOL FULLBUILDCMD; do + COMMITCMD DIFFTOOL FULLBUILDCMD SIGEXT SIGID; do if [[ -z ${!VAR} ]]; then echo "Configure $VAR var in /etc/libretools.conf" -- cgit v1.2.2 From b9dbed0ae6709351dd244c87581c2d558a9d129f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:12:37 -0500 Subject: libremakepkg: fix bug in makepkg_conf_get --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index f06bb17..deb26b2 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -65,7 +65,7 @@ makepkg_conf_get() { if [[ -z ${!setting:-} ]]; then eval $(grep "^$setting=" "/etc/makepkg.conf") fi - if [[ -z ${!setting:-} && -n ${2} ]]; then + if [[ -z ${!setting:-} && -n ${2:-} ]]; then eval "$setting='$2'" fi } -- cgit v1.2.2 From b81efba931aae92fa7cfafb0f2d070ba203a86f2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:14:26 -0500 Subject: libremakepkg: forget -R --- src/chroot-tools/libremakepkg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index deb26b2..4b49931 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -122,7 +122,6 @@ usage() { echo ' on the username' echo '' echo " -m Use the command MAKEPKG instead of 'makepkg'" - echo " -R Repackage" echo '' echo ' -h Show this message' } @@ -134,7 +133,6 @@ main() { [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy makepkg_args='-s --noconfirm -L ' - REPACKAGE=false MAKEPKG=makepkg while getopts 'n:l:m:Rh' arg ; do @@ -142,7 +140,6 @@ main() { n) CHROOT=$OPTARG;; l) CHROOTCOPY=$OPTARG;; m) MAKEPKG=$OPTARG;; - R) REPACKAGE=true; makepkg_args+=' -R ';; h) usage; exit 0;; *) usage; exit 1;; esac @@ -183,11 +180,13 @@ main() { export CARCH chroot_init + libre_check_pkgbuild - $REPACKAGE || chroot_extract + chroot_extract libre_check_src chroot_build libre_check_pkg + copy_pkgs copy_logs } -- cgit v1.2.2 From de74c8b50e734128f4641a20e3c4812713366f40 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 16:14:49 -0500 Subject: libremakepkg: match makepkg's error message if PKGBUILD does not exist --- src/chroot-tools/libremakepkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 4b49931..4e810d1 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -159,7 +159,8 @@ main() { fi if [[ ! -f PKGBUILD ]]; then - error "This must be run in a directory containing a PKGBUILD" + # This is the message used by makepkg + error "PKGBUILD does not exist" exit 1 fi -- cgit v1.2.2 From 42d3216254bb31c7a43c64df3b51bbb05c57cbd4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 18:27:00 -0500 Subject: libremakepkg: autoclean before building --- src/chroot-tools/libremakepkg.gpl2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index bc8a9be..1077b66 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -65,11 +65,13 @@ chroot_extract() { chown -R nobody "$copydir"/{build,pkgdest,srcdest} + cp -a "$(which chcleanup)" "${copydir}/clean" local file="$copydir/chrootextract" echo '#!/bin/bash' > "$file" echo '. /etc/profile' >> "$file" echo 'export HOME=/build' >> "$file" echo 'cd /build' >> "$file" + echo '/clean' >> "$file" echo "sudo -u nobody ${MAKEPKG} $makepkg_args -o" >> "$file" chmod 755 "$file" archroot "$copydir" -r /chrootextract -- cgit v1.2.2 From 63467291c9890288e983abae3c72e112aa028c66 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 18:27:24 -0500 Subject: librechroot: use PATH to find chcleanup --- src/chroot-tools/librechroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index e93c57e..6594f15 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -121,7 +121,7 @@ main() { ;; clean_pacman) msg "Intelligently cleaning packages" - cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" + cp -a "$(which chcleanup)" "${copydir}/clean" echo '#!/bin/bash' > "${copydir}/cleanstrap" echo 'mkdir /build' >> "${copydir}/cleanstrap" echo 'cd /build; /clean' >> "${copydir}/cleanstrap" -- cgit v1.2.2 From 098d7430e6447c4658704c3bcf88ea1ed7a5206b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Nov 2012 18:27:47 -0500 Subject: libretools.conf: fix FULLBUILDCMD --- src/libretools.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libretools.conf b/src/libretools.conf index 747d28c..5e45350 100644 --- a/src/libretools.conf +++ b/src/libretools.conf @@ -77,9 +77,9 @@ COMMITCMD=git ## Uncomment one of those or make one of your choice # Normal fullpkg -FULLBUILDCMD="sudo libremakepkg -cuN" +FULLBUILDCMD="sudo libremakepkg" # Cross compiling fullkpg -# FULLBUILDCMD="sudo libremakepkg -cuN -d '/path/to/cross-compiling/chroot'" +# FULLBUILDCMD="sudo libremakepkg -n cross-compile-chroot" # Build from within the chroot (or host system) # FULLBUILDCMD="makepkg -sL --noconfirm" -- cgit v1.2.2