From acaa58d1833510973cf41fa8349fd3be39c596d8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 17 Apr 2016 19:11:28 -0400 Subject: Backport changes from the lukeshu/xbs branch. Notable, remove the files.db stuff that became extraneous with pacman 5. --- config | 4 ++ cron-jobs/devlist-mailer | 5 +-- cron-jobs/ftpdir-cleanup | 10 ++++- cron-jobs/sourceballs | 11 +++-- cron-jobs/sourceballs.skip | 24 ++++++++--- db-functions | 105 +++++++-------------------------------------- db-move | 4 +- 7 files changed, 57 insertions(+), 106 deletions(-) diff --git a/config b/config index 041c9eb..43bef5e 100644 --- a/config +++ b/config @@ -34,3 +34,7 @@ DBEXT=".db.tar.gz" FILESEXT=".files.tar.gz" PKGEXT=".pkg.tar.?z" SRCEXT=".src.tar.gz" + +# Where to send error emails, and who they are from +LIST="maintenance@lists.parabola.nu" +FROM="repo@parabola.nu" diff --git a/cron-jobs/devlist-mailer b/cron-jobs/devlist-mailer index 1a05521..7f298b9 100755 --- a/cron-jobs/devlist-mailer +++ b/cron-jobs/devlist-mailer @@ -2,9 +2,8 @@ #Dummy helper to send email to arch-dev # It does nothing if no output -LIST="arch-dev-public@archlinux.org" -#LIST="aaronmgriffin@gmail.com" -FROM="repomaint@archlinux.org" +# Load $LIST and $FROM from the config file +. "$(dirname "$(readlink -e "$0")")/../config" SUBJECT="Repository Maintenance $(date +"%d-%m-%Y")" if [ $# -ge 1 ]; then diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 4a2b418..4063c09 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -22,6 +22,14 @@ clean_pkg() { fi } +script_lock + +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${arch}" || exit 1 + done +done + "${CLEANUP_DRYRUN}" && warning 'dry run mode is active' for repo in "${PKGREPOS[@]}"; do @@ -56,7 +64,7 @@ done # get a list of all available packages in the pacakge pool find "$FTP_BASE/${PKGPOOL}" -name "*${PKGEXT}" -printf '%f\n' | sort > "${WORKDIR}/pool" # create a list of packages in our db -cat "${WORKDIR}/db-"* | sort -u > "${WORKDIR}/db" +find "${WORKDIR}" -maxdepth 1 -type f -name 'db-*' -exec cat {} \; | sort -u > "${WORKDIR}/db" old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db")) if [ ${#old_pkgs[@]} -ge 1 ]; then diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index c12a128..c02912a 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -63,11 +63,10 @@ for repo in "${PKGREPOS[@]}"; do if grep -Fqx "${pkgbase}" "${dirname}/sourceballs.skip"; then continue fi - # Commenting out, we'll sourceball everything # Check if the license or .force file does not enforce creating a source package -# if ! (chk_license ${pkglicense[@]} || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then -# continue -# fi + if ! ([[ -z ${ALLOWED_LICENSES[*]} ]] || chk_license "${pkglicense[@]}" || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then + continue + fi # Store the expected file name of the source package echo "${pkgbase}-${pkgver}${SRCEXT}" >> "${WORKDIR}/expected-src-pkgs" @@ -118,8 +117,8 @@ for repo in "${PKGREPOS[@]}"; do done # Cleanup old source packages -cat "${WORKDIR}/expected-src-pkgs" | sort -u > "${WORKDIR}/expected-src-pkgs.sort" -cat "${WORKDIR}/available-src-pkgs" | sort -u > "${WORKDIR}/available-src-pkgs.sort" +find "${WORKDIR}" -maxdepth 1 -type f -name 'expected-src-pkgs' -exec cat {} \; | sort -u > "${WORKDIR}/expected-src-pkgs.sort" +find "${WORKDIR}" -maxdepth 1 -type f -name 'available-src-pkgs' -exec cat {} \; | sort -u > "${WORKDIR}/available-src-pkgs.sort" old_pkgs=($(comm -23 "${WORKDIR}/available-src-pkgs.sort" "${WORKDIR}/expected-src-pkgs.sort")) if [ ${#old_pkgs[@]} -ge 1 ]; then diff --git a/cron-jobs/sourceballs.skip b/cron-jobs/sourceballs.skip index 14d6f4b..0e1731c 100644 --- a/cron-jobs/sourceballs.skip +++ b/cron-jobs/sourceballs.skip @@ -1,14 +1,28 @@ -nexuiz-data +0ad-data +alienarena-data +blobwars-data +btanks-data +dangerdeep-data +egoboo-data +fillets-ng-data +flightgear-data +frogatto-data +gcompris-data +naev-data +openarena-data +rocksndiamonds-data +smc-data +speed-dreams-data torcs-data tremulous-data ufoai-data -frogatto-data vdrift-data -naev-data -btanks-data +warmux-data wesnoth-data -texlive-bin +widelands-data +xonotic-data texlive-bibtexextra +texlive-bin texlive-core texlive-fontsextra texlive-formatsextra diff --git a/db-functions b/db-functions index d76aa41..885e825 100644 --- a/db-functions +++ b/db-functions @@ -1,7 +1,7 @@ #!/hint/bash # Some PKGBUILDs need CARCH to be set -CARCH="x86_64" +CARCH=$(. "$(librelib conf.sh)"; load_files makepkg; echo "$CARCH") # Useful functions UMASK="" @@ -26,73 +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 -# 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 -} - -## -# 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 -} +# Used: plain, msg, msg2, warning, error, in_array, get_full_version, abort, die +# Overwritten: cleanup +# Ignored: stat_busy, stat_done, +# setup_workdir, trap_abort, trap_exit, +# lock, slock, lock_close +# pkgver_equal, find_cached_package, check_root +. "$(librelib common)" script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" @@ -141,22 +89,11 @@ cleanup() { if (( REPO_MODIFIED )); then date +%s > "${FTP_BASE}/lastupdate" - date -u +%s > "${FTP_BASE}/lastsync" fi [ "$1" ] && exit "$1" } -abort() { - msg 'Aborting...' - cleanup 0 -} - -die() { - error "$@" - cleanup 1 -} - trap abort INT QUIT TERM HUP trap cleanup EXIT @@ -165,7 +102,6 @@ trap cleanup EXIT repo_lock () { local LOCKDIR="$TMPDIR/.repolock.$1.$2" local DBLOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${DBEXT}.lck" - local FILESLOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${FILESEXT}.lck" local _count local _trial local _timeout @@ -177,10 +113,6 @@ repo_lock () { 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 [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$FILESLOCKFILE")" - return 1 - fi if [ $# -eq 2 ]; then _lockblock=true @@ -340,7 +272,7 @@ check_pkgfile() { in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 - if echo "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then + if echo "${pkgfile##*/}" | grep "${pkgname}-${pkgver}-${pkgarch}" &>/dev/null; then return 0 else return 1 @@ -492,10 +424,8 @@ arch_repo_add() { 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 \ + /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" \ || error 'repo-add %q %s' "${repo}${DBEXT}" "${pkgs_str% }" - /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error 'repo-add -f %q %s' "${repo}${FILESEXT}" "${pkgs_str% }" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -507,17 +437,14 @@ arch_repo_remove() { local arch=$2 local pkgs=("${@:3}") local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" - local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" if [ ! -f "${dbfile}" ]; then 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 \ + /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" \ || error 'repo-remove %q %s' "${dbfile}" "${pkgs_str% }" - /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ - || error 'repo-remove %q %s' "${filesfile}" "${pkgs_str% }" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 diff --git a/db-move b/db-move index 275a11a..82403c1 100755 --- a/db-move +++ b/db-move @@ -34,7 +34,7 @@ for pkgbase in "${args[@]:2}"; do die "Could not read pkgname" fi - pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") + pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version) if [ -z "${pkgver}" ]; then die "Could not read pkgver" fi @@ -74,7 +74,7 @@ for pkgbase in "${args[@]:2}"; do fi msg2 '%s (%s)' "${pkgbase}" "${tarches[*]}" pkgnames=($(. "${xbsrepo_to}/PKGBUILD"; echo "${pkgname[@]}")) - pkgver=$(. "${xbsrepo_to}/PKGBUILD"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") + pkgver=$(. "${xbsrepo_to}/PKGBUILD"; get_full_version) for pkgname in "${pkgnames[@]}"; do for tarch in "${tarches[@]}"; do -- cgit v1.2.3 From fc2e33cd67dfd2f27346d65ec525101ad3b92afc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 17 Apr 2016 19:11:45 -0400 Subject: mv cron-jobs/repo-sanity-check db-check-repo-sanity --- cron-jobs/repo-sanity-check | 57 --------------------------------------------- db-check-repo-sanity | 57 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 57 deletions(-) delete mode 100755 cron-jobs/repo-sanity-check create mode 100755 db-check-repo-sanity diff --git a/cron-jobs/repo-sanity-check b/cron-jobs/repo-sanity-check deleted file mode 100755 index 239f042..0000000 --- a/cron-jobs/repo-sanity-check +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# Solves issue165... on the old roundup install. From the database -# backups, the title was "Older/deprecated packages never leave the -# repo", I don't know how the body of the issue is stored in the DB, -# but the title says enough, I think. - -. "$(dirname "$(readlink -e "$0")")/../config" -. "$(dirname "$(readlink -e "$0")")/../db-functions" - -# Traverse all repos -for _repo in "${PKGREPOS[@]}"; do - msg "Cleaning up [%s]" "${_repo}" - - # Find all pkgnames on this repo's abs - on_abs=($( - find "${SVNREPO}/${_repo}" -name PKGBUILD | \ - while read pkgbuild; do - source "${pkgbuild}" >/dev/null 2>&1 - # cleanup to save memory - unset build package source md5sums pkgdesc pkgver pkgrel epoch \ - url license arch depends makedepends optdepends options \ - >/dev/null 2>&1 - - # also cleanup package functions - for _pkg in "${pkgname[@]}"; do - unset "package_${pkg}" >/dev/null 2>&1 - done - - # this fills the on_abs array - echo "${pkgname[@]}" - done - )) - - # quit if abs is empty - if [ ${#on_abs[*]} -eq 0 ]; then - warning "[%s]'s ABS tree is empty, skipping" "${_repo}" - break - fi - - # Find all pkgnames on repos - on_repo=($( - find "${FTP_BASE}/${_repo}" -name "*.pkg.tar.?z" \ - -printf "%f\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+-[^-]\+$/\1/" - )) - - # Compares them, whatever is on repos but not on abs should be removed - remove=($(comm -13 \ - <(printf '%s\n' "${on_abs[@]}" | sort -u) \ - <(printf '%s\n' "${on_repo[@]}" | sort -u) )) - - # Remove them from databases, ftpdir-cleanup will take care of the rest - find "${FTP_BASE}/${_repo}" -name "*.db.tar.?z" \ - -exec repo-remove {} "${remove[@]}" \; >/dev/null 2>&1 - - msg2 "Removed the following packages:" - plain '%s' "${remove[@]}" -done diff --git a/db-check-repo-sanity b/db-check-repo-sanity new file mode 100755 index 0000000..239f042 --- /dev/null +++ b/db-check-repo-sanity @@ -0,0 +1,57 @@ +#!/bin/bash +# Solves issue165... on the old roundup install. From the database +# backups, the title was "Older/deprecated packages never leave the +# repo", I don't know how the body of the issue is stored in the DB, +# but the title says enough, I think. + +. "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" + +# Traverse all repos +for _repo in "${PKGREPOS[@]}"; do + msg "Cleaning up [%s]" "${_repo}" + + # Find all pkgnames on this repo's abs + on_abs=($( + find "${SVNREPO}/${_repo}" -name PKGBUILD | \ + while read pkgbuild; do + source "${pkgbuild}" >/dev/null 2>&1 + # cleanup to save memory + unset build package source md5sums pkgdesc pkgver pkgrel epoch \ + url license arch depends makedepends optdepends options \ + >/dev/null 2>&1 + + # also cleanup package functions + for _pkg in "${pkgname[@]}"; do + unset "package_${pkg}" >/dev/null 2>&1 + done + + # this fills the on_abs array + echo "${pkgname[@]}" + done + )) + + # quit if abs is empty + if [ ${#on_abs[*]} -eq 0 ]; then + warning "[%s]'s ABS tree is empty, skipping" "${_repo}" + break + fi + + # Find all pkgnames on repos + on_repo=($( + find "${FTP_BASE}/${_repo}" -name "*.pkg.tar.?z" \ + -printf "%f\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+-[^-]\+$/\1/" + )) + + # Compares them, whatever is on repos but not on abs should be removed + remove=($(comm -13 \ + <(printf '%s\n' "${on_abs[@]}" | sort -u) \ + <(printf '%s\n' "${on_repo[@]}" | sort -u) )) + + # Remove them from databases, ftpdir-cleanup will take care of the rest + find "${FTP_BASE}/${_repo}" -name "*.db.tar.?z" \ + -exec repo-remove {} "${remove[@]}" \; >/dev/null 2>&1 + + msg2 "Removed the following packages:" + plain '%s' "${remove[@]}" +done -- cgit v1.2.3 From b7edc550e67393483efe179d5d5cd8bd484a9a05 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:11:17 -0400 Subject: Add README --- README | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..4e1fbe2 --- /dev/null +++ b/README @@ -0,0 +1,83 @@ +The executables that you (might) care about are: + + dbscripts/ + ├── cron-jobs/ + │   ├── db-cleanup [Parabola only] + │   ├── devlist-mailer + │   ├── ftpdir-cleanup + │   ├── integrity-check + │   ├── make_repo_torrents [Parabola only] + │   ├── sourceballs + │   ├── update-web-db [Arch Linux only] + │   └── update-web-files-db [Arch Linux only] + ├── db-check-nonfree [Parabola only] + ├── db-check-nonfree-in-db [Parabola only] + ├── db-check-package-libraries [Parabola only] + ├── db-check-repo-sanity [Parabola only] + ├── db-check-unsigned-packages [Parabola only] + ├── db-check-unsigned-packages.py [Parabola only] + ├── db-import-archlinux-any-to-ours [Parabola only] + ├── db-import-archlinux-pkg [Parabola only] + ├── db-import-archlinux-src [Parabola only] + ├── db-import-archlinuxarm-pkg [Parabola only] + ├── db-init [Parabola only] + ├── db-move + ├── db-remove + ├── db-repo-add + ├── db-repo-remove + ├── db-update + ├── make_individual_torrent [Parabola only] + └── testing2x [Arch Linux only] + +Ok, now let's talk about what those are. + +There are 3 "main" programs: + + - db-update : add packages to repositories + - db-move : move packages from one repository to another + - db-remove : remove packages from repositories + +Of course, sometimes things go wrong, and you need to drop to a +lower-level, but you don't want to go all the way down to pacman's +repo-add/repo-remove. So, we have: + + - db-repo-add + - db-repo-remove + +Now, we'd like to be able to check that the repos are all OK, so we +have + + - cron-jobs/integrity-check + +Instead of enhancing integrity-check, Parabola developers have decided +to write multiple stand-alone tools that should probably be merged +into integrity-check + + - db-check-* + +When we remove a package from a repository, it stays in the package +"pool". We would like to be able to eventually remove packages from +the pool, to reclaim the disk space: + + - cron-jobs/ftpdir-cleanup + - cron-jobs/db-cleanup + +Both of these programs do the exact same thing. Parabola developers +decided to write their own from scratch, instead of modifying +ftpdir-cleanup. They should eventually be merged. + +But, Parabola doesn't just publish our own packages, we also import +packages from elsewhere: + + - db-import-${source}* + +Unfortunately, these scripts are horribly duct-taped together and are +aweful. I hate them. + +Things that haven't been mentioned yet: + + - cron-jobs/devlist-mailer + - cron-jobs/make_repo_torrents + - cron-jobs/sourceballs + - db-init + - make_individual_torrent -- cgit v1.2.3 From 0d6706721278efd42eefa3a4d54ee9773711e65e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:14:35 -0400 Subject: testing cleanup (backported from lukeshu/xbs) --- config.testing | 10 ++++++++++ db-functions | 8 ++++++++ test/lib/common.inc | 37 +++++++++++++++++++++++-------------- test/test.d/create-filelists.sh | 2 +- test/test.d/db-update.sh | 6 +++--- test/test.d/testing2x.sh | 2 +- 6 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 config.testing diff --git a/config.testing b/config.testing new file mode 100644 index 0000000..24c2283 --- /dev/null +++ b/config.testing @@ -0,0 +1,10 @@ +#!/hint/bash + +# The host architecture +ARCH_HOST=$(uname -m) +# Which architectures should we test building for? +ARCH_BUILD=("$ARCH_HOST"); if [[ $ARCH_HOST == x86_64 ]]; then ARCH_BUILD+=("i686"); fi + +# override the default TMPDIR +[[ -n $MASTER_TMPDIR ]] || export MASTER_TMPDIR="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" +TMPDIR=$MASTER_TMPDIR diff --git a/db-functions b/db-functions index 885e825..bd87064 100644 --- a/db-functions +++ b/db-functions @@ -449,3 +449,11 @@ arch_repo_remove() { REPO_MODIFIED=1 } + +arch_svn() { + if [ -z "${SVNUSER}" ]; then + /usr/bin/svn "${@}" + else + sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" + fi +} diff --git a/test/lib/common.inc b/test/lib/common.inc index bef8749..1831602 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -46,21 +46,19 @@ oneTimeSetUp() { if ! "${build}"; then if [ "${pkgarch[0]}" == 'any' ]; then - sudo extra-x86_64-build || die 'extra-x86_64-build failed' + sudo libremakepkg || die 'libremakepkg failed' else for a in "${pkgarch[@]}"; do if in_array "$a" "${ARCH_BUILD[@]}"; then - sudo "extra-${a}-build" || die "extra-${a}-build failed" + 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" fi done fi - for a in "${pkgarch[@]}"; do - if in_array "$a" "${ARCH_BUILD[@]}"; then - for p in "${pkgname[@]}"; do - cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" - done - fi - done fi popd >/dev/null done @@ -82,6 +80,7 @@ setUp() { PKGREPOS=('core' 'extra' 'testing') PKGPOOL='pool/packages' + SRCPOOL='pool/sources' mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} for r in "${PKGREPOS[@]}"; do @@ -105,11 +104,21 @@ setUp() { arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done + mkdir -p "${TMP}/home/.config/libretools" + export XDG_CONFIG_HOME="${TMP}/home/.config" + printf '%s\n' \ + 'SVNURL=foo' \ + "SVNREPO=\"${TMP}/svn-packages-copy\"" \ + "ARCHES=($(printf '%q ' "${BUILD_ARCHES[@]}"))" \ + > "$XDG_CONFIG_HOME/libretools/xbs-abs.conf" + printf '%s\n' 'BUILDSYSTEM=abs' > "$XDG_CONFIG_HOME/xbs.conf" + cat < "$(dirname "${BASH_SOURCE[0]}")/../../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" PKGREPOS=("${PKGREPOS[@]}") PKGPOOL="${PKGPOOL}" + SRCPOOL="${SRCPOOL}" TESTING_REPO='testing' STABLE_REPOS=('core' 'extra') CLEANUP_DESTDIR="${TMP}/package-cleanup" @@ -139,7 +148,7 @@ releasePackage() { local pkgname pushd "${TMP}/svn-packages-copy/${pkgbase}/trunk/" >/dev/null - archrelease "${repo}-${arch}" >/dev/null 2>&1 + xbs release "${repo}" "${arch}" >/dev/null 2>&1 pkgver=$(. PKGBUILD; get_full_version) pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) popd >/dev/null @@ -167,12 +176,12 @@ checkAnyPackageDB() { for arch in "${ARCH_BUILD[@]}"; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} is not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}")" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" if "${REQUIRE_SIGNATURE}"; then [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}.sig")" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi @@ -208,7 +217,7 @@ checkPackageDB() { [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}")" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" if "${REQUIRE_SIGNATURE}"; then @@ -216,7 +225,7 @@ checkPackageDB() { [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" [ -r "${STAGING}/${repo}/${pkg}.sig" ] && fail "${repo}/${pkg}.sig found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}.sig")" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 20dafc6..837c432 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -59,7 +59,7 @@ testCreateSplitFileLists() { ../db-update for pkgbase in "${pkgs[@]}"; do - pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) + pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo "${pkgname[@]}")) for pkgname in "${pkgnames[@]}"; do for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/bin/${pkgname}" &>/dev/null; then diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 540eccf..5d3c833 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -80,7 +80,7 @@ testUpdateAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build + sudo libremakepkg mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -98,7 +98,7 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build + sudo libremakepkg mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -130,7 +130,7 @@ testUpdateSameAnyPackageToDifferentRepositories() { ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) local arch - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index c611ce4..8232490 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -10,7 +10,7 @@ testTesting2xAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build + sudo libremakepkg mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null -- cgit v1.2.3 From 5f183002d8149790b06bf3d5787ad4decee8b259 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:17:05 -0400 Subject: Handle split packages with different pkgver. makepkg 5(?) dropped support for making these, but the code is there in lukeshu/xbs, so go ahead and backport it. --- db-move | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/db-move b/db-move index 82403c1..d6b1f5e 100755 --- a/db-move +++ b/db-move @@ -34,11 +34,6 @@ for pkgbase in "${args[@]:2}"; do die "Could not read pkgname" fi - pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version) - if [ -z "${pkgver}" ]; then - die "Could not read pkgver" - fi - if [ "${pkgarch}" == 'any' ]; then tarches=("${ARCHES[@]}") else @@ -46,6 +41,10 @@ for pkgbase in "${args[@]:2}"; do fi for pkgname in "${pkgnames[@]}"; do + pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version "${pkgname}") + if [ -z "${pkgver}" ]; then + die "Could not read pkgver" + fi for tarch in "${tarches[@]}"; do getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} >/dev/null done @@ -74,9 +73,9 @@ for pkgbase in "${args[@]:2}"; do fi msg2 '%s (%s)' "${pkgbase}" "${tarches[*]}" pkgnames=($(. "${xbsrepo_to}/PKGBUILD"; echo "${pkgname[@]}")) - pkgver=$(. "${xbsrepo_to}/PKGBUILD"; get_full_version) for pkgname in "${pkgnames[@]}"; do + pkgver=$(. "${xbsrepo_to}/PKGBUILD"; get_full_version "${pkgname}") for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}) pkgfile="${pkgpath##*/}" -- cgit v1.2.3 From 7691cb7d1e5378fbecb3e833a830aac6432fe105 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:17:55 -0400 Subject: db-functions: learn some new functions from Arch Linux upstream --- db-functions | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/db-functions b/db-functions index bd87064..cf1b8eb 100644 --- a/db-functions +++ b/db-functions @@ -163,6 +163,13 @@ _grep_pkginfo() { echo "${_ret#${2} = }" } +# usage: _grep_buildinfo pkgfile pattern +_grep_buildinfo() { + local _ret + + _ret="$(/usr/bin/bsdtar -xOqf "$1" .BUILDINFO | grep -m 1 "^${2} = ")" + echo "${_ret#${2} = }" +} # Get the package base or name as fallback getpkgbase() { @@ -225,6 +232,24 @@ getpkgarch() { echo "$_ver" } +check_packager() { + local _packager + + _packager=$(_grep_pkginfo "$1" "packager") + [[ $_packager && $_packager != 'Unknown Packager' ]] +} + +check_buildinfo() { + /usr/bin/bsdtar -tf "$1" .BUILDINFO >/dev/null 2>&1 +} + +check_builddir() { + local _builddir + + _builddir=$(_grep_buildinfo "$1" "builddir") + [[ $_builddir && $_builddir = '/build' ]] +} + getpkgfile() { if [[ ${#} -ne 1 ]]; then error 'No canonical package found!' -- cgit v1.2.3 From 6385605e0ba5a53ae1662efb3efa3aa35155e3df Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:18:18 -0400 Subject: get rid of stupid differences between this and lukeshu/xbs --- db-functions | 1 - db-move | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/db-functions b/db-functions index cf1b8eb..f021299 100644 --- a/db-functions +++ b/db-functions @@ -341,7 +341,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}" diff --git a/db-move b/db-move index d6b1f5e..89a0ad6 100755 --- a/db-move +++ b/db-move @@ -71,7 +71,7 @@ for pkgbase in "${args[@]:2}"; do else tarches=("${pkgarch}") fi - msg2 '%s (%s)' "${pkgbase}" "${tarches[*]}" + msg2 "%s (%s)" "${pkgbase}" "${tarches[*]}" pkgnames=($(. "${xbsrepo_to}/PKGBUILD"; echo "${pkgname[@]}")) for pkgname in "${pkgnames[@]}"; do -- cgit v1.2.3 From aa0e029fce58e0f8b1a5508069450ebbfa9a9c2e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:21:51 -0400 Subject: db-update: add some stricter checks from Arch Linux upstream --- db-update | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/db-update b/db-update index a1552c0..b769b5d 100755 --- a/db-update +++ b/db-update @@ -43,9 +43,21 @@ for repo in "${repos[@]}"; do if ! check_pkgfile "${pkg}"; then 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 %s does not have a valid signature" "${repo}/${pkg##*/}" + fi if ! check_pkgrepos "${pkg}"; then die "Package %s already exists in another repository" "${repo}/${pkg##*/}" fi + if ! check_packager "${pkg}"; then + die "Package ${repo}/${pkg##*/} does not have a valid packager" + fi + if ! check_buildinfo "${pkg}"; then + die "Package ${repo}/${pkg##*/} does not have a .BUILDINFO file" + fi + if ! check_builddir "${pkg}"; then + die "Package ${repo}/${pkg##*/} was not built in a chroot" + fi done # This is fucking obnoxious #if ! check_splitpkgs ${repo} "${pkgs[@]}"; then -- cgit v1.2.3 From 4bc5d6607295d4054d67e0dfe6da56cbb7381999 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 Jun 2016 23:23:01 -0400 Subject: Drop support code for old pkgpool-les repository format. We switched away in 2011 at the latest. --- db-functions | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/db-functions b/db-functions index f021299..1d37123 100644 --- a/db-functions +++ b/db-functions @@ -378,17 +378,6 @@ check_pkgrepos() { [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1 - local repo - local arch - 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}/${pkgfile##*/}" ] && return 1 - [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}.sig" ] && return 1 - done - done - return 0 } -- cgit v1.2.3