fix/improve repository manager (2)

This commit is contained in:
Daniel Langbein 2021-04-25 15:30:41 +02:00
parent d790b861a0
commit 08ec3a4a26
2 changed files with 12 additions and 21 deletions

View File

@ -6,19 +6,9 @@ source /etc/de-p1st-repo/arch-repo.cfg || exit
cd "${LOCAL_PKG_DIR}" || exit cd "${LOCAL_PKG_DIR}" || exit
# get list of new packages, one package per line
rsync --ignore-existing --out-format="%n" --dry-run \
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" > new-pkg.txt || exit
# transfer new packages using rsync # transfer new packages using rsync
rsync --ignore-existing --progress --human-readable \ rsync --ignore-existing --progress --human-readable \
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit ./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
# transfer new-pkg.txt
rsync --ignore-times --checksum --progress --human-readable \
new-pkg.txt "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
# add each new package to database # add each new package to database
ssh "${REMOTE_SSH_HOST}" "/usr/bin/arch-repo-receive-new" ssh "${REMOTE_SSH_HOST}" "/usr/bin/arch-repo-receive-new"

View File

@ -13,20 +13,21 @@ function add_to_db(){
sort_pkgname_pkgver || return $? sort_pkgname_pkgver || return $?
echo "For each package: Add latest version to database ..." echo "For each package: Add latest version to database ..."
for PKGNAME in ./pkg/*; do for PKGNAME in ./db/*; do
# #
# get latest version for PKGNAME # get latest version for $PKGNAME
# #
local LATEST local LATEST
for PKGVER in ./pkg/"${PKGNAME}"/*; do # pick one random version as starting point for the latest version
for PKGVER in ./db/"${PKGNAME}"/*; do
LATEST="$PKGVER" LATEST="$PKGVER"
break break
done done
local cmp local cmp
for PKGVER in ./pkg/"$PKGNAME"/*; do for PKGVER in ./db/"$PKGNAME"/*; do
# compare the currently known latest version # compare the currently known latest version
# with the next version # with the next version
cmp=$(vercmp "$LATEST" "$PKGVER") || return $? cmp=$(vercmp "$LATEST" "$PKGVER") || return $?
@ -39,8 +40,8 @@ function add_to_db(){
# #
# add latest version of PKGNAME to database # add latest version of PKGNAME to database
# #
PKG=$(cat "./pkg/${PKGNAME}/${LATEST}") || return $? PKG=$(cat "./db/${PKGNAME}/${LATEST}") || return $?
repo-add -n "${REMOTE_DB_NAME}.db.tar.gz" "${PKG}" || return $? repo-add --new "${REMOTE_DB_NAME}.db.tar.gz" "${PKG}" || return $?
true true
done done
@ -48,7 +49,7 @@ function add_to_db(){
# #
# create files "./pkg/$pkgname/$pkgver" with content "$path_to_file" = "$PKG" # create files "./db/$pkgname/$pkgver" with content "$path_to_file" = "$PKG"
# #
function sort_pkgname_pkgver(){ function sort_pkgname_pkgver(){
echo "Sorting packages by package name and package version ..." echo "Sorting packages by package name and package version ..."
@ -56,11 +57,11 @@ function sort_pkgname_pkgver(){
for PKG in ./*.pkg.tar.{xz,zst}; do for PKG in ./*.pkg.tar.{xz,zst}; do
get_pkginfo "$PKG" || return $? get_pkginfo "$PKG" || return $?
get_pkgname "$PKGINFO" || return $? get_pkgname "$PKGINFO" || return $?
get_pkgver "$PKGINFO" || return $? get_pkgver "$PKGINFO" || return $?
echo "Creating file pkg/${PKGNAME} with content ${PKG} ..." echo "Creating file ./db/${PKGNAME} with content ${PKG} ..."
mkdir -p "pkg/${PKGNAME}" || return $? mkdir -p "db/${PKGNAME}" || return $?
echo "${PKG}" > "pkg/${PKGNAME}/${PKGVER}" || return $? echo "${PKG}" > "db/${PKGNAME}/${PKGVER}" || return $?
done done
} }