From d568b8aeb0be95d6a1da7da0434de23e6b2260e2 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 23 Mar 2011 19:50:56 +0100 Subject: Add support for packages which use the epoch variable --- db-functions | 15 ++++++++++++++- db-move | 4 ++-- test/lib/common.inc | 4 ++-- test/packages/pkg-simple-epoch/Makefile | 1 + test/packages/pkg-simple-epoch/PKGBUILD | 23 +++++++++++++++++++++++ test/packages/pkg-simple-epoch/test.c | 1 + test/test.d/create-filelists.sh | 2 +- test/test.d/db-move.sh | 22 ++++++++++++++++++++++ test/test.d/db-remove.sh | 2 +- test/test.d/db-update.sh | 6 ++++++ test/test.d/ftpdir-cleanup.sh | 28 ++++++++++++++++++++++++++++ test/test.d/sourceballs.sh | 2 +- 12 files changed, 102 insertions(+), 8 deletions(-) create mode 120000 test/packages/pkg-simple-epoch/Makefile create mode 100644 test/packages/pkg-simple-epoch/PKGBUILD create mode 120000 test/packages/pkg-simple-epoch/test.c diff --git a/db-functions b/db-functions index 7d431fc..676ecf4 100644 --- a/db-functions +++ b/db-functions @@ -71,6 +71,19 @@ in_array() { 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 +} + script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then @@ -328,7 +341,7 @@ check_pkgsvn() { [ $? -ge 1 ] && return 1 fi - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgver}-${pkgrel}")" + local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" [ "${svnver}" == "${_pkgver}" ] || return 1 local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) diff --git a/db-move b/db-move index ae21781..ced90a3 100755 --- a/db-move +++ b/db-move @@ -36,7 +36,7 @@ for pkgbase in ${args[@]:2}; do die "Could not read pkgname" fi - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}") + pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) if [ -z "${pkgver}" ]; then die "Could not read pkgver" fi @@ -75,7 +75,7 @@ for pkgbase in ${args[@]:2}; do fi msg2 "${pkgbase} ($(echo ${tarches[@]}))" pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}") + pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) if [ -d "${svnrepo_to}" ]; then /usr/bin/svn rm --force -q "${svnrepo_to}" diff --git a/test/lib/common.inc b/test/lib/common.inc index 208400c..46747ff 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -18,7 +18,7 @@ oneTimeSetUp() { pushd $d >/dev/null pkgname=($(. PKGBUILD; echo ${pkgname[@]})) pkgarch=($(. PKGBUILD; echo ${arch[@]})) - pkgversion=$(. PKGBUILD; echo ${pkgver}-${pkgrel}) + pkgversion=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) build=true for a in ${pkgarch[@]}; do @@ -112,7 +112,7 @@ releasePackage() { pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null archrelease ${repo}-${arch} >/dev/null 2&>1 - pkgver=$(. PKGBUILD; echo "${pkgver}-${pkgrel}") + pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) popd >/dev/null cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}.pkg.tar.* "${STAGING}"/${repo}/ } diff --git a/test/packages/pkg-simple-epoch/Makefile b/test/packages/pkg-simple-epoch/Makefile new file mode 120000 index 0000000..50be211 --- /dev/null +++ b/test/packages/pkg-simple-epoch/Makefile @@ -0,0 +1 @@ +../../src/Makefile \ No newline at end of file diff --git a/test/packages/pkg-simple-epoch/PKGBUILD b/test/packages/pkg-simple-epoch/PKGBUILD new file mode 100644 index 0000000..eebe2bd --- /dev/null +++ b/test/packages/pkg-simple-epoch/PKGBUILD @@ -0,0 +1,23 @@ +pkgname=pkg-simple-epoch +pkgver=1 +pkgrel=1 +epoch=1 +pkgdesc="A package called ${pkgname}" +arch=('i686' 'x86_64') +url='http://www.archlinux.org/' +license=('GPL') +depends=('glibc') +makedepends=('gcc') +source=('Makefile' 'test.c') +md5sums=('c6cb8dcc86253355fed559416d0c8dcf' + '3c1e4279feb678fd9cabaccdb28e40d0') + +build() { + cd ${srcdir} + make +} + +package() { + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname} +} diff --git a/test/packages/pkg-simple-epoch/test.c b/test/packages/pkg-simple-epoch/test.c new file mode 120000 index 0000000..ed5b5ac --- /dev/null +++ b/test/packages/pkg-simple-epoch/test.c @@ -0,0 +1 @@ +../../src/test.c \ No newline at end of file diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index da76710..08b6790 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -5,7 +5,7 @@ curdir=$(readlink -e $(dirname $0)) testCreateSimpleFileLists() { local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 57cbf71..6da25c4 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -27,6 +27,28 @@ testMoveSimplePackages() { done } +testMoveEpochPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-epoch') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update + + ../db-move testing extra pkg-simple-epoch + + for arch in ${arches[@]}; do + checkPackage extra pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} + checkRemovedPackage testing pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} + done +} + testMoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index b66466d..573bd71 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -5,7 +5,7 @@ curdir=$(readlink -e $(dirname $0)) testRemovePackages() { local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 5a3d01d..8acfbeb 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -30,6 +30,12 @@ testAddSingleSimplePackage() { checkPackage extra 'pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686' } +testAddSingleEpochPackage() { + releasePackage extra 'pkg-simple-epoch' 'i686' + ../db-update + checkPackage extra 'pkg-simple-epoch-1:1-1-i686.pkg.tar.xz' 'i686' +} + testAddAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index e9b977b..17287f5 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -34,6 +34,34 @@ testCleanupSimplePackages() { done } +testCleanupEpochPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-epoch') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-epoch extra ${arch} + done + + ../cron-jobs/ftpdir-cleanup >/dev/null + + for arch in ${arches[@]}; do + local pkg1="pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" + checkRemovedPackage extra 'pkg-simple-epoch' ${arch} + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" + done +} + testCleanupAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 8cba017..11bd0f4 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -5,7 +5,7 @@ curdir=$(readlink -e $(dirname $0)) testSourceballs() { local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch -- cgit v1.2.3-54-g00ecf From 575ba47d34870f8d7e83bc05f274f40a2d52d8fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 26 Mar 2011 13:35:59 +0100 Subject: Adjust test for latest devtools; Be less generic with package extension --- .gitignore | 2 +- config | 2 +- test/lib/common.inc | 6 +++--- test/test.d/db-move.sh | 4 ++-- test/test.d/db-update.sh | 6 +++--- test/test.d/ftpdir-cleanup.sh | 4 ++-- test/test.d/pool-transition.sh | 14 +++++++------- test/test.d/testing2x.sh | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index de95927..f47d96a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *~ /config.local -test/packages/*/*.pkg.tar.* +test/packages/*/*.pkg.tar.?z diff --git a/config b/config index 53191e0..b595636 100644 --- a/config +++ b/config @@ -22,7 +22,7 @@ TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) DBEXT=".db.tar.gz" FILESEXT=".files.tar.gz" -PKGEXT=".pkg.tar.*" +PKGEXT=".pkg.tar.?z" SRCEXT=".src.tar.gz" # Allowed licenses: get sourceballs only for licenses in this array diff --git a/test/lib/common.inc b/test/lib/common.inc index 46747ff..8a53768 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -29,10 +29,10 @@ oneTimeSetUp() { if ! ${build}; then if [ "${pkgarch[0]}" == 'any' ]; then - extra-x86_64-build || die 'extra-x86_64-build failed' + sudo extra-x86_64-build || die 'extra-x86_64-build failed' else for a in ${pkgarch[@]}; do - extra-${a}-build || die "extra-${a}-build failed" + sudo extra-${a}-build || die "extra-${a}-build failed" done fi for a in ${pkgarch[@]}; do @@ -114,7 +114,7 @@ releasePackage() { archrelease ${repo}-${arch} >/dev/null 2&>1 pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) popd >/dev/null - cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}.pkg.tar.* "${STAGING}"/${repo}/ + cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/ } checkAnyPackage() { diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 6da25c4..40b40de 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -82,12 +82,12 @@ testMoveSplitPackages() { ../db-move testing extra pkg-split-a for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/pkg-split-a"/*-${arch}${PKGEXT}; do checkPackage extra $(basename ${pkg}) ${arch} done done for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-b"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/pkg-split-b"/*-${arch}${PKGEXT}; do checkPackage testing $(basename ${pkg}) ${arch} done done diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 8acfbeb..e38c328 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -68,7 +68,7 @@ testAddSplitPackages() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do checkPackage extra $(basename ${pkg}) ${arch} done done @@ -82,7 +82,7 @@ testUpdateAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 + sudo extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -100,7 +100,7 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 + sudo extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 17287f5..77b02b8 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -106,13 +106,13 @@ testCleanupSplitPackages() { ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}${PKGEXT}; do checkRemovedPackage extra ${pkgs[0]} ${arch} [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done - for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}${PKGEXT}; do checkPackage extra $(basename ${pkg}) ${arch} done done diff --git a/test/test.d/pool-transition.sh b/test/test.d/pool-transition.sh index 6d82e00..5873f00 100755 --- a/test/test.d/pool-transition.sh +++ b/test/test.d/pool-transition.sh @@ -22,7 +22,7 @@ testMovePackagesWithoutPool() { # transform two packages to old style layout for arch in ${arches[@]}; do for old in 0 2; do - for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}${PKGEXT}; do pkg=$(basename $pkg) mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done @@ -37,7 +37,7 @@ testMovePackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do checkPackage extra $(basename ${pkg}) ${arch} done checkRemovedPackage testing ${pkgbase} ${arch} @@ -63,7 +63,7 @@ testUpdateAnyPackageWithoutPool() { pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 + sudo extra-i686-build >/dev/null 2>&1 mv "${pkg2}" "${pkgdir}/${pkgname}/" popd >/dev/null @@ -94,7 +94,7 @@ testMoveAnyPackagesWithoutPool() { ../db-update # transform a package to old style layout - for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do pkg=$(basename $pkg) mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do @@ -109,13 +109,13 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgbase}"/*-any${PKGEXT}; do checkAnyPackage extra $(basename ${pkg}) done checkRemovedAnyPackage testing ${pkgbase} done - for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do pkg=$(basename $pkg) for arch in any i686 x86_64; do [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" @@ -131,7 +131,7 @@ testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { ../db-update # transform a package to old style layout - for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do + for pkg in "${pkgdir}/pkg-any-a"/*-any${PKGEXT}; do pkg=$(basename $pkg) mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" for arch in i686 x86_64; do diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index 436716d..eda6cd6 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 svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 + sudo extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null -- cgit v1.2.3-54-g00ecf From fc6a6ab07bde03c7f20d5a4ed971f8e699ee9b20 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 26 Mar 2011 14:13:57 +0100 Subject: Use repo-add to create the files database for each repo --- cron-jobs/create-filelists | 101 ---------------------------------------- db-functions | 24 ++++++++-- test/lib/common.inc | 38 +++++++++------ test/test.d/create-filelists.sh | 25 ++++------ 4 files changed, 54 insertions(+), 134 deletions(-) delete mode 100755 cron-jobs/create-filelists diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists deleted file mode 100755 index 8bcfc0b..0000000 --- a/cron-jobs/create-filelists +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" - -script_lock - -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_lock ${repo} ${arch} || exit 1 - done -done - -#adjust the nice level to run at a lower priority -renice +10 -p $$ > /dev/null - -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repodb="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" - filedb="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" - - if [ ! -f "${repodb}" ]; then - continue - fi - # get a list of package files defined in the repo db - mkdir -p "${WORKDIR}/db-dir-${repo}-${arch}" - bsdtar -xf "${repodb}" -C "${WORKDIR}/db-dir-${repo}-${arch}" - # This should actualy be faster than reading all the just extracted files - bsdtar -xOf "${repodb}" | awk '/^%FILENAME%/{getline;print}' | sort > "${WORKDIR}/db-${repo}-${arch}" - - # get a list of package files defined in the files db - mkdir -p "${WORKDIR}/files-current-dir-${repo}-${arch}" - if [ ! -f "${filedb}" ]; then - touch "${WORKDIR}/files-${repo}-${arch}" - else - bsdtar -xf "${filedb}" -C "${WORKDIR}/files-current-dir-${repo}-${arch}" - bsdtar -xOf "${filedb}" | awk '/^%FILENAME%/{getline;print}' | sort > "${WORKDIR}/files-${repo}-${arch}" - fi - done -done - -case "${FILESEXT}" in - *.gz) TAR_OPT="z" ;; - *.bz2) TAR_OPT="j" ;; - *.xz) TAR_OPT="J" ;; - *) die "Unknown compression type for FILESEXT=${FILESEXT}" ;; -esac - -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - filedb="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" - - if [ ! -f "${WORKDIR}/db-${repo}-${arch}" ]; then - # remove any files db that might be in this empty repo - if [ -f "${filedb}" ]; then - rm -f "${filedb}" - fi - continue - fi - - # Check if updating the files db is needed - if ! diff -q "${WORKDIR}/db-${repo}-${arch}" "${WORKDIR}/files-${repo}-${arch}" >/dev/null; then - mkdir -p "${WORKDIR}/files-new-dir-${repo}-${arch}" - - # Include all unchanged file lists - # Note: deleted packages are implicitly excluded - for f in $(comm -12 "${WORKDIR}/db-${repo}-${arch}" "${WORKDIR}/files-${repo}-${arch}"); do - mv "${WORKDIR}/files-current-dir-${repo}-${arch}/${f%*-*${PKGEXT}}" \ - "${WORKDIR}/files-new-dir-${repo}-${arch}" - done - - # Create file lists for new packages - for f in $(comm -23 "${WORKDIR}/db-${repo}-${arch}" "${WORKDIR}/files-${repo}-${arch}"); do - tdir="${WORKDIR}/files-new-dir-${repo}-${arch}/${f%*-*${PKGEXT}}" - mkdir "${tdir}" - echo '%FILES%' > "${tdir}/files" - bsdtar --exclude=.* -tf "${FTP_BASE}/${repo}/os/${arch}/${f}" >> "${tdir}/files" - - # add desc and depends file from db - dbdir="${WORKDIR}/db-dir-${repo}-${arch}/${f%*-*${PKGEXT}}" - mv "${dbdir}/desc" "${tdir}/desc" - mv "${dbdir}/depends" "${tdir}/depends" - done - - # Create the actual file db - pushd "${WORKDIR}/files-new-dir-${repo}-${arch}" >/dev/null - bsdtar -c${TAR_OPT}f "${WORKDIR}/${arch}-${repo}${FILESEXT}" * - popd >/dev/null - mv -f "${WORKDIR}/${arch}-${repo}${FILESEXT}" "${filedb}" - ln -sf "${repo}${FILESEXT}" "${filedb%.tar.*}" - fi - done -done - -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_unlock ${repo} ${arch} - done -done - -script_unlock diff --git a/db-functions b/db-functions index 676ecf4..b469039 100644 --- a/db-functions +++ b/db-functions @@ -148,7 +148,8 @@ trap cleanup EXIT #repo_lock [timeout] repo_lock () { local LOCKDIR="$TMPDIR/.repolock.$1.$2" - local LOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${DBEXT}.lck" + 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 @@ -156,8 +157,12 @@ repo_lock () { local _owner # This is the lock file used by repo-add and repo-remove - if [ -f "${LOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat $LOCKFILE)" + if [ -f "${DBLOCKFILE}" ]; then + 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})" return 1 fi @@ -445,6 +450,7 @@ check_repo_permission() { 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 done return 0 @@ -454,11 +460,14 @@ set_repo_permission() { local repo=$1 local arch=$2 local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" + local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" 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}" else error "You don't have permission to change ${dbfile}" fi @@ -471,8 +480,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 \ + /usr/bin/repo-add -q "${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[@]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" } @@ -482,12 +493,15 @@ 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 '${dbfile}'" return 1 fi - /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ + /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} \ || error "repo-remove ${dbfile} ${pkgs[@]}" + /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ + || error "repo-remove ${filesfile} ${pkgs[@]}" set_repo_permission "${repo}" "${arch}" } diff --git a/test/lib/common.inc b/test/lib/common.inc index 8a53768..2cf2769 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -121,6 +121,7 @@ checkAnyPackage() { local repo=$1 local pkg=$2 local arch + local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" @@ -131,9 +132,11 @@ checkAnyPackage() { done [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ - || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + for db in ${DBEXT} ${FILESEXT}; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" + done [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } @@ -142,6 +145,7 @@ checkPackage() { local repo=$1 local pkg=$2 local arch=$3 + local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" @@ -150,9 +154,11 @@ checkPackage() { [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ - || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + for db in ${DBEXT} ${FILESEXT}; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" + done local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -164,10 +170,13 @@ checkRemovedPackage() { local repo=$1 local pkgbase=$2 local arch=$3 + local db - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ - && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + for db in ${DBEXT} ${FILESEXT}; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" + done svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ @@ -178,11 +187,14 @@ checkRemovedAnyPackage() { local repo=$1 local pkgbase=$2 local arch + local db - for arch in i686 x86_64; do - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ - && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + for db in ${DBEXT} ${FILESEXT}; do + for arch in i686 x86_64; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" + done done svn up -q "${TMP}/svn-packages-copy/${pkgbase}" diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 08b6790..80b0927 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -16,11 +16,10 @@ testCreateSimpleFileLists() { done ../db-update - ../cron-jobs/create-filelists for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/${pkgbase}"; then - fail "usr/bin/${pkgbase} not found in ${arch}/extra.files.tar.gz" + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then + fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi done done @@ -37,11 +36,10 @@ testCreateAnyFileLists() { done ../db-update - ../cron-jobs/create-filelists for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/share/${pkgbase}/test"; then - fail "usr/share/${pkgbase}/test not found in ${arch}/extra.files.tar.gz" + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then + fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi done done @@ -63,13 +61,12 @@ testCreateSplitFileLists() { done ../db-update - ../cron-jobs/create-filelists for pkgbase in ${pkgs[@]}; do pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) for pkgname in ${pkgnames[@]}; do for arch in ${arches[@]}; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/${pkgname}"; then - fail "usr/bin/${pkgname} not found in ${arch}/extra.files.tar.gz" + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then + fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi done done @@ -89,19 +86,17 @@ testCleanupFileLists() { done done ../db-update - ../cron-jobs/create-filelists for arch in ${arches[@]}; do ../db-remove pkg-simple-a extra ${arch} done - ../cron-jobs/create-filelists for arch in ${arches[@]}; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/pkg-simple-b"; then - fail "usr/bin/pkg-simple-b not found in ${arch}/extra.files.tar.gz" + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then + fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi - if bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/pkg-simple-a"; then - fail "usr/bin/pkg-simple-a still found in ${arch}/extra.files.tar.gz" + if bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-a"; then + fail "usr/bin/pkg-simple-a still found in ${arch}/extra${FILESEXT}" fi done -- cgit v1.2.3-54-g00ecf From 9abfc4fe1d3e31bc7bd03287029aacd8287ce6ee Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 1 Apr 2011 22:14:52 +0200 Subject: Recompiled alpm python module against pacman 3.5 --- cron-jobs/check_archlinux/alpm.so | Bin 7166 -> 7190 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/cron-jobs/check_archlinux/alpm.so b/cron-jobs/check_archlinux/alpm.so index 50f0f97..72f737e 100755 Binary files a/cron-jobs/check_archlinux/alpm.so and b/cron-jobs/check_archlinux/alpm.so differ -- cgit v1.2.3-54-g00ecf From a7b293ad4d819fa77592818af27f7c2a3b9b2ca4 Mon Sep 17 00:00:00 2001 From: Rémy Oudompheng Date: Fri, 1 Apr 2011 00:54:57 +0200 Subject: Add signature files to update/move/remove targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signature files are optional and the previous behaviour is unchanged when signatures files do not exist. Signed-off-by: Rémy Oudompheng Signed-off-by: Pierre Schmitz --- cron-jobs/ftpdir-cleanup | 10 ++++++++-- db-move | 3 +++ db-update | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 09e8a49..bb1661a 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -10,9 +10,12 @@ clean_pkg() { if ! ${CLEANUP_DRYRUN}; then for pkg in "$@"; do if [ -h "$pkg" ]; then - rm -f "$pkg" + rm -f "$pkg" "$pkg.sig" else mv -f "$pkg" "$CLEANUP_DESTDIR" + if [ -e "$pkg.sig" ]; then + mv -f "$pkg.sig" "$CLEANUP_DESTDIR" + fi touch "${CLEANUP_DESTDIR}/$(basename ${pkg})" fi done @@ -100,7 +103,10 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from the cleanup directory..." for old_pkg in ${old_pkgs[@]}; do msg2 "${old_pkg}" - ${CLEANUP_DRYRUN} || rm -f "${CLEANUP_DESTDIR}/${old_pkg}" + if ! ${CLEANUP_DRYRUN}; then + rm -f "${CLEANUP_DESTDIR}/${old_pkg}" + rm -f "${CLEANUP_DESTDIR}/${old_pkg}.sig" + fi done fi diff --git a/db-move b/db-move index ced90a3..ff1b0e2 100755 --- a/db-move +++ b/db-move @@ -96,6 +96,9 @@ for pkgbase in ${args[@]:2}; do cp ${pkgpath} ${FTP_BASE}/${PKGPOOL} fi ln -s "../../../${PKGPOOL}/${pkgfile}" ${ftppath_to}/${tarch}/ + if [ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]; then + ln -s "../../../${PKGPOOL}/${pkgfile}.sig" ${ftppath_to}/${tarch}/ + fi add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} " remove_pkgs[${tarch}]+="${pkgname} " done diff --git a/db-update b/db-update index 5bdce5e..4b9c78f 100755 --- a/db-update +++ b/db-update @@ -64,6 +64,13 @@ for repo in ${repos[@]}; do mv "${pkg}" "$FTP_BASE/${PKGPOOL}" fi ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" + # also move signatures + if [ -f "${pkg}.sig" ]; then + mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}" + fi + if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then + ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}" + fi add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then -- cgit v1.2.3-54-g00ecf From 1ce0c6368d0908e25f9bd1bb8183b5f29053fac8 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 2 Apr 2011 13:19:05 +0200 Subject: Add simple checks for handling signed packages In addition to this dbscripts wont accept unsigned pacakges when REQUIRE_SIGNATURE is set to true. Note: At this point no signature verification is performed at all. --- config | 2 ++ db-functions | 10 ++++++++++ test/lib/common.inc | 30 +++++++++++++++++++++++++++++- test/test.d/signed-packages.sh | 13 +++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 test/test.d/signed-packages.sh diff --git a/config b/config index b595636..89e3633 100644 --- a/config +++ b/config @@ -14,6 +14,8 @@ SOURCE_CLEANUP_DRYRUN=false # Time in days to keep moved sourcepackages SOURCE_CLEANUP_KEEP=14 +REQUIRE_SIGNATURE=false + LOCK_DELAY=10 LOCK_TIMEOUT=300 diff --git a/db-functions b/db-functions index b469039..a3e2168 100644 --- a/db-functions +++ b/db-functions @@ -284,6 +284,9 @@ getpkgfile() { elif [ ! -f "${1}" ]; then error "Package ${1} not found!" exit 1 + elif ${REQUIRE_SIGNATURE} && [ ! -f "${1}.sig" ]; then + error "Package signature ${1}.sig not found!" + exit 1 fi echo ${1} @@ -300,6 +303,9 @@ getpkgfiles() { if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 + elif ${REQUIRE_SIGNATURE} && [ ! -f "${f}.sig" ]; then + error "Package signature ${f}.sig not found!" + exit 1 fi done @@ -411,14 +417,18 @@ check_pkgrepos() { [ $? -ge 1 ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/$(basename ${pkgfile})" ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/$(basename ${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}/$(basename ${pkgfile})" ] && return 1 + [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile}).sig" ] && return 1 done done diff --git a/test/lib/common.inc b/test/lib/common.inc index 2cf2769..eb46508 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -95,6 +95,7 @@ setUp() { TMPDIR="${TMP}/tmp" CLEANUP_DRYRUN=false SOURCE_CLEANUP_DRYRUN=false + REQUIRE_SIGNATURE=true eot . "$(dirname ${BASH_SOURCE[0]})/../../config" } @@ -115,6 +116,13 @@ releasePackage() { pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) popd >/dev/null cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/ + + if ${REQUIRE_SIGNATURE}; then + # TODO: really sign the packages with a valid key + find "${STAGING}"/${repo}/ -type f \ + -name "*-${pkgver}-${arch}${PKGEXT}" \ + -exec touch {}.sig \; + fi } checkAnyPackage() { @@ -124,13 +132,23 @@ checkAnyPackage() { local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" + if ${REQUIRE_SIGNATURE}; then + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" + fi for arch in i686 x86_64; do - [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" + [ -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}" ] \ || 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" ] \ + || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" + fi done [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir" for db in ${DBEXT} ${FILESEXT}; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ @@ -139,6 +157,7 @@ checkAnyPackage() { done [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" + [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist" } checkPackage() { @@ -154,6 +173,15 @@ checkPackage() { [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" + if ${REQUIRE_SIGNATURE}; then + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" + [ -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" ] \ + || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" + fi + for db in ${DBEXT} ${FILESEXT}; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ diff --git a/test/test.d/signed-packages.sh b/test/test.d/signed-packages.sh new file mode 100755 index 0000000..5d6f4ff --- /dev/null +++ b/test/test.d/signed-packages.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testAddUnsignedPackage() { + releasePackage extra 'pkg-simple-a' 'i686' + # remove any signature + rm "${STAGING}"/extra/*.sig + ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is missing!" +} + +. "${curdir}/../lib/shunit2" -- cgit v1.2.3-54-g00ecf