Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6fae43d
wip: add support for debug packages
eli-schwartz Jun 14, 2020
3c8016a
debug prints
eli-schwartz Sep 1, 2020
b54cfdc
test: sync dummy packages impl with makepkg
eli-schwartz Sep 1, 2020
838a0dc
test: let the Makefile drive the needed work
eli-schwartz Sep 1, 2020
c9c030b
wip: debug: lock both repos at once
eli-schwartz Sep 1, 2020
190f762
test: add fixture for splitdebug package
eli-schwartz Sep 1, 2020
b99091e
tests: Added CASES to top-level Makefile
Foxboron Feb 24, 2021
bf6f0df
wip: debug: unlock both repos at once
Foxboron Mar 2, 2021
482d91f
wip: debug: support debug packages with db-remove
Foxboron Mar 2, 2021
64b2993
wip: debug: add strip binary
Foxboron Mar 3, 2021
a4f759e
wip: debug: Added package pool creation for debug
Foxboron Mar 3, 2021
4978995
wip: debug: added first debug package test
Foxboron Mar 3, 2021
8de0741
wip: debug: Added debug shortcut
Foxboron Mar 3, 2021
39e8367
wip: debug: checkRemovedPackage finds debug packages
Foxboron Mar 4, 2021
e8c8d4b
wip: debug: added debug db-move test case
Foxboron Mar 4, 2021
1d63a24
wip: debug: db-move debug package support
Foxboron Mar 4, 2021
e6546ad
wip: debug: Ensure the actual package is moved
Foxboron Mar 4, 2021
3da9a23
wip: debug: added db-remove test for debug packages
Foxboron Mar 4, 2021
683f13f
db-remove: removed unused variable
Foxboron Mar 4, 2021
e504fa5
wip: tests: extend db-remove debug pkg test
Foxboron Mar 4, 2021
6f544f3
wip: debug: Added db-repo-add test case
Foxboron Mar 7, 2021
7a24942
wip: debug: add db-repo-remove test
Foxboron Mar 7, 2021
79cee7f
wip: debug: Added testing2x test suite
Foxboron Mar 7, 2021
51b3373
wip: debug: found internal is_globfile
Foxboron Mar 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
IMAGE:=dbscripts/test
RUN_OPTIONS:=--rm --network=none -v $(PWD):/dbscripts:ro --tmpfs=/tmp:exec -w /dbscripts/test
RUN_OPTIONS:=--rm --network=none -v $(PWD):/dbscripts:ro -v dbscripts:/build --tmpfs=/tmp:exec -w /dbscripts/test
CASES ?= cases
CRUN := docker

test-image:
docker build --pull -t $(IMAGE) test
$(CRUN) build --pull -t $(IMAGE) test

test: test-image
docker run $(RUN_OPTIONS) $(IMAGE) make test
$(CRUN) run $(RUN_OPTIONS) $(IMAGE) make CASES=$(CASES) test

test-coverage: test-image
rm -rf ${PWD}/coverage
mkdir -m 777 ${PWD}/coverage
docker run $(RUN_OPTIONS) -v ${PWD}/coverage:/coverage -e COVERAGE_DIR=/coverage $(IMAGE) make test-coverage
$(CRUN) run $(RUN_OPTIONS) -v ${PWD}/coverage:/coverage -e COVERAGE_DIR=/coverage $(IMAGE) make test-coverage

.PHONY: test-image test test-coverage
35 changes: 31 additions & 4 deletions db-functions
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ trap cleanup EXIT


