From 766a076891a37cebc7b448241c8c183c32f49d9e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 18:05:41 -0500 Subject: rm repo-remove -- in Oct 2012 fauno removed repo-add, but left this The customized repo-{add,remove} did license extraction for packages. They were based on the versions from pacman 3.5.0 Here is a diff between the stock versions from 3.5.0, and the modified version that we had: --- repo-add.sh.in 2013-12-31 18:02:13.546351038 -0500 +++ repo-remove.in 2013-12-31 18:13:19.957948677 -0500 @@ -20,6 +20,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +LICENSESDIR=/home/parabolavnx/licenses + # gettext initialization export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='@localedir@' @@ -309,6 +311,22 @@ fi fi + # Extracts licenses to a common license dir + msg "Extracting license" + if bsdtar -xOf ${pkgfile} .PKGINFO | grep "license" | grep "custom" ; then + if [ -d ${LICENSESDIR}/${pkgname} ]; then + rm -r ${LICENSESDIR}/${pkgname} + fi + + # Change dir to licenses, and extract them stripping the first part of the path + bsdtar -C ${LICENSESDIR}/ --include="usr/share/licenses/" \ + --strip-components 3 -xf ${pkgfile} >/dev/null 2>&1 + + if [ $? -ne 0 ]; then + warning "This package doesn't contain a license dir" + fi + fi + return 0 } # end db_write_entry @@ -328,6 +346,12 @@ rm -rf $pkgentry pkgentry=$(find_pkgentry $pkgname) done + + msg "Removing license" + if [ -d ${LICENSESDIR}/${pkgname} ]; then + rm -r ${LICENSESDIR}/${pkgname} + fi + return $notfound } # end db_remove_entry --- repo-remove | 561 ------------------------------------------------------------ 1 file changed, 561 deletions(-) delete mode 100755 repo-remove diff --git a/repo-remove b/repo-remove deleted file mode 100755 index c4bf96f..0000000 --- a/repo-remove +++ /dev/null @@ -1,561 +0,0 @@ -#!/bin/bash -# -# repo-add - add a package to a given repo database file -# repo-remove - remove a package entry from a given repo database file -# Generated from repo-add.in; do not edit by hand. -# -# Copyright (c) 2006-2008 Aaron Griffin -# Copyright (c) 2007-2008 Dan McGee -# -# 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 2 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 . - -LICENSESDIR=/home/parabolavnx/licenses - -# gettext initialization -export TEXTDOMAIN='pacman' -export TEXTDOMAINDIR='/usr/share/locale' - -myver='3.5.0' -confdir='/home/parabolavnx/etc' - -QUIET=0 -DELTA=0 -WITHFILES=0 -REPO_DB_FILE= -LOCKFILE= -CLEAN_LOCK=0 - -# ensure we have a sane umask set -umask 0022 - -msg() { - (( QUIET )) && return - local mesg=$1; shift - printf "==> ${mesg}\n" "$@" >&1 -} - -msg2() { - (( QUIET )) && return - local mesg=$1; shift - printf " -> ${mesg}\n" "$@" >&1 -} - -warning() { - local mesg=$1; shift - printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 -} - -error() { - local mesg=$1; shift - printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 -} - -# print usage instructions -usage() { - printf "repo-add, repo-remove (pacman) %s\n\n" "$myver" - printf "$(gettext "Usage: repo-add [-d] [-f] [-q] ...\n")" - printf "$(gettext "Usage: repo-remove [-q] ...\n\n")" - printf "$(gettext "\ -repo-add will update a package database by reading a package file.\n\ -Multiple packages to add can be specified on the command line.\n\n")" - printf "$(gettext "\ -repo-remove will update a package database by removing the package name\n\ -specified on the command line from the given repo database. Multiple\n\ -packages to remove can be specified on the command line.\n\n")" - printf "$(gettext "\ -Use the -q/--quiet flag to minimize output to basic messages, warnings,\n\ -and errors.\n\n")" - printf "$(gettext "\ -Use the -d/--delta flag to automatically generate and add a delta file\n\ -between the old entry and the new one, if the old package file is found\n\ -next to the new one.\n\n")" - printf "$(gettext "\ -Use the -f/--files flag to update a database including file entries.\n\n")" - echo "$(gettext "Example: repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz")" - echo "$(gettext "Example: repo-remove /path/to/repo.db.tar.gz kernel26")" -} - -version() { - printf "repo-add, repo-remove (pacman) %s\n\n" "$myver" - printf "$(gettext "\ -Copyright (C) 2006-2008 Aaron Griffin .\n\ -Copyright (c) 2007-2008 Dan McGee .\n\n\ -This is free software; see the source for copying conditions.\n\ -There is NO WARRANTY, to the extent permitted by law.\n")" -} - -# write a list entry -# arg1 - Entry name -# arg2 - List -# arg3 - File to write to -write_list_entry() { - if [[ -n $2 ]]; then - echo "%$1%" >>$3 - echo -e $2 >>$3 - fi -} - -find_pkgentry() -{ - local pkgname=$1 - local pkgentry - for pkgentry in $tmpdir/$pkgname*; do - name=${pkgentry##*/} - if [[ ${name%-*-*} = $pkgname ]]; then - echo $pkgentry - return 0 - fi - done - return 1 -} - -# Get the package name from the delta filename -get_delta_pkgname() { - local tmp - - tmp=${1##*/} - echo ${tmp%-*-*_to*} -} - -# write a delta entry -# arg1 - path to delta file -db_write_delta() -{ - deltafile="$1" - pkgname="$(get_delta_pkgname $deltafile)" - - pkgentry=$(find_pkgentry $pkgname) - if [[ -z $pkgentry ]]; then - error "$(gettext "No database entry for package '%s'.")" "$pkgname" - return 1 - fi - deltas="$pkgentry/deltas" - if [[ ! -f $deltas ]]; then - echo -e "%DELTAS%" >$deltas - fi - # get md5sum and compressed size of package - md5sum="$(openssl dgst -md5 "$deltafile")" - md5sum="${md5sum##* }" - csize=$(stat -L -c %s "$deltafile") - - oldfile=$(xdelta3 printhdr $deltafile | grep "XDELTA filename (source)" | sed 's/.*: *//') - newfile=$(xdelta3 printhdr $deltafile | grep "XDELTA filename (output)" | sed 's/.*: *//') - - if grep -q "$oldfile.*$newfile" $deltas; then - sed -i.backup "/$oldfile.*$newfile/d" $deltas && rm -f $deltas.backup - fi - msg2 "$(gettext "Adding 'deltas' entry : %s -> %s")" "$oldfile" "$newfile" - echo ${deltafile##*/} $md5sum $csize $oldfile $newfile >> $deltas - - return 0 -} # end db_write_delta - -# remove a delta entry -# arg1 - path to delta file -db_remove_delta() -{ - deltafile="$1" - filename=${deltafile##*/} - pkgname="$(get_delta_pkgname $deltafile)" - - pkgentry=$(find_pkgentry $pkgname) - if [[ -z $pkgentry ]]; then - return 1 - fi - deltas="$pkgentry/deltas" - if [[ ! -f $deltas ]]; then - return 1 - fi - if grep -q "$filename" $deltas; then - sed -i.backup "/$filename/d" $deltas && rm -f $deltas.backup - msg2 "$(gettext "Removing existing entry '%s'...")" "$filename" - return 0 - fi - - return 1 -} # end db_remove_delta - -# write an entry to the pacman database -# arg1 - path to package -db_write_entry() -{ - # blank out all variables - local pkgfile="$1" - local pkgname pkgver pkgdesc csize size md5sum url arch builddate packager \ - _groups _licenses _replaces _depends _conflicts _provides _optdepends - - local OLDIFS="$IFS" - # IFS (field separator) is only the newline character - IFS=" -" - - # read info from the zipped package - local line var val - for line in $(bsdtar -xOqf "$pkgfile" .PKGINFO | - grep -v '^#' | sed 's|\(\w*\)\s*=\s*\(.*\)|\1 \2|'); do - # bash awesomeness here- var is always one word, val is everything else - var=${line%% *} - val=${line#* } - declare $var="$val" - case "$var" in - group) _groups="$_groups$group\n" ;; - license) _licenses="$_licenses$license\n" ;; - replaces) _replaces="$_replaces$replaces\n" ;; - depend) _depends="$_depends$depend\n" ;; - conflict) _conflicts="$_conflicts$conflict\n" ;; - provides) _provides="$_provides$provides\n" ;; - optdepend) _optdepends="$_optdepends$optdepend\n" ;; - esac - done - - IFS=$OLDIFS - - # get md5sum and compressed size of package - md5sum="$(openssl dgst -md5 "$pkgfile")" - md5sum="${md5sum##* }" - csize=$(stat -L -c %s "$pkgfile") - - # ensure $pkgname and $pkgver variables were found - if [[ -z $pkgname || -z $pkgver ]]; then - error "$(gettext "Invalid package file '%s'.")" "$pkgfile" - return 1 - fi - - pushd "$tmpdir" >/dev/null - if [[ -d $pkgname-$pkgver ]]; then - warning "$(gettext "An entry for '%s' already existed")" "$pkgname-$pkgver" - else - if (( DELTA )); then - pkgentry=$(find_pkgentry $pkgname) - if [[ -n $pkgentry ]]; then - local oldfilename=$(grep -A1 FILENAME $pkgentry/desc | tail -n1) - local oldfile="$(dirname $1)/$oldfilename" - fi - fi - fi - - # remove an existing entry if it exists, ignore failures - db_remove_entry "$pkgname" - - # create package directory - mkdir "$pkgname-$pkgver" - pushd "$pkgname-$pkgver" >/dev/null - - # restore an eventual deltas file - [[ -f ../$pkgname.deltas ]] && mv "../$pkgname.deltas" deltas - - # create desc entry - msg2 "$(gettext "Creating '%s' db entry...")" 'desc' - echo -e "%FILENAME%\n$(basename "$1")\n" >>desc - echo -e "%NAME%\n$pkgname\n" >>desc - [[ -n $pkgbase ]] && echo -e "%BASE%\n$pkgbase\n" >>desc - echo -e "%VERSION%\n$pkgver\n" >>desc - [[ -n $pkgdesc ]] && echo -e "%DESC%\n$pkgdesc\n" >>desc - write_list_entry "GROUPS" "$_groups" "desc" - [[ -n $csize ]] && echo -e "%CSIZE%\n$csize\n" >>desc - [[ -n $size ]] && echo -e "%ISIZE%\n$size\n" >>desc - - # compute checksums - msg2 "$(gettext "Computing md5 checksums...")" - echo -e "%MD5SUM%\n$md5sum\n" >>desc - - [[ -n $url ]] && echo -e "%URL%\n$url\n" >>desc - write_list_entry "LICENSE" "$_licenses" "desc" - [[ -n $arch ]] && echo -e "%ARCH%\n$arch\n" >>desc - [[ -n $builddate ]] && echo -e "%BUILDDATE%\n$builddate\n" >>desc - [[ -n $packager ]] && echo -e "%PACKAGER%\n$packager\n" >>desc - write_list_entry "REPLACES" "$_replaces" "desc" - - # create depends entry - msg2 "$(gettext "Creating '%s' db entry...")" 'depends' - # create the file even if it will remain empty - touch "depends" - write_list_entry "DEPENDS" "$_depends" "depends" - write_list_entry "CONFLICTS" "$_conflicts" "depends" - write_list_entry "PROVIDES" "$_provides" "depends" - write_list_entry "OPTDEPENDS" "$_optdepends" "depends" - - popd >/dev/null - popd >/dev/null - - # create files file if wanted - if (( WITHFILES )); then - msg2 "$(gettext "Creating '%s' db entry...")" 'files' - local files_path="$tmpdir/$pkgname-$pkgver/files" - echo "%FILES%" >$files_path - bsdtar --exclude='.*' -tf "$pkgfile" >>$files_path - fi - - # create a delta file - if (( DELTA )); then - if [[ -n $oldfilename ]]; then - if [[ -f $oldfile ]]; then - delta=$(pkgdelta -q $oldfile $1) - if [[ -f $delta ]]; then - db_write_delta $delta - fi - else - warning "$(gettext "Old package file not found: %s")" "$oldfilename" - fi - fi - fi - - # Extracts licenses to a common license dir - msg "Extracting license" - if bsdtar -xOf ${pkgfile} .PKGINFO | grep "license" | grep "custom" ; then - if [ -d ${LICENSESDIR}/${pkgname} ]; then - rm -r ${LICENSESDIR}/${pkgname} - fi - - # Change dir to licenses, and extract them stripping the first part of the path - bsdtar -C ${LICENSESDIR}/ --include="usr/share/licenses/" \ - --strip-components 3 -xf ${pkgfile} >/dev/null 2>&1 - - if [ $? -ne 0 ]; then - warning "This package doesn't contain a license dir" - fi - fi - - return 0 -} # end db_write_entry - -# remove existing entries from the DB -# arg1 - package name -db_remove_entry() { - local pkgname=$1 - local notfound=1 - local pkgentry=$(find_pkgentry $pkgname) - while [[ -n $pkgentry ]]; do - notfound=0 - if [[ -f $pkgentry/deltas ]]; then - mv "$pkgentry/deltas" "$tmpdir/$pkgname.deltas" - fi - msg2 "$(gettext "Removing existing entry '%s'...")" \ - "$(basename $pkgentry)" - rm -rf $pkgentry - pkgentry=$(find_pkgentry $pkgname) - done - - msg "Removing license" - if [ -d ${LICENSESDIR}/${pkgname} ]; then - rm -r ${LICENSESDIR}/${pkgname} - fi - - return $notfound -} # end db_remove_entry - -check_repo_db() -{ - # check lock file - if ( set -o noclobber; echo "$$" > "$LOCKFILE") 2> /dev/null; then - CLEAN_LOCK=1 - else - error "$(gettext "Failed to acquire lockfile: %s.")" "$LOCKFILE" - [[ -f $LOCKFILE ]] && error "$(gettext "Held by process %s")" "$(cat $LOCKFILE)" - exit 1 - fi - - if [[ -f $REPO_DB_FILE ]]; then - # there are two situations we can have here- a DB with some entries, - # or a DB with no contents at all. - if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' >/dev/null 2>&1; then - # check empty case - if [[ -n $(bsdtar -tqf "$REPO_DB_FILE" '*' 2>/dev/null) ]]; then - error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE" - exit 1 - fi - fi - msg "$(gettext "Extracting database to a temporary location...")" - bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir" - else - case "$cmd" in - repo-remove) - error "$(gettext "Repository file '%s' was not found.")" "$REPO_DB_FILE" - exit 1 - ;; - repo-add) - # check if the file can be created (write permission, directory existence, etc) - if ! touch "$REPO_DB_FILE"; then - error "$(gettext "Repository file '%s' could not be created.")" "$REPO_DB_FILE" - exit 1 - fi - rm -f "$REPO_DB_FILE" - ;; - esac - fi -} - -add() -{ - if [[ ! -f $1 ]]; then - error "$(gettext "File '%s' not found.")" "$1" - return 1 - fi - - if [[ ${1##*.} == "delta" ]]; then - deltafile=$1 - msg "$(gettext "Adding delta '%s'")" "$deltafile" - if ! type xdelta3 &>/dev/null; then - error "$(gettext "Cannot find the xdelta3 binary! Is xdelta3 installed?")" - exit 1 - fi - if db_write_delta "$deltafile"; then - return 0 - else - return 1 - fi - fi - - pkgfile=$1 - if ! bsdtar -tqf "$pkgfile" .PKGINFO >/dev/null 2>&1; then - error "$(gettext "'%s' is not a package file, skipping")" "$pkgfile" - return 1 - fi - - msg "$(gettext "Adding package '%s'")" "$pkgfile" - - db_write_entry "$pkgfile" -} - -remove() -{ - if [[ ${1##*.} == "delta" ]]; then - deltafile=$1 - msg "$(gettext "Searching for delta '%s'...")" "$deltafile" - if db_remove_delta "$deltafile"; then - return 0 - else - error "$(gettext "Delta matching '%s' not found.")" "$deltafile" - return 1 - fi - fi - - pkgname=$1 - msg "$(gettext "Searching for package '%s'...")" "$pkgname" - - if db_remove_entry "$pkgname"; then - rm -f "$tmpdir/$pkgname.deltas" - return 0 - else - error "$(gettext "Package matching '%s' not found.")" "$pkgname" - return 1 - fi -} - -trap_exit() -{ - echo - error "$@" - exit 1 -} - -clean_up() { - local exit_code=$? - - [[ -d $tmpdir ]] && rm -rf "$tmpdir" - (( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE" - - exit $exit_code -} - -# PROGRAM START - -# determine whether we have gettext; make it a no-op if we do not -if ! type gettext &>/dev/null; then - gettext() { - echo "$@" - } -fi - -case "$1" in - -h|--help) usage; exit 0;; - -V|--version) version; exit 0;; -esac - -# figure out what program we are -cmd="$(basename $0)" -if [[ $cmd != "repo-add" && $cmd != "repo-remove" ]]; then - error "$(gettext "Invalid command name '%s' specified.")" "$cmd" - exit 1 -fi - -tmpdir=$(mktemp -d /tmp/repo-tools.XXXXXXXXXX) || (\ - error "$(gettext "Cannot create temp directory for database building.")"; \ - exit 1) - -trap 'clean_up' EXIT -trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT -trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT -trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR - -success=0 -# parse arguments -for arg in "$@"; do - case "$arg" in - -q|--quiet) QUIET=1;; - -d|--delta) DELTA=1;; - -f|--files) WITHFILES=1;; - *) - if [[ -z $REPO_DB_FILE ]]; then - REPO_DB_FILE="$arg" - LOCKFILE="$REPO_DB_FILE.lck" - check_repo_db - else - case "$cmd" in - repo-add) add $arg && success=1 ;; - repo-remove) remove $arg && success=1 ;; - esac - fi - ;; - esac -done - -# if at least one operation was a success, re-zip database -if (( success )); then - msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE" - - case "$REPO_DB_FILE" in - *tar.gz) TAR_OPT="z" ;; - *tar.bz2) TAR_OPT="j" ;; - *tar.xz) TAR_OPT="J" ;; - *) warning "$(gettext "'%s' does not have a valid archive extension.")" \ - "$REPO_DB_FILE" ;; - esac - - filename=$(basename "$REPO_DB_FILE") - - pushd "$tmpdir" >/dev/null - if [[ -n $(ls) ]]; then - bsdtar -c${TAR_OPT}f "$filename" * - else - # we have no packages remaining? zip up some emptyness - warning "$(gettext "No packages remain, creating empty database.")" - bsdtar -c${TAR_OPT}f "$filename" -T /dev/null - fi - popd >/dev/null - - [[ -f $REPO_DB_FILE ]] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old" - [[ -f $tmpdir/$filename ]] && mv "$tmpdir/$filename" "$REPO_DB_FILE" - dblink="${REPO_DB_FILE%.tar.*}" - target=${REPO_DB_FILE##*/} - ln -sf "$target" "$dblink" 2>/dev/null || \ - ln -f "$target" "$dblink" 2>/dev/null || \ - cp "$REPO_DB_FILE" "$dblink" -else - msg "$(gettext "No packages modified, nothing to do.")" - exit 1 -fi - -exit 0 -# vim: set ts=2 sw=2 noet: -- cgit v1.2.3-2-g168b From 3537841a9287ea1c7871545ffebb855561f7c1e0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:17:35 -0500 Subject: misc touch up - TODO: add trailing newline - config: add text editor hint - config.orig: remove - getrepos: quote, use -- - db-functions: hardcode some paths, remove needless nullglob --- TODO | 2 +- config | 2 +- config.orig | 54 ------------------------------------------------------ createrepos | 2 +- db-functions | 21 ++++++++------------- 5 files changed, 11 insertions(+), 70 deletions(-) delete mode 100644 config.orig diff --git a/TODO b/TODO index 3219b1c..9dd4b52 100644 --- a/TODO +++ b/TODO @@ -7,4 +7,4 @@ * Fix db-move - - Make it use abslibre \ No newline at end of file + - Make it use abslibre diff --git a/config b/config index 8b8117f..0152b69 100644 --- a/config +++ b/config @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash # as a hint to text editors FTP_BASE="/srv/http/repo/public" ARCH_BASE="/srv/http/repo/public" SVNREPO="/var/abs" diff --git a/config.orig b/config.orig deleted file mode 100644 index a32f82f..0000000 --- a/config.orig +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -<<<<<<< HEAD -FTP_BASE="/srv/http/repo/public" -ARCH_BASE="/srv/http/repo/public" -SVNREPO="/srv/http/repo/abslibre" -======= -FTP_BASE="/srv/http/repo/public/temprepo" -ARCH_BASE="/srv/http/repo/public/temprepo" -SVNREPO="/var/abs" ->>>>>>> 801ea2c927ace5ee892209dd8e3c1044e1b3842e - -# Repos from Arch -ARCHREPOS=('core' 'testing') #'extra' 'community' 'testing' 'multilib') -# Official Parabola repos -OURREPOS=('libre' 'libre-testing') -# User repos -USERREPOS=('~fauno' '~smv' '~xihh' '~mtjm' '~brendan') -# Community project repos -PROJREPOS=('social' 'elementary' 'kernels' 'radio' 'security' 'sugar') -PKGREPOS=(${ARCHREPOS[@]} ${OURREPOS[@]} ${USERREPOS[@]} ${PROJREPOS[@]}) -PKGPOOL='pool/packages' -SRCPOOL='sources/packages' - -CLEANUP_DESTDIR="$FTP_BASE/old/packages" -CLEANUP_DRYRUN=true -# Time in days to keep moved packages -CLEANUP_KEEP=30 - -SOURCE_CLEANUP_DESTDIR="$FTP_BASE/old/sources" -SOURCE_CLEANUP_DRYRUN=true -# Time in days to keep moved sourcepackages -SOURCE_CLEANUP_KEEP=30 - -REQUIRE_SIGNATURE=true - -LOCK_DELAY=10 -LOCK_TIMEOUT=300 - -STAGING="$FTP_BASE/staging" -TMPDIR="/tmp" -ARCHARCHES=(i686 x86_64) -OURARCHES=(mips64el) -ARCHES=(${ARCHARCHES[@]} ${OURARCHES[@]}) -DBEXT=".db.tar.gz" -FILESEXT=".files.tar.gz" -PKGEXT=".pkg.tar.?z" -SRCEXT=".src.tar.gz" - -<<<<<<< HEAD -MAKEPKGCONF="~/.makepkg.conf" -======= -MAKEPKGCONF="/etc/makepkg.conf" ->>>>>>> 801ea2c927ace5ee892209dd8e3c1044e1b3842e -BLACKLIST_FILE="$HOME/blacklist/blacklist.txt" diff --git a/createrepos b/createrepos index 4ee057b..926c158 100755 --- a/createrepos +++ b/createrepos @@ -3,6 +3,6 @@ source $(dirname $0)/config -mkdir -p ${FTP_BASE}/{${PKGPOOL},${SRCPOOL}} ${ARCH_BASE} ${CLEANUP_DESTDIR} ${SOURCE_CLEANUP_DESTDIR} ${STAGING} +mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${ARCH_BASE}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}" $(dirname $0)/create-repo ${PKGREPOS[@]} diff --git a/db-functions b/db-functions index 4c247a7..458a370 100644 --- a/db-functions +++ b/db-functions @@ -87,7 +87,7 @@ get_full_version() { script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - local _owner="$(stat -c %U $LOCKDIR)" + local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" error "Script $(basename $0) is already locked by $_owner." exit 1 else @@ -178,7 +178,7 @@ repo_lock () { _count=0 while [ $_count -le $_trial ] || $_lockblock ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - _owner="$(stat -c %U $LOCKDIR)" + _owner="$(/usr/bin/stat -c %U $LOCKDIR)" warning "Repo [${1}] (${2}) is already locked by $_owner. " msg2 "Retrying in $LOCK_DELAY seconds..." else @@ -211,7 +211,7 @@ repo_unlock () { #repo_unlock _grep_pkginfo() { local _ret - _ret="$(bsdtar -xOqf "$1" .PKGINFO | grep -m 1 "^${2} = ")" + _ret="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | grep -m 1 "^${2} = ")" echo "${_ret#${2} = }" } @@ -293,9 +293,6 @@ getpkgfile() { } getpkgfiles() { -# Ignore anything that doesn't glob to PKGEXT - shopt -s nullglob - local f if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then error 'Duplicate packages found!' @@ -313,8 +310,6 @@ getpkgfiles() { done echo ${@} - - shopt -u nullglob } check_pkgfile() { @@ -485,7 +480,7 @@ set_repo_permission() { local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" if [ -w "${dbfile}" ]; then - local group=$(stat --printf='%G' "$(dirname "${dbfile}")") + local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") chgrp $group "${dbfile}" || error "Could not change group of ${dbfile} to $group" chgrp $group "${filesfile}" || error "Could not change group of ${filesfile} to $group" chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" @@ -502,9 +497,9 @@ arch_repo_add() { # package files might be relative to repo dir pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null - repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \ + /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \ || error "repo-add ${repo}${DBEXT} ${pkgs[@]}" - repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ + /usr/bin/repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -521,9 +516,9 @@ arch_repo_remove() { error "No database found at '${dbfile}'" return 1 fi - repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ + /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ || error "repo-remove ${dbfile} ${pkgs[@]}" - repo-remove -q "${filesfile}" ${pkgs[@]} \ + /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ || error "repo-remove ${filesfile} ${pkgs[@]}" set_repo_permission "${repo}" "${arch}" } -- cgit v1.2.3-2-g168b From 1bcc49058febc7e2723c455879da6ff3b9ca6576 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:18:36 -0500 Subject: Use `mktemp -t` to respect $TMPDIR --- db-functions | 2 +- get-repos | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db-functions b/db-functions index 458a370..f56ca19 100644 --- a/db-functions +++ b/db-functions @@ -16,7 +16,7 @@ restore_umask () { } # set up general environment -WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) +WORKDIR=$(mktemp -dt "$(basename $0).XXXXXXXXXX") LOCKS=() # check if messages are to be printed using color diff --git a/get-repos b/get-repos index bfc08ff..796051c 100755 --- a/get-repos +++ b/get-repos @@ -20,7 +20,7 @@ trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR -TMPDIR="$(mktemp -d /tmp/$(basename $0).XXXX)" +TMPDIR="$(mktemp -dt "$(basename $0).XXXX")" DBLIST=() # Repos -- cgit v1.2.3-2-g168b From 0811dea8b9c695ed9e67b22d389142956bd1cdd8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 17:40:26 -0500 Subject: Fix quoting on arrays. --- config | 2 +- createrepos | 2 +- db-functions | 22 +++++++++++----------- db-move | 2 +- db-remove | 14 +++++++------- db-update | 16 ++++++++-------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/config b/config index 0152b69..9d72ebd 100644 --- a/config +++ b/config @@ -12,7 +12,7 @@ USERREPOS=('~smv' '~xihh' '~brendan' '~lukeshu' '~emulatorman' '~aurelien' '~jor # Community project repos PROJREPOS=('pcr' 'kernels' 'cross' 'java' 'java-ugly' 'nonprism') # Remote repos -PKGREPOS=(${ARCHREPOS[@]} ${OURREPOS[@]} ${USERREPOS[@]} ${PROJREPOS[@]}) +PKGREPOS=("${ARCHREPOS[@]}" "${OURREPOS[@]}" "${USERREPOS[@]}" "${PROJREPOS[@]}") PKGPOOL='pool/packages' SRCPOOL='sources/packages' diff --git a/createrepos b/createrepos index 926c158..1840c83 100755 --- a/createrepos +++ b/createrepos @@ -5,4 +5,4 @@ source $(dirname $0)/config mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${ARCH_BASE}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}" -$(dirname $0)/create-repo ${PKGREPOS[@]} +$(dirname $0)/create-repo "${PKGREPOS[@]}" diff --git a/db-functions b/db-functions index f56ca19..59e9c29 100644 --- a/db-functions +++ b/db-functions @@ -445,8 +445,8 @@ check_pkgrepos() { #usage: chk_license ${license[@]}" chk_license() { local l - for l in ${@}; do - in_array ${l} ${ALLOWED_LICENSES[@]} && return 0 + for l in "${@}"; do + in_array "${l}" "${ALLOWED_LICENSES[@]}" && return 0 done return 1 @@ -458,7 +458,7 @@ check_repo_permission() { [ ${#PKGREPOS[@]} -eq 0 ] && return 1 [ -z "${PKGPOOL}" ] && return 1 - in_array "${repo}" ${PKGREPOS[@]} || return 1 + in_array "${repo}" "${PKGREPOS[@]}" || return 1 [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 @@ -497,10 +497,10 @@ arch_repo_add() { # package files might be relative to repo dir pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null - /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \ - || error "repo-add ${repo}${DBEXT} ${pkgs[@]}" - /usr/bin/repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" + /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" >/dev/null \ + || error "repo-add ${repo}${DBEXT} ${pkgs[*]}" + /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ + || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" } @@ -516,9 +516,9 @@ arch_repo_remove() { error "No database found at '${dbfile}'" return 1 fi - /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ - || error "repo-remove ${dbfile} ${pkgs[@]}" - /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ - || error "repo-remove ${filesfile} ${pkgs[@]}" + /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" >/dev/null \ + || error "repo-remove ${dbfile} ${pkgs[*]}" + /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ + || error "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" } diff --git a/db-move b/db-move index 010d941..69f24ac 100755 --- a/db-move +++ b/db-move @@ -66,7 +66,7 @@ for pkgbase in ${args[@]:2}; do if [ -f "${svnrepo_from}/PKGBUILD" ]; then if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi diff --git a/db-remove b/db-remove index f0785e5..255aa32 100755 --- a/db-remove +++ b/db-remove @@ -10,24 +10,24 @@ fi repo="$1" arch="$2" -pkgbases=(${@:3}) +pkgbases=("${@:3}") if ! check_repo_permission $repo; then die "You don't have permission to remove packages from ${repo}" fi if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("$arch") fi -for tarch in ${tarches[@]}; do +for tarch in "${tarches[@]}"; do repo_lock $repo $tarch || exit 1 done remove_pkgs=() -for pkgbase in ${pkgbases[@]}; do +for pkgbase in "${pkgbases[@]}"; do msg "Removing $pkgbase from [$repo]..." if [ -d "${SVNREPO}/$repo/$pkgbase" ]; then @@ -36,11 +36,11 @@ for pkgbase in ${pkgbases[@]}; do warning "$pkgbase not found in ABS(libre)" warning "Removing only $pkgbase from the repo" warning "If it was a split package you have to remove the others yourself!" - remove_pkgs[${#remove_pkgs[*]}]=$pkgbase + remove_pkgs+=("$pkgbase") fi done -for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${remove_pkgs[@]} +for tarch in "${tarches[@]}"; do + arch_repo_remove "${repo}" "${tarch}" "${remove_pkgs[@]}" repo_unlock $repo $tarch done diff --git a/db-update b/db-update index 1fddb8a..cdde63b 100755 --- a/db-update +++ b/db-update @@ -15,14 +15,14 @@ if [ $? -ge 1 ]; then fi # TODO: this might lock too much (architectures) -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do repo_lock ${repo} ${pkgarch} || exit 1 done done # check if packages are valid -for repo in ${repos[@]}; do +for repo in "${repos[@]}"; do pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then if [ ${#pkgs[@]} -gt 0 ] && ! check_repo_permission "${repo}"; then @@ -48,7 +48,7 @@ for repo in ${repos[@]}; do fi done -for repo in ${repos[@]}; do +for repo in "${repos[@]}"; do msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) for pkgarch in ${ARCHES[@]}; do @@ -69,16 +69,16 @@ for repo in ${repos[@]}; do if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}" fi - add_pkgs[${#add_pkgs[*]}]=${pkgfile} + add_pkgs+=("${pkgfile}") done if [ ${#add_pkgs[@]} -ge 1 ]; then - arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]} + arch_repo_add "${repo}" "${pkgarch}" "${add_pkgs[@]}" fi done done -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do repo_unlock ${repo} ${pkgarch} done done -- cgit v1.2.3-2-g168b From 1d08899c3ac82047fe614a7694e5a7235f808cfd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 14:52:20 -0500 Subject: Remove extra local_config loads. Some files were loading local_config even if they did not use any settings from it. --- any-to-ours | 1 - db-cleanup | 1 - get-repos | 1 - 3 files changed, 3 deletions(-) diff --git a/any-to-ours b/any-to-ours index a1d6686..b927b82 100755 --- a/any-to-ours +++ b/any-to-ours @@ -8,7 +8,6 @@ trap_exit() { } source $(dirname $0)/config -source $(dirname $0)/local_config source $(dirname $0)/libremessages # From makepkg diff --git a/db-cleanup b/db-cleanup index 841800b..abad390 100755 --- a/db-cleanup +++ b/db-cleanup @@ -16,7 +16,6 @@ trap_exit() { } source $(dirname $0)/config -source $(dirname $0)/local_config source $(dirname $0)/libremessages # From makepkg diff --git a/get-repos b/get-repos index 796051c..92db9a2 100755 --- a/get-repos +++ b/get-repos @@ -10,7 +10,6 @@ trap_exit() { } source $(dirname $0)/config -source $(dirname $0)/local_config source $(dirname $0)/libremessages # From makepkg -- cgit v1.2.3-2-g168b From b6e8ebd66d22abf5439485985a7851e768c71e8a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:04:43 -0500 Subject: Be very careful about using $0. --- any-to-ours | 4 ++-- create-repo | 8 ++++---- createrepos | 4 ++-- cron-jobs/ftpdir-cleanup | 4 ++-- cron-jobs/integrity-check | 4 ++-- cron-jobs/repo-sanity-check | 4 ++-- cron-jobs/sourceballs | 2 +- cron-jobs/sourceballs2 | 2 +- cron-jobs/update-abs-tarballs | 2 +- cron-jobs/update-web-db | 6 +++--- db-check-nonfree | 6 +++--- db-cleanup | 4 ++-- db-functions | 14 +++++++------- db-list-unsigned-packages | 8 ++++---- db-move | 6 +++--- db-remove | 6 +++--- db-repo-add | 6 +++--- db-repo-remove | 6 +++--- db-sync | 16 ++++++++-------- db-update | 6 +++--- get-repos | 6 +++--- migrate-repo | 2 +- mkrepo | 4 ++-- repo-restore-to-normal | 4 ++-- testing2x | 8 ++++---- yf-update | 12 ++++++------ 26 files changed, 77 insertions(+), 77 deletions(-) diff --git a/any-to-ours b/any-to-ours index b927b82..a1697c7 100755 --- a/any-to-ours +++ b/any-to-ours @@ -7,8 +7,8 @@ trap_exit() { exit 1 } -source $(dirname $0)/config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/libremessages" # From makepkg set -E diff --git a/create-repo b/create-repo index 58842c3..24b890d 100755 --- a/create-repo +++ b/create-repo @@ -1,11 +1,11 @@ #!/bin/bash # Creates repository structure -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -eq 0 ]; then - msg "Usage: $0 repo1 [repo2 ... repoX]" + msg "Usage: ${0##*/} repo1 [repo2 ... repoX]" exit 1 fi @@ -21,4 +21,4 @@ for _repo in $@; do done done -msg "Don't forget to add them to the PKGREPOS array on $(dirname $0)/config" +msg "Don't forget to add them to the PKGREPOS array on %s/config" "$(dirname "$(readlink -e "$0")")" diff --git a/createrepos b/createrepos index 1840c83..a8f93e8 100755 --- a/createrepos +++ b/createrepos @@ -1,8 +1,8 @@ #!/bin/bash # Creates the repo structure defined in config -source $(dirname $0)/config +source "$(dirname "$(readlink -e "$0")")/config" mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${ARCH_BASE}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}" -$(dirname $0)/create-repo "${PKGREPOS[@]}" +"$(dirname "$(readlink -e "$0")")/create-repo" "${PKGREPOS[@]}" diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 83e6e17..8d691b5 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" clean_pkg() { local pkg diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index d4f9694..05a56a5 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -1,6 +1,6 @@ #!/bin/bash -dirname="$(dirname $0)" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../db-functions" . "${dirname}/../config" @@ -8,7 +8,7 @@ dirname="$(dirname $0)" script_lock if [ $# -ne 1 ]; then - die "usage: $(basename $0) " + die "usage: ${0##*/} " fi mailto=$1 diff --git a/cron-jobs/repo-sanity-check b/cron-jobs/repo-sanity-check index 1ba90a6..2aa7892 100755 --- a/cron-jobs/repo-sanity-check +++ b/cron-jobs/repo-sanity-check @@ -1,8 +1,8 @@ #!/bin/bash # Solves issue165 -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" # Traverse all repos for _repo in ${PKGREPOS[@]}; do diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index ee074bd..73d8432 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -1,6 +1,6 @@ #!/bin/bash -dirname="$(dirname $(readlink -e $0))" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../db-functions" . "${dirname}/../config" pushd "${WORKDIR}" >/dev/null diff --git a/cron-jobs/sourceballs2 b/cron-jobs/sourceballs2 index 5644268..eb46579 100755 --- a/cron-jobs/sourceballs2 +++ b/cron-jobs/sourceballs2 @@ -4,7 +4,7 @@ # Makepkg --allsource every package # Remove the old sourceballs -dirname="$(dirname $(readlink -e $0))" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../db-functions" . "${dirname}/../config" . "${MAKEPKGCONF}" diff --git a/cron-jobs/update-abs-tarballs b/cron-jobs/update-abs-tarballs index 824ac34..901cc4b 100755 --- a/cron-jobs/update-abs-tarballs +++ b/cron-jobs/update-abs-tarballs @@ -1,6 +1,6 @@ #!/bin/bash -. "$(dirname $0)/../config" +. "$(dirname "$(readlink -e "$0")")/../config" rsync -av --exclude=staging/ parabolagnulinux.org::abstar/ ${FTP_BASE}/ diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 6ced4c1..825eea6 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" # setup paths SPATH="/srv/http/archweb" @@ -14,7 +14,7 @@ REPOS=('community-testing' 'multilib-testing' 'multilib' 'community' 'extra' 'te LOGOUT="/tmp/archweb_update.log" # figure out what operation to perform -cmd="$(basename $0)" +cmd="${0##*/}" if [[ $cmd != "update-web-db" && $cmd != "update-web-files-db" ]]; then die "Invalid command name '$cmd' specified!" fi diff --git a/db-check-nonfree b/db-check-nonfree index ecad3b9..661daa6 100755 --- a/db-check-nonfree +++ b/db-check-nonfree @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -ge 1 ]; then - warning "Calling $(basename $0) with a specific repository is not supported" + warning "Calling ${0##*/} with a specific repository is not supported" exit 1 fi diff --git a/db-cleanup b/db-cleanup index abad390..57ef36e 100755 --- a/db-cleanup +++ b/db-cleanup @@ -15,8 +15,8 @@ trap_exit() { exit 1 } -source $(dirname $0)/config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/libremessages" # From makepkg set -E diff --git a/db-functions b/db-functions index 59e9c29..26b23e4 100644 --- a/db-functions +++ b/db-functions @@ -16,7 +16,7 @@ restore_umask () { } # set up general environment -WORKDIR=$(mktemp -dt "$(basename $0).XXXXXXXXXX") +WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") LOCKS=() # check if messages are to be printed using color @@ -85,10 +85,10 @@ get_full_version() { } script_lock() { - local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - error "Script $(basename $0) is already locked by $_owner." + error "Script ${0##*/} is already locked by $_owner." exit 1 else set_umask @@ -97,9 +97,9 @@ script_lock() { } script_unlock() { - local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then - warning "Script $(basename $0) was not locked!" + warning "Script ${0##*/} was not locked!" restore_umask return 1 else @@ -123,8 +123,8 @@ cleanup() { repo_unlock $repo $arch fi done - if [ -d "$TMPDIR/.scriptlock.$(basename $0)" ]; then - msg "Removing left over lock from $(basename $0)" + if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then + msg "Removing left over lock from ${0##*/}" script_unlock fi rm -rf "$WORKDIR" diff --git a/db-list-unsigned-packages b/db-list-unsigned-packages index 3b5a5bd..985d1c0 100755 --- a/db-list-unsigned-packages +++ b/db-list-unsigned-packages @@ -20,11 +20,11 @@ set -e # unsigned packages available for architecture $1 and specified for # architecture $2 (usually $1 or any, default is to list all). -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 1 ]; then - msg "usage: $(basename $0) " + msg "usage: ${0##*/} " exit 1 fi @@ -34,5 +34,5 @@ shift for repo in ${PKGREPOS[@]} do db="${FTP_BASE}/${repo}/os/${arch}/${repo}.db" - [ -f "$db" ] && "$(dirname $0)/db-list-unsigned-packages.py" "$repo" "$@" < "$db" + [ -f "$db" ] && "$(dirname "$(readlink -e "$0")")/db-list-unsigned-packages.py" "$repo" "$@" < "$db" done diff --git a/db-move b/db-move index 69f24ac..a3f1532 100755 --- a/db-move +++ b/db-move @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi diff --git a/db-remove b/db-remove index 255aa32..4e45881 100755 --- a/db-remove +++ b/db-remove @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi diff --git a/db-repo-add b/db-repo-add index b83fb77..2b7894a 100755 --- a/db-repo-add +++ b/db-repo-add @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi diff --git a/db-repo-remove b/db-repo-remove index 4f04ed1..09e34da 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi diff --git a/db-sync b/db-sync index e8481d6..c4d495e 100755 --- a/db-sync +++ b/db-sync @@ -21,7 +21,7 @@ ${VERBOSE} && extra="-v" # Returns contents of a repo get_repos() { - mkdir -p ${TMPDIR}/$0.$$.cache + mkdir -p ${TMPDIR}/${0##*/}.$$.cache # Exclude everything but db files rsync ${extra} -mrtlH --no-p --include="*/" \ --include="*.db" \ @@ -30,7 +30,7 @@ get_repos() { --include="*${FILESEXT}" \ --exclude="*" \ --delete-after \ - rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/$0.$$.cache + rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache } get_repo_content() { @@ -48,7 +48,7 @@ get_blacklist() { # repo # arch get_repo_file() { - echo "${TMPDIR}/$0.$$.cache/${1}/os/${2}/${1}" + echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" } # Process the databases and get the libre packages @@ -118,7 +118,7 @@ init() { rsync ${extra} -rtlH \ --delay-updates \ --safe-links \ - ${TMPDIR}/$0.$$.cache/${_repo}/os/${_arch}/ \ + ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ ${FTP_BASE}/${_repo}/os/${_arch}/ # Cleanup @@ -176,9 +176,9 @@ trap_exit() { } -source $(dirname $0)/config -source $(dirname $0)/local_config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/local_config" +source "$(dirname "$(readlink -e "$0")")/libremessages" # From makepkg set -E @@ -189,4 +189,4 @@ trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR init -rm -r ${TMPDIR}/$0.$$.cache +rm -r ${TMPDIR}/${0##*/}.$$.cache diff --git a/db-update b/db-update index cdde63b..86faec3 100755 --- a/db-update +++ b/db-update @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -ge 1 ]; then - warning "Calling $(basename $0) with a specific repository is no longer supported" + warning "Calling ${0##*/} with a specific repository is no longer supported" exit 1 fi diff --git a/get-repos b/get-repos index 92db9a2..a477cf2 100755 --- a/get-repos +++ b/get-repos @@ -9,8 +9,8 @@ trap_exit() { exit 1 } -source $(dirname $0)/config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/libremessages" # From makepkg set -E @@ -19,7 +19,7 @@ trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR -TMPDIR="$(mktemp -dt "$(basename $0).XXXX")" +TMPDIR="$(mktemp -dt "${0##*/}.XXXX")" DBLIST=() # Repos diff --git a/migrate-repo b/migrate-repo index 2e44adb..751d5bd 100755 --- a/migrate-repo +++ b/migrate-repo @@ -1,6 +1,6 @@ #!/bin/bash -source $(dirname $0)/config +source "$(dirname "$(readlink -e "$0")")/config" #dryrun="--dry-run" diff --git a/mkrepo b/mkrepo index 5f704cc..10d014b 100755 --- a/mkrepo +++ b/mkrepo @@ -3,8 +3,8 @@ # License: GPLv3+ # Description: A script to quickly create new [repos] -source $(dirname $0)/config -source $(dirname $0)/local_config +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/local_config" # TODO it would be simpler to expand arrays to {element1,element2,etc} for repo in $@; do diff --git a/repo-restore-to-normal b/repo-restore-to-normal index 9463731..3636920 100755 --- a/repo-restore-to-normal +++ b/repo-restore-to-normal @@ -1,8 +1,8 @@ #!/bin/bash # Solves issue165 -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" CLEANUP_DESTDIR=/home/parabolavnx/repo/pool/restore PKGREPOS=(community) diff --git a/testing2x b/testing2x index 54cae11..14a45de 100755 --- a/testing2x +++ b/testing2x @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 1 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi @@ -54,7 +54,7 @@ for repo in 'core' 'extra'; do repo_unlock ${repo} ${pkgarch} done if [ -n "${pkgs[${repo}]}" ]; then - "$(dirname $0)/db-move" 'testing' "${repo}" ${pkgs[${repo}]} + "$(dirname "$(readlink -e "$0")")/db-move" 'testing' "${repo}" ${pkgs[${repo}]} fi done diff --git a/yf-update b/yf-update index 9c2131e..3bce4aa 100755 --- a/yf-update +++ b/yf-update @@ -1,17 +1,17 @@ #!/bin/bash -source $(dirname $0)/local_config -source $(dirname $0)/config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/local_config" +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/libremessages" blacklist_mtime=$(printf "%.0f" $(find ${blacklist} -printf "%T@")) -last_bl_mtime=$(cat $(dirname $0)/yftime) +last_bl_mtime=$(cat "$(dirname "$(readlink -e "$0")")/yftime") if [ $blacklist_mtime -gt $last_bl_mtime ]; then - pushd $(dirname $0)/yf + pushd "$(dirname "$(readlink -e "$0")")/yf" makepkg -f find . -name "*${PKGEXT}" -exec mv {} ${STAGING}/libre \; popd - echo ${blacklist_mtime} > $(dirname $0)/yftime + echo ${blacklist_mtime} > "$(dirname "$(readlink -e "$0")")/yftime" msg2 "built and staged" else msg2 "nothing to do" -- cgit v1.2.3-2-g168b From 8650ad4fdef09b1244ba138531b6a1e2bbd0975b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 18:00:12 -0500 Subject: Get rid of $ARCH_BASE; these days it is the same as $FTP_BASE --- config | 1 - createrepos | 2 +- cron-jobs/sourceballs | 10 +++++----- cron-jobs/sourceballs2 | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/config b/config index 9d72ebd..c3f9a55 100644 --- a/config +++ b/config @@ -1,6 +1,5 @@ #!/bin/bash # as a hint to text editors FTP_BASE="/srv/http/repo/public" -ARCH_BASE="/srv/http/repo/public" SVNREPO="/var/abs" # Repos from Arch diff --git a/createrepos b/createrepos index a8f93e8..8da2455 100755 --- a/createrepos +++ b/createrepos @@ -3,6 +3,6 @@ source "$(dirname "$(readlink -e "$0")")/config" -mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${ARCH_BASE}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}" +mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}" "$(dirname "$(readlink -e "$0")")/create-repo" "${PKGREPOS[@]}" diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 73d8432..4debcee 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -21,10 +21,10 @@ renice +10 -p $$ > /dev/null for repo in ${PKGREPOS[@]}; do for arch in ${ARCHES[@]}; do # Repo does not exist; skip it - if [ ! -f "${ARCH_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then + if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then continue fi - bsdtar -xOf "${ARCH_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" \ + bsdtar -xOf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" \ | awk '/^%NAME%/ { getline b }; /^%BASE%/ { getline b }; /^%VERSION%/ { getline v }; @@ -46,7 +46,7 @@ for repo in ${PKGREPOS[@]}; do done # Create a list of all available source package file names -find "${ARCH_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" +find "${FTP_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" # Check for all packages if we need to build a source package for repo in ${PKGREPOS[@]}; do @@ -96,7 +96,7 @@ for repo in ${PKGREPOS[@]}; do pushd "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null makepkg --nocolor --allsource --ignorearch # >/dev/null 2>&1 if [ $? -eq 0 ] && [ -f "${pkgbase}-${pkgver}${SRCEXT}" ]; then - mv "${pkgbase}-${pkgver}${SRCEXT}" "${ARCH_BASE}/${SRCPOOL}" + mv "${pkgbase}-${pkgver}${SRCEXT}" "${FTP_BASE}/${SRCPOOL}" # Avoid creating the same source package for every arch echo "${pkgbase}-${pkgver}${SRCEXT}" >> "${WORKDIR}/available-src-pkgs" newpkgs[${#newpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" @@ -132,7 +132,7 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then for old_pkg in ${old_pkgs[@]}; do msg2 "${old_pkg}" if ! ${SOURCE_CLEANUP_DRYRUN}; then - mv "$ARCH_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}" + mv "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}" touch "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" fi done diff --git a/cron-jobs/sourceballs2 b/cron-jobs/sourceballs2 index eb46579..bbe227d 100755 --- a/cron-jobs/sourceballs2 +++ b/cron-jobs/sourceballs2 @@ -17,7 +17,7 @@ script_lock renice +10 -p $$ > /dev/null # Create a list of all available source package file names -find "${ARCH_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" +find "${FTP_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" pushd "${SVNREPO}" >/dev/null -- cgit v1.2.3-2-g168b From 62142bcbac5f457b2172c7311741f90fedf0c776 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 15:20:16 -0500 Subject: fix comments, indentation --- cron-jobs/sourceballs | 12 ++++++------ db-functions | 14 +++++++------- db-move | 2 +- db-remove | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 4debcee..6393472 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -59,11 +59,11 @@ for repo in ${PKGREPOS[@]}; do pkgarch=${pkginfo[2]} pkglicense=(${pkginfo[@]:3}) - # Should this packages be skipped? + # Should this package be skipped? if grep -Fqx "${pkgbase}" "${dirname}/sourceballs.skip"; then continue fi - # Commenting out, we'll sourceball everything + # Commenting out, we'll sourceball everything # Check if the license or .force file does not enforce creating a source package # if ! (chk_license ${pkglicense[@]} || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then # continue @@ -83,10 +83,10 @@ for repo in ${PKGREPOS[@]}; do #svn export -q "${SVNREPO}/${pkgbase}/repos/${repo}-${pkgarch}" \ # "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null 2>&1 - # If it's on official repos, nor [libre], nor [libre-testing] - cp -r "${SVNREPO}/$repo/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 || \ - cp -r "${SVNREPO}/libre/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 || \ - cp -r "${SVNREPO}/libre-testing/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 + # If it's on official repos, nor [libre], nor [libre-testing] + cp -r "${SVNREPO}/$repo/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 || \ + cp -r "${SVNREPO}/libre/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 || \ + cp -r "${SVNREPO}/libre-testing/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 if [ $? -ge 1 ]; then failedpkgs[${#failedpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" continue diff --git a/db-functions b/db-functions index 26b23e4..e681504 100644 --- a/db-functions +++ b/db-functions @@ -375,7 +375,7 @@ check_splitpkgs() { for pkgfile in ${pkgfiles[@]}; do issplitpkg "${pkgfile}" || continue local _pkgbase="$(getpkgbase ${pkgfile})" - msg2 "Checking $_pkgbase" + msg2 "Checking $_pkgbase" local _pkgname="$(getpkgname ${pkgfile})" local _pkgarch="$(getpkgarch ${pkgfile})" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" @@ -384,14 +384,14 @@ check_splitpkgs() { if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - cp -r ${SVNREPO}/$repo/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null 2>&1 || \ - cp -r ${SVNREPO}/libre/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null 2>&1 || \ - cp -r ${SVNREPO}/libre-testing/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/$_pkgbase">/dev/null 2>&1 + cp -r ${SVNREPO}/$repo/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null 2>&1 || \ + cp -r ${SVNREPO}/libre/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null 2>&1 || \ + cp -r ${SVNREPO}/libre-testing/$_pkgbase/PKGBUILD "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/$_pkgbase">/dev/null 2>&1 [[ $? -ge 1 ]] && { - echo "Failed $_pkgbase-$_pkgver-$_pkgarch" - return 1 - } + echo "Failed $_pkgbase-$_pkgver-$_pkgarch" + return 1 + } fi local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) diff --git a/db-move b/db-move index a3f1532..41ef4c1 100755 --- a/db-move +++ b/db-move @@ -24,7 +24,7 @@ for pkgarch in ${ARCHES[@]}; do repo_lock ${repo_from} ${pkgarch} || exit 1 done -# No idea why we loop twice... -- fauno +# First loop is to check that all necessary files exist for pkgbase in ${args[@]:2}; do for pkgarch in ${ARCHES[@]} 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" diff --git a/db-remove b/db-remove index 4e45881..2a12dba 100755 --- a/db-remove +++ b/db-remove @@ -30,8 +30,8 @@ remove_pkgs=() for pkgbase in "${pkgbases[@]}"; do msg "Removing $pkgbase from [$repo]..." - if [ -d "${SVNREPO}/$repo/$pkgbase" ]; then - remove_pkgs=($(. "${SVNREPO}/$repo/$pkgbase/PKGBUILD"; echo ${pkgname[@]})) + if [ -d "${SVNREPO}/$repo/$pkgbase" ]; then + remove_pkgs=($(. "${SVNREPO}/$repo/$pkgbase/PKGBUILD"; echo ${pkgname[@]})) else warning "$pkgbase not found in ABS(libre)" warning "Removing only $pkgbase from the repo" -- cgit v1.2.3-2-g168b From eefb787983d2608511214bcd682f3d8271bac60c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 16:44:51 -0500 Subject: Normalize to load config then local_config then db-functions --- create-repo | 2 +- cron-jobs/ftpdir-cleanup | 2 +- cron-jobs/integrity-check | 2 +- cron-jobs/repo-sanity-check | 2 +- cron-jobs/sourceballs | 2 +- cron-jobs/sourceballs2 | 2 +- cron-jobs/update-web-db | 2 +- db-check-nonfree | 2 +- db-list-unsigned-packages | 2 +- db-move | 2 +- db-remove | 2 +- db-repo-add | 2 +- db-repo-remove | 2 +- db-update | 2 +- repo-restore-to-normal | 2 +- testing2x | 2 +- yf-update | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/create-repo b/create-repo index 24b890d..21a2a9c 100755 --- a/create-repo +++ b/create-repo @@ -1,8 +1,8 @@ #!/bin/bash # Creates repository structure -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -eq 0 ]; then msg "Usage: ${0##*/} repo1 [repo2 ... repoX]" diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 8d691b5..b290138 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/../db-functions" . "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" clean_pkg() { local pkg diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index 05a56a5..86a8f1d 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -2,8 +2,8 @@ dirname="$(dirname "$(readlink -e "$0")")" -. "${dirname}/../db-functions" . "${dirname}/../config" +. "${dirname}/../db-functions" script_lock diff --git a/cron-jobs/repo-sanity-check b/cron-jobs/repo-sanity-check index 2aa7892..ee4c061 100755 --- a/cron-jobs/repo-sanity-check +++ b/cron-jobs/repo-sanity-check @@ -1,8 +1,8 @@ #!/bin/bash # Solves issue165 -. "$(dirname "$(readlink -e "$0")")/../db-functions" . "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" # Traverse all repos for _repo in ${PKGREPOS[@]}; do diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 6393472..c9aadba 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -1,8 +1,8 @@ #!/bin/bash dirname="$(dirname "$(readlink -e "$0")")" -. "${dirname}/../db-functions" . "${dirname}/../config" +. "${dirname}/../db-functions" pushd "${WORKDIR}" >/dev/null script_lock diff --git a/cron-jobs/sourceballs2 b/cron-jobs/sourceballs2 index bbe227d..1432bdf 100755 --- a/cron-jobs/sourceballs2 +++ b/cron-jobs/sourceballs2 @@ -5,8 +5,8 @@ # Remove the old sourceballs dirname="$(dirname "$(readlink -e "$0")")" -. "${dirname}/../db-functions" . "${dirname}/../config" +. "${dirname}/../db-functions" . "${MAKEPKGCONF}" pushd "${WORKDIR}" >/dev/null diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 825eea6..713e75e 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/../db-functions" . "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" # setup paths SPATH="/srv/http/archweb" diff --git a/db-check-nonfree b/db-check-nonfree index 661daa6..5cb7f6f 100755 --- a/db-check-nonfree +++ b/db-check-nonfree @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -ge 1 ]; then warning "Calling ${0##*/} with a specific repository is not supported" diff --git a/db-list-unsigned-packages b/db-list-unsigned-packages index 985d1c0..5105096 100755 --- a/db-list-unsigned-packages +++ b/db-list-unsigned-packages @@ -20,8 +20,8 @@ set -e # unsigned packages available for architecture $1 and specified for # architecture $2 (usually $1 or any, default is to list all). -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 1 ]; then msg "usage: ${0##*/} " diff --git a/db-move b/db-move index 41ef4c1..eed48eb 100755 --- a/db-move +++ b/db-move @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} ..." diff --git a/db-remove b/db-remove index 2a12dba..46585ad 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} ..." diff --git a/db-repo-add b/db-repo-add index 2b7894a..a6355a1 100755 --- a/db-repo-add +++ b/db-repo-add @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} ..." diff --git a/db-repo-remove b/db-repo-remove index 09e34da..7077d62 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} ..." diff --git a/db-update b/db-update index 86faec3..e3da232 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -ge 1 ]; then warning "Calling ${0##*/} with a specific repository is no longer supported" diff --git a/repo-restore-to-normal b/repo-restore-to-normal index 3636920..3fe4816 100755 --- a/repo-restore-to-normal +++ b/repo-restore-to-normal @@ -1,8 +1,8 @@ #!/bin/bash # Solves issue165 -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" CLEANUP_DESTDIR=/home/parabolavnx/repo/pool/restore PKGREPOS=(community) diff --git a/testing2x b/testing2x index 14a45de..b6828fc 100755 --- a/testing2x +++ b/testing2x @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 1 ]; then msg "usage: ${0##*/} ..." diff --git a/yf-update b/yf-update index 3bce4aa..b6dff14 100755 --- a/yf-update +++ b/yf-update @@ -1,6 +1,6 @@ #!/bin/bash -source "$(dirname "$(readlink -e "$0")")/local_config" source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/local_config" source "$(dirname "$(readlink -e "$0")")/libremessages" blacklist_mtime=$(printf "%.0f" $(find ${blacklist} -printf "%T@")) -- cgit v1.2.3-2-g168b From 9d9116bd23720cf6c5b27aa39e5cc4c71de1fb26 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:27:07 -0500 Subject: Fix some array quoting. --- create-repo | 4 ++-- cron-jobs/check_archlinux/parse_pkgbuilds.sh | 22 +++++++++++----------- cron-jobs/ftpdir-cleanup | 10 +++++----- cron-jobs/repo-sanity-check | 4 ++-- cron-jobs/sourceballs | 28 ++++++++++++++-------------- cron-jobs/sourceballs2 | 4 ++-- db-check-nonfree | 22 +++++++++++----------- db-functions | 26 +++++++++++++------------- db-list-unsigned-packages | 2 +- db-move | 28 ++++++++++++++-------------- db-update | 8 ++++---- get-repos | 6 +++--- repo-restore-to-normal | 6 +++--- 13 files changed, 85 insertions(+), 85 deletions(-) diff --git a/create-repo b/create-repo index 21a2a9c..1ec9798 100755 --- a/create-repo +++ b/create-repo @@ -10,12 +10,12 @@ if [ $# -eq 0 ]; then fi msg "Creating repos..." -for _repo in $@; do +for _repo in "$@"; do msg2 "Creating [${_repo}]" mkdir -p "${FTP_BASE}/staging/${_repo}" || \ error "Failed creating staging dir" - for _arch in ${ARCHES[@]}; do + for _arch in "${ARCHES[@]}"; do mkdir -p "${FTP_BASE}/${_repo}/os/${_arch}" || \ error "Failed creating ${_arch} dir" done diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh index 3f92169..c8d8618 100755 --- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh +++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh @@ -6,18 +6,18 @@ exit() { return; } splitpkg_overrides=('depends' 'optdepends' 'provides' 'conflicts') -variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' ${splitpkg_overrides[@]}) +variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' "${splitpkg_overrides[@]}") readonly -a variables splitpkg_overrides backup_package_variables() { - for var in ${splitpkg_overrides[@]}; do + for var in "${splitpkg_overrides[@]}"; do indirect="${var}_backup" eval "${indirect}=(\${$var[@]})" done } restore_package_variables() { - for var in ${splitpkg_overrides[@]}; do + for var in "${splitpkg_overrides[@]}"; do indirect="${var}_backup" if [ -n "${!indirect}" ]; then eval "${var}=(\${$indirect[@]})" @@ -42,31 +42,31 @@ print_info() { if [ -n "$arch" ]; then echo "%ARCH%" - for i in ${arch[@]}; do echo $i; done + for i in "${arch[@]}"; do echo $i; done echo "" fi if [ -n "$depends" ]; then echo "%DEPENDS%" - for i in ${depends[@]}; do + for i in "${depends[@]}"; do echo $i done echo "" fi if [ -n "$makedepends" ]; then echo "%MAKEDEPENDS%" - for i in ${makedepends[@]}; do + for i in "${makedepends[@]}"; do echo $i done echo "" fi if [ -n "$conflicts" ]; then echo "%CONFLICTS%" - for i in ${conflicts[@]}; do echo $i; done + for i in "${conflicts[@]}"; do echo $i; done echo "" fi if [ -n "$provides" ]; then echo "%PROVIDES%" - for i in ${provides[@]}; do echo $i; done + for i in "${provides[@]}"; do echo $i; done echo "" fi } @@ -75,7 +75,7 @@ source_pkgbuild() { ret=0 dir=$1 pkgbuild=$dir/PKGBUILD - for var in ${variables[@]}; do + for var in "${variables[@]}"; do unset ${var} done source $pkgbuild &>/dev/null || ret=$? @@ -88,7 +88,7 @@ source_pkgbuild() { if [ "${#pkgname[@]}" -gt "1" ]; then pkgbase=${pkgbase:-${pkgname[0]}} - for pkg in ${pkgname[@]}; do + for pkg in "${pkgname[@]}"; do if [ "$(type -t package_${pkg})" != "function" ]; then echo -e "%INVALID%\n$pkgbuild\n" return 1 @@ -98,7 +98,7 @@ source_pkgbuild() { while IFS= read -r line; do var=${line%%=*} var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters - for realvar in ${variables[@]}; do + for realvar in "${variables[@]}"; do if [ "$var" == "$realvar" ]; then eval $line break diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index b290138..6455ed7 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -25,8 +25,8 @@ clean_pkg() { ${CLEANUP_DRYRUN} && warning 'dry run mode is active' -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then continue fi @@ -69,7 +69,7 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then fi # cleanup of legacy $repo/os/any directories -for repo in ${PKGREPOS[@]}; do +for repo in "${PKGREPOS[@]}"; do if [ ! -d "${FTP_BASE}/${repo}/os/any" ]; then continue fi @@ -103,8 +103,8 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then done fi -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do repo_unlock ${repo} ${arch} done done diff --git a/cron-jobs/repo-sanity-check b/cron-jobs/repo-sanity-check index ee4c061..9d351df 100755 --- a/cron-jobs/repo-sanity-check +++ b/cron-jobs/repo-sanity-check @@ -5,7 +5,7 @@ . "$(dirname "$(readlink -e "$0")")/../db-functions" # Traverse all repos -for _repo in ${PKGREPOS[@]}; do +for _repo in "${PKGREPOS[@]}"; do msg "Cleaning up [${_repo}]" # Find all pkgnames on this repo's abs @@ -19,7 +19,7 @@ for _repo in ${PKGREPOS[@]}; do >/dev/null 2>&1 # also cleanup package functions - for _pkg in ${pkgname[@]}; do + for _pkg in "${pkgname[@]}"; do unset package_${pkg} >/dev/null 2>&1 done diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index c9aadba..8171980 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -7,8 +7,8 @@ pushd "${WORKDIR}" >/dev/null script_lock -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do repo_lock ${repo} ${arch} || exit 1 done done @@ -18,8 +18,8 @@ renice +10 -p $$ > /dev/null # Create a readable file for each repo with the following format # - [ ] -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +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 continue @@ -39,8 +39,8 @@ for repo in ${PKGREPOS[@]}; do done | sort -u > "${WORKDIR}/db-${repo}" done -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do repo_unlock ${repo} ${arch} done done @@ -49,15 +49,15 @@ done find "${FTP_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" # Check for all packages if we need to build a source package -for repo in ${PKGREPOS[@]}; do +for repo in "${PKGREPOS[@]}"; do newpkgs=() failedpkgs=() while read line; do - pkginfo=(${line}) + pkginfo=("${line}") pkgbase=${pkginfo[0]} pkgver=${pkginfo[1]} pkgarch=${pkginfo[2]} - pkglicense=(${pkginfo[@]:3}) + pkglicense=("${pkginfo[@]:3}") # Should this package be skipped? if grep -Fqx "${pkgbase}" "${dirname}/sourceballs.skip"; then @@ -88,7 +88,7 @@ for repo in ${PKGREPOS[@]}; do cp -r "${SVNREPO}/libre/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 || \ cp -r "${SVNREPO}/libre-testing/${pkgbase}" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/" >/dev/null 2>&1 if [ $? -ge 1 ]; then - failedpkgs[${#failedpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" + failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}") continue fi @@ -109,13 +109,13 @@ for repo in ${PKGREPOS[@]}; do if [ ${#newpkgs[@]} -ge 1 ]; then msg "Adding source packages for [${repo}]..." - for new_pkg in ${newpkgs[@]}; do + for new_pkg in "${newpkgs[@]}"; do msg2 "${new_pkg}" done fi if [ ${#failedpkgs[@]} -ge 1 ]; then msg "Failed to create source packages for [${repo}]..." - for failed_pkg in ${failedpkgs[@]}; do + for failed_pkg in "${failedpkgs[@]}"; do msg2 "${failed_pkg}" done fi @@ -129,7 +129,7 @@ old_pkgs=($(comm -23 "${WORKDIR}/available-src-pkgs.sort" "${WORKDIR}/expected-s if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages..." ${SOURCE_CLEANUP_DRYRUN} && warning 'dry run mode is active' - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" if ! ${SOURCE_CLEANUP_DRYRUN}; then mv "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}" @@ -141,7 +141,7 @@ fi old_pkgs=($(find ${SOURCE_CLEANUP_DESTDIR} -type f -name "*${SRCEXT}" -mtime +${SOURCE_CLEANUP_KEEP} -printf '%f\n')) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages from the cleanup directory..." - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" ${SOURCE_CLEANUP_DRYRUN} || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" done diff --git a/cron-jobs/sourceballs2 b/cron-jobs/sourceballs2 index 1432bdf..2a26e6a 100755 --- a/cron-jobs/sourceballs2 +++ b/cron-jobs/sourceballs2 @@ -21,7 +21,7 @@ find "${FTP_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort pushd "${SVNREPO}" >/dev/null -for repo in ${PKGREPOS[@]}; do +for repo in "${PKGREPOS[@]}"; do msg "Sourceballing [${repo}]" pushd $repo >/dev/null @@ -40,7 +40,7 @@ for repo in ${PKGREPOS[@]}; do unset build package url pkgdesc source md5sums depends makedepends \ optdepends license arch options check mksource - for _pkg in ${pkgname[@]}; do + for _pkg in "${pkgname[@]}"; do unset package_${_pkg} >/dev/null 2>&1 done diff --git a/db-check-nonfree b/db-check-nonfree index 5cb7f6f..6e2dc17 100755 --- a/db-check-nonfree +++ b/db-check-nonfree @@ -9,16 +9,16 @@ if [ $# -ge 1 ]; then fi # TODO: this might lock too much (architectures) -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do repo_lock ${repo} ${pkgarch} || exit 1 done done msg "Check nonfree in repo:" nonfree=($(cut -d: -f1 ${BLACKLIST_FILE} | sort -u)) -for repo in ${ARCHREPOS[@]}; do - for pkgarch in ${ARCHES[@]}; do +for repo in "${ARCHREPOS[@]}"; do + for pkgarch in "${ARCHES[@]}"; do msg2 "$repo $pkgarch" if [ ! -f "${FTP_BASE}/${repo}/os/${pkgarch}/${repo}${DBEXT}" ]; then continue @@ -27,20 +27,20 @@ for repo in ${ARCHREPOS[@]}; do unset cleanpkgs cleanpkgs=() dbpkgs=($(bsdtar -xOf "${FTP_BASE}/${repo}/os/${pkgarch}/${repo}${DBEXT}" | awk '/^%NAME%/{getline;print}' | sort -u )) - for pkgname in ${dbpkgs[@]}; do - if in_array ${pkgname} ${nonfree[@]}; then - cleanpkgs+=(${pkgname}) + for pkgname in "${dbpkgs[@]}"; do + if in_array "${pkgname}" "${nonfree[@]}"; then + cleanpkgs+=("${pkgname}") fi done if [ ${#cleanpkgs[@]} -ge 1 ]; then - msg2 "Nonfree: ${cleanpkgs[@]}" - arch_repo_remove "${repo}" "${pkgarch}" ${cleanpkgs[@]} + msg2 "Nonfree: ${cleanpkgs[*]}" + arch_repo_remove "${repo}" "${pkgarch}" "${cleanpkgs[@]}" fi done done -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do repo_unlock ${repo} ${pkgarch} done done diff --git a/db-functions b/db-functions index e681504..83e0613 100644 --- a/db-functions +++ b/db-functions @@ -115,7 +115,7 @@ cleanup() { local arch trap - EXIT INT QUIT TERM - for l in ${LOCKS[@]}; do + for l in "${LOCKS[@]}"; do repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then @@ -299,7 +299,7 @@ getpkgfiles() { exit 1 fi - for f in ${@}; do + for f in "${@}"; do if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 @@ -309,7 +309,7 @@ getpkgfiles() { fi done - echo ${@} + echo "${@}" } check_pkgfile() { @@ -322,7 +322,7 @@ check_pkgfile() { local pkgarch="$(getpkgarch ${pkgfile})" [ $? -ge 1 ] && return 1 - in_array "${pkgarch}" ${ARCHES[@]} 'any' || return 1 + in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 if echo "$(basename ${pkgfile})" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then return 0 @@ -343,7 +343,7 @@ check_pkgsvn() { [ $? -ge 1 ] && return 1 local repo="${2}" - in_array "${repo}" ${PKGREPOS[@]} || return 1 + in_array "${repo}" "${PKGREPOS[@]}" || return 1 if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" @@ -356,7 +356,7 @@ check_pkgsvn() { [ "${svnver}" == "${_pkgver}" ] || return 1 local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - in_array "${_pkgname}" ${svnnames[@]} || return 1 + in_array "${_pkgname}" "${svnnames[@]}" || return 1 return 0 } @@ -364,7 +364,7 @@ check_pkgsvn() { check_splitpkgs() { local repo="${1}" shift - local pkgfiles=(${@}) + local pkgfiles=("${@}") local pkgfile local pkgdir local svnname @@ -372,7 +372,7 @@ check_splitpkgs() { mkdir -p "${WORKDIR}/check_splitpkgs/" pushd "${WORKDIR}/check_splitpkgs" >/dev/null - for pkgfile in ${pkgfiles[@]}; do + for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue local _pkgbase="$(getpkgbase ${pkgfile})" msg2 "Checking $_pkgbase" @@ -395,7 +395,7 @@ check_splitpkgs() { fi local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - for svnname in ${svnnames[@]}; do + for svnname in "${svnnames[@]}"; do echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" done done @@ -430,8 +430,8 @@ check_pkgrepos() { local repo local arch - for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do + for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile})" ] && return 1 @@ -493,7 +493,7 @@ set_repo_permission() { arch_repo_add() { local repo=$1 local arch=$2 - local pkgs=(${@:3}) + local pkgs=("${@:3}") # package files might be relative to repo dir pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null @@ -508,7 +508,7 @@ arch_repo_add() { arch_repo_remove() { local repo=$1 local arch=$2 - local pkgs=(${@:3}) + local pkgs=("${@:3}") local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" diff --git a/db-list-unsigned-packages b/db-list-unsigned-packages index 5105096..f593686 100755 --- a/db-list-unsigned-packages +++ b/db-list-unsigned-packages @@ -31,7 +31,7 @@ fi arch=$1 shift -for repo in ${PKGREPOS[@]} +for repo in "${PKGREPOS[@]}" do db="${FTP_BASE}/${repo}/os/${arch}/${repo}.db" [ -f "$db" ] && "$(dirname "$(readlink -e "$0")")/db-list-unsigned-packages.py" "$repo" "$@" < "$db" diff --git a/db-move b/db-move index eed48eb..a6abb8f 100755 --- a/db-move +++ b/db-move @@ -8,7 +8,7 @@ if [ $# -lt 3 ]; then exit 1 fi -args=(${@}) +args=("${@}") repo_from="${args[0]}" repo_to="${args[1]}" ftppath_from="${FTP_BASE}/${repo_from}/os/" @@ -19,14 +19,14 @@ if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then fi # TODO: this might lock too much (architectures) -for pkgarch in ${ARCHES[@]}; do +for pkgarch in "${ARCHES[@]}"; do repo_lock ${repo_to} ${pkgarch} || exit 1 repo_lock ${repo_from} ${pkgarch} || exit 1 done # First loop is to check that all necessary files exist -for pkgbase in ${args[@]:2}; do - for pkgarch in ${ARCHES[@]} 'any'; do +for pkgbase in "${args[@]:2}"; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) @@ -40,13 +40,13 @@ for pkgbase in ${args[@]:2}; do fi if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null done done @@ -60,8 +60,8 @@ msg "Moving packages from [${repo_from}] to [${repo_to}]..." declare -A add_pkgs declare -A remove_pkgs -for pkgbase in ${args[@]:2}; do - for pkgarch in ${ARCHES[@]} 'any'; do +for pkgbase in "${args[@]:2}"; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" if [ -f "${svnrepo_from}/PKGBUILD" ]; then @@ -70,12 +70,12 @@ for pkgbase in ${args[@]:2}; do else tarches=("${pkgarch}") fi - msg2 "${pkgbase} ($(echo ${tarches[@]}))" + msg2 "${pkgbase} (${tarches[*]})" pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) pkgfile=$(basename "${pkgpath}") @@ -96,14 +96,14 @@ for pkgbase in ${args[@]:2}; do done done -for tarch in ${ARCHES[@]}; do +for tarch in "${ARCHES[@]}"; do 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 done -for pkgarch in ${ARCHES[@]}; do +for pkgarch in "${ARCHES[@]}"; do repo_unlock ${repo_from} ${pkgarch} repo_unlock ${repo_to} ${pkgarch} done diff --git a/db-update b/db-update index e3da232..60cc6cd 100755 --- a/db-update +++ b/db-update @@ -28,7 +28,7 @@ for repo in "${repos[@]}"; do if [ ${#pkgs[@]} -gt 0 ] && ! check_repo_permission "${repo}"; then die "You don't have permission to update packages in ${repo}" fi - for pkg in ${pkgs[@]}; do + for pkg in "${pkgs[@]}"; do if [ -h "${pkg}" ]; then die "Package ${repo}/$(basename ${pkg}) is a symbolic link" fi @@ -40,7 +40,7 @@ for repo in "${repos[@]}"; do fi done # This is fucking obnoxious - #if ! check_splitpkgs ${repo} ${pkgs[@]}; then + #if ! check_splitpkgs ${repo} "${pkgs[@]}"; then # die "Missing split packages for ${repo}" #fi else @@ -51,10 +51,10 @@ done for repo in "${repos[@]}"; do msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) - for pkgarch in ${ARCHES[@]}; do + for pkgarch in "${ARCHES[@]}"; do add_pkgs=() arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) - for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do + for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do pkgfile="$(basename ${pkg})" msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run diff --git a/get-repos b/get-repos index a477cf2..b98d601 100755 --- a/get-repos +++ b/get-repos @@ -23,8 +23,8 @@ TMPDIR="$(mktemp -dt "${0##*/}.XXXX")" DBLIST=() # Repos -for _repo in ${PKGREPOS[@]}; do - for _arch in ${ARCHES[@]}; do +for _repo in "${PKGREPOS[@]}"; do + for _arch in "${ARCHES[@]}"; do DBLIST+=("http://repo.parabolagnulinux.org/${_repo}/os/${_arch}/${_repo}${FILESEXT}") done done @@ -35,7 +35,7 @@ wget --directory-prefix=${TMPDIR} \ --no-verbose \ --force-directories \ --no-host-directories \ - ${DBLIST[@]} || true + "${DBLIST[@]}" || true # Always return true, some databases are expect to be missing # Create the arches regexp arch1|arch2 diff --git a/repo-restore-to-normal b/repo-restore-to-normal index 3fe4816..063aacf 100755 --- a/repo-restore-to-normal +++ b/repo-restore-to-normal @@ -12,7 +12,7 @@ PKGREPOS=(community) # sed "s/^\(.\+-[^-]\+-[^-]\+\)-[^-]\+$/\1/")) # Traverse all repos -for _repo in ${PKGREPOS[@]}; do +for _repo in "${PKGREPOS[@]}"; do msg "Restoring [${_repo}]" # Find all pkgnames on this repo's abs @@ -27,7 +27,7 @@ for _repo in ${PKGREPOS[@]}; do >/dev/null 2>&1 # also cleanup package functions - for _pkg in ${pkgname[@]}; do + for _pkg in "${pkgname[@]}"; do unset package_${pkg} >/dev/null 2>&1 # this fills the on_abs array echo ${_pkg}-${pkgver}-${pkgrel} @@ -49,7 +49,7 @@ for _repo in ${PKGREPOS[@]}; do msg2 "Restoring the following packages:" # plain "$(echo ${restore[@]} | tr ' ' "\n")" - for _pkg in ${on_abs[@]}; do + for _pkg in "${on_abs[@]}"; do find ${CLEANUP_DESTDIR} -name "${_pkg}*" -exec cp -v '{}' ${STAGING}/${_repo} \; done -- cgit v1.2.3-2-g168b From aefd5a4d961e3eca3326c90ba266d04b325c1f15 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 20:36:20 -0500 Subject: db-sync: use tab indent --- db-sync | 263 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 131 insertions(+), 132 deletions(-) diff --git a/db-sync b/db-sync index c4d495e..0e07757 100755 --- a/db-sync +++ b/db-sync @@ -21,158 +21,157 @@ ${VERBOSE} && extra="-v" # Returns contents of a repo get_repos() { - mkdir -p ${TMPDIR}/${0##*/}.$$.cache -# Exclude everything but db files - rsync ${extra} -mrtlH --no-p --include="*/" \ - --include="*.db" \ - --include="*${DBEXT}" \ - --include="*.files" \ - --include="*${FILESEXT}" \ - --exclude="*" \ - --delete-after \ - rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache + mkdir -p ${TMPDIR}/${0##*/}.$$.cache + # Exclude everything but db files + rsync ${extra} -mrtlH --no-p --include="*/" \ + --include="*.db" \ + --include="*${DBEXT}" \ + --include="*.files" \ + --include="*${FILESEXT}" \ + --exclude="*" \ + --delete-after \ + rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache } get_repo_content() { -# Return all contents - bsdtar tf ${1} | \ - cut -d "/" -f 1 | \ - sort -u + # Return all contents + bsdtar tf ${1} | \ + cut -d "/" -f 1 | \ + sort -u } # Prints blacklisted packages get_blacklist() { - cut -d ':' -f 1 "${BLACKLIST_FILE}" + cut -d ':' -f 1 "${BLACKLIST_FILE}" } # repo # arch get_repo_file() { - echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" + echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" } # Process the databases and get the libre packages init() { -# Get the blacklisted packages - blacklist=($(get_blacklist)) -# Store all the whitelist files - whitelists=() - - msg "${#blacklist[@]} packages in blacklist" - -# Sync the repos databases - get_repos - -# Traverse all repo-arch pairs - for _repo in ${ARCHREPOS[@]}; do - for _arch in ${ARCHARCHES[@]}; do - msg "Processing ${_repo}-${_arch}" - - db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} - files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} - - if [ ! -f "${db_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${db_file}" - continue - fi - if [ ! -f "${files_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${files_file}" - continue - fi - -# Remove blacklisted packages and count them -# TODO capture all removed packages for printing on debug mode - msg2 "Removing blacklisted packages from .db database..." - LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" - msg2 "Removing blacklisted packages from .files database..." - LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" - -# Get db contents - db=($(get_repo_content ${db_file})) - - msg2 "Process clean db for syncing..." - -# Create a whitelist, add * wildcard to end -# TODO due to lack of -arch suffix, the pool sync retrieves every arch even if -# we aren't syncing them - echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist - - msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" - -# Sync excluding everything but whitelist -# We delete here for cleanup - rsync ${extra} -rtlH \ - --delete-after \ - --delete-excluded \ - --delay-updates \ - --include-from=/tmp/${_repo}-${_arch}.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - -# Add a new whitelist - whitelists+=(/tmp/${_repo}-${_arch}.whitelist) - - msg "Putting databases back in place" - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - -# Cleanup - unset db - done - done - - - msg "Syncing package pool" -# Concatenate all whitelists - cat ${whitelists[@]} | sort -u > /tmp/any.whitelist - - msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" - -# Sync -# *Don't delete-after*, this is the job of cleanup scripts. It will remove our -# packages too - for PKGPOOL in ${PKGPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ - ${FTP_BASE}/${PKGPOOL}/ - done - -# Sync sources - msg "Syncing source pool" - #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist - - #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" -# Sync -# *Don't delete-after*, this is the job of cleanup scripts. It will remove our -# packages too - for SRCPOOL in ${SRCPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ - ${FTP_BASE}/${SRCPOOL}/ - done - - -# Cleanup - unset blacklist whitelists _arch _repo repo_file + # Get the blacklisted packages + blacklist=($(get_blacklist)) + # Store all the whitelist files + whitelists=() + + msg "${#blacklist[@]} packages in blacklist" + + # Sync the repos databases + get_repos + + # Traverse all repo-arch pairs + for _repo in ${ARCHREPOS[@]}; do + for _arch in ${ARCHARCHES[@]}; do + msg "Processing ${_repo}-${_arch}" + + db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} + files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} + + if [ ! -f "${db_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${db_file}" + continue + fi + if [ ! -f "${files_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${files_file}" + continue + fi + + # Remove blacklisted packages and count them + # TODO capture all removed packages for printing on debug mode + msg2 "Removing blacklisted packages from .db database..." + LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" + msg2 "Removing blacklisted packages from .files database..." + LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" + + # Get db contents + db=($(get_repo_content ${db_file})) + + msg2 "Process clean db for syncing..." + + # Create a whitelist, add * wildcard to end + # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if + # we aren't syncing them + echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + + msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" + + # Sync excluding everything but whitelist + # We delete here for cleanup + rsync ${extra} -rtlH \ + --delete-after \ + --delete-excluded \ + --delay-updates \ + --include-from=/tmp/${_repo}-${_arch}.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Add a new whitelist + whitelists+=(/tmp/${_repo}-${_arch}.whitelist) + + msg "Putting databases back in place" + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Cleanup + unset db + done + done + + + msg "Syncing package pool" + # Concatenate all whitelists + cat ${whitelists[@]} | sort -u > /tmp/any.whitelist + + msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" + + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for PKGPOOL in ${PKGPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ + ${FTP_BASE}/${PKGPOOL}/ + done + + # Sync sources + msg "Syncing source pool" + #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist + + #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for SRCPOOL in ${SRCPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ + ${FTP_BASE}/${SRCPOOL}/ + done + + # Cleanup + unset blacklist whitelists _arch _repo repo_file } trap_exit() { - echo - error "$@" - exit 1 + echo + error "$@" + exit 1 } -- cgit v1.2.3-2-g168b From d3afe9bb766bbdfaab1474d21fd5e28f0a356039 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 20:49:48 -0500 Subject: Avoid using $(basename $var) , use ${var##*/} instead --- abslibre | 2 +- cron-jobs/ftpdir-cleanup | 2 +- db-functions | 10 +++++----- db-move | 2 +- db-update | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/abslibre b/abslibre index fa777ac..a5733f0 100755 --- a/abslibre +++ b/abslibre @@ -96,7 +96,7 @@ sync_pre_mips64el() { # Create .abs.tar.gz tarballs create_tarballs() { for repo in ${ABSLIBRE}/{i686,x86_64}/*; do - baserepo=$(basename $repo) + baserepo=${repo##*/} arch=$(basename $(dirname $repo)) # Remove the old one diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 6455ed7..cb14382 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -16,7 +16,7 @@ clean_pkg() { if [ -e "$pkg.sig" ]; then mv -f "$pkg.sig" "$CLEANUP_DESTDIR" fi - touch "${CLEANUP_DESTDIR}/$(basename ${pkg})" + touch "${CLEANUP_DESTDIR}/${pkg##*/}" fi done fi diff --git a/db-functions b/db-functions index 83e0613..52ad8bb 100644 --- a/db-functions +++ b/db-functions @@ -324,7 +324,7 @@ check_pkgfile() { in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 - if echo "$(basename ${pkgfile})" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then + if echo "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then return 0 else return 1 @@ -425,8 +425,8 @@ check_pkgrepos() { [ -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}/$(basename ${pkgfile})" ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/$(basename ${pkgfile}).sig" ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1 local repo local arch @@ -434,8 +434,8 @@ check_pkgrepos() { for arch in "${ARCHES[@]}"; do [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 - [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile})" ] && return 1 - [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile}).sig" ] && return 1 + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ] && return 1 + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}.sig" ] && return 1 done done diff --git a/db-move b/db-move index a6abb8f..f1c3dea 100755 --- a/db-move +++ b/db-move @@ -77,7 +77,7 @@ for pkgbase in "${args[@]:2}"; do for pkgname in "${pkgnames[@]}"; do for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) - pkgfile=$(basename "${pkgpath}") + pkgfile="${pkgpath##*/}" # copy package to pool if needed # TODO: can be removed once every package has been moved to the package pool diff --git a/db-update b/db-update index 60cc6cd..99c8be5 100755 --- a/db-update +++ b/db-update @@ -30,13 +30,13 @@ for repo in "${repos[@]}"; do fi for pkg in "${pkgs[@]}"; do if [ -h "${pkg}" ]; then - die "Package ${repo}/$(basename ${pkg}) is a symbolic link" + die "Package ${repo}/${pkg##*/} is a symbolic link" fi if ! check_pkgfile "${pkg}"; then - die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" + die "Package ${repo}/${pkg##*/} is not consistent with its meta data" fi if ! check_pkgrepos "${pkg}"; then - die "Package ${repo}/$(basename ${pkg}) already exists in another repository" + die "Package ${repo}/${pkg##*/} already exists in another repository" fi done # This is fucking obnoxious @@ -55,7 +55,7 @@ for repo in "${repos[@]}"; do add_pkgs=() arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do - pkgfile="$(basename ${pkg})" + pkgfile="${pkg##*/}" msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then -- cgit v1.2.3-2-g168b From a1fe8b8d0b49b9285189b1e8e2b5858b0fa4e2aa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:13:03 -0500 Subject: remove unused variables from local_config --- local_config | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/local_config b/local_config index 8f3946a..9b4415e 100644 --- a/local_config +++ b/local_config @@ -1,4 +1,7 @@ -# Mirror options +#/bin/bash # as a hint to text editors +_paraboladir=/srv/http/repo/public + +# db-sync #mirror="mirrors.uk2.net" mirror="mirrors.kernel.org" #mirror="mirror.umd.edu" @@ -7,25 +10,11 @@ mirror="mirrors.kernel.org" #mirror="mirror.de.leaseweb.net" mirrorpath="archlinux" -# Directories: they should end without / -paraboladir=/srv/http/repo/public -tempdir=/tmp -archdb=${tempdir}/db -docs_dir=${paraboladir}/docs -repodir=${paraboladir} -licenses_dir=${docs_dir}/pending_licenses -# End Directories - -# Files -logname=${paraboladir}/log/$(date -u +%Y%m%d-%H:%M)-repo-maintainer.log -rsout_file=${tempdir}/rsout -rsync_not_needed=${tempdir}/rsync_not_needed - -rsync_blacklist=${docs_dir}/rsyncBlacklist +# mkrepo +repodir=${_paraboladir} -blacklist=${docs_dir}/blacklist.txt -whitelist=${docs_dir}/whitelist.txt +# yf-update +blacklist=${_paraboladir}/docs/blacklist.txt +whitelist=${_paraboladir}/docs/whitelist.txt -# Rsync commands -rsync_list_command="rsync -rptgoL --exclude='*.abs.tar.*' --list-only --no-motd " -rsync_update_command="rsync -vrptgoL --exclude='*.abs.tar.*' --no-motd " +unset _paraboladir -- cgit v1.2.3-2-g168b From 93eb77cbad072a25b9aa5542ce7fa59746ca9284 Mon Sep 17 00:00:00 2001 From: aurelien Date: Sat, 11 Jan 2014 12:39:37 +0100 Subject: modification on db-update for mail --- db-update | 1 + 1 file changed, 1 insertion(+) diff --git a/db-update b/db-update index 99c8be5..73d5d3f 100755 --- a/db-update +++ b/db-update @@ -91,5 +91,6 @@ while read -r file; do else mkdir -p -- "${pub%/*}" mv -vn "$file" "$pub" + echo "At `date`, script \"`basename $0`\" mailed to "maintenance@lists.parabolagnulinux.org"." fi done < <(find other sources -type f) -- cgit v1.2.3-2-g168b From 2d217815fcfe05152272c20e49e4e69927d04a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Wed, 15 Jan 2014 19:12:38 -0200 Subject: revert to old db-sync until fix it, rename lastest db-sync to db-sync.orig --- db-sync | 265 +++++++++++++++++++++++++++++------------------------------ db-sync.orig | 191 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 321 insertions(+), 135 deletions(-) create mode 100755 db-sync.orig diff --git a/db-sync b/db-sync index 0e07757..81dee24 100755 --- a/db-sync +++ b/db-sync @@ -21,163 +21,158 @@ ${VERBOSE} && extra="-v" # Returns contents of a repo get_repos() { - mkdir -p ${TMPDIR}/${0##*/}.$$.cache - # Exclude everything but db files - rsync ${extra} -mrtlH --no-p --include="*/" \ - --include="*.db" \ - --include="*${DBEXT}" \ - --include="*.files" \ - --include="*${FILESEXT}" \ - --exclude="*" \ - --delete-after \ - rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache + mkdir -p ${TMPDIR}/$0.$$.cache +# Exclude everything but db files + rsync ${extra} -mrtlH --no-p --include="*/" \ + --include="*.db" \ + --include="*${DBEXT}" \ + --exclude="*" \ + --delete-after \ + rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/$0.$$.cache } get_repo_content() { - # Return all contents - bsdtar tf ${1} | \ - cut -d "/" -f 1 | \ - sort -u +# Return all contents + bsdtar tf ${1} | \ + cut -d "/" -f 1 | \ + sort -u } # Prints blacklisted packages get_blacklist() { - cut -d ':' -f 1 "${BLACKLIST_FILE}" + cut -d ':' -f 1 "${BLACKLIST_FILE}" } # repo # arch get_repo_file() { - echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" +# shopt -s nullglob + + echo "${TMPDIR}/$0.$$.cache/${1}/os/${2}/${1}${DBEXT}" } # Process the databases and get the libre packages init() { - # Get the blacklisted packages - blacklist=($(get_blacklist)) - # Store all the whitelist files - whitelists=() - - msg "${#blacklist[@]} packages in blacklist" - - # Sync the repos databases - get_repos - - # Traverse all repo-arch pairs - for _repo in ${ARCHREPOS[@]}; do - for _arch in ${ARCHARCHES[@]}; do - msg "Processing ${_repo}-${_arch}" - - db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} - files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} - - if [ ! -f "${db_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${db_file}" - continue - fi - if [ ! -f "${files_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${files_file}" - continue - fi - - # Remove blacklisted packages and count them - # TODO capture all removed packages for printing on debug mode - msg2 "Removing blacklisted packages from .db database..." - LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" - msg2 "Removing blacklisted packages from .files database..." - LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" - - # Get db contents - db=($(get_repo_content ${db_file})) - - msg2 "Process clean db for syncing..." - - # Create a whitelist, add * wildcard to end - # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if - # we aren't syncing them - echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist - - msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" - - # Sync excluding everything but whitelist - # We delete here for cleanup - rsync ${extra} -rtlH \ - --delete-after \ - --delete-excluded \ - --delay-updates \ - --include-from=/tmp/${_repo}-${_arch}.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - - # Add a new whitelist - whitelists+=(/tmp/${_repo}-${_arch}.whitelist) - - msg "Putting databases back in place" - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - - # Cleanup - unset db - done - done - - - msg "Syncing package pool" - # Concatenate all whitelists - cat ${whitelists[@]} | sort -u > /tmp/any.whitelist - - msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" - - # Sync - # *Don't delete-after*, this is the job of cleanup scripts. It will remove our - # packages too - for PKGPOOL in ${PKGPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ - ${FTP_BASE}/${PKGPOOL}/ - done - - # Sync sources - msg "Syncing source pool" - #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist - - #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" - # Sync - # *Don't delete-after*, this is the job of cleanup scripts. It will remove our - # packages too - for SRCPOOL in ${SRCPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ - ${FTP_BASE}/${SRCPOOL}/ - done - - # Cleanup - unset blacklist whitelists _arch _repo repo_file +# Get the blacklisted packages + blacklist=($(get_blacklist)) +# Store all the whitelist files + whitelists=() + + msg "${#blacklist[@]} packages in blacklist" + +# Sync the repos databases + get_repos + +# Traverse all repo-arch pairs + for _repo in ${ARCHREPOS[@]}; do + for _arch in ${ARCHARCHES[@]}; do + msg "Processing ${_repo}-${_arch}" + + repo_file=$(get_repo_file ${_repo} ${_arch}) + + if [ ! -f "${repo_file}" ]; then + warning "${repo_file} doesn't exist, skipping this repo-arch" + continue + fi + +# Remove blacklisted packages and count them +# TODO capture all removed packages for printing on debug mode + msg2 "Removing blacklisted packages: $( + LC_ALL=C repo-remove ${repo_file} ${blacklist[@]} 2>&1 | \ + grep "\-> Removing" 2>/dev/null| wc -l)" + +# Get db contents + db=($(get_repo_content ${repo_file})) + + msg2 "Process clean db for syncing..." + +# Create a whitelist, add * wildcard to end +# TODO due to lack of -arch suffix, the pool sync retrieves every arch even if +# we aren't syncing them + echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + + msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" + +# Sync excluding everything but whitelist +# We delete here for cleanup + rsync ${extra} -rtlH \ + --delete-after \ + --delete-excluded \ + --delay-updates \ + --include-from=/tmp/${_repo}-${_arch}.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + +# Add a new whitelist + whitelists+=(/tmp/${_repo}-${_arch}.whitelist) + + msg "Putting databases back in place" + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + ${TMPDIR}/$0.$$.cache/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + +# Cleanup + unset db + done + done + + + msg "Syncing package pool" +# Concatenate all whitelists + cat ${whitelists[@]} | sort -u > /tmp/any.whitelist + + msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" + +# Sync +# *Don't delete-after*, this is the job of cleanup scripts. It will remove our +# packages too + for PKGPOOL in ${PKGPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ + ${FTP_BASE}/${PKGPOOL}/ + done + +# Sync sources + msg "Syncing source pool" + #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist + + #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" +# Sync +# *Don't delete-after*, this is the job of cleanup scripts. It will remove our +# packages too + for SRCPOOL in ${SRCPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ + ${FTP_BASE}/${SRCPOOL}/ + done + + +# Cleanup + unset blacklist whitelists _arch _repo repo_file } trap_exit() { - echo - error "$@" - exit 1 + echo + error "$@" + exit 1 } -source "$(dirname "$(readlink -e "$0")")/config" -source "$(dirname "$(readlink -e "$0")")/local_config" -source "$(dirname "$(readlink -e "$0")")/libremessages" +source $(dirname $0)/config +source $(dirname $0)/local_config +source $(dirname $0)/libremessages # From makepkg set -E @@ -188,4 +183,4 @@ trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR init -rm -r ${TMPDIR}/${0##*/}.$$.cache +rm -r ${TMPDIR}/$0.$$.cache diff --git a/db-sync.orig b/db-sync.orig new file mode 100755 index 0000000..0e07757 --- /dev/null +++ b/db-sync.orig @@ -0,0 +1,191 @@ +#!/bin/bash +# Syncs Arch repos based on info contained in repo.db files +# License: GPLv3 + +# Principles +# * Get repo.db from an Arch-like repo +# * Generate a list of available packages +# * Create sync whitelist (based on package blacklist) +# * Get packages +# * Check package signatures +# * Check database signatures +# * Sync repo => repo + +# TODO +# * make a tarball of files used for forensics +# * get files db + +# Run as `V=true db-sync` to get verbose output +VERBOSE=${V} +${VERBOSE} && extra="-v" + +# Returns contents of a repo +get_repos() { + mkdir -p ${TMPDIR}/${0##*/}.$$.cache + # Exclude everything but db files + rsync ${extra} -mrtlH --no-p --include="*/" \ + --include="*.db" \ + --include="*${DBEXT}" \ + --include="*.files" \ + --include="*${FILESEXT}" \ + --exclude="*" \ + --delete-after \ + rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache +} + +get_repo_content() { + # Return all contents + bsdtar tf ${1} | \ + cut -d "/" -f 1 | \ + sort -u +} + +# Prints blacklisted packages +get_blacklist() { + cut -d ':' -f 1 "${BLACKLIST_FILE}" +} + +# repo +# arch +get_repo_file() { + echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" +} + +# Process the databases and get the libre packages +init() { + + # Get the blacklisted packages + blacklist=($(get_blacklist)) + # Store all the whitelist files + whitelists=() + + msg "${#blacklist[@]} packages in blacklist" + + # Sync the repos databases + get_repos + + # Traverse all repo-arch pairs + for _repo in ${ARCHREPOS[@]}; do + for _arch in ${ARCHARCHES[@]}; do + msg "Processing ${_repo}-${_arch}" + + db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} + files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} + + if [ ! -f "${db_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${db_file}" + continue + fi + if [ ! -f "${files_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${files_file}" + continue + fi + + # Remove blacklisted packages and count them + # TODO capture all removed packages for printing on debug mode + msg2 "Removing blacklisted packages from .db database..." + LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" + msg2 "Removing blacklisted packages from .files database..." + LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" + + # Get db contents + db=($(get_repo_content ${db_file})) + + msg2 "Process clean db for syncing..." + + # Create a whitelist, add * wildcard to end + # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if + # we aren't syncing them + echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + + msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" + + # Sync excluding everything but whitelist + # We delete here for cleanup + rsync ${extra} -rtlH \ + --delete-after \ + --delete-excluded \ + --delay-updates \ + --include-from=/tmp/${_repo}-${_arch}.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Add a new whitelist + whitelists+=(/tmp/${_repo}-${_arch}.whitelist) + + msg "Putting databases back in place" + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Cleanup + unset db + done + done + + + msg "Syncing package pool" + # Concatenate all whitelists + cat ${whitelists[@]} | sort -u > /tmp/any.whitelist + + msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" + + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for PKGPOOL in ${PKGPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ + ${FTP_BASE}/${PKGPOOL}/ + done + + # Sync sources + msg "Syncing source pool" + #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist + + #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for SRCPOOL in ${SRCPOOLS[@]}; do + rsync ${extra} -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ + ${FTP_BASE}/${SRCPOOL}/ + done + + # Cleanup + unset blacklist whitelists _arch _repo repo_file +} + +trap_exit() { + echo + error "$@" + exit 1 +} + + +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/local_config" +source "$(dirname "$(readlink -e "$0")")/libremessages" + +# From makepkg +set -E + +trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT +trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT +trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR + +init + +rm -r ${TMPDIR}/${0##*/}.$$.cache -- cgit v1.2.3-2-g168b From 0684ad038134d7c9ccbaebc709c4267a904b98b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Wed, 15 Jan 2014 19:31:03 -0200 Subject: db-update: add shopt -s nullglob and remove mail script to maintenance@lists.parabolagnulinux.org because it's unstable --- db-update | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db-update b/db-update index 73d5d3f..186ed55 100755 --- a/db-update +++ b/db-update @@ -3,6 +3,8 @@ . "$(dirname "$(readlink -e "$0")")/config" . "$(dirname "$(readlink -e "$0")")/db-functions" +shopt -s nullglob + if [ $# -ge 1 ]; then warning "Calling ${0##*/} with a specific repository is no longer supported" exit 1 @@ -91,6 +93,5 @@ while read -r file; do else mkdir -p -- "${pub%/*}" mv -vn "$file" "$pub" - echo "At `date`, script \"`basename $0`\" mailed to "maintenance@lists.parabolagnulinux.org"." fi done < <(find other sources -type f) -- cgit v1.2.3-2-g168b From 0f9c53d616116cac705b01bfabb2186506aac52a Mon Sep 17 00:00:00 2001 From: Parabola Date: Thu, 16 Jan 2014 04:02:30 +0000 Subject: fix new db-sync --- db-sync | 281 ++++++++++++++++++++++++++++++----------------------------- db-sync.orig | 191 ---------------------------------------- 2 files changed, 144 insertions(+), 328 deletions(-) delete mode 100755 db-sync.orig diff --git a/db-sync b/db-sync index 81dee24..c90f89b 100755 --- a/db-sync +++ b/db-sync @@ -13,174 +13,181 @@ # TODO # * make a tarball of files used for forensics -# * get files db # Run as `V=true db-sync` to get verbose output VERBOSE=${V} ${VERBOSE} && extra="-v" +WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") +trap "rm -rf -- $(printf '%q' "${WORKDIR}")" EXIT + # Returns contents of a repo get_repos() { - mkdir -p ${TMPDIR}/$0.$$.cache -# Exclude everything but db files - rsync ${extra} -mrtlH --no-p --include="*/" \ - --include="*.db" \ - --include="*${DBEXT}" \ - --exclude="*" \ - --delete-after \ - rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/$0.$$.cache + # Exclude everything but db files + rsync ${extra} --no-motd -mrtlH --no-p --include="*/" \ + --include="*.db" \ + --include="*${DBEXT}" \ + --include="*.files" \ + --include="*${FILESEXT}" \ + --exclude="*" \ + --delete-after \ + rsync://${mirror}/${mirrorpath}/ "$WORKDIR" } get_repo_content() { -# Return all contents - bsdtar tf ${1} | \ - cut -d "/" -f 1 | \ - sort -u + # Return all contents + bsdtar tf ${1} | \ + cut -d "/" -f 1 | \ + sort -u } # Prints blacklisted packages get_blacklist() { - cut -d ':' -f 1 "${BLACKLIST_FILE}" + cut -d ':' -f 1 "${BLACKLIST_FILE}" } # repo # arch get_repo_file() { -# shopt -s nullglob - - echo "${TMPDIR}/$0.$$.cache/${1}/os/${2}/${1}${DBEXT}" + echo "${WORKDIR}/${1}/os/${2}/${1}" } # Process the databases and get the libre packages init() { -# Get the blacklisted packages - blacklist=($(get_blacklist)) -# Store all the whitelist files - whitelists=() - - msg "${#blacklist[@]} packages in blacklist" - -# Sync the repos databases - get_repos - -# Traverse all repo-arch pairs - for _repo in ${ARCHREPOS[@]}; do - for _arch in ${ARCHARCHES[@]}; do - msg "Processing ${_repo}-${_arch}" - - repo_file=$(get_repo_file ${_repo} ${_arch}) - - if [ ! -f "${repo_file}" ]; then - warning "${repo_file} doesn't exist, skipping this repo-arch" - continue - fi - -# Remove blacklisted packages and count them -# TODO capture all removed packages for printing on debug mode - msg2 "Removing blacklisted packages: $( - LC_ALL=C repo-remove ${repo_file} ${blacklist[@]} 2>&1 | \ - grep "\-> Removing" 2>/dev/null| wc -l)" - -# Get db contents - db=($(get_repo_content ${repo_file})) - - msg2 "Process clean db for syncing..." - -# Create a whitelist, add * wildcard to end -# TODO due to lack of -arch suffix, the pool sync retrieves every arch even if -# we aren't syncing them - echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist - - msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" - -# Sync excluding everything but whitelist -# We delete here for cleanup - rsync ${extra} -rtlH \ - --delete-after \ - --delete-excluded \ - --delay-updates \ - --include-from=/tmp/${_repo}-${_arch}.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - -# Add a new whitelist - whitelists+=(/tmp/${_repo}-${_arch}.whitelist) - - msg "Putting databases back in place" - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - ${TMPDIR}/$0.$$.cache/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - -# Cleanup - unset db - done - done - - - msg "Syncing package pool" -# Concatenate all whitelists - cat ${whitelists[@]} | sort -u > /tmp/any.whitelist - - msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" - -# Sync -# *Don't delete-after*, this is the job of cleanup scripts. It will remove our -# packages too - for PKGPOOL in ${PKGPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ - ${FTP_BASE}/${PKGPOOL}/ - done - -# Sync sources - msg "Syncing source pool" - #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist - - #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" -# Sync -# *Don't delete-after*, this is the job of cleanup scripts. It will remove our -# packages too - for SRCPOOL in ${SRCPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ - ${FTP_BASE}/${SRCPOOL}/ - done - - -# Cleanup - unset blacklist whitelists _arch _repo repo_file + # Get the blacklisted packages + blacklist=($(get_blacklist)) + # Store all the whitelist files + whitelists=() + + msg "%d packages in blacklist" ${#blacklist[@]} + + # Sync the repos databases + get_repos + + # Traverse all repo-arch pairs + for _repo in ${ARCHREPOS[@]}; do + for _arch in ${ARCHARCHES[@]}; do + msg "Processing ${_repo}-${_arch}" + + db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} + files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} + + if [ ! -f "${db_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${db_file}" + continue + fi + if [ ! -f "${files_file}" ]; then + warning "%s doesn't exist, skipping this repo-arch" "${files_file}" + continue + fi + + # Remove blacklisted packages and count them + # TODO capture all removed packages for printing on debug mode + msg2 "Removing blacklisted packages from %s database..." .db + LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" \ + |& sed -n 's/-> Removing/ &/p' + msg2 "Removing blacklisted packages from %s database..." .files + LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" \ + |& sed -n 's/-> Removing/ &/p' + # Get db contents + db=($(get_repo_content ${db_file})) + + msg2 "Process clean db for syncing..." + + # Create a whitelist, add * wildcard to end + # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if + # we aren't syncing them + printf '%s\n' "${db[@]}" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist + + msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" + + # Sync excluding everything but whitelist + # We delete here for cleanup + rsync ${extra} --no-motd -rtlH \ + --delete-after \ + --delete-excluded \ + --delay-updates \ + --include-from=/tmp/${_repo}-${_arch}.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Add a new whitelist + whitelists+=(/tmp/${_repo}-${_arch}.whitelist) + + msg "Putting databases back in place" + rsync ${extra} --no-motd -rtlH \ + --delay-updates \ + --safe-links \ + ${WORKDIR}/${_repo}/os/${_arch}/ \ + ${FTP_BASE}/${_repo}/os/${_arch}/ + + # Cleanup + unset db + done + done + + + msg "Syncing package pool" + # Concatenate all whitelists + cat ${whitelists[@]} | sort -u > /tmp/any.whitelist + + msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" + + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for PKGPOOL in ${PKGPOOLS[@]}; do + rsync ${extra} --no-motd -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ + ${FTP_BASE}/${PKGPOOL}/ + done + + # Sync sources + msg "Syncing source pool" + #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist + #msg2 "Retrieving %d sources from pool" $(wc -l < /tmp/any-src.whitelist) + + # Sync + # *Don't delete-after*, this is the job of cleanup scripts. It will remove our + # packages too + for SRCPOOL in ${SRCPOOLS[@]}; do + rsync ${extra} --no-motd -rtlH \ + --delay-updates \ + --safe-links \ + --include-from=/tmp/any.whitelist \ + --exclude="*" \ + rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ + ${FTP_BASE}/${SRCPOOL}/ + done + + # Cleanup + unset blacklist whitelists _arch _repo repo_file } trap_exit() { - echo - error "$@" - exit 1 + local signal=$1; shift + echo + error "$@" + trap -- "$signal" + kill "-$signal" "$$" } - -source $(dirname $0)/config -source $(dirname $0)/local_config -source $(dirname $0)/libremessages +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/local_config" +source "$(dirname "$(readlink -e "$0")")/libremessages" # From makepkg set -E - -trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT -trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT -trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR +for signal in TERM HUP QUIT; do + trap "trap_exit $signal '%s signal caught. Exiting...' $signal" $signal +done +trap 'trap_exit INT "Aborted by user! Exiting..."' INT +trap 'trap_exit USR1 "An unknown error has occurred. Exiting..."' ERR init - -rm -r ${TMPDIR}/$0.$$.cache diff --git a/db-sync.orig b/db-sync.orig deleted file mode 100755 index 0e07757..0000000 --- a/db-sync.orig +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/bash -# Syncs Arch repos based on info contained in repo.db files -# License: GPLv3 - -# Principles -# * Get repo.db from an Arch-like repo -# * Generate a list of available packages -# * Create sync whitelist (based on package blacklist) -# * Get packages -# * Check package signatures -# * Check database signatures -# * Sync repo => repo - -# TODO -# * make a tarball of files used for forensics -# * get files db - -# Run as `V=true db-sync` to get verbose output -VERBOSE=${V} -${VERBOSE} && extra="-v" - -# Returns contents of a repo -get_repos() { - mkdir -p ${TMPDIR}/${0##*/}.$$.cache - # Exclude everything but db files - rsync ${extra} -mrtlH --no-p --include="*/" \ - --include="*.db" \ - --include="*${DBEXT}" \ - --include="*.files" \ - --include="*${FILESEXT}" \ - --exclude="*" \ - --delete-after \ - rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache -} - -get_repo_content() { - # Return all contents - bsdtar tf ${1} | \ - cut -d "/" -f 1 | \ - sort -u -} - -# Prints blacklisted packages -get_blacklist() { - cut -d ':' -f 1 "${BLACKLIST_FILE}" -} - -# repo -# arch -get_repo_file() { - echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}" -} - -# Process the databases and get the libre packages -init() { - - # Get the blacklisted packages - blacklist=($(get_blacklist)) - # Store all the whitelist files - whitelists=() - - msg "${#blacklist[@]} packages in blacklist" - - # Sync the repos databases - get_repos - - # Traverse all repo-arch pairs - for _repo in ${ARCHREPOS[@]}; do - for _arch in ${ARCHARCHES[@]}; do - msg "Processing ${_repo}-${_arch}" - - db_file=$(get_repo_file ${_repo} ${_arch})${DBEXT} - files_file=$(get_repo_file ${_repo} ${_arch})${FILESEXT} - - if [ ! -f "${db_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${db_file}" - continue - fi - if [ ! -f "${files_file}" ]; then - warning "%s doesn't exist, skipping this repo-arch" "${files_file}" - continue - fi - - # Remove blacklisted packages and count them - # TODO capture all removed packages for printing on debug mode - msg2 "Removing blacklisted packages from .db database..." - LC_ALL=C repo-remove "${db_file}" "${blacklist[@]}" - msg2 "Removing blacklisted packages from .files database..." - LC_ALL=C repo-remove "${files_file}" "${blacklist[@]}" - - # Get db contents - db=($(get_repo_content ${db_file})) - - msg2 "Process clean db for syncing..." - - # Create a whitelist, add * wildcard to end - # TODO due to lack of -arch suffix, the pool sync retrieves every arch even if - # we aren't syncing them - echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist - - msg2 "$(wc -l /tmp/${_repo}-${_arch}.whitelist | cut -d' ' -f1) packages in whitelist" - - # Sync excluding everything but whitelist - # We delete here for cleanup - rsync ${extra} -rtlH \ - --delete-after \ - --delete-excluded \ - --delay-updates \ - --include-from=/tmp/${_repo}-${_arch}.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - - # Add a new whitelist - whitelists+=(/tmp/${_repo}-${_arch}.whitelist) - - msg "Putting databases back in place" - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \ - ${FTP_BASE}/${_repo}/os/${_arch}/ - - # Cleanup - unset db - done - done - - - msg "Syncing package pool" - # Concatenate all whitelists - cat ${whitelists[@]} | sort -u > /tmp/any.whitelist - - msg2 "Retrieving $(wc -l /tmp/any.whitelist | cut -d' ' -f1) packages from pool" - - # Sync - # *Don't delete-after*, this is the job of cleanup scripts. It will remove our - # packages too - for PKGPOOL in ${PKGPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${PKGPOOL}/ \ - ${FTP_BASE}/${PKGPOOL}/ - done - - # Sync sources - msg "Syncing source pool" - #sed "s|\.pkg\.tar\.|.src.tar.|" /tmp/any.whitelist > /tmp/any-src.whitelist - - #msg2 "Retrieving $(wc -l /tmp/any-src.whitelist | cut -d' ' -f1) sources from pool" - # Sync - # *Don't delete-after*, this is the job of cleanup scripts. It will remove our - # packages too - for SRCPOOL in ${SRCPOOLS[@]}; do - rsync ${extra} -rtlH \ - --delay-updates \ - --safe-links \ - --include-from=/tmp/any.whitelist \ - --exclude="*" \ - rsync://${mirror}/${mirrorpath}/${SRCPOOL}/ \ - ${FTP_BASE}/${SRCPOOL}/ - done - - # Cleanup - unset blacklist whitelists _arch _repo repo_file -} - -trap_exit() { - echo - error "$@" - exit 1 -} - - -source "$(dirname "$(readlink -e "$0")")/config" -source "$(dirname "$(readlink -e "$0")")/local_config" -source "$(dirname "$(readlink -e "$0")")/libremessages" - -# From makepkg -set -E - -trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT -trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT -trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR - -init - -rm -r ${TMPDIR}/${0##*/}.$$.cache -- cgit v1.2.3-2-g168b