diff options
-rwxr-xr-x | db-cleanup | 2 | ||||
-rw-r--r-- | db-functions | 15 | ||||
-rwxr-xr-x | db-move | 2 | ||||
-rwxr-xr-x | db-update | 36 | ||||
-rw-r--r-- | test/lib/common.inc | 62 |
5 files changed, 58 insertions, 59 deletions
@@ -29,7 +29,7 @@ EXTRAFLAGS=() "${CLEANUP_DRYRUN}" && EXTRAFLAGS+=(--dry-run) filter=$(mktemp -t "${0##*/}.XXXXXXXXXX") -trap "rm $(printf %q "$filter")" EXIT +trap "rm -f -- $(printf %q "$filter")" EXIT for _repo in "${PKGREPOS[@]}"; do for _arch in "${ARCHES[@]}"; do diff --git a/db-functions b/db-functions index f703386..a1e86d9 100644 --- a/db-functions +++ b/db-functions @@ -1,7 +1,7 @@ #!/bin/bash # Some PKGBUILDs need CARCH to be set -CARCH=$(. $(librelib conf.sh); load_files makepkg; echo $CARCH) +CARCH=$(. "$(librelib conf.sh)"; load_files makepkg; echo "$CARCH") # Useful functions UMASK="" @@ -251,7 +251,7 @@ getpkgfile() { getpkgfiles() { local f - if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then + if [ ! -z "$(printf '%s\n' "${@%\.*}" | sort | uniq -D)" ]; then error 'Duplicate packages found!' exit 1 fi @@ -302,7 +302,7 @@ check_pkgxbs() { in_array "${repo}" "${PKGREPOS[@]}" || return 1 - local xbsver="$(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; get_full_version "${_pkgname}")" + local xbsver="$(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; get_full_version "${_pkgname}")" [ "${xbsver}" == "${_pkgver}" ] || return 1 local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) @@ -332,8 +332,7 @@ check_splitpkgs() { echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) - for xbsname in "${xbsnames[@]}"; do - echo "${xbsname}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" + printf '%s\n' "${xbsnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done done popd >/dev/null @@ -441,13 +440,13 @@ arch_repo_remove() { local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" if [ ! -f "${dbfile}" ]; then - error "No database found at '${dbfile}'" + error "No database found at '%s'" "${dbfile}" return 1 fi /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" >/dev/null \ - || error "repo-remove ${dbfile} ${pkgs[*]}" + || error '%s' "repo-remove ${dbfile} ${pkgs[*]}" /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ - || error "repo-remove ${filesfile} ${pkgs[*]}" + || error '%s' "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 @@ -15,7 +15,7 @@ ftppath_from="${FTP_BASE}/${repo_from}/os/" ftppath_to="${FTP_BASE}/${repo_to}/os/" if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; then - die "You don't have permission to move packages from ${repo_from} to ${repo_to}" + die "You don't have permission to move packages from %s to %s" "${repo_from}" "${repo_to}" fi # TODO: this might lock too much (architectures) @@ -6,18 +6,18 @@ shopt -s nullglob if [ $# -ge 1 ]; then - warning "Calling ${0##*/} with a specific repository is no longer supported" + warning "Calling %s with a specific repository is no longer supported" "${0##*/}" exit 1 fi # Find repos with packages to release staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)) if [ $? -ge 1 ]; then - die "Could not read ${STAGING}" + die "Could not read %s" "${STAGING}" fi repos=() -for staging_repo in ${staging_repos[@]##*/}; do +for staging_repo in "${staging_repos[@]##*/}"; do if in_array "${staging_repo}" "${PKGREPOS[@]}"; then repos+=("${staging_repo}") fi @@ -26,7 +26,7 @@ done # TODO: this might lock too much (architectures) for repo in "${repos[@]}"; do for pkgarch in "${ARCHES[@]}"; do - repo_lock ${repo} ${pkgarch} || exit 1 + repo_lock "${repo}" "${pkgarch}" || exit 1 done done @@ -35,42 +35,42 @@ for repo in "${repos[@]}"; do pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then if [ ${#pkgs[@]} -gt 0 ] && ! check_repo_permission "${repo}"; then - die "You don't have permission to update packages in ${repo}" + die "You don't have permission to update packages in %s" "${repo}" fi for pkg in "${pkgs[@]}"; do if [ -h "${pkg}" ]; then - die "Package ${repo}/${pkg##*/} is a symbolic link" + die "Package %s is a symbolic link" "${repo}/${pkg##*/}" fi if ! check_pkgfile "${pkg}"; then - die "Package ${repo}/${pkg##*/} is not consistent with its meta data" + die "Package %s is not consistent with its meta data" "${repo}/${pkg##*/}" fi - if ${REQUIRE_SIGNATURE} && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then - die "Package ${repo}/${pkg##*/} does not have a valid signature" + if "${REQUIRE_SIGNATURE}" && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then + die "Package %s does not have a valid signature" "${repo}/${pkg##*/}" fi if ! check_pkgxbs "${pkg}" "${repo}"; then - die "Package ${repo}/${pkg##*/} is not consistent with xbs" + die "Package %s is not consistent with XBS" "${repo}/${pkg##*/}" fi if ! check_pkgrepos "${pkg}"; then - die "Package ${repo}/${pkg##*/} already exists in another repository" + die "Package %s already exists in another repository" "${repo}/${pkg##*/}" fi done - if ! check_splitpkgs ${repo} ${pkgs[@]}; then - die "Missing split packages for ${repo}" + if ! check_splitpkgs "${repo}" "${pkgs[@]}"; then + die "Missing split packages for %s" "${repo}" fi else - die "Could not read ${STAGING}" + die "Could not read %s" "${STAGING}" fi done for repo in "${repos[@]}"; do - msg "Updating [${repo}]..." + msg "Updating [%s]..." "${repo}" any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) for pkgarch in "${ARCHES[@]}"; do add_pkgs=() - arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) + arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-"${pkgarch}"${PKGEXT} 2>/dev/null)) for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do pkgfile="${pkg##*/}" - msg2 "${pkgfile} (${pkgarch})" + msg2 "%s (%s)" "${pkgfile}" "${pkgarch}" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then mv "${pkg}" "$FTP_BASE/${PKGPOOL}" @@ -93,7 +93,7 @@ done for repo in "${repos[@]}"; do for pkgarch in "${ARCHES[@]}"; do - repo_unlock ${repo} ${pkgarch} + repo_unlock "${repo}" "${pkgarch}" done done diff --git a/test/lib/common.inc b/test/lib/common.inc index 1feb1bb..b9a2f9d 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -33,9 +33,9 @@ signpkg() { . ~/.makepkg.conf fi if [[ -n $GPGKEY ]]; then - SIGNWITHKEY="-u ${GPGKEY}" + SIGNWITHKEY=(-u "${GPGKEY}") fi - gpg --detach-sign --use-agent ${SIGNWITHKEY} ${@} || die + gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" "${@}" || die } oneTimeSetUp() { @@ -47,8 +47,8 @@ oneTimeSetUp() { local pkgarch local pkgversion local build - pkgdir="$(mktemp -dqt ${0##*/}.XXXXXXXXXX)" - cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" + pkgdir="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" + cp -Lr "$(dirname "${BASH_SOURCE[0]}")"/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do pushd $d >/dev/null @@ -57,21 +57,21 @@ oneTimeSetUp() { pkgversion=$(. PKGBUILD; get_full_version) build=true - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false + for a in "${pkgarch[@]}"; do + for p in "${pkgname[@]}"; do + [ ! -f "${p}-${pkgversion}-${a}"${PKGEXT} ] && build=false done done - if ! ${build}; then + if ! "${build}"; then if [ "${pkgarch[0]}" == 'any' ]; then - sudo libremakepkg || die 'libremakepkg failed' + sudo libremakepkg || die 'libremakepkg failed' else - for a in ${pkgarch[@]}; do - if in_array $a ${arches[@]}; then - sudo setarch $a libremakepkg -n $a || die "setarch ${a} libremakepkg -n ${a} failed" - for p in ${pkgname[@]}; do - cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/${d##*/} + for a in "${pkgarch[@]}"; do + if in_array "$a" "${arches[@]}"; then + sudo setarch "$a" libremakepkg -n "$a" || die "setarch ${a} libremakepkg -n ${a} failed" + for p in "${pkgname[@]}"; do + cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]})/../packages/${d##*/}")" done else warning "skipping arch %s" "$a" @@ -93,9 +93,9 @@ setUp() { local r local a - [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists" + [ -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" ] && die "$(dirname "${BASH_SOURCE[0]}")/../../config.local exists" init_tmpdir - TMP="$(mktemp -dqt ${0##*/}.XXXXXXXXXX)" + TMP="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" #msg "Using ${TMP}" PKGREPOS=('core' 'extra' 'testing') @@ -103,9 +103,9 @@ setUp() { SRCPOOL='pool/sources' mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} - for r in ${PKGREPOS[@]}; do + for r in "${PKGREPOS[@]}"; do mkdir -p "${TMP}/staging/${r}" - for a in ${ARCHES[@]}; do + for a in "${ARCHES[@]}"; do mkdir -p "${TMP}/ftp/${r}/os/${a}" done done @@ -119,8 +119,8 @@ setUp() { for p in "${pkgdir}"/*; do pkg=${p##*/} mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} - cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/ - arch_svn add -q "${TMP}/svn-packages-copy"/${pkg} + cp "${p}"/* "${TMP}/svn-packages-copy/${pkg}/trunk/" + arch_svn add -q "${TMP}/svn-packages-copy/${pkg}" arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done @@ -130,13 +130,13 @@ setUp() { 'SVNURL=foo' \ "SVNREPO=\"${TMP}/svn-packages-copy\"" \ "ARCHES=($(arches))" \ - > $XDG_CONFIG_HOME/libretools/xbs-abs.conf - printf '%s\n' 'BUILDSYSTEM=abs' > $XDG_CONFIG_HOME/xbs.conf + > "$XDG_CONFIG_HOME/libretools/xbs-abs.conf" + printf '%s\n' 'BUILDSYSTEM=abs' > "$XDG_CONFIG_HOME/xbs.conf" - cat <<eot > "$(dirname ${BASH_SOURCE[0]})/../../config.local" + cat <<eot > "$(dirname "${BASH_SOURCE[0]}")/../../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="${TMP}/svn-packages-copy" - PKGREPOS=(${PKGREPOS[@]}) + PKGREPOS=("${PKGREPOS[@]}") PKGPOOL="${PKGPOOL}" SRCPOOL="${SRCPOOL}" TESTING_REPO='testing' @@ -149,12 +149,12 @@ setUp() { SOURCE_CLEANUP_DRYRUN=false REQUIRE_SIGNATURE=true eot - . "$(dirname ${BASH_SOURCE[0]})/../../config" + . "$(dirname "${BASH_SOURCE[0]}")/../../config" } tearDown() { rm -rf "${TMP}" - rm -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" + rm -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" echo } @@ -167,17 +167,17 @@ releasePackage() { local pkgver local pkgname - pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null - xbs release ${repo} ${arch} >/dev/null 2>&1 + pushd "${TMP}/svn-packages-copy/${pkgbase}/trunk/" >/dev/null + xbs release "${repo}" "${arch}" >/dev/null 2>&1 pkgver=$(. PKGBUILD; get_full_version) pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) popd >/dev/null - cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/ + cp "${pkgdir}/${pkgbase}"/*-"${pkgver}-${arch}"${PKGEXT} "${STAGING}/${repo}/" if "${REQUIRE_SIGNATURE}"; then for a in "${arch[@]}"; do for p in "${pkgname[@]}"; do - signpkg "${STAGING}"/${repo}/${p}-${pkgver}-${a}${PKGEXT} + signpkg "${STAGING}/${repo}/${p}-${pkgver}-${a}"${PKGEXT} done done fi @@ -190,7 +190,7 @@ checkAnyPackageDB() { local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" fi |