#repo_lock <repo-name> <arch> [timeout]
repo_lock () {
repo_lock() {
local repo base=${1}; shift
for repo in ${base} ${base}-debug; do
_repo_lock ${repo} "${@}"
done
}

_repo_lock () {
local LOCKDIR="$TMPDIR/.repolock.$1.$2"
local DBLOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${DBEXT}.lck"
local _count
Expand Down Expand Up @@ -152,7 +159,14 @@ repo_lock () {
return 1
}

repo_unlock () { #repo_unlock <repo-name> <arch>
repo_unlock(){
local repo base=${1}; shift
for repo in ${base} ${base}-debug; do
_repo_unlock ${repo} "${@}"
done
}

_repo_unlock () { #repo_unlock <repo-name> <arch>
local LOCKDIR="$TMPDIR/.repolock.$1.$2"
if [[ ! -d $LOCKDIR ]]; then
warning "Repo lock [%s] (%s) was not locked!" "$1" "$2"
Expand Down Expand Up @@ -234,6 +248,14 @@ getpkgarch() {
echo "$_ver"
}

is_debug_package() {
local pkgfile=${1}
local pkgbase="$(getpkgbase "${pkgfile}")"
local pkgname="$(getpkgname "${pkgfile}")"

[[ ${pkgbase}-debug = ${pkgname} ]]
}

check_packager() {
local _packager

Expand Down Expand Up @@ -310,7 +332,7 @@ check_pkgvcs() {
read -ra vcsnames <<<"${vcsnames}"

[[ "${vcsver}" = "${_pkgver}" ]] || return 1
in_array "${_pkgname}" "${vcsnames[@]}" || return 1
in_array "${_pkgname}" "${vcsnames[@]}" "${_pkgbase}-debug" || return 1

return 0
}
Expand All @@ -334,6 +356,7 @@ check_splitpkgs() {

# not a split package
(( ${#vcsnames[@]} > 1 )) || continue
[[ ${_pkgbase}-debug = ${_pkgname} ]] && continue

mkdir -p "${repo}/${_pkgarch}/${_pkgbase}"
echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging"
Expand Down Expand Up @@ -410,7 +433,7 @@ check_repo_permission() {
(( ${#PKGREPOS[@]} == 0 )) && return 1
[[ -z "${PKGPOOL}" ]] && return 1

in_array "${repo}" "${PKGREPOS[@]}" || return 1
in_array "${repo}" "${PKGREPOS[@]}" "${DEBUGREPOS[@]}" || return 1

[[ -w $FTP_BASE/${PKGPOOL} ]] || return 1

Expand All @@ -426,6 +449,7 @@ check_repo_permission() {
}

set_repo_permission() {
local -; set -x
local repo=$1
local arch=$2
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
Expand All @@ -443,11 +467,13 @@ set_repo_permission() {
}

arch_repo_modify() {
echo "call: arch_repo_modify ${@@Q}"
local action=$1
local repo=$2
local arch=$3
local pkgs=("${@:4}")
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
tree "${FTP_BASE}"

if [[ ${action} = remove && ! -f ${dbfile} ]]; then
error "No database found at '%s'" "$dbfile"
Expand All @@ -456,6 +482,7 @@ arch_repo_modify() {

# package files for repo-add might be relative to repo dir
pushd "${dbfile%/*}" >/dev/null
ls
/usr/bin/"repo-${action}" -q "${dbfile}" "${pkgs[@]}" \
|| error '%s' "repo-${action} ${dbfile@Q} ${pkgs[*]@Q}"
set_repo_permission "${repo}" "${arch}"
Expand Down
24 changes: 24 additions & 0 deletions db-move
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ args=("${@}")
repo_from="${args[0]}"
repo_to="${args[1]}"
ftppath_from="${FTP_BASE}/${repo_from}/os/"
ftppath_debug_from="${FTP_BASE}/${repo_from}-debug/os/"
ftppath_to="${FTP_BASE}/${repo_to}/os/"
ftppath_debug_to="${FTP_BASE}/${repo_to}-debug/os/"

check_leapfrog=false
if in_array "${repo_from}" "${STAGING_REPOS[@]}" && in_array "${repo_to}" "${STABLE_REPOS[@]}"; then
Expand Down Expand Up @@ -65,7 +67,9 @@ msg "Moving packages from [%s] to [%s]..." "$repo_from" "$repo_to"

for arch in "${ARCHES[@]}"; do
declare -a add_pkgs_$arch
declare -a add_debug_pkgs_$arch
declare -a remove_pkgs_$arch
declare -a remove_debug_pkgs_$arch
done
for pkgbase in "${args[@]:2}"; do
tag_list=""
Expand All @@ -88,7 +92,9 @@ for pkgbase in "${args[@]:2}"; do

for tarch in "${tarches[@]}"; do
declare -n add_pkgs="add_pkgs_${tarch}"
declare -n add_debug_pkgs="add_debug_pkgs_${tarch}"
declare -n remove_pkgs="remove_pkgs_${tarch}"
declare -n remove_debug_pkgs="remove_debug_pkgs_${tarch}"
for pkgname in "${pkgnames[@]}"; do
pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS})
pkgfile="${pkgpath##*/}"
Expand All @@ -99,6 +105,18 @@ for pkgbase in "${args[@]:2}"; do
fi
add_pkgs+=("${FTP_BASE}/${PKGPOOL}/${pkgfile}")
remove_pkgs+=("${pkgname}")

debug_pkgpath=$(getpkgfile "${ftppath_debug_from}/${tarch}/${pkgname}-debug-${pkgver}-${pkgarch}"${PKGEXTS})
debug_pkgfile="${debug_pkgpath##*/}"
if [[ -f ${debug_pkgpath} ]]; then
msg2 "Found debug package %s" "${pkgname}-debug"
ln -s "../../../${PKGPOOL}-debug/${debug_pkgfile}" "${ftppath_debug_to}/${tarch}/"
if [[ -f ${FTP_BASE}/${PKGPOOL}-debug/${debug_pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}-debug/${debug_pkgfile}.sig" "${ftppath_debug_to}/${tarch}/"
fi
add_debug_pkgs+=("${FTP_BASE}/${PKGPOOL}-debug/${debug_pkgfile}")
remove_debug_pkgs+=("${pkgname}-debug")
fi
done
done
fi
Expand All @@ -109,11 +127,17 @@ done

for tarch in "${ARCHES[@]}"; do
declare -n add_pkgs="add_pkgs_${tarch}"
declare -n add_debug_pkgs="add_debug_pkgs_${tarch}"
declare -n remove_pkgs="remove_pkgs_${tarch}"
declare -n remove_debug_pkgs="remove_debug_pkgs_${tarch}"
if [[ -n ${add_pkgs[@]} ]]; then
arch_repo_modify add "${repo_to}" "${tarch}" "${add_pkgs[@]}"
arch_repo_modify remove "${repo_from}" "${tarch}" "${remove_pkgs[@]}"
fi
if [[ -n ${add_debug_pkgs[@]} ]]; then
arch_repo_modify add "${repo_to}-debug" "${tarch}" "${add_debug_pkgs[@]}"
arch_repo_modify remove "${repo_from}-debug" "${tarch}" "${remove_debug_pkgs[@]}"
fi
done

for pkgarch in "${ARCHES[@]}"; do
Expand Down
13 changes: 11 additions & 2 deletions db-remove
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ repo="$1"
arch="$2"
pkgbases=("${@:3}")

ftppath="$FTP_BASE/$repo/os"
vcsrepo="$repo-$arch"

if ! check_repo_permission "$repo"; then
Expand Down Expand Up @@ -45,6 +44,16 @@ for pkgbase in "${pkgbases[@]}"; do
done

for tarch in "${tarches[@]}"; do
arch_repo_modify remove "${repo}" "${tarch}" "${remove_pkgs[@]}"
if (( ${#remove_pkgs[@]} >= 1 )); then
arch_repo_modify remove "${repo}" "${tarch}" "${remove_pkgs[@]}"
for pkg in "${remove_pkgs[@]}"; do
if is_globfile "${FTP_BASE}/${repo}-debug/os/${tarch}/${pkg}-debug"*; then
msg "Found debug package. Removing %s from [%s]..." "$pkg" "$repo"
remove_debug_pkgs+=("${pkg}-debug")
arch_repo_modify remove "${repo}-debug" "${tarch}" "${pkg}-debug"
fi
done
fi

repo_unlock "$repo" "$tarch"
done
33 changes: 26 additions & 7 deletions db-update
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,50 @@ done

for repo in "${repos[@]}"; do
msg "Updating [%s]..." "$repo"
tree "${STAGING}/${repo}"
any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXTS} 2>/dev/null))
for pkgarch in "${ARCHES[@]}"; do
add_pkgs=()
debug_pkgs=()
arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*"-${pkgarch}"${PKGEXTS} 2>/dev/null))
for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do
pkgfile="${pkg##*/}"

if is_debug_package "${pkg}"; then
debug_pkgs+=("${pkgfile}")
currentpool=${PKGPOOL}-debug
currentrepo=${repo}-debug
else
add_pkgs+=("${pkgfile}")
currentpool=${PKGPOOL}
currentrepo=${repo}
fi

msg2 '%s (%s)' "$pkgfile" "$pkgarch"
# any packages might have been moved by the previous run
if [[ -f ${pkg} ]]; then
mv "${pkg}" "$FTP_BASE/${PKGPOOL}"
mv "${pkg}" "$FTP_BASE/${currentpool}"
fi
ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}"
ln -s "../../../${currentpool}/${pkgfile}" "$FTP_BASE/${currentrepo}/os/${pkgarch}"
# also move signatures
if [[ -f ${pkg}.sig ]]; then
mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}"
mv "${pkg}.sig" "$FTP_BASE/${currentpool}"
fi
"$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/db-archive" "${FTP_BASE}/${PKGPOOL}/${pkg##*/}"
if [[ -f $FTP_BASE/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}"
if [[ ${PKGPOOL} = ${currentpool} ]]; then
# do not archive debug info, this is not of historic interest
"$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/db-archive" "${FTP_BASE}/${PKGPOOL}/${pkg##*/}"
fi
if [[ -f $FTP_BASE/${currentpool}/${pkgfile}.sig ]]; then
ln -s "../../../${currentpool}/${pkgfile}.sig" "$FTP_BASE/${currentrepo}/os/${pkgarch}"
fi
add_pkgs+=("${pkgfile}")
done
declare -p add_pkgs debug_pkgs
if (( ${#add_pkgs[@]} >= 1 )); then
arch_repo_modify add "${repo}" "${pkgarch}" ${add_pkgs[@]}
fi
if (( ${#debug_pkgs[@]} >= 1 )); then
arch_repo_modify add "${repo}-debug" "${pkgarch}" ${debug_pkgs[@]}
fi
done
done

Expand Down
9 changes: 5 additions & 4 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM archlinux/base
RUN pacman -Syu --noconfirm --needed sudo fakeroot awk subversion make kcov bash-bats gettext grep
FROM docker.io/archlinux/base
RUN pacman -Syu --noconfirm --needed sudo fakeroot awk subversion make kcov bash-bats gettext grep tree binutils
RUN pacman-key --init
RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/wheel
RUN useradd -N -g users -G wheel -d /build -m tester
RUN useradd -N -g users -G wheel -d /tester -m tester
RUN mkdir -p /build; chown -R tester: /build
VOLUME ["/build"]
USER tester
RUN echo -e "\
Key-Type: RSA\n\
Expand All @@ -16,5 +18,4 @@ Expire-Date: 0\n\
| gpg --quiet --batch --no-tty --no-permission-warning --gen-key
RUN gpg --export | sudo pacman-key -a -
RUN sudo pacman-key --lsign-key tester@localhost
ENV BUILDDIR=/build
ENV PACKAGER="Bob Tester <tester@localhost>"
8 changes: 5 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
CASES ?= cases

test:
PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) bats cases
BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) bats $(CASES)

test-coverage:
PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) kcov \
BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) kcov \
--include-path=$(CURDIR)/../ \
--exclude-path=$(CURDIR)/../test,$(CURDIR)/../cron-jobs/makepkg.conf,$(CURDIR)/../config \
$(COVERAGE_DIR) \
bats cases
bats $(CASES)

.PHONY: test test-coverage
39 changes: 39 additions & 0 deletions test/cases/db-move.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,54 @@ load ../lib/common
local arch

for pkgbase in ${pkgs[@]}; do
echo "releasing to testing: $pkgbase"
releasePackage testing ${pkgbase}
done

echo "db-updating..."
db-update

echo "db-move testing -> extra pkg-simple-a"
db-move testing extra pkg-simple-a

echo checkRemovedPackage testing pkg-simple-a
checkRemovedPackage testing pkg-simple-a
echo checkPackage extra pkg-simple-a 1-1
checkPackage extra pkg-simple-a 1-1
echo checkPackage testing pkg-simple-b 1-1
checkPackage testing pkg-simple-b 1-1
}

@test "move debug package" {
local arches=('i686' 'x86_64')
local pkgs=('pkg-debuginfo' 'pkg-simple-b')
local pkgbase
local arch

for pkgbase in ${pkgs[@]}; do
echo "releasing to testing: $pkgbase"
releasePackage testing ${pkgbase}
done

echo "db-updating..."
db-update

echo "db-move testing -> extra pkg-debuginfo"
db-move testing extra pkg-debuginfo

echo checkRemovedPackage testing pkg-debuginfo
checkRemovedPackage testing pkg-debuginfo

echo checkRemovedPackage testing-debug pkg-debuginfo-debug
checkRemovedPackage testing-debug pkg-debuginfo

echo checkPackage extra pkg-debuginfo 1-1
checkPackage extra pkg-debuginfo 1-1

echo checkPackage extra-debug pkg-debuginfo 1-1
checkPackage extra-debug pkg-debuginfo 1-1

echo checkPackage testing pkg-simple-b 1-1
checkPackage testing pkg-simple-b 1-1
}

Expand Down
25 changes: 25 additions & 0 deletions test/cases/db-remove.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ load ../lib/common
done
}

@test "remove debug package" {
local arches=('i686' 'x86_64')
local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch' 'pkg-debuginfo')
local debug_pkgs=('pkg-debuginfo')
local pkgbase
local arch

for pkgbase in ${pkgs[@]}; do
releasePackage extra ${pkgbase}
done

db-update

for pkgbase in ${pkgs[@]}; do
for arch in ${arches[@]}; do
db-remove extra ${arch} ${pkgbase}
done
done

checkRemovedPackage extra pkg-debuginfo
for pkgbase in ${debug_pkgs[@]}; do
checkRemovedPackage extra-debug ${pkgbase}
done
}

@test "remove multiple packages" {
local arches=('i686' 'x86_64')
local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch')
Expand Down
Loading