summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config6
-rwxr-xr-xcron-jobs/check_archlinux/check_packages.py8
-rwxr-xr-xcron-jobs/check_archlinux/parse_pkgbuilds.sh2
-rwxr-xr-xcron-jobs/devlist-mailer6
-rwxr-xr-xcron-jobs/ftpdir-cleanup20
-rwxr-xr-xcron-jobs/integrity-check2
-rwxr-xr-xcron-jobs/sourceballs12
-rw-r--r--db-functions119
-rwxr-xr-xdb-import-pkg86
-rwxr-xr-xdb-move20
-rwxr-xr-xdb-remove6
-rwxr-xr-xdb-repo-add4
-rwxr-xr-xdb-repo-remove4
-rwxr-xr-xdb-update23
-rw-r--r--test/cases/common.bats10
-rwxr-xr-xtest/cases/db-repo-add.bats6
-rwxr-xr-xtest/cases/db-update.bats5
-rwxr-xr-xtest/cases/ftpdir-cleanup.bats6
-rw-r--r--test/lib/common.bash10
19 files changed, 169 insertions, 186 deletions
diff --git a/config b/config
index 43c9776..83131fb 100644
--- a/config
+++ b/config
@@ -22,13 +22,11 @@ SOURCE_CLEANUP_KEEP=30
LOCK_DELAY=10
[ -n "${STAGING:-}" ] || STAGING="$HOME/staging/unknown/staging"
-#export TMPDIR="/tmp"
-export TMPDIR=/srv/repo/tmp
-mkdir -p "$TMPDIR"
+export TMPDIR="/tmp"
ARCHES=(x86_64 i686 armv7h)
DBEXT=".db.tar.gz"
FILESEXT=".files.tar.gz"
-PKGEXT=".pkg.tar.?z"
+PKGEXTS=".pkg.tar.?z"
SRCEXT=".src.tar.gz"
# Where to send error emails, and who they are from
diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py
index d233bf6..a77b7ba 100755
--- a/cron-jobs/check_archlinux/check_packages.py
+++ b/cron-jobs/check_archlinux/check_packages.py
@@ -366,15 +366,15 @@ def print_usage():
print "Options:"
print " --abs-tree=<path[,path]> Check the specified tree(s) (default : /var/abs)"
print " --repos=<r1,r2,...> Check the specified repos (default : core,extra)"
- print " --arch=<i686|x86_64> Check the specified arch (default : i686)"
+ print " --arch=<i686|x86_64> Check the specified arch (default : x86_64)"
print " --repo-dir=<path> Check the dbs at the specified path (default : /srv/ftp)"
print " -h, --help Show this help and exit"
print ""
print "Examples:"
print "\n Check core and extra in existing abs tree:"
- print " ./check_packages.py --abs-tree=/var/abs --repos=core,extra --arch=i686"
+ print " ./check_packages.py --abs-tree=/var/abs --repos=core,extra --arch=x86_64"
print "\n Check community:"
- print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=i686"
+ print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=x86_64"
print ""
if __name__ == "__main__":
@@ -383,7 +383,7 @@ if __name__ == "__main__":
## Default list of repos to check
repos = ['core', 'extra']
## Default arch
- arch = "i686"
+ arch = "x86_64"
## Default repodir
repodir = "/srv/ftp"
diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
index b857ac8..c6d6944 100755
--- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh
+++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Usage : parse_pkgbuilds.sh arch <pkgbuilds_dir1,dir2,...>
-# Example : parse_pkgbuilds.sh i686 /var/abs/core /var/abs/extra
+# Example : parse_pkgbuilds.sh x86_64 /var/abs/core /var/abs/extra
exit() { return; }
diff --git a/cron-jobs/devlist-mailer b/cron-jobs/devlist-mailer
index 7f298b9..578d23e 100755
--- a/cron-jobs/devlist-mailer
+++ b/cron-jobs/devlist-mailer
@@ -6,17 +6,17 @@
. "$(dirname "$(readlink -e "$0")")/../config"
SUBJECT="Repository Maintenance $(date +"%d-%m-%Y")"
-if [ $# -ge 1 ]; then
+if (( $# >= 1 )); then
SUBJECT="$1 $(date +"%d-%m-%Y")"
fi
-if [ $# -ge 2 ]; then
+if (( $# >= 2 )); then
LIST="$2"
fi
stdin="$(cat)"
#echo used to strip whitespace for checking for actual data
-if [ -n "$(echo $stdin)" ]; then
+if [[ -n "$(echo $stdin)" ]]; then
echo "Subject: $SUBJECT
To: $LIST
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 6c4873d..fe96266 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -9,11 +9,11 @@ clean_pkg() {
if ! "${CLEANUP_DRYRUN}"; then
for pkg in "$@"; do
- if [ -h "$pkg" ]; then
+ if [[ -h $pkg ]]; then
rm -f "$pkg" "$pkg.sig"
else
mv_acl "$pkg" "$CLEANUP_DESTDIR/${pkg##*/}"
- if [ -e "$pkg.sig" ]; then
+ if [[ -e $pkg.sig ]]; then
mv_acl "$pkg.sig" "$CLEANUP_DESTDIR/${pkg##*/}.sig"
fi
touch "${CLEANUP_DESTDIR}/${pkg##*/}"
@@ -34,16 +34,16 @@ done
for repo in "${PKGREPOS[@]}"; do
for arch in "${ARCHES[@]}"; do
- if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then
+ if [[ ! -f ${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT} ]]; then
continue
fi
# get a list of actual available package files
- find "${FTP_BASE}/${repo}/os/${arch}" -xtype f -name "*${PKGEXT}" -printf '%f\n' | sort > "${WORKDIR}/repo-${repo}-${arch}"
+ find "${FTP_BASE}/${repo}/os/${arch}" -xtype f -name "*${PKGEXTS}" -printf '%f\n' | sort > "${WORKDIR}/repo-${repo}-${arch}"
# get a list of package files defined in the repo db
bsdtar -xOf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" | awk '/^%FILENAME%/{getline;print}' | sort > "${WORKDIR}/db-${repo}-${arch}"
missing_pkgs=($(comm -13 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}"))
- if [ ${#missing_pkgs[@]} -ge 1 ]; then
+ if (( ${#missing_pkgs[@]} >= 1 )); then
error "Missing packages in [%s] (%s)..." "$repo" "$arch"
for missing_pkg in "${missing_pkgs[@]}"; do
msg2 '%s' "${missing_pkg}"
@@ -51,7 +51,7 @@ for repo in "${PKGREPOS[@]}"; do
fi
old_pkgs=($(comm -23 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}"))
- if [ ${#old_pkgs[@]} -ge 1 ]; then
+ if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from [%s] (%s)..." "$repo" "$arch"
for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
@@ -62,12 +62,12 @@ for repo in "${PKGREPOS[@]}"; do
done
# get a list of all available packages in the pacakge pool
-find "$FTP_BASE/${PKGPOOL}" -name "*${PKGEXT}" -printf '%f\n' | sort > "${WORKDIR}/pool"
+find "$FTP_BASE/${PKGPOOL}" -name "*${PKGEXTS}" -printf '%f\n' | sort > "${WORKDIR}/pool"
# create a list of packages in our db
find "${WORKDIR}" -maxdepth 1 -type f -name 'db-*' -exec cat {} \; | sort -u > "${WORKDIR}/db"
old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db"))
-if [ ${#old_pkgs[@]} -ge 1 ]; then
+if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from package pool..."
for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
@@ -75,8 +75,8 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then
done
fi
-old_pkgs=($(find "${CLEANUP_DESTDIR}" -type f -name "*${PKGEXT}" -mtime +"${CLEANUP_KEEP}" -printf '%f\n'))
-if [ ${#old_pkgs[@]} -ge 1 ]; then
+old_pkgs=($(find "${CLEANUP_DESTDIR}" -type f -name "*${PKGEXTS}" -mtime +"${CLEANUP_KEEP}" -printf '%f\n'))
+if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from the cleanup directory..."
for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check
index 7459380..5d9d0d0 100755
--- a/cron-jobs/integrity-check
+++ b/cron-jobs/integrity-check
@@ -7,7 +7,7 @@ dirname="$(dirname "$(readlink -e "$0")")"
script_lock
-if [ $# -ne 1 ]; then
+if (( $# != 1 )); then
die "usage: %s <mailto>" "${0##*/}"
fi
mailto=$1
diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index 67a5fe5..062a1be 100755
--- a/cron-jobs/sourceballs
+++ b/cron-jobs/sourceballs
@@ -21,7 +21,7 @@ renice +10 -p $$ > /dev/null
for repo in "${PKGREPOS[@]}"; do
for arch in "${ARCHES[@]}"; do
# Repo does not exist; skip it
- if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then
+ if [[ ! -f ${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT} ]]; then
continue
fi
bsdtar -xOf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" \
@@ -77,7 +77,7 @@ for repo in "${PKGREPOS[@]}"; do
mkdir -p -m0770 "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}"
cp -a "$(xbs releasepath "${pkgbase}" "${repo}" "${pkgarch}")" \
"${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null 2>&1
- if [ $? -ge 1 ]; then
+ if (( $? >= 1 )); then
failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}")
continue
fi
@@ -85,7 +85,7 @@ for repo in "${PKGREPOS[@]}"; do
# Build the actual source package
pushd "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null
SRCPKGDEST=. makepkg --nocolor --allsource --ignorearch --skippgpcheck >"${WORKDIR}/${pkgbase}.log" 2>&1
- if [ $? -eq 0 ] && [ -f "${pkgbase}-${pkgver}${SRCEXT}" ]; then
+ if (( $? == 0 )) && [[ -f ${pkgbase}-${pkgver}${SRCEXT} ]]; then
mv_acl "${pkgbase}-${pkgver}${SRCEXT}" "${FTP_BASE}/${SRCPOOL}/${pkgbase}-${pkgver}${SRCEXT}"
# Avoid creating the same source package for every arch
echo "${pkgbase}-${pkgver}${SRCEXT}" >> "${WORKDIR}/available-src-pkgs"
@@ -117,7 +117,7 @@ find "${WORKDIR}" -maxdepth 1 -type f -name 'expected-src-pkgs' -exec cat {} \;
find "${WORKDIR}" -maxdepth 1 -type f -name 'available-src-pkgs' -exec cat {} \; | sort -u > "${WORKDIR}/available-src-pkgs.sort"
old_pkgs=($(comm -23 "${WORKDIR}/available-src-pkgs.sort" "${WORKDIR}/expected-src-pkgs.sort"))
-if [ ${#old_pkgs[@]} -ge 1 ]; then
+if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old source packages..."
"${SOURCE_CLEANUP_DRYRUN}" && warning 'dry run mode is active'
for old_pkg in "${old_pkgs[@]}"; do
@@ -130,7 +130,7 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then
fi
old_pkgs=($(find "${SOURCE_CLEANUP_DESTDIR}" -type f -name "*${SRCEXT}" -mtime +"${SOURCE_CLEANUP_KEEP}" -printf '%f\n'))
-if [ ${#old_pkgs[@]} -ge 1 ]; then
+if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old source packages from the cleanup directory..."
for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
@@ -138,7 +138,7 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then
done
fi
-if [ -f "${WORKDIR}/makepkg-fail.log" ]; then
+if [[ -f ${WORKDIR}/makepkg-fail.log ]]; then
msg "Log of failed packages"
cat "${WORKDIR}/makepkg-fail.log"
fi
diff --git a/db-functions b/db-functions
index 6aaab98..f78ade8 100644
--- a/db-functions
+++ b/db-functions
@@ -6,8 +6,7 @@ CARCH=$(. "$(librelib conf.sh)"; load_conf makepkg.conf; echo "$CARCH")
# Useful functions
UMASK=""
set_umask () {
- [ "$UMASK" == "" ] && UMASK="$(umask)"
- export UMASK
+ export UMASK="${UMASK:-$(umask)}"
umask 002
}
@@ -26,7 +25,7 @@ mv_acl() {
# set up general environment
WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX")
-if [ -n "${SVNUSER}" ]; then
+if [[ -n ${SVNUSER} ]]; then
setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}"
setfacl -m d:u:"${USER}":rwx "${WORKDIR}"
setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}"
@@ -56,7 +55,7 @@ script_lock() {
script_unlock() {
local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}"
- if [ ! -d "$LOCKDIR" ]; then
+ if [[ ! -d $LOCKDIR ]]; then
warning "Script %s was not locked!" "${0##*/}"
restore_umask
return 1
@@ -76,12 +75,12 @@ cleanup() {
for l in "${LOCKS[@]}"; do
repo=${l%.*}
arch=${l#*.}
- if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then
+ if [[ -d $TMPDIR/.repolock.$repo.$arch ]]; then
msg "Removing left over lock from [%s] (%s)" "$repo" "$arch"
repo_unlock "$repo" "$arch"
fi
done
- if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then
+ if [[ -d $TMPDIR/.scriptlock.${0##*/} ]]; then
msg "Removing left over lock from %s" "${0##*/}"
script_unlock
fi
@@ -91,7 +90,7 @@ cleanup() {
date +%s > "${FTP_BASE}/lastupdate"
fi
- [ "$1" ] && exit "$1"
+ [[ -n $1 ]] && exit "$1"
}
trap abort INT QUIT TERM HUP
@@ -109,22 +108,22 @@ repo_lock () {
local _owner
# This is the lock file used by repo-add and repo-remove
- if [ -f "${DBLOCKFILE}" ]; then
+ if [[ -f ${DBLOCKFILE} ]]; then
error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$DBLOCKFILE")"
return 1
fi
- if [ $# -eq 2 ]; then
+ if (( $# == 2 )); then
_lockblock=true
_trial=0
- elif [ $# -eq 3 ]; then
+ elif (( $# == 3 )); then
_lockblock=false
_timeout=$3
let _trial=$_timeout/$LOCK_DELAY
fi
_count=0
- while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do
+ while (( _count <= _trial )) || "$_lockblock" ; do
if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then
_owner="$(/usr/bin/stat -c %U "$LOCKDIR")"
warning "Repo [%s] (%s) is already locked by %s." "$1" "$2" "$_owner"
@@ -144,7 +143,7 @@ repo_lock () {
repo_unlock () { #repo_unlock <repo-name> <arch>
local LOCKDIR="$TMPDIR/.repolock.$1.$2"
- if [ ! -d "$LOCKDIR" ]; then
+ if [[ ! -d $LOCKDIR ]]; then
warning "Repo lock [%s] (%s) was not locked!" "$1" "$2"
restore_umask
return 1
@@ -176,7 +175,7 @@ getpkgbase() {
local _base
_base="$(_grep_pkginfo "$1" "pkgbase")"
- if [ -z "$_base" ]; then
+ if [[ -z $_base ]]; then
getpkgname "$1"
else
echo "$_base"
@@ -187,7 +186,7 @@ issplitpkg() {
local _base
_base="$(_grep_pkginfo "$1" "pkgbase")"
- if [ -z "$_base" ]; then
+ if [[ -z $_base ]]; then
return 1
else
return 0
@@ -199,7 +198,7 @@ getpkgname() {
local _name
_name="$(_grep_pkginfo "$1" "pkgname")"
- if [ -z "$_name" ]; then
+ if [[ -z $_name ]]; then
error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -212,7 +211,7 @@ getpkgver() {
local _ver
_ver="$(_grep_pkginfo "$1" "pkgver")"
- if [ -z "$_ver" ]; then
+ if [[ -z $_ver ]]; then
error "Package '%s' has no pkgver in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -224,7 +223,7 @@ getpkgarch() {
local _ver
_ver="$(_grep_pkginfo "$1" "arch")"
- if [ -z "$_ver" ]; then
+ if [[ -z $_ver ]]; then
error "Package '%s' has no arch in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -236,7 +235,7 @@ check_packager() {
local _packager
_packager=$(_grep_pkginfo "$1" "packager")
- [[ $_packager && $_packager != 'Unknown Packager' ]]
+ [[ -n $_packager && $_packager != 'Unknown Packager' ]]
}
check_buildinfo() {
@@ -247,17 +246,17 @@ check_builddir() {
local _builddir
_builddir=$(_grep_buildinfo "$1" "builddir")
- [[ $_builddir && $_builddir = '/build' ]]
+ [[ -n $_builddir && $_builddir = '/build' ]]
}
getpkgfile() {
- if [[ ${#} -ne 1 ]]; then
+ if (( $# != 1 )); then
error 'No canonical package found!'
exit 1
- elif [ ! -f "${1}" ]; then
+ elif [[ ! -f ${1} ]]; then
error "Package %s not found!" "$1"
exit 1
- elif [ ! -f "${1}.sig" ]; then
+ elif [[ ! -f ${1}.sig ]]; then
error "Package signature %s not found!" "$1.sig"
exit 1
fi
@@ -266,34 +265,25 @@ getpkgfile() {
}
getpkgfiles() {
- local f
- if [ ! -z "$(printf '%s\n' "${@%\.*}" | sort | uniq -D)" ]; then
+ local f files
+ if [[ ! -z "$(printf '%s\n' "${@%\.*}" | sort | uniq -D)" ]]; then
error 'Duplicate packages found!'
exit 1
fi
for f in "$@"; do
- if [ ! -f "${f}" ]; then
- error "Package %s not found!" "$f"
- exit 1
- elif [ ! -f "${f}.sig" ]; then
- error "Package signature %s not found!" "$f.sig"
- exit 1
- fi
+ files+=("$(getpkgfile "$f")") || exit 1
done
- echo "${@}"
+ echo "${files[@]}"
}
check_pkgfile() {
local pkgfile=$1
- local pkgname="$(getpkgname "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local pkgver="$(getpkgver "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local pkgarch="$(getpkgarch "${pkgfile}")"
- [ $? -ge 1 ] && return 1
+ local pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local pkgarch="$(getpkgarch "${pkgfile}")" || return 1
in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1
@@ -306,20 +296,16 @@ check_pkgfile() {
check_pkgxbs() {
local pkgfile="${1}"
- local _pkgbase="$(getpkgbase "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local _pkgname="$(getpkgname "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local _pkgver="$(getpkgver "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local _pkgarch="$(getpkgarch "${pkgfile}")"
- [ $? -ge 1 ] && return 1
+ local _pkgbase="$(getpkgbase "${pkgfile}")" || return 1
+ local _pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local _pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local _pkgarch="$(getpkgarch "${pkgfile}")" || return 1
local repo="${2}"
in_array "${repo}" "${PKGREPOS[@]}" || return 1
local xbsver="$(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; get_full_version "${_pkgname}")"
- [ "${xbsver}" == "${_pkgver}" ] || return 1
+ [[ "${xbsver}" = "${_pkgver}" ]] || return 1
local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}"))
in_array "${_pkgname}" "${xbsnames[@]}" || return 1
@@ -352,10 +338,10 @@ check_splitpkgs() {
popd >/dev/null
for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do
- [ ! -d "${pkgdir}" ] && continue
+ [[ ! -d ${pkgdir} ]] && continue
sort -u "${pkgdir}/staging" -o "${pkgdir}/staging"
sort -u "${pkgdir}/xbs" -o "${pkgdir}/xbs"
- if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/xbs")" ]; then
+ if [[ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/xbs")" ]]; then
return 1
fi
done
@@ -366,17 +352,14 @@ check_splitpkgs() {
check_pkgrepos() {
local pkgfile=$1
- local pkgname="$(getpkgname "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local pkgver="$(getpkgver "${pkgfile}")"
- [ $? -ge 1 ] && return 1
- local pkgarch="$(getpkgarch "${pkgfile}")"
- [ $? -ge 1 ] && return 1
+ local pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local pkgarch="$(getpkgarch "${pkgfile}")" || return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1
+ [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} ] && return 1
+ [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS}.sig ] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/} ]] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig ]] && return 1
return 0
}
@@ -394,19 +377,19 @@ chk_license() {
check_repo_permission() {
local repo=$1
- [ ${#PKGREPOS[@]} -eq 0 ] && return 1
- [ -z "${PKGPOOL}" ] && return 1
+ (( ${#PKGREPOS[@]} == 0 )) && return 1
+ [[ -z "${PKGPOOL}" ]] && return 1
in_array "${repo}" "${PKGREPOS[@]}" || return 1
- [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1
+ [[ -w $FTP_BASE/${PKGPOOL} ]] || return 1
local arch
for arch in "${ARCHES[@]}"; do
local dir="${FTP_BASE}/${repo}/os/${arch}/"
- [ -w "${dir}" ] || return 1
- [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1
- [ -f "${dir}${repo}"${FILESEXT} -a ! -w "${dir}${repo}"${FILESEXT} ] && return 1
+ [[ -w ${dir} ]] || return 1
+ [[ -f ${dir}${repo}${DBEXT} && ! -w ${dir}${repo}${DBEXT} ]] && return 1
+ [[ -f ${dir}${repo}${FILESEXT} && ! -w ${dir}${repo}${FILESEXT} ]] && return 1
done
return 0
@@ -418,7 +401,7 @@ set_repo_permission() {
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}"
- if [ -w "${dbfile}" ]; then
+ if [[ -w ${dbfile} ]]; then
local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")")
chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "$dbfile" "$group"
chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "$filesfile" "$group"
@@ -450,7 +433,7 @@ arch_repo_remove() {
local pkgs=("${@:3}")
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
- if [ ! -f "${dbfile}" ]; then
+ if [[ ! -f ${dbfile} ]]; then
error "No database found at '%s'" "$dbfile"
return 1
fi
@@ -462,7 +445,7 @@ arch_repo_remove() {
}
arch_svn() {
- if [ -z "${SVNUSER}" ]; then
+ if [[ -z ${SVNUSER} ]]; then
/usr/bin/svn "${@}"
else
sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}"
diff --git a/db-import-pkg b/db-import-pkg
index 4f0cd57..f56c671 100755
--- a/db-import-pkg
+++ b/db-import-pkg
@@ -43,13 +43,13 @@ get_repo_dir() {
#
# pkgname [epoch:]pkgver-pkgrel
db_list_pkgs() {
- bsdtar tf "${1}" |
+ bsdtar tf "$1" |
cut -d "/" -f 1 |
sed -r 's/-([^-]*-[^-]*)$/ \1/' |
sort -u
}
-# usage: filter_blacklisted <FULL_LIST >WHITE_LIST
+# usage: filter_blacklisted <FULL_LIST >FILTERED_LIST
#
# Given a list of packages in the format:
#
@@ -62,7 +62,7 @@ filter_blacklisted() {
<(blacklist-cat | blacklist-get-pkg | sort -u)
}
-# usage: filter_duplicates <FULL_LIST >WHITE_LIST
+# usage: filter_duplicates <FULL_LIST >FILTERED_LIST
#
# Given a list of packages in the format:
#
@@ -72,11 +72,12 @@ filter_blacklisted() {
# parabolaweb, librechroot, and who-knows-what-else. This only
# filters exact pkgname/epoch/pkgver/pkgrel matches.
filter_duplicates() {
- # FIXME: won't work when PKGEXT is an extglob
+ # FIXME: this will need to be adjusted when we turn PKGEXTS in
+ # to an extglob.
sort -u | comm -23 \
- \
- <(find "${FTP_BASE}/pool/" -name "*-any${PKGEXT}" -printf "%f\n" |
- sed 's/-any\.pkg.*//' |
+ <(find "${FTP_BASE}/pool/" -name "*-any${PKGEXTS}" -printf "%f\n" |
+ sed 's/-any\.pkg.*//' |
sed -r 's/-([^-]*-[^-]*)$/ \1/' |
sort -u)
}
@@ -138,10 +139,11 @@ sync_repo() {
# archlinux32/zip-3.0-7-i686.pkg.tar.xz
# packages/rhino-1.7.7.1-1-any.pkg.tar.xz
poolify() {
- local arch=$1 pool=$2
+ local -r arch=$1 pool=$2
+
local pkgname fullpkgver
+ local restore paths path
while read -r pkgname fullpkgver; do
- local restore paths path
restore=$(shopt -p extglob)
shopt -s extglob
paths=(
@@ -170,11 +172,11 @@ poolify() {
# usage: make_repo_symlinks TAG <POOLFILELIST
make_repo_symlinks() {
- local tag=$1
+ local -r tag=$1
- local repo=${tag%-*}
- local arch=${tag##*-}
- local repodir=${WORKDIR}/staging-rsync/${repo}/os/${arch}
+ local -r repo=${tag%-*}
+ local -r arch=${tag##*-}
+ local -r repodir=${WORKDIR}/staging-rsync/${repo}/os/${arch}
msg2 "Putting symlinks in %s" "${repo}/os/${arch}"
mkdir -p -- "${repodir}"
@@ -192,24 +194,21 @@ make_repo_dbs() {
local -r into=${FTP_BASE}/${1}/os/${2}/
local -r db_file=${from}/${1}${DBEXT}
local -r files_file=${from}/${1}${FILESEXT}
- local -r whitelist=${WORKDIR}/${1}-${2}.whitelist
# create fresh databases to reflect actual `any.pkg.tar.xz` packages.
# this also avoids corrupt upstream metadata (ALARM)
msg2 "Adding whitelisted packages to clean DBs ..."
pushd "${from}"
- local pkgfiles
- pkgfiles=($(sed -e "s|\$|${PKGEXT}|" "$whitelist"))
- local UMASK=$(umask)
+ local -r UMASK=$(umask)
umask 002
- repo-add "${db_file##*/}" "${pkgfiles[@]}"
+ repo-add "${db_file##*/}" *${PKGEXTS}
umask "$UMASK" >/dev/null
popd >/dev/null
mkdir -p -- "$into"
# This bit is based on db-functions:set_repo_permission()
- local group=$(/usr/bin/stat --printf='%G' "${into}")
+ local -r group=$(/usr/bin/stat --printf='%G' "${into}")
chgrp "$group" "${db_file}"
chgrp "$group" "${files_file}"
chmod g+w "${db_file}"
@@ -278,7 +277,7 @@ main() {
blacklist-update
# Sync the repos databases
- msg 'Downloading .db and .files files'
+ msg 'Downloading .db and .files files to import'
mkdir "${WORKDIR}/rsync"
fetch_dbs "${ARCHMIRROR_fullmodule}/" "$WORKDIR/rsync"
@@ -336,11 +335,10 @@ main() {
# everything from /new/.
local whitelists=()
- local reponame
for _tag in "${ARCHTAGS[@]}"; do
- reponame=${_tag%-*}
+ msg "Processing %s" "$_tag"
+ _repo=${_tag%-*}
_arch=${_tag##*-}
- msg "Processing %s-%s" "${_arch}" "${reponame}"
# Create a whitelist, add * wildcard to end.
#
# FIXME: due to lack of -arch suffix, the pool sync
@@ -349,30 +347,35 @@ main() {
# IMPORTANT: the . in the sed command is needed
# because an empty whitelist would consist of a single
# * allowing any package to pass through.
- sed -e 's/ /-/' -e 's|.$|&*|g' \
- <"${WORKDIR}/new/${_tag}.txt" \
- >"${WORKDIR}/${reponame}-${_arch}.whitelist"
case "$UPSTREAM" in
packages|community)
+ sed -e 's/ /-/' -e 's|.$|&*|g' \
+ <"${WORKDIR}/new/${_tag}.txt" \
+ >"${WORKDIR}/${_tag}.whitelist"
# Append to whitelists array so that we can
# later sync_pool() all packages
- whitelists+=("${WORKDIR}/${reponame}-${_arch}.whitelist")
+ whitelists+=("${WORKDIR}/${_tag}.whitelist")
# Get repo packages (symlinks)
- mkdir -p "${WORKDIR}/staging-rsync/${reponame}/os/${_arch}"
sync_repo \
- "${ARCHMIRROR_fullmodule}/$(get_repo_dir "${reponame}" "${_arch}")/" \
- "${WORKDIR}/${reponame}-${_arch}.whitelist" \
- "${WORKDIR}/staging-rsync/${reponame}/os/${_arch}/"
+ "${ARCHMIRROR_fullmodule}/$(get_repo_dir "${_repo}" "${_arch}")/" \
+ "${WORKDIR}/${_tag}.whitelist" \
+ "${WORKDIR}/staging-rsync/${_repo}/os/${_arch}/"
;;
archlinux32|archlinuxarm)
# Upstream doesn't use an $ARCHPKGPOOL
filter_duplicates \
<"${WORKDIR}/new/${_tag}.txt" \
| sed -e 's/ /-/' -e 's|.$|&*|g' \
- > "${WORKDIR}/${reponame}-${_arch}-nodups.whitelist"
- sync_pool "${ARCHMIRROR_fullmodule}/${_arch}/${reponame}/" \
- "${WORKDIR}/${reponame}-${_arch}-nodups.whitelist" \
+ > "${WORKDIR}/${_tag}.whitelist"
+ sync_pool \
+ "${ARCHMIRROR_fullmodule}/$(get_repo_dir "${_repo}" "${_arch}")/" \
+ "${WORKDIR}/${_tag}.whitelist" \
"${FTP_BASE}/${ARCHPKGPOOL}/"
+ poolify "${_arch}" "${ARCHPKGPOOL}" \
+ <"${WORKDIR}/new/${_tag}.txt" \
+ >"${WORKDIR}/${_tag}.pool"
+ make_repo_symlinks "$_tag" \
+ <"${WORKDIR}/${_tag}.pool"
;;
esac
done
@@ -381,33 +384,24 @@ main() {
packages|community)
# Concatenate all whitelists, check for single *s just in case
cat "${whitelists[@]}" | grep -v "^\*$" |
- sort -u > "${WORKDIR}/${UPSTREAM}-all.whitelist"
+ sort -u > "${WORKDIR}/all.whitelist"
# FIXME: make_whitelist() wildcards should be narrowed
# down to respect the architecture of the tag
msg "Syncing package pool"
sync_pool \
"${ARCHMIRROR_fullmodule}/${ARCHPKGPOOL}/" \
- "${WORKDIR}/${UPSTREAM}-all.whitelist" \
+ "${WORKDIR}/all.whitelist" \
"${FTP_BASE}/${ARCHPKGPOOL}/"
msg "Syncing source pool"
sync_pool \
"${ARCHMIRROR_fullmodule}/${ARCHSRCPOOL}/" \
- "${WORKDIR}/${UPSTREAM}-all.whitelist" \
+ "${WORKDIR}/all.whitelist" \
"${FTP_BASE}/${ARCHSRCPOOL}/"
;;
archlinux32|archlinuxarm)
- msg "Generating symbolic links to pool"
-
- for _tag in "${ARCHTAGS[@]}"; do
- _arch=${_tag##*-}
- poolify "${_arch}" "${ARCHPKGPOOL}" \
- <"${WORKDIR}/new/${_tag}.txt" \
- >"${WORKDIR}/${_tag}.pool"
- make_repo_symlinks "$_tag" \
- <"${WORKDIR}/${_tag}.pool"
- done
+ : # do nothing
;;
esac
diff --git a/db-move b/db-move
index cb3f94c..c4aaa70 100755
--- a/db-move
+++ b/db-move
@@ -3,7 +3,7 @@
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}"
exit 1
fi
@@ -28,13 +28,13 @@ done
for pkgbase in "${args[@]:2}"; do
for pkgarch in "${ARCHES[@]}" 'any'; do
xbsrepo_from="$(xbs releasepath "${pkgbase}" "${repo_from}" "${pkgarch}")"
- if [ -r "${xbsrepo_from}/PKGBUILD" ]; then
+ if [[ -r ${xbsrepo_from}/PKGBUILD ]]; then
pkgnames=($(. "${xbsrepo_from}/PKGBUILD"; echo "${pkgname[@]}"))
- if [ ${#pkgnames[@]} -lt 1 ]; then
+ if (( ${#pkgnames[@]} < 1 )); then
die "Could not read pkgname"
fi
- if [ "${pkgarch}" == 'any' ]; then
+ if [[ ${pkgarch} = any ]]; then
tarches=("${ARCHES[@]}")
else
tarches=("${pkgarch}")
@@ -42,11 +42,11 @@ for pkgbase in "${args[@]:2}"; do
for pkgname in "${pkgnames[@]}"; do
pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version "${pkgname}")
- if [ -z "${pkgver}" ]; then
+ if [[ -z ${pkgver} ]]; then
die "Could not read pkgver"
fi
for tarch in "${tarches[@]}"; do
- getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} >/dev/null
+ getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} >/dev/null
done
done
continue 2
@@ -67,7 +67,7 @@ for pkgbase in "${args[@]:2}"; do
for pkgarch in "${arches[@]}"; do
xbsrepo_to="$(xbs releasepath "$pkgbase" "$repo_to" "$pkgarch")"
if true; then # to add an indent level to make merging easier
- if [ "${pkgarch}" == 'any' ]; then
+ if [[ ${pkgarch} = any ]]; then
tarches=("${ARCHES[@]}")
else
tarches=("${pkgarch}")
@@ -78,11 +78,11 @@ for pkgbase in "${args[@]:2}"; do
for pkgname in "${pkgnames[@]}"; do
pkgver=$(. "${xbsrepo_to}/PKGBUILD"; get_full_version "${pkgname}")
for tarch in "${tarches[@]}"; do
- pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT})
+ pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS})
pkgfile="${pkgpath##*/}"
ln -s "../../../${PKGPOOL}/${pkgfile}" "${ftppath_to}/${tarch}/"
- if [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig" ]; then
+ if [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "${ftppath_to}/${tarch}/"
fi
add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} "
@@ -94,7 +94,7 @@ for pkgbase in "${args[@]:2}"; do
done
for tarch in "${ARCHES[@]}"; do
- if [ -n "${add_pkgs[${tarch}]}" ]; then
+ if [[ -n ${add_pkgs[${tarch}]} ]]; then
arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]}
arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]}
fi
diff --git a/db-remove b/db-remove
index 2c98d9a..f6aeadb 100755
--- a/db-remove
+++ b/db-remove
@@ -3,7 +3,7 @@
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}"
exit 1
fi
@@ -16,7 +16,7 @@ if ! check_repo_permission "$repo"; then
die "You don't have permission to remove packages from %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=("${ARCHES[@]}")
else
tarches=("$arch")
@@ -31,7 +31,7 @@ for pkgbase in "${pkgbases[@]}"; do
msg "Removing %s from [%s]..." "$pkgbase" "$repo"
path="$(xbs releasepath "$pkgbase" "$repo" "$arch")"
- if [ -d "$path" ]; then
+ if [[ -d $path ]]; then
remove_pkgs+=($(. "$path/PKGBUILD"; echo "${pkgname[@]}"))
xbs unrelease "$pkgbase" "$repo" "$arch"
else
diff --git a/db-repo-add b/db-repo-add
index 0fc69fe..3ee3528 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -3,7 +3,7 @@
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}"
exit 1
fi
@@ -18,7 +18,7 @@ if ! check_repo_permission "$repo"; then
die "You don't have permission to add packages to %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=("${ARCHES[@]}")
else
tarches=("$arch")
diff --git a/db-repo-remove b/db-repo-remove
index ba4bbfd..a0b8c1c 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -3,7 +3,7 @@
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}"
exit 1
fi
@@ -18,7 +18,7 @@ if ! check_repo_permission "$repo"; then
die "You don't have permission to remove packages from %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=("${ARCHES[@]}")
else
tarches=("$arch")
diff --git a/db-update b/db-update
index 4e2da33..39ed5e6 100755
--- a/db-update
+++ b/db-update
@@ -3,14 +3,13 @@
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
-if [ $# -ge 1 ]; then
+if (( $# >= 1 )); then
warning "Calling %s with a specific repository is no longer supported" "${0##*/}"
exit 1
fi
# Find repos with packages to release
-staging_repos=($(find "${STAGING}" -mindepth 1 -maxdepth 3 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u))
-if [ $? -ge 1 ]; then
+if ! staging_repos=($(find "${STAGING}" -mindepth 1 -maxdepth 3 -type f -name "*${PKGEXTS}" -printf '%h\n' | sort -u)); then
die "Could not read %s" "$STAGING"
fi
@@ -34,10 +33,10 @@ for repo in "${repos[@]}"; do
if ! check_repo_permission "${repo}"; then
die "You don't have permission to update packages in %s" "$repo"
fi
- pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT}))
- if [ $? -eq 0 ]; then
+ pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXTS}))
+ if (( $? == 0 )); then
for pkg in "${pkgs[@]}"; do
- if [ -h "${pkg}" ]; then
+ if [[ -h ${pkg} ]]; then
die "Package %s is a symbolic link" "$repo/${pkg##*/}"
fi
if ! check_pkgfile "${pkg}"; then
@@ -70,28 +69,28 @@ done
for repo in "${repos[@]}"; do
msg "Updating [%s]..." "$repo"
- any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null))
+ any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXTS} 2>/dev/null))
for pkgarch in "${ARCHES[@]}"; do
add_pkgs=()
- arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-"${pkgarch}"${PKGEXT} 2>/dev/null))
+ arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-"${pkgarch}"${PKGEXTS} 2>/dev/null))
for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do
pkgfile="${pkg##*/}"
msg2 "%s (%s)" "${pkgfile}" "${pkgarch}"
# any packages might have been moved by the previous run
- if [ -f "${pkg}" ]; then
+ if [[ -f ${pkg} ]]; then
mv "${pkg}" "$FTP_BASE/${PKGPOOL}"
fi
ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}"
# also move signatures
- if [ -f "${pkg}.sig" ]; then
+ if [[ -f ${pkg}.sig ]]; then
mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}"
fi
- if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then
+ if [[ -f $FTP_BASE/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}"
fi
add_pkgs+=("${pkgfile}")
done
- if [ ${#add_pkgs[@]} -ge 1 ]; then
+ if (( ${#add_pkgs[@]} >= 1 )); then
arch_repo_add "${repo}" "${pkgarch}" "${add_pkgs[@]}"
fi
done
diff --git a/test/cases/common.bats b/test/cases/common.bats
new file mode 100644
index 0000000..8b4c3a0
--- /dev/null
+++ b/test/cases/common.bats
@@ -0,0 +1,10 @@
+load ../lib/common
+
+@test "commands display usage message by default" {
+ for cmd in db-move db-remove db-repo-add db-repo-remove; do
+ echo Testing $cmd
+ run $cmd
+ (( $status == 1 ))
+ [[ $output == *'usage: '* ]]
+ done
+}
diff --git a/test/cases/db-repo-add.bats b/test/cases/db-repo-add.bats
index ef6cfe7..90f7697 100755
--- a/test/cases/db-repo-add.bats
+++ b/test/cases/db-repo-add.bats
@@ -30,7 +30,7 @@ __movePackageToRepo() {
releasePackage extra "$pkgbase"
for arch in "${ARCH_BUILD[@]}"; do
__movePackageToRepo extra ${pkgbase} ${arch}
- db-repo-add extra "${arch}" "${pkgbase}-1-1-${arch}.pkg.tar.xz"
+ db-repo-add extra "${arch}" "${pkgbase}-1-1-${arch}${PKGEXT}"
done
done
@@ -52,7 +52,7 @@ __movePackageToRepo() {
add_pkgs=()
for pkgbase in "${pkgs[@]}"; do
__movePackageToRepo extra ${pkgbase} ${arch}
- add_pkgs+=("${pkgbase}-1-1-${arch}.pkg.tar.xz")
+ add_pkgs+=("${pkgbase}-1-1-${arch}${PKGEXT}")
done
db-repo-add extra "${arch}" "${add_pkgs[@]}"
done
@@ -70,7 +70,7 @@ __movePackageToRepo() {
for pkgbase in ${pkgs[@]}; do
releasePackage extra ${pkgbase}
__movePackageToRepo extra ${pkgbase} any
- db-repo-add extra any ${pkgbase}-1-1-any.pkg.tar.xz
+ db-repo-add extra any ${pkgbase}-1-1-any${PKGEXT}
done
for pkgbase in ${pkgs[@]}; do
diff --git a/test/cases/db-update.bats b/test/cases/db-update.bats
index 56e364b..e3ef73f 100755
--- a/test/cases/db-update.bats
+++ b/test/cases/db-update.bats
@@ -90,7 +90,7 @@ load ../lib/common
db-update
checkPackage extra pkg-any-a
- releasePackage extra pkg-any-a
+ PKGEXT=.pkg.tar.gz releasePackage extra pkg-any-a
run db-update
[ "$status" -ne 0 ]
}
@@ -147,8 +147,7 @@ load ../lib/common
local p
releasePackage extra 'pkg-any-a'
for p in "${STAGING}"/extra/*${PKGEXT}; do
- unxz "$p"
- xz -0 "${p%%.xz}"
+ printf '%s\n' "Not a real package" | gpg -v --detach-sign --no-armor --use-agent - > "${p}.sig"
done
run db-update
[ "$status" -ne 0 ]
diff --git a/test/cases/ftpdir-cleanup.bats b/test/cases/ftpdir-cleanup.bats
index 00fbe94..0918392 100755
--- a/test/cases/ftpdir-cleanup.bats
+++ b/test/cases/ftpdir-cleanup.bats
@@ -79,7 +79,7 @@ __checkRepoRemovedPackage() {
db-remove extra any pkg-any-a
ftpdir-cleanup
- local pkg1='pkg-any-a-1-1-any.pkg.tar.xz'
+ local pkg1="pkg-any-a-1-1-any${PKGEXT}"
checkRemovedPackage extra 'pkg-any-a'
for arch in ${ARCH_BUILD[@]}; do
__checkRepoRemovedPackage extra 'pkg-any-a' ${arch}
@@ -133,8 +133,8 @@ __checkRepoRemovedPackage() {
ftpdir-cleanup
- local pkgfilea="pkg-simple-a-1-1-${arch}.pkg.tar.xz"
- local pkgfileb="pkg-simple-b-1-1-${arch}.pkg.tar.xz"
+ local pkgfilea="pkg-simple-a-1-1-${arch}${PKGEXT}"
+ local pkgfileb="pkg-simple-b-1-1-${arch}${PKGEXT}"
for arch in "${ARCH_BUILD[@]}"; do
touch -d "-$(expr ${CLEANUP_KEEP} + 1)days" ${CLEANUP_DESTDIR}/${pkgfilea}{,.sig}
done
diff --git a/test/lib/common.bash b/test/lib/common.bash
index b1e5a37..aa8febe 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -27,8 +27,7 @@ __buildPackage() {
if [[ -n ${BUILDDIR} ]]; then
cache=${BUILDDIR}/$(__getCheckSum PKGBUILD)
- if [[ -d ${cache} ]]; then
- cp -Lv ${cache}/*${PKGEXT}{,.sig} ${pkgdest}
+ if cp -Lv ${cache}/*${PKGEXT}{,.sig} ${pkgdest} 2>/dev/null; then
return 0
else
mkdir -p ${cache}
@@ -38,12 +37,13 @@ __buildPackage() {
pkgarches=($(. PKGBUILD; echo ${arch[@]}))
for tarch in ${pkgarches[@]}; do
if [ "${tarch}" == 'any' ]; then
- sudo librechroot -n "dbscripts@${tarch}" make
+ sudo librechroot -n "dbscripts@${tarch}" sync
mapfile -tO "${#pkgfiles[@]}" pkgfiles < <(PKGDEST=${pkgdest} PKGEXT=${PKGEXT} makepkg --packagelist)
else
- sudo librechroot -n "dbscripts@${tarch}" -A "$tarch" make
+ sudo librechroot -n "dbscripts@${tarch}" -A "$tarch" sync
mapfile -tO "${#pkgfiles[@]}" pkgfiles < <(PKGDEST=${pkgdest} PKGEXT=${PKGEXT} CARCH=${tarch} makepkg --packagelist)
fi
+ sudo librechroot -n "dbscripts@${tarch}" run bash -c "$(printf '%q ' echo "PKGEXT=${PKGEXT@Q}") >> /etc/makepkg.conf"
sudo PKGDEST="${pkgdest}" libremakepkg -n "dbscripts@${tarch}"
done
@@ -62,6 +62,7 @@ setup() {
local pkg
local r
local a
+ PKGEXT=".pkg.tar.xz"
TMP="$(mktemp -d)"
@@ -83,7 +84,6 @@ setup() {
SOURCE_CLEANUP_DRYRUN=false
eot
. config
- PKGEXT=".pkg.tar.xz"
mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}}