summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rwxr-xr-xsrc/abslibre-tools/librerelease16
-rwxr-xr-xsrc/abslibre-tools/librestage60
-rwxr-xr-xsrc/aur74
-rwxr-xr-xsrc/is_built6
-rw-r--r--src/lib/conf.sh2
-rwxr-xr-xsrc/lib/libreblacklist7
-rw-r--r--src/libretools.conf26
-rwxr-xr-xsrc/pkgbuild-check-licenses4
-rwxr-xr-xsrc/pkgbuild-check-nonfree7
-rw-r--r--test/is_built-test.sh9
-rw-r--r--test/lib-blacklist-test.sh49
12 files changed, 161 insertions, 100 deletions
diff --git a/AUTHORS b/AUTHORS
index 6ab8015..747e012 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
Joshua Haase
Nicolás Reynolds
+Luke Shumaker
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
index 5adb013..ed7f70c 100755
--- a/src/abslibre-tools/librerelease
+++ b/src/abslibre-tools/librerelease
@@ -76,10 +76,9 @@ create_signature() {
if (( ! ret )); then
msg2 "$(gettext "Created signature file %s.")" "$filename.sig"
else
- warning "$(gettext "Failed to sign package file.")"
+ error "$(gettext "Failed to sign package file.")"
+ return $ret
fi
-
- return $ret
}
function sign_packages {
@@ -163,10 +162,12 @@ function main {
}
function release_packages {
- [[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}"
+ if [[ -n $HOOKPRERELEASE ]]; then
+ msg "Running HOOKPRERELEASE..."
+ bash -c "${HOOKPRERELEASE}"
+ fi
clean_non_packages
- # Sign packages or fail
sign_packages || return 1
# Make the permissions of the packages 644 otherwise the user will get access
@@ -200,7 +201,10 @@ function release_packages {
msg "Running db-update on repos"
ssh ${REPODEST%%:*} dbscripts/db-update
- [[ ! -z ${HOOKPOSTRELEASE} ]] && bash -c "${HOOKPOSTRELEASE}"
+ if [[ -n $HOOKPOSTRELEASE ]]; then
+ msg "Running HOOKPOSTRELEASE..."
+ bash -c "${HOOKPOSTRELEASE}"
+ fi
return 0
}
diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage
index e209beb..16dc772 100755
--- a/src/abslibre-tools/librestage
+++ b/src/abslibre-tools/librestage
@@ -58,48 +58,44 @@ main() {
}
# Load configuration
-
load_files libretools
- check_vars libretools WORKDIR || return 1
-
- load_files makepkg
+ check_vars libretools WORKDIR ARCHES || return 1
# Load the PKGBUILD
source ./PKGBUILD
- if [[ $arch == 'any' ]]; then
- CARCH='any'
- fi
# Now for the main routine.
staged=false
- for _pkgname in "${pkgname[@]}"; do
- pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT}
- pkgpath="$(find . "$PKGDEST" -maxdepth 1 -type f -name "$pkgfile"|sed 1q)"
-
- if [[ ! -f "${pkgpath}" ]]; then
- continue
- else
- pkgpath="$(readlink -f "$pkgpath")"
- fi
+ for CARCH in "${ARCHES[@]}" any; do
+ for _pkgname in "${pkgname[@]}"; do
+ pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT}
+ pkgpath="$(find . "$PKGDEST" -maxdepth 1 -type f -name "$pkgfile"|sed 1q)"
- msg "Found ${pkgfile}"
-
- canonical="" # is empty for the first iteration, set after that
- for repo in "${repos[@]}"; do
- mkdir -p "${WORKDIR}/staging/${repo}"
- if [[ -z $canonical ]]; then
- canonical="${WORKDIR}/staging/${repo}/${pkgfile}"
- cmd=(cp "$pkgpath" "$canonical")
- else
- cmd=(ln "$canonical" "${WORKDIR}/staging/${repo}/${pkgfile}")
- fi
- if "${cmd[@]}"; then
- msg2 "%s staged on [%s]" "$_pkgname" "$repo"
- staged=true
+ if [[ ! -f "${pkgpath}" ]]; then
+ continue
else
- error "Can't put %s on [%s]" "$_pkgname" "$repo"
- return 1
+ pkgpath="$(readlink -f "$pkgpath")"
fi
+
+ msg "Found ${pkgfile}"
+
+ canonical="" # is empty for the first iteration, set after that
+ for repo in "${repos[@]}"; do
+ mkdir -p "${WORKDIR}/staging/${repo}"
+ if [[ -z $canonical ]]; then
+ canonical="${WORKDIR}/staging/${repo}/${pkgfile}"
+ cmd=(cp "$pkgpath" "$canonical")
+ else
+ cmd=(ln "$canonical" "${WORKDIR}/staging/${repo}/${pkgfile}")
+ fi
+ if "${cmd[@]}"; then
+ msg2 "%s staged on [%s]" "$_pkgname" "$repo"
+ staged=true
+ else
+ error "Can't put %s on [%s]" "$_pkgname" "$repo"
+ return 1
+ fi
+ done
done
done
diff --git a/src/aur b/src/aur
index 86b93e6..e4c535c 100755
--- a/src/aur
+++ b/src/aur
@@ -47,51 +47,66 @@ main() {
load_files libretools
check_vars libretools DIFFTOOL || exit 1
+ local startdir="$(pwd)"
local missing_deps=()
local ret=0
- for _pkg in "$@"; do
-
- # Remove the version
- _pkg="${_pkg%%[<>=]*}"
-
- if [[ -f "${_pkg}/PKGBUILD" ]]; then
- warning "${_pkg} already existed."
+ local pkg
+ local copy_new
+ local copy_old
+ for pkg in "$@"; do
+ pkg="${pkg%%[<>=]*}" # remove the version
+ msg "Processing package: %s" "$pkg"
+ copy_new="$startdir/$pkg"
+ copy_old=
+
+ if [[ -f "${copy_new}/PKGBUILD" ]]; then
+ warning "%s already exists, will compare with new version." "$pkg"
# Store our copy of the PKGBUILD dir
- _diff="${PWD}/${_pkg}"
- pushd $(mktemp --tmpdir -d ${_pkg}.XXXX) &>/dev/null
- msg2 "Downloading PKGBUILD into ${PWD} for diff"
+ copy_old=$copy_new
+ copy_new="$(mktemp --tmpdir -d aur-${pkg}.new.XXXX)/$pkg"
+ cd "${copy_new%/*}"
fi
- msg "Downloading $_pkg..."
- local url=https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz
+ msg2 "Downloading"
+ local url="https://aur.archlinux.org/packages/${pkg:0:2}/$pkg/$pkg.tar.gz"
set -o pipefail
- if ! wget -O- "$url" | bsdtar xf -; then
+ if ! wget -O- -q "$url" | bsdtar xf -; then
ret=$(($ret|2))
- error "Couldn't get $_pkg"
+ error "Couldn't get %s" "$pkg"
continue
fi
set +o pipefail
- pushd $_pkg &>/dev/null
-
- if [[ ! -z $_diff ]]; then
+ if [[ -n $copy_old ]]; then
msg2 "Diffing files"
+ cd "$copy_new"
+
# Diff all files with our difftool
+ local diffed=false
for file in *; do
- "${DIFFTOOL}" "${_diff}/${file}" "${file}"
+ if ! cmp -s "${copy_old}/${file}" "${copy_new}/${file}" ; then
+ warning "%s != %s" "${copy_old}/${file}" "${copy_new}/${file}"
+ diffed=true
+ "${DIFFTOOL}" "${copy_old}/${file}" "${copy_new}/${file}"
+ fi
done
- read -p "Press enter to continue."
+ if $diffed; then
+ read -p "Press enter to continue."
+ fi
# Go back to our copy to continue working
- pushd "${_diff}" &>/dev/null
+ cd "$copy_old"
+ rm -rf -- "${copy_new%/*}"
+ else
+ cd "$copy_new"
fi
. PKGBUILD
################################################################
- pkgbuild-check-nonfree
+ pkgbuild-check-nonfree -c
case $? in
0) :;;
15) warning "This PKGBUILD links to known unfree packages";;
@@ -103,7 +118,7 @@ main() {
local s=0
pkgbuild-check-licenses || s=$?
for i in 1 2 4; do
- if [[ $s -eq $(($s & $i)) ]]; then
+ if [[ $i -eq $(($s & $i)) ]]; then
case $i in
1) warning "pkgbuild-check-licenses encountered an error";;
2) warning "This PKGBUILD has an uncommon license";;
@@ -115,31 +130,32 @@ main() {
################################################################
- _deps=(
+ local _deps=(
# depends
"${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"
# mksource depends
"${mkdepends[@]}" "${mkmakedepends[@]}" "${mkcheckdepends[@]}"
)
+ local _dep
+ msg2 "Checking dependencies"
for _dep in "${_deps[@]}"; do
_dep=${_dep/[<>=]*/}
if ! is_built $_dep; then
if ! pacman -Sddp "$_dep" &>/dev/null ; then
- msg2 "$_dep will be get from AUR"
+ plain "%s: will be downloaded from AUR" "$_dep"
missing_deps+=($_dep)
fi
else
- msg2 "$_dep is on repos"
+ plain "%s: is on repos" "$_dep"
fi
done
-
- popd &>/dev/null
+ cd "$startdir"
done
if [[ ${#missing_deps[*]} -gt 0 ]]; then
- msg2 "Retrieving missing deps: %s" "${missing_deps[*]}"
+ msg "Retrieving missing deps: %s" "${missing_deps[*]}"
"$0" "${missing_deps[@]}"
- ret=$(($ret|2))
+ ret=$(($ret|$?))
fi
return $ret;
}
diff --git a/src/is_built b/src/is_built
index e6797fd..a1da507 100755
--- a/src/is_built
+++ b/src/is_built
@@ -2,7 +2,7 @@
cmd=${0##*/}
usage() {
- echo "Usage: $cmd [-h] pkgname pkgver"
+ echo "Usage: $cmd [-h] pkgname [pkgver]"
echo
echo "Detect if a given package version is already in repos"
echo "Assuming you want greater or equal."
@@ -21,13 +21,13 @@ while getopts 'h' arg; do
*) usage >&2; exit 2 ;;
esac
done
-if [[ $# != 2 ]]; then
+if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
usage >&2
exit 2
fi
pkg=${1}
-ver=${2}
+ver=${2:-0}
pver=$(LC_ALL=C pacman -Sddp --print-format '%v' "${pkg}" 2>/dev/null)
# if pacman fails or returns nothing
diff --git a/src/lib/conf.sh b/src/lib/conf.sh
index 67aeb96..840e908 100644
--- a/src/lib/conf.sh
+++ b/src/lib/conf.sh
@@ -93,7 +93,7 @@ load_files() {
# Load the files
for file in $(list_files $slug); do
if [[ -r $file ]]; then
- . "$file"
+ . "$file" || return 1
fi
done
diff --git a/src/lib/libreblacklist b/src/lib/libreblacklist
index 5cfb410..fb8b43a 100755
--- a/src/lib/libreblacklist
+++ b/src/lib/libreblacklist
@@ -40,10 +40,9 @@ blacklist-cat() {
# Usage: blacklist-update
# Updates (or creates) the cached copy of the blacklist
blacklist-update() (
- set -euE # allow it to not be set globally
. libremessages
- load_files libretools
- check_vars libretools BLACKLIST
+ load_files libretools || return 1
+ check_vars libretools BLACKLIST || return 1
local remote_blacklist="$BLACKLIST"
local local_blacklist="$XDG_CACHE_HOME/libretools/blacklist.txt"
@@ -53,7 +52,7 @@ blacklist-update() (
mkdir -p "${local_blacklist%/*}"
if wget -N -q -O "${local_blacklist}.part" "$remote_blacklist" 2>/dev/null; then
stat_done
- mv "${local_blacklist}.part" "$local_blacklist"
+ mv -f "${local_blacklist}.part" "$local_blacklist"
else
stat_done
rm "${local_blacklist}.part"
diff --git a/src/libretools.conf b/src/libretools.conf
index 78e6fb8..593aed6 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -4,12 +4,15 @@
# misc #
################################################################################
+# The dir where you work on
+WORKDIR=/home/$LIBREUSER/packages
+
## Blacklist URL
BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt
## Diff tool (vimdiff, gvimdiff, meld, etc)
## Used by `aur`, `diff-unfree`
-DIFFTOOL=`which vimdiff gvimdiff meld colordiff diff 2>/dev/null|sed 's/\s.*//;1q'`
+DIFFTOOL=`which kdiff3 meld gvimdiff vimdiff colordiff diff 2>/dev/null|sed 's/\s.*//;1q'`
## The repos you'll be packaging for
## Used by `toru`, `createworkdir`
@@ -19,29 +22,28 @@ DIFFTOOL=`which vimdiff gvimdiff meld colordiff diff 2>/dev/null|sed 's/\s.*//;1
# 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 you'll be packaging for
+## Used by `librestage`
+ARCHES=('x86_64' 'i686' 'mips64el')
+
+## ABSLibre
+#ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git
+ABSLIBREGIT=ssh://git@projects.parabolagnulinux.org:1863/srv/git/abslibre.git
+
################################################################################
-# abslibre #
+# librerelease #
################################################################################
-# The dir where you work on
-WORKDIR=/home/$LIBREUSER/packages
-
## Where to upload packages to
# Don't change unless you know what you're doing and you won't screw
# anything ;)
REPODEST=repo@repo:/srv/http/repo/public
## Assumes something similar in your .ssh/config:
-
# Host repo
# Port 1863
# HostName repo.parabolagnulinux.org
-## ABSLibre
-ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git
-#ABSLIBREGIT=ssh://git@projects.parabolagnulinux.org:1863/srv/git/abslibre.git
-
-# Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.)
-# This is called by librerelease.
+## These are run before and after uploading packages
HOOKPRERELEASE="ssh -fN ${REPODEST%%:*}"
HOOKPOSTRELEASE="sudo librechroot clean-repo"
diff --git a/src/pkgbuild-check-licenses b/src/pkgbuild-check-licenses
index 8b8f703..846a6e4 100755
--- a/src/pkgbuild-check-licenses
+++ b/src/pkgbuild-check-licenses
@@ -122,11 +122,9 @@ main() {
return 1
fi
- blacklist-update || return $_E_ERROR
-
local ret=0
for pkgbuild in "${pkgbuilds[@]}"; do
- check_deps "$pkgbuild" || ret=$(($ret|$?))
+ check_licenses "$pkgbuild" || ret=$(($ret|$?))
done
return $ret
}
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index 92496be..0f1f6ff 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -87,14 +87,17 @@ usage() {
echo " 15: Depends on non-free packages"
echo ''
echo "Options:"
+ echo ' -c Use the cached blacklist, do not try downloading.'
echo ' -f Allow running as root user'
echo ' -h Show this message'
}
main() {
local asroot=false
- while getopts 'fh' arg; do
+ local cache=false
+ while getopts 'cfh' arg; do
case "$arg" in
+ c) cache=true;;
f) asroot=true;;
h) usage; return 0;;
*) usage; return 1;;
@@ -112,7 +115,7 @@ main() {
return 1
fi
- blacklist-update || return 1
+ $cache || blacklist-update || return 1
local ret=0
for pkgbuild in "${pkgbuilds[@]}"; do
diff --git a/test/is_built-test.sh b/test/is_built-test.sh
index bcd46f5..04b17cd 100644
--- a/test/is_built-test.sh
+++ b/test/is_built-test.sh
@@ -21,17 +21,16 @@ it_displays_help() {
it_fails_with_0_args() {
is_built >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
- [[ $stat > 1 ]]
+ [[ $stat -gt 1 ]]
[[ -z "$(cat $tmpdir/stdout)" ]]
[[ -n "$(cat $tmpdir/stderr)" ]]
}
-it_fails_with_1_arg() {
- is_built sh >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+it_succeeds_with_1_arg() {
+ is_built sh >$tmpdir/stdout 2>$tmpdir/stderr
- [[ $stat > 1 ]]
[[ -z "$(cat $tmpdir/stdout)" ]]
- [[ -n "$(cat $tmpdir/stderr)" ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
}
it_returns_1_for_non_existent_package() {
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 1432ff6..049a2a7 100644
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -2,13 +2,14 @@
describe libreblacklist
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-libreblacklist.XXXXXXXXXXXX)
- stat=0
+ _before
}
after() {
- rm -rf -- "$tmpdir" "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME"
+ _after
}
it_works_with_just_pkgname() {
@@ -66,6 +67,48 @@ it_fails_cat_when_there_is_no_blacklist_or_network() {
[[ -n "$(cat $tmpdir/stderr)" ]]
}
+it_fails_update_when_BLACKLIST_is_unset() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_cat_when_syntax_error_in_conf() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ # there is a stray single quote in there
+ echo "BLACKLIST='https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_downloads_the_blacklist_as_needed() {
+ require network || return 0
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ -n "$(cat $tmpdir/stdout)" ]]
+}
+
+it_downloads_the_blacklist_repeatedly() {
+ require network || return 0
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist update
+ libreblacklist update
+}
+
it_displays_help_and_fails_with_no_args() {
libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?