From bba8c33a039ec4d1e1d13f88304ba0aeb754b03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Fri, 22 Apr 2011 00:30:43 -0700 Subject: Midnight fix --- db-functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 20bfa0e..4dddcb5 100644 --- a/db-functions +++ b/db-functions @@ -211,7 +211,7 @@ repo_unlock () { #repo_unlock _grep_pkginfo() { local _ret - _ret="$(bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^${2} = ")" + _ret="$(bsdtar -xOqf "$1" .PKGINFO | grep -m 1 "^${2} = ")" echo "${_ret#${2} = }" } @@ -499,7 +499,7 @@ arch_repo_add() { pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \ || error "repo-add ${repo}${DBEXT} ${pkgs[@]}" - /usr/bin/repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ + repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -518,7 +518,7 @@ arch_repo_remove() { fi repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ || error "repo-remove ${dbfile} ${pkgs[@]}" - /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ + repo-remove -q "${filesfile}" ${pkgs[@]} \ || error "repo-remove ${filesfile} ${pkgs[@]}" set_repo_permission "${repo}" "${arch}" } -- cgit v1.2.3-2-g168b From 834327b7defe8273f7978328ad1b822960cd5ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Tue, 14 Feb 2012 12:00:50 -0300 Subject: Ignore rsync temp files --- db-functions | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 4dddcb5..4c247a7 100644 --- a/db-functions +++ b/db-functions @@ -293,6 +293,9 @@ 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!' @@ -310,6 +313,8 @@ getpkgfiles() { done echo ${@} + + shopt -u nullglob } check_pkgfile() { -- cgit v1.2.3-2-g168b From 5ba4756a52e8f1280d4dbcff62dec4a4aeb47d1c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 12 Jun 2013 19:32:48 -0600 Subject: Don't make assumptions about the host architecture. --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index b3a4293..4029abf 100644 --- a/db-functions +++ b/db-functions @@ -1,7 +1,7 @@ #!/bin/bash # Some PKGBUILDs need CARCH to be set -CARCH="x86_64" +CARCH=$(. $(librelib conf.sh); load_files makepkg; echo $CARCH) # Useful functions UMASK="" -- cgit v1.2.3-2-g168b From 9ea7be252eb359fa8d42eb74897b216158736f56 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 12 Jun 2013 19:52:00 -0600 Subject: fix TMPDIR --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 4029abf..01629bc 100644 --- a/db-functions +++ b/db-functions @@ -16,7 +16,7 @@ restore_umask () { } # set up general environment -WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX") +WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") if [ -n "${SVNUSER}" ]; then setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" setfacl -m d:u:"${USER}":rwx "${WORKDIR}" -- cgit v1.2.3-2-g168b From 5c72f37618b77e7c7ebcab2c998e7be468c34e02 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 15 Jun 2013 13:57:06 -0600 Subject: db-functions: use common.sh --- db-functions | 58 +++++++--------------------------------------------------- 1 file changed, 7 insertions(+), 51 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 01629bc..523e872 100644 --- a/db-functions +++ b/db-functions @@ -24,57 +24,13 @@ if [ -n "${SVNUSER}" ]; then fi LOCKS=() -# check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW -if [[ -t 2 ]]; then - ALL_OFF="$(tput sgr0)" - BOLD="$(tput bold)" - BLUE="${BOLD}$(tput setaf 4)" - GREEN="${BOLD}$(tput setaf 2)" - RED="${BOLD}$(tput setaf 1)" - YELLOW="${BOLD}$(tput setaf 3)" -fi -readonly ALL_OFF BOLD BLUE GREEN RED YELLOW - -plain() { - local mesg=$1; shift - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" -} - -msg() { - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" -} - -msg2() { - local mesg=$1; shift - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" -} - -warning() { - local mesg=$1; shift - printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -error() { - local mesg=$1; shift - printf "${RED}==> ERROR${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -## -# usage : in_array( $needle, $haystack ) -# return : 0 - found -# 1 - not found -## -in_array() { - local needle=$1; shift - [[ -z $1 ]] && return 1 # Not Found - local item - for item in "$@"; do - [[ $item = $needle ]] && return 0 # Found - done - return 1 # Not Found -} +# Used: plain, msg, msg2, warning, error, in_array +# Overwritten: get_full_version, +# cleanup, abort, die +# Ignored: stat_busy, stat_done, +# setup_workdir, trab_abort, trap_exit, +# lock, slock, lock_close +. $(librelib common) ## # usage : get_full_version( $epoch, $pkgver, $pkgrel ) -- cgit v1.2.3-2-g168b From 33b8cb611363102e23972cf3914a03d65cb3cad8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Jun 2013 23:59:15 -0600 Subject: use xbs, not svn --- db-functions | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 523e872..c98b26f 100644 --- a/db-functions +++ b/db-functions @@ -17,11 +17,6 @@ restore_umask () { # set up general environment WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") -if [ -n "${SVNUSER}" ]; then - setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" - setfacl -m d:u:"${USER}":rwx "${WORKDIR}" - setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" -fi LOCKS=() # Used: plain, msg, msg2, warning, error, in_array @@ -292,7 +287,7 @@ check_pkgfile() { fi } -check_pkgsvn() { +check_pkgxbs() { local pkgfile="${1}" local _pkgbase="$(getpkgbase ${pkgfile})" [ $? -ge 1 ] && return 1 @@ -306,18 +301,11 @@ check_pkgsvn() { in_array "${repo}" ${PKGREPOS[@]} || return 1 - if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null - [ $? -ge 1 ] && return 1 - fi - - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" - [ "${svnver}" == "${_pkgver}" ] || return 1 + local xbsver="$(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" + [ "${xbsver}" == "${_pkgver}" ] || return 1 - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - in_array "${_pkgname}" ${svnnames[@]} || return 1 + local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; echo ${pkgname[@]})) + in_array "${_pkgname}" ${xbsnames[@]} || return 1 return 0 } @@ -328,7 +316,7 @@ check_splitpkgs() { local pkgfiles=(${@}) local pkgfile local pkgdir - local svnname + local xbsname mkdir -p "${WORKDIR}/check_splitpkgs/" pushd "${WORKDIR}/check_splitpkgs" >/dev/null @@ -341,16 +329,9 @@ check_splitpkgs() { mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" - if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null - [ $? -ge 1 ] && return 1 - fi - - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - for svnname in ${svnnames[@]}; do - echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" + local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; echo ${pkgname[@]})) + for xbsname in ${xbsnames[@]}; do + echo "${xbsname}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done done popd >/dev/null @@ -358,8 +339,8 @@ check_splitpkgs() { for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do [ ! -d "${pkgdir}" ] && continue sort -u "${pkgdir}/staging" -o "${pkgdir}/staging" - sort -u "${pkgdir}/svn" -o "${pkgdir}/svn" - if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/svn")" ]; then + sort -u "${pkgdir}/xbs" -o "${pkgdir}/xbs" + if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/xbs")" ]; then return 1 fi done @@ -465,11 +446,3 @@ arch_repo_remove() { || error "repo-remove ${filesfile} ${pkgs[@]}" set_repo_permission "${repo}" "${arch}" } - -arch_svn() { - if [ -z "${SVNUSER}" ]; then - /usr/bin/svn "${@}" - else - sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" - fi -} -- cgit v1.2.3-2-g168b From 761b56dcffedc6e484d38c74267810e491add951 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 16 Jun 2013 22:06:51 -0600 Subject: touch up --- db-functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index c98b26f..dabb22b 100644 --- a/db-functions +++ b/db-functions @@ -369,8 +369,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 @@ -382,7 +382,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 -- cgit v1.2.3-2-g168b From 7034eed1f7ceec379b34f8dd782fb986c7165ad4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 29 Jun 2013 00:45:43 -0600 Subject: use the get_full_version from libremessages (actually, common.sh) It works properly when split packages have different versions. --- db-functions | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index dabb22b..f5e2b3d 100644 --- a/db-functions +++ b/db-functions @@ -19,27 +19,13 @@ restore_umask () { WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") LOCKS=() -# Used: plain, msg, msg2, warning, error, in_array -# Overwritten: get_full_version, -# cleanup, abort, die +# Used: plain, msg, msg2, warning, error, in_array, get_full_version +# Overwritten: cleanup, abort, die # Ignored: stat_busy, stat_done, # setup_workdir, trab_abort, trap_exit, # lock, slock, lock_close . $(librelib common) -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then @@ -301,7 +287,7 @@ check_pkgxbs() { in_array "${repo}" ${PKGREPOS[@]} || return 1 - local xbsver="$(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" + 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[@]})) -- cgit v1.2.3-2-g168b From fbce7db101feaba0d69bf185b54270c1aa6d65ab Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 19 Mar 2013 19:53:38 +0100 Subject: sourceballs: fix ACL issues on nymeria ACLs from the WORKDIR were used, leading to problems as these weren't world-readable. Fix follows ftpdir-cleanup. Signed-off-by: Jan Alexander Steffens (heftig) Signed-off-by: Pierre Schmitz --- db-functions | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index b3a4293..4a9a42a 100644 --- a/db-functions +++ b/db-functions @@ -15,6 +15,15 @@ restore_umask () { umask $UMASK >/dev/null } +# just like mv -f, but we touch the file and then copy the content so +# default ACLs in the target dir will be applied +mv_acl() { + rm -f "$2" + touch "$2" + cat "$1" >"$2" || return 1 + rm -f "$1" +} + # set up general environment WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX") if [ -n "${SVNUSER}" ]; then -- cgit v1.2.3-2-g168b From 0b43e8cdee1ee46ea79e4d089136e76e767b4d5b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 23 Jan 2013 23:03:35 +0100 Subject: Add lastupdate file This allows for faster checking if an update might be needed and helps to let reporead run when something changed. Signed-off-by: Florian Pritz --- db-functions | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 4a9a42a..bb49894 100644 --- a/db-functions +++ b/db-functions @@ -32,6 +32,7 @@ if [ -n "${SVNUSER}" ]; then setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" fi LOCKS=() +REPO_MODIFIED=0 # check if messages are to be printed using color unset ALL_OFF BOLD BLUE GREEN RED YELLOW @@ -142,6 +143,11 @@ cleanup() { script_unlock fi rm -rf "$WORKDIR" + + if (( REPO_MODIFIED )); then + date +%s > "${FTP_BASE}/lastupdate" + fi + [ "$1" ] && exit $1 } @@ -499,6 +505,8 @@ arch_repo_add() { || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" + + REPO_MODIFIED=1 } arch_repo_remove() { @@ -517,6 +525,8 @@ arch_repo_remove() { /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ || error "repo-remove ${filesfile} ${pkgs[@]}" set_repo_permission "${repo}" "${arch}" + + REPO_MODIFIED=1 } arch_svn() { -- cgit v1.2.3-2-g168b From f65c477e42f46a3e22b5fbc5da790f9561483770 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 31 Dec 2013 14:50:37 -0500 Subject: clean up --- db-functions | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 072f43d..0b59a53 100644 --- a/db-functions +++ b/db-functions @@ -135,7 +135,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 @@ -250,9 +250,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!' @@ -270,8 +267,6 @@ getpkgfiles() { done echo ${@} - - shopt -u nullglob } check_pkgfile() { @@ -330,7 +325,7 @@ check_splitpkgs() { for pkgfile in ${pkgfiles[@]}; do issplitpkg "${pkgfile}" || continue local _pkgbase="$(getpkgbase ${pkgfile})" - msg2 "Checking $_pkgbase" + msg2 "Checking %s" "$_pkgbase" local _pkgname="$(getpkgname ${pkgfile})" local _pkgarch="$(getpkgarch ${pkgfile})" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" @@ -411,7 +406,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}" @@ -428,9 +423,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}" @@ -449,9 +444,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 4a0e623b0c8162b466695be7f5091c76b8c0b63b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 16:14:55 -0500 Subject: db-functions: use ${array[*]} when appropriate --- db-functions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 0b59a53..efb6172 100644 --- a/db-functions +++ b/db-functions @@ -424,9 +424,9 @@ 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[@]}" + || error "repo-add ${repo}${DBEXT} ${pkgs[*]}" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" + || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -445,9 +445,9 @@ arch_repo_remove() { return 1 fi /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ - || error "repo-remove ${dbfile} ${pkgs[@]}" + || error "repo-remove ${dbfile} ${pkgs[*]}" /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ - || error "repo-remove ${filesfile} ${pkgs[@]}" + || error "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 -- cgit v1.2.3-2-g168b From 39fbf0d8d3cdc666912c597d41d5b6a70fc0c725 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 20:53:38 -0500 Subject: Fix some array quoting. --- db-functions | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index efb6172..5b10e05 100644 --- a/db-functions +++ b/db-functions @@ -67,7 +67,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 @@ -256,7 +256,7 @@ getpkgfiles() { exit 1 fi - for f in ${@}; do + for f in "${@}"; do if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 @@ -266,7 +266,7 @@ getpkgfiles() { fi done - echo ${@} + echo "${@}" } check_pkgfile() { @@ -279,7 +279,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 "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then return 0 @@ -300,13 +300,13 @@ check_pkgxbs() { [ $? -ge 1 ] && return 1 local repo="${2}" - in_array "${repo}" ${PKGREPOS[@]} || return 1 + in_array "${repo}" "${PKGREPOS[@]}" || return 1 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[@]})) - in_array "${_pkgname}" ${xbsnames[@]} || return 1 + in_array "${_pkgname}" "${xbsnames[@]}" || return 1 return 0 } @@ -314,7 +314,7 @@ check_pkgxbs() { check_splitpkgs() { local repo="${1}" shift - local pkgfiles=(${@}) + local pkgfiles=("${@}") local pkgfile local pkgdir local xbsname @@ -322,7 +322,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 %s" "$_pkgbase" @@ -332,7 +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 + for xbsname in "${xbsnames[@]}"; do echo "${xbsname}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done done @@ -419,13 +419,13 @@ 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 - /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/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[@]} \ + /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -436,7 +436,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}" @@ -444,9 +444,9 @@ arch_repo_remove() { error "No database found at '${dbfile}'" return 1 fi - /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ + /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" >/dev/null \ || error "repo-remove ${dbfile} ${pkgs[*]}" - /usr/bin/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 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 --- db-functions | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'db-functions') 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') 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 -- 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. --- db-functions | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'db-functions') 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}" } -- 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. --- db-functions | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'db-functions') 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" -- 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 --- db-functions | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'db-functions') 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[@]})) -- 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. --- db-functions | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'db-functions') 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}" -- 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 --- db-functions | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'db-functions') 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 -- cgit v1.2.3-2-g168b From c52b1fa175b0bcc1bd2ec86ca7f4a926905dce0b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 17 Jun 2014 22:11:32 -0400 Subject: db-functions: add mv_acl --- db-functions | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 52ad8bb..6b49e6a 100644 --- a/db-functions +++ b/db-functions @@ -15,6 +15,15 @@ restore_umask () { umask $UMASK >/dev/null } +# just like mv -f, but we touch the file and then copy the content so +# default ACLs in the target dir will be applied +mv_acl() { + rm -f "$2" + touch "$2" + cat "$1" >"$2" || return 1 + rm -f "$1" +} + # set up general environment WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") LOCKS=() -- cgit v1.2.3-2-g168b From c54e53593927e5469cfe13bacd29d25168235606 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 17 Jun 2014 23:23:31 -0400 Subject: more quoting fixes --- db-functions | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 5b10e05..86a2b1e 100644 --- a/db-functions +++ b/db-functions @@ -12,7 +12,7 @@ set_umask () { } restore_umask () { - umask $UMASK >/dev/null + umask "$UMASK" >/dev/null } # just like mv -f, but we touch the file and then copy the content so @@ -39,7 +39,7 @@ REPO_MODIFIED=0 script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" + local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" error "Script ${0##*/} is already locked by $_owner." exit 1 else @@ -72,7 +72,7 @@ cleanup() { arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then msg "Removing left over lock from [${repo}] (${arch})" - repo_unlock $repo $arch + repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then @@ -85,7 +85,7 @@ cleanup() { date +%s > "${FTP_BASE}/lastupdate" fi - [ "$1" ] && exit $1 + [ "$1" ] && exit "$1" } abort() { @@ -133,9 +133,9 @@ repo_lock () { fi _count=0 - while [ $_count -le $_trial ] || $_lockblock ; do + while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - _owner="$(/usr/bin/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 @@ -143,7 +143,7 @@ repo_lock () { set_umask return 0 fi - sleep $LOCK_DELAY + sleep "$LOCK_DELAY" let _count=$_count+1 done @@ -241,12 +241,12 @@ getpkgfile() { elif [ ! -f "${1}" ]; then error "Package ${1} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${1}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then error "Package signature ${1}.sig not found!" exit 1 fi - echo ${1} + echo "${1}" } getpkgfiles() { @@ -260,7 +260,7 @@ getpkgfiles() { if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${f}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then error "Package signature ${f}.sig not found!" exit 1 fi @@ -272,11 +272,11 @@ getpkgfiles() { check_pkgfile() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 @@ -305,7 +305,7 @@ check_pkgxbs() { 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[@]})) + eval "local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; printf '%q ' "${pkgname[@]}"))" in_array "${_pkgname}" "${xbsnames[@]}" || return 1 return 0 @@ -331,7 +331,7 @@ check_splitpkgs() { mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" - local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; echo ${pkgname[@]})) + eval "local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; printf '%q ' "${pkgname[@]}"))" for xbsname in "${xbsnames[@]}"; do echo "${xbsname}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done -- cgit v1.2.3-2-g168b From 878a9afd8fe40fa4263c5af04491ff91c8f0c09a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 00:10:08 -0400 Subject: Use printf-formatters when possible (incomplete) --- db-functions | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 86a2b1e..a2f638e 100644 --- a/db-functions +++ b/db-functions @@ -40,7 +40,7 @@ script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - error "Script ${0##*/} is already locked by $_owner." + error "Script %s is already locked by $_owner." "${0##*/}" exit 1 else set_umask @@ -51,7 +51,7 @@ script_lock() { script_unlock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then - warning "Script ${0##*/} was not locked!" + warning "Script %s was not locked!" "${0##*/}" restore_umask return 1 else @@ -71,12 +71,12 @@ cleanup() { repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then - msg "Removing left over lock from [${repo}] (${arch})" + msg "Removing left over lock from [%s] (%s)" "${repo}" "${arch}" repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then - msg "Removing left over lock from ${0##*/}" + msg "Removing left over lock from %s" "${0##*/}" script_unlock fi rm -rf "$WORKDIR" @@ -115,11 +115,11 @@ repo_lock () { # This is the lock file used by repo-add and repo-remove if [ -f "${DBLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat $DBLOCKFILE)" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$DBLOCKFILE")" return 1 fi if [ -f "${FILESLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat ${FILESLOCKFILE})" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$FILESLOCKFILE")" return 1 fi @@ -136,8 +136,8 @@ repo_lock () { while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - warning "Repo [${1}] (${2}) is already locked by $_owner. " - msg2 "Retrying in $LOCK_DELAY seconds..." + warning "Repo [%s] (%s) is already locked by %s. " "${1}" "${2}" "$_owner" + msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else LOCKS[${#LOCKS[*]}]="$1.$2" set_umask @@ -147,14 +147,14 @@ repo_lock () { let _count=$_count+1 done - error "Repo [${1}] (${2}) is already locked by $_owner. Giving up!" + error "Repo [%s] (%s) is already locked by %s. Giving up!" "${1}" "${2}" "$_owner" return 1 } repo_unlock () { #repo_unlock local LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then - warning "Repo lock [${1}] (${2}) was not locked!" + warning "Repo lock [%s] (%s) was not locked!" "${1}" "${2}" restore_umask return 1 else @@ -202,7 +202,7 @@ getpkgname() { _name="$(_grep_pkginfo "$1" "pkgname")" if [ -z "$_name" ]; then - error "Package '$1' has no pkgname in the PKGINFO. Fail!" + error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1" exit 1 fi @@ -215,7 +215,7 @@ getpkgver() { _ver="$(_grep_pkginfo "$1" "pkgver")" if [ -z "$_ver" ]; then - error "Package '$1' has no pkgver in the PKGINFO. Fail!" + error "Package '%s' has no pkgver in the PKGINFO. Fail!" "$1" exit 1 fi @@ -227,7 +227,7 @@ getpkgarch() { _ver="$(_grep_pkginfo "$1" "arch")" if [ -z "$_ver" ]; then - error "Package '$1' has no arch in the PKGINFO. Fail!" + error "Package '%s' has no arch in the PKGINFO. Fail!" "$1" exit 1 fi -- cgit v1.2.3-2-g168b From 5e84c1596d3ae2a66bd859f1fac2490025946fbb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 00:13:55 -0400 Subject: use += when possible --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index a2f638e..006dde9 100644 --- a/db-functions +++ b/db-functions @@ -139,7 +139,7 @@ repo_lock () { warning "Repo [%s] (%s) is already locked by %s. " "${1}" "${2}" "$_owner" msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else - LOCKS[${#LOCKS[*]}]="$1.$2" + LOCKS+=("$1.$2") set_umask return 0 fi -- cgit v1.2.3-2-g168b From 43f8af33f08924092826e2094d15be704e842f3a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 00:32:24 -0400 Subject: more quoting and printf fixes --- db-functions | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 006dde9..6e27148 100644 --- a/db-functions +++ b/db-functions @@ -40,7 +40,7 @@ script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - error "Script %s is already locked by $_owner." "${0##*/}" + error "Script %s is already locked by %s." "${0##*/}" "$_owner" exit 1 else set_umask @@ -136,7 +136,7 @@ repo_lock () { while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - warning "Repo [%s] (%s) is already locked by %s. " "${1}" "${2}" "$_owner" + warning "Repo [%s] (%s) is already locked by %s." "${1}" "${2}" "$_owner" msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else LOCKS+=("$1.$2") @@ -239,10 +239,10 @@ getpkgfile() { error 'No canonical package found!' exit 1 elif [ ! -f "${1}" ]; then - error "Package ${1} not found!" + error "Package %s not found!" "${1}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then - error "Package signature ${1}.sig not found!" + error "Package signature %s not found!" "${1}.sig" exit 1 fi @@ -258,10 +258,10 @@ getpkgfiles() { for f in "${@}"; do if [ ! -f "${f}" ]; then - error "Package ${f} not found!" + error "Package %s not found!" "${f}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then - error "Package signature ${f}.sig not found!" + error "Package signature %s not found!" "${f}.sig" exit 1 fi done @@ -290,13 +290,13 @@ check_pkgfile() { check_pkgxbs() { local pkgfile="${1}" - local _pkgbase="$(getpkgbase ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgname="$(getpkgname ${pkgfile})" + local _pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgver="$(getpkgver ${pkgfile})" + local _pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 local repo="${2}" @@ -324,10 +324,10 @@ check_splitpkgs() { for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue - local _pkgbase="$(getpkgbase ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" msg2 "Checking %s" "$_pkgbase" - local _pkgname="$(getpkgname ${pkgfile})" - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgname="$(getpkgname "${pkgfile}")" + local _pkgarch="$(getpkgarch "${pkgfile}")" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" @@ -353,11 +353,11 @@ check_splitpkgs() { check_pkgrepos() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 @@ -389,11 +389,11 @@ check_repo_permission() { [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 local arch - for arch in ${ARCHES}; do + for arch in "${ARCHES[@]}"; do local dir="${FTP_BASE}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 - [ -f "${dir}"${repo}${DBEXT} -a ! -w "${dir}"${repo}${DBEXT} ] && return 1 - [ -f "${dir}"${repo}${FILESEXT} -a ! -w "${dir}"${repo}${FILESEXT} ] && return 1 + [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 + [ -f "${dir}${repo}"${FILESEXT} -a ! -w "${dir}${repo}"${FILESEXT} ] && return 1 done return 0 @@ -407,12 +407,12 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then 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}" - chmod g+w "${filesfile}" || error "Could not set write permission for group $group to ${filesfile}" + chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" + chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "${filesfile}" "$group" + chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" + chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "${filesfile}" else - error "You don't have permission to change ${dbfile}" + error "You don't have permission to change %s" "${dbfile}" fi } @@ -424,9 +424,9 @@ 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[*]}" + || error '%s' "repo-add ${repo}${DBEXT} ${pkgs[*]}" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" + || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" -- cgit v1.2.3-2-g168b From bcaa90a2e6f26191ff4aa9e0279080d1efeec3e7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 11:04:32 -0400 Subject: db-functions: line repetitive things up --- db-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 6e27148..ebf1d47 100644 --- a/db-functions +++ b/db-functions @@ -407,9 +407,9 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") - chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" + chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "${filesfile}" "$group" - chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" + chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "${filesfile}" else error "You don't have permission to change %s" "${dbfile}" -- cgit v1.2.3-2-g168b From e8f411803648f64b386dd2970b024b9ba15ba682 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 11:12:18 -0400 Subject: The eval+printf %q thing wasn't worth the hard-to-read code --- db-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index ebf1d47..f703386 100644 --- a/db-functions +++ b/db-functions @@ -305,7 +305,7 @@ check_pkgxbs() { local xbsver="$(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; get_full_version "${_pkgname}")" [ "${xbsver}" == "${_pkgver}" ] || return 1 - eval "local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; printf '%q ' "${pkgname[@]}"))" + local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) in_array "${_pkgname}" "${xbsnames[@]}" || return 1 return 0 @@ -331,7 +331,7 @@ check_splitpkgs() { mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" - eval "local xbsnames=($(. "`xbs releasepath ${_pkgbase} ${repo} ${_pkgarch}`/PKGBUILD"; printf '%q ' "${pkgname[@]}"))" + local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) for xbsname in "${xbsnames[@]}"; do echo "${xbsname}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done -- cgit v1.2.3-2-g168b From 7d061a7e0faa365ae2448154c010eed26409713d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 11:58:49 -0400 Subject: more quoting an printf fixes --- db-functions | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'db-functions') 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 -- cgit v1.2.3-2-g168b From 46510e1fc48f37ce76c2bf5f19f885bba8d5d098 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 13:05:12 -0400 Subject: Clean up quoting. --- db-functions | 74 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 6b49e6a..1384080 100644 --- a/db-functions +++ b/db-functions @@ -12,7 +12,7 @@ set_umask () { } restore_umask () { - umask $UMASK >/dev/null + umask "$UMASK" >/dev/null } # just like mv -f, but we touch the file and then copy the content so @@ -75,7 +75,7 @@ in_array() { [[ -z $1 ]] && return 1 # Not Found local item for item in "$@"; do - [[ $item = $needle ]] && return 0 # Found + [[ $item = "$needle" ]] && return 0 # Found done return 1 # Not Found } @@ -87,16 +87,16 @@ in_array() { get_full_version() { if [[ $1 -eq 0 ]]; then # zero epoch case, don't include it in version - echo $2-$3 + echo "$2-$3" else - echo $1:$2-$3 + echo "$1:$2-$3" fi } script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" + local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" error "Script ${0##*/} is already locked by $_owner." exit 1 else @@ -129,7 +129,7 @@ cleanup() { arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then msg "Removing left over lock from [${repo}] (${arch})" - repo_unlock $repo $arch + repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then @@ -137,7 +137,7 @@ cleanup() { script_unlock fi rm -rf "$WORKDIR" - [ "$1" ] && exit $1 + [ "$1" ] && exit "$1" } abort() { @@ -167,11 +167,11 @@ repo_lock () { # This is the lock file used by repo-add and repo-remove if [ -f "${DBLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat $DBLOCKFILE)" + error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat "$DBLOCKFILE")" return 1 fi if [ -f "${FILESLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat ${FILESLOCKFILE})" + error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat "$FILESLOCKFILE")" return 1 fi @@ -185,17 +185,17 @@ repo_lock () { fi _count=0 - while [ $_count -le $_trial ] || $_lockblock ; do + while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - _owner="$(/usr/bin/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 - LOCKS[${#LOCKS[*]}]="$1.$2" + LOCKS+=("$1.$2") set_umask return 0 fi - sleep $LOCK_DELAY + sleep "$LOCK_DELAY" let _count=$_count+1 done @@ -293,7 +293,7 @@ getpkgfile() { elif [ ! -f "${1}" ]; then error "Package ${1} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${1}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then error "Package signature ${1}.sig not found!" exit 1 fi @@ -303,7 +303,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 @@ -312,7 +312,7 @@ getpkgfiles() { if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${f}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then error "Package signature ${f}.sig not found!" exit 1 fi @@ -324,11 +324,11 @@ getpkgfiles() { check_pkgfile() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 @@ -342,13 +342,13 @@ check_pkgfile() { check_pkgsvn() { local pkgfile="${1}" - local _pkgbase="$(getpkgbase ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgname="$(getpkgname ${pkgfile})" + local _pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgver="$(getpkgver ${pkgfile})" + local _pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 local repo="${2}" @@ -361,10 +361,10 @@ check_pkgsvn() { [ $? -ge 1 ] && return 1 fi - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" + local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}")" [ "${svnver}" == "${_pkgver}" ] || return 1 - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) + local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) in_array "${_pkgname}" "${svnnames[@]}" || return 1 return 0 @@ -383,19 +383,19 @@ check_splitpkgs() { for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue - local _pkgbase="$(getpkgbase ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" msg2 "Checking $_pkgbase" - local _pkgname="$(getpkgname ${pkgfile})" - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgname="$(getpkgname "${pkgfile}")" + local _pkgarch="$(getpkgarch "${pkgfile}")" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" 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" @@ -403,7 +403,7 @@ check_splitpkgs() { } fi - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) + local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) for svnname in "${svnnames[@]}"; do echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" done @@ -475,8 +475,8 @@ check_repo_permission() { for arch in ${ARCHES}; do local dir="${FTP_BASE}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 - [ -f "${dir}"${repo}${DBEXT} -a ! -w "${dir}"${repo}${DBEXT} ] && return 1 - [ -f "${dir}"${repo}${FILESEXT} -a ! -w "${dir}"${repo}${FILESEXT} ] && return 1 + [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 + [ -f "${dir}${repo}"${FILESEXT} -a ! -w "${dir}${repo}"${FILESEXT} ] && return 1 done return 0 @@ -490,9 +490,9 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then 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}" + 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}" chmod g+w "${filesfile}" || error "Could not set write permission for group $group to ${filesfile}" else error "You don't have permission to change ${dbfile}" -- cgit v1.2.3-2-g168b From cc3720b21451fbf73e0075b0955653fb37d1e106 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 13:15:50 -0400 Subject: use abort() and die() from librelib --- db-functions | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index a1e86d9..6bab5a0 100644 --- a/db-functions +++ b/db-functions @@ -29,8 +29,8 @@ WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") LOCKS=() REPO_MODIFIED=0 -# Used: plain, msg, msg2, warning, error, in_array, get_full_version -# Overwritten: cleanup, abort, die +# Used: plain, msg, msg2, warning, error, in_array, get_full_version, abort, die +# Overwritten: cleanup # Ignored: stat_busy, stat_done, # setup_workdir, trab_abort, trap_exit, # lock, slock, lock_close @@ -88,16 +88,6 @@ cleanup() { [ "$1" ] && exit "$1" } -abort() { - msg 'Aborting...' - cleanup 0 -} - -die() { - error "$*" - cleanup 1 -} - trap abort INT QUIT TERM HUP trap cleanup EXIT -- cgit v1.2.3-2-g168b From 386c2d00249eb244bbcc9a173a64f9435b70180a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 13:45:10 -0400 Subject: Use printf formatters instead of string interpolation. I used this command to find them: egrep -r --exclude-dir={test,.git} '(plain|msg|msg2|warning|error|stat_busy|stat_done|abort|die)\s+"?[^"]*\$' --- db-functions | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 1384080..51fc1bd 100644 --- a/db-functions +++ b/db-functions @@ -97,7 +97,7 @@ script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - error "Script ${0##*/} is already locked by $_owner." + error "Script %s is already locked by %s." "${0##*/}" "$_owner" exit 1 else set_umask @@ -108,7 +108,7 @@ script_lock() { script_unlock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then - warning "Script ${0##*/} was not locked!" + warning "Script %s was not locked!" "${0##*/}" restore_umask return 1 else @@ -128,12 +128,12 @@ cleanup() { repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then - msg "Removing left over lock from [${repo}] (${arch})" + msg "Removing left over lock from [%s] (%s)" "${repo}" "${arch}" repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then - msg "Removing left over lock from ${0##*/}" + msg "Removing left over lock from %s" "${0##*/}" script_unlock fi rm -rf "$WORKDIR" @@ -146,7 +146,7 @@ abort() { } die() { - error "$*" + error "$@" cleanup 1 } @@ -167,11 +167,11 @@ repo_lock () { # This is the lock file used by repo-add and repo-remove if [ -f "${DBLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat "$DBLOCKFILE")" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$DBLOCKFILE")" return 1 fi if [ -f "${FILESLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat "$FILESLOCKFILE")" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$2" "$2" "$(<"$FILESLOCKFILE")" return 1 fi @@ -188,8 +188,8 @@ repo_lock () { while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - warning "Repo [${1}] (${2}) is already locked by $_owner. " - msg2 "Retrying in $LOCK_DELAY seconds..." + warning "Repo [%s] (%s) is already locked by %s." "$1" "$2" "$_owner" + msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else LOCKS+=("$1.$2") set_umask @@ -199,14 +199,14 @@ repo_lock () { let _count=$_count+1 done - error "Repo [${1}] (${2}) is already locked by $_owner. Giving up!" + error "Repo [%s] (%s) is already locked by %s. Giving up!" "${1}" "${2}" "$_owner" return 1 } repo_unlock () { #repo_unlock local LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then - warning "Repo lock [${1}] (${2}) was not locked!" + warning "Repo lock [%s] (%s) was not locked!" "${1}" "${2}" restore_umask return 1 else @@ -254,7 +254,7 @@ getpkgname() { _name="$(_grep_pkginfo "$1" "pkgname")" if [ -z "$_name" ]; then - error "Package '$1' has no pkgname in the PKGINFO. Fail!" + error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1" exit 1 fi @@ -267,7 +267,7 @@ getpkgver() { _ver="$(_grep_pkginfo "$1" "pkgver")" if [ -z "$_ver" ]; then - error "Package '$1' has no pkgver in the PKGINFO. Fail!" + error "Package '%s' has no pkgver in the PKGINFO. Fail!" "$1" exit 1 fi @@ -279,7 +279,7 @@ getpkgarch() { _ver="$(_grep_pkginfo "$1" "arch")" if [ -z "$_ver" ]; then - error "Package '$1' has no arch in the PKGINFO. Fail!" + error "Package '%s' has no arch in the PKGINFO. Fail!" "$1" exit 1 fi @@ -291,10 +291,10 @@ getpkgfile() { error 'No canonical package found!' exit 1 elif [ ! -f "${1}" ]; then - error "Package ${1} not found!" + error "Package %s not found!" "${1}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then - error "Package signature ${1}.sig not found!" + error "Package signature %s not found!" "${1}.sig" exit 1 fi @@ -310,10 +310,10 @@ getpkgfiles() { for f in "${@}"; do if [ ! -f "${f}" ]; then - error "Package ${f} not found!" + error "Package %s not found!" "${f}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then - error "Package signature ${f}.sig not found!" + error "Package signature %s not found!" "${f}.sig" exit 1 fi done @@ -384,7 +384,7 @@ check_splitpkgs() { for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue local _pkgbase="$(getpkgbase "${pkgfile}")" - msg2 "Checking $_pkgbase" + msg2 "Checking %s" "$_pkgbase" local _pkgname="$(getpkgname "${pkgfile}")" local _pkgarch="$(getpkgarch "${pkgfile}")" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" @@ -490,12 +490,12 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then 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}" - chmod g+w "${filesfile}" || error "Could not set write permission for group $group to ${filesfile}" + chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" + chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "${filesfile}" "$group" + chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" + chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "${filesfile}" else - error "You don't have permission to change ${dbfile}" + error "You don't have permission to change %s" "${dbfile}" fi } @@ -507,9 +507,9 @@ 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[*]}" + || error '%s' "repo-add ${repo}${DBEXT} ${pkgs[*]}" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" + || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" } @@ -522,12 +522,12 @@ 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}" } -- cgit v1.2.3-2-g168b From b3c27405fb9e2686d3db9ee23ca616dc6b93b1f3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 14:20:35 -0400 Subject: silly whitespace and similar fidling --- db-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 51fc1bd..accc508 100644 --- a/db-functions +++ b/db-functions @@ -188,7 +188,7 @@ repo_lock () { while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - warning "Repo [%s] (%s) is already locked by %s." "$1" "$2" "$_owner" + warning "Repo [%s] (%s) is already locked by %s." "${1}" "${2}" "$_owner" msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else LOCKS+=("$1.$2") @@ -490,7 +490,7 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") - chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" + chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "${filesfile}" "$group" chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "${filesfile}" -- cgit v1.2.3-2-g168b From 12faf7365342bcfebb951dd748d48b5db8a1acba Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 14:20:54 -0400 Subject: oops --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index accc508..e45f673 100644 --- a/db-functions +++ b/db-functions @@ -171,7 +171,7 @@ repo_lock () { return 1 fi if [ -f "${FILESLOCKFILE}" ]; then - error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$2" "$2" "$(<"$FILESLOCKFILE")" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$FILESLOCKFILE")" return 1 fi -- cgit v1.2.3-2-g168b From 108262939f3b80bc82e1a2eec983944f448f2afd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 14:21:18 -0400 Subject: db-functions:check_repo_permissions: ARCHES is an array --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index e45f673..ca43259 100644 --- a/db-functions +++ b/db-functions @@ -472,7 +472,7 @@ check_repo_permission() { [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 local arch - for arch in ${ARCHES}; do + for arch in "${ARCHES[@]}"; do local dir="${FTP_BASE}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 -- cgit v1.2.3-2-g168b From 14dc8bc6bf985464c119910eeb22f65f534a57b0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 14:21:29 -0400 Subject: more quoting fixes --- db-functions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index ca43259..5ccaaad 100644 --- a/db-functions +++ b/db-functions @@ -298,7 +298,7 @@ getpkgfile() { exit 1 fi - echo ${1} + echo "${1}" } getpkgfiles() { @@ -425,11 +425,11 @@ check_splitpkgs() { check_pkgrepos() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 -- cgit v1.2.3-2-g168b From 809e7ede093e6348552a9dc3d28b61e669bb49fd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 14:34:32 -0400 Subject: db-funtions:check_splitpkgs(): use printf instead of a loop --- db-functions | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 5ccaaad..6543d96 100644 --- a/db-functions +++ b/db-functions @@ -404,8 +404,7 @@ check_splitpkgs() { fi local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - for svnname in "${svnnames[@]}"; do - echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" + printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" done done popd >/dev/null -- cgit v1.2.3-2-g168b From cdc18bf703f6f6a55053b86c36df3775ed02eea7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 19:26:57 -0400 Subject: oops --- db-functions | 1 - 1 file changed, 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 6543d96..a4b072b 100644 --- a/db-functions +++ b/db-functions @@ -405,7 +405,6 @@ check_splitpkgs() { local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" - done done popd >/dev/null -- cgit v1.2.3-2-g168b From 3c2585392d46a3726d25696882d09ec0bf11d1f5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 19:39:08 -0400 Subject: db-functions: update ${FTP_DIR}/lastupdate when we modify the repo. Of course, this only works for things that use db-functions, so db-sync won't touch it. --- db-functions | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index a4b072b..2eeffbb 100644 --- a/db-functions +++ b/db-functions @@ -27,6 +27,7 @@ mv_acl() { # set up general environment WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") LOCKS=() +REPO_MODIFIED=0 # check if messages are to be printed using color unset ALL_OFF BOLD BLUE GREEN RED YELLOW @@ -137,6 +138,11 @@ cleanup() { script_unlock fi rm -rf "$WORKDIR" + + if (( REPO_MODIFIED )); then + date +%s > "${FTP_BASE}/lastupdate" + fi + [ "$1" ] && exit "$1" } @@ -510,6 +516,8 @@ arch_repo_add() { || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" + + REPO_MODIFIED=1 } arch_repo_remove() { @@ -528,4 +536,6 @@ arch_repo_remove() { /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ || error '%s' "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" + + REPO_MODIFIED=1 } -- cgit v1.2.3-2-g168b From b4ddeae83daca2e29d9b978abd50f49d2e6692ef Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 24 Jun 2014 22:43:54 -0400 Subject: foo --- db-functions | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 5d13022..1febb12 100644 --- a/db-functions +++ b/db-functions @@ -315,7 +315,6 @@ check_splitpkgs() { for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue local _pkgbase="$(getpkgbase "${pkgfile}")" - msg2 "Checking %s" "$_pkgbase" local _pkgname="$(getpkgname "${pkgfile}")" local _pkgarch="$(getpkgarch "${pkgfile}")" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" @@ -411,7 +410,7 @@ 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 \ + /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" \ || error '%s' "repo-add ${repo}${DBEXT} ${pkgs[*]}" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" @@ -432,7 +431,7 @@ arch_repo_remove() { error "No database found at '%s'" "${dbfile}" return 1 fi - /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" >/dev/null \ + /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" \ || error '%s' "repo-remove ${dbfile} ${pkgs[*]}" /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ || error '%s' "repo-remove ${filesfile} ${pkgs[*]}" -- cgit v1.2.3-2-g168b From 2c72fef7bd097105e57e05a4a49d0eda060735ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mas=C5=82owski?= Date: Sat, 4 Oct 2014 21:21:49 +0200 Subject: Update lastsync after db-sync or cleanup. --- db-functions | 1 + 1 file changed, 1 insertion(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 2eeffbb..dd8e2dc 100644 --- a/db-functions +++ b/db-functions @@ -141,6 +141,7 @@ cleanup() { if (( REPO_MODIFIED )); then date +%s > "${FTP_BASE}/lastupdate" + date -u +%s > "${FTP_BASE}/lastsync" fi [ "$1" ] && exit "$1" -- cgit v1.2.3-2-g168b From d0834f7e6bd53ea729374eab138bb38a36c73996 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 20 May 2015 20:41:17 -0600 Subject: Clean up shebangs --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index dd8e2dc..a0b20cd 100644 --- a/db-functions +++ b/db-functions @@ -1,4 +1,4 @@ -#!/bin/bash +#!/hint/bash # Some PKGBUILDs need CARCH to be set CARCH="x86_64" -- cgit v1.2.3-2-g168b From af138659e5042debbb57deba5c0419ba744f75fd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 25 May 2015 01:29:34 -0600 Subject: Pull in more changes from lukeshu/archlinux+cleanup+librelib --- db-functions | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index c1bf6e8..d0c45a4 100644 --- a/db-functions +++ b/db-functions @@ -26,15 +26,21 @@ mv_acl() { # set up general environment WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") +if [ -n "${SVNUSER}" ]; then + setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" + setfacl -m d:u:"${USER}":rwx "${WORKDIR}" + setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" +fi LOCKS=() REPO_MODIFIED=0 # Used: plain, msg, msg2, warning, error, in_array, get_full_version, abort, die # Overwritten: cleanup # Ignored: stat_busy, stat_done, -# setup_workdir, trab_abort, trap_exit, +# setup_workdir, trap_abort, trap_exit, # lock, slock, lock_close -. $(librelib common) +# pkgver_equal, find_cached_package, check_root +. "$(librelib common)" script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" @@ -83,7 +89,6 @@ cleanup() { if (( REPO_MODIFIED )); then date +%s > "${FTP_BASE}/lastupdate" - date -u +%s > "${FTP_BASE}/lastsync" fi [ "$1" ] && exit "$1" @@ -225,6 +230,13 @@ getpkgarch() { echo "$_ver" } +check_packager() { + local _packager + + _packager=$(_grep_pkginfo "$1" "packager") + [[ $_packager && $_packager != 'Unknown Packager' ]] +} + getpkgfile() { if [[ ${#} -ne 1 ]]; then error 'No canonical package found!' -- cgit v1.2.3-2-g168b From f338cb024ffad54b051000bba3d42fd343e363ae Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 5 Jun 2015 00:49:37 -0600 Subject: db-functions: do better printing of whitespace-separated filenames --- db-functions | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index a0b20cd..deaa008 100644 --- a/db-functions +++ b/db-functions @@ -509,12 +509,13 @@ arch_repo_add() { local arch=$2 local pkgs=("${@:3}") + printf -v pkgs_str -- '%q ' "${pkgs[@]}" # 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 '%s' "repo-add ${repo}${DBEXT} ${pkgs[*]}" + || error 'repo-add %q %s' "${repo}${DBEXT}" "${pkgs_str% }" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" + || error 'repo-add -f %q %s' "${repo}${FILESEXT}" "${pkgs_str% }" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -532,10 +533,11 @@ arch_repo_remove() { error "No database found at '%s'" "${dbfile}" return 1 fi + printf -v pkgs_str -- '%q ' "${pkgs[@]}" /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" >/dev/null \ - || error '%s' "repo-remove ${dbfile} ${pkgs[*]}" + || error 'repo-remove %q %s' "${dbfile}" "${pkgs_str% }" /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ - || error '%s' "repo-remove ${filesfile} ${pkgs[*]}" + || error 'repo-remove %q %s' "${filesfile}" "${pkgs_str% }" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 -- cgit v1.2.3-2-g168b From 17a94df0c108f09cada98535138136779b4e13a4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 24 May 2015 12:41:09 -0600 Subject: Use XBS instead of the SVN/ABS grossness. * config: drop SVNREPO * cron-jobs/sourceballs: Replace commented out SVN code and active ABS code with XBS code. The XBS code is fairly similar to the SVN code, the difference being that it uses `xbs releasepath` instead of `svn export`. * db-functions: - Rename check_pkgsvn to check_pkgxbs - check_pkgxbs: Drop the `svn export` bit, as `xbs releasepath` assumes that a working directory already exists. Replace the paths created by the `svn export` with calls to `xbs releasepath`. - check_splitpkgs: Drop the ABS `cp` -r bit, as `xbs releasepath` assumes that a working directory already exists. Replace the paths created by the `cp -r` with calls to `xbs releasepath`. Rename the variables and temporary files s/svn/xbs/ . * db-move: - First loop: Rename the variable svnrepo_from to xbsrepo_from, and get the value from `xbs releasepath`. - Second loop: Run `xbs move` before the inner loop to get a list of architectures. Rename the variable `svnrepo_from` to `xbsrepo_to`, and get the value for it from `xbs releasepath`. Because xbs guarantees that the PKGBUILD exists for the architectures listed, replace the check for whether the PKGBUILD exists with `if true`, to keep merging easy (as opposed to removing the if, and de-indenting the whole thing). * db-remove: Get the location of the PKGBUILD from `xbs releasepath`, call `xbs unrelease`, and adjust a message to use `xbs name` and mention the appropriate repo/arch pair. --- db-functions | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'db-functions') diff --git a/db-functions b/db-functions index deaa008..d76aa41 100644 --- a/db-functions +++ b/db-functions @@ -347,7 +347,7 @@ check_pkgfile() { fi } -check_pkgsvn() { +check_pkgxbs() { local pkgfile="${1}" local _pkgbase="$(getpkgbase "${pkgfile}")" [ $? -ge 1 ] && return 1 @@ -361,18 +361,11 @@ check_pkgsvn() { in_array "${repo}" "${PKGREPOS[@]}" || return 1 - if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null - [ $? -ge 1 ] && return 1 - fi - - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}")" - [ "${svnver}" == "${_pkgver}" ] || return 1 + local xbsver="$(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; get_full_version "${_pkgname}")" + [ "${xbsver}" == "${_pkgver}" ] || return 1 - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - in_array "${_pkgname}" "${svnnames[@]}" || return 1 + local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) + in_array "${_pkgname}" "${xbsnames[@]}" || return 1 return 0 } @@ -383,7 +376,7 @@ check_splitpkgs() { local pkgfiles=("${@}") local pkgfile local pkgdir - local svnname + local xbsname mkdir -p "${WORKDIR}/check_splitpkgs/" pushd "${WORKDIR}/check_splitpkgs" >/dev/null @@ -397,29 +390,16 @@ check_splitpkgs() { mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" - 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 - - [[ $? -ge 1 ]] && { - echo "Failed $_pkgbase-$_pkgver-$_pkgarch" - return 1 - } - fi - - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" + local xbsnames=($(. "$(xbs releasepath "${_pkgbase}" "${repo}" "${_pkgarch}")/PKGBUILD"; echo "${pkgname[@]}")) + printf '%s\n' "${xbsnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/xbs" done popd >/dev/null for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do [ ! -d "${pkgdir}" ] && continue sort -u "${pkgdir}/staging" -o "${pkgdir}/staging" - sort -u "${pkgdir}/svn" -o "${pkgdir}/svn" - if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/svn")" ]; then + sort -u "${pkgdir}/xbs" -o "${pkgdir}/xbs" + if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/xbs")" ]; then return 1 fi done -- cgit v1.2.3-2-g168b