arch-repo: list VCS packages

This commit is contained in:
Daniel Langbein 2021-05-24 15:09:45 +02:00
parent fe975126df
commit 41271634c9
9 changed files with 189 additions and 99 deletions

View File

@ -19,27 +19,27 @@ PACMAN_CFG_ADDITION='pkg/de-p1st-pacman/pacman.d/de-p1st' # will be used to exte
################################ ################################
if [ "$1" = "clean" ] ; then if [ "$1" = "clean" ] ; then
sudo rm -r "${BUILD_DIR}" || exit sudo rm -r "${BUILD_DIR}" || exit $?
elif [ -d "${BUILD_DIR}" ] ; then elif [ -d "${BUILD_DIR}" ] ; then
echo "Build dir does already exist and may not be empty!" echo "Build dir does already exist and may not be empty!"
echo "Run '$0 clean' to start a clean ISO build." echo "Run '$0 clean' to start a clean ISO build."
exit 1 exit 1
fi fi
mkdir "$BUILD_DIR" || exit mkdir "$BUILD_DIR" || exit $?
# The releng profile is used to create the official monthly installation ISO # The releng profile is used to create the official monthly installation ISO
PROFILE=/usr/share/archiso/configs/releng/ PROFILE=/usr/share/archiso/configs/releng/
if [ ! -d "${PROFILE}" ] ; then if [ ! -d "${PROFILE}" ] ; then
echo "Installing dependency 'archiso' with sudo ..." echo "Installing dependency 'archiso' with sudo ..."
sudo pacman -S --needed archiso || exit sudo pacman -S --needed archiso || exit $?
fi fi
cp -r "$PROFILE" "$BUILD_DIR"/profile || exit cp -r "$PROFILE" "$BUILD_DIR"/profile || exit $?
# extend the builder's pacman.conf (add de-p1st mirrors) # extend the builder's pacman.conf (add de-p1st mirrors)
# https://wiki.archlinux.org/index.php/Archiso#Custom_local_repository # https://wiki.archlinux.org/index.php/Archiso#Custom_local_repository
cat "${PACMAN_CFG_ADDITION}" >> "$BUILD_DIR"/profile/pacman.conf || exit cat "${PACMAN_CFG_ADDITION}" >> "$BUILD_DIR"/profile/pacman.conf || exit $?
for PKG in "${PKGS[@]}"; do for PKG in "${PKGS[@]}"; do
echo "${PKG}" >> "${BUILD_DIR}"/profile/packages.x86_64 echo "${PKG}" >> "${BUILD_DIR}"/profile/packages.x86_64
@ -47,7 +47,7 @@ done
### ###
mkdir "${BUILD_DIR}/work_dir" && mkdir "${BUILD_DIR}/out_dir" || exit mkdir "${BUILD_DIR}/work_dir" && mkdir "${BUILD_DIR}/out_dir" || exit $?
echo "running 'sudo mkarchiso' ..." echo "running 'sudo mkarchiso' ..."
sudo mkarchiso -v -w "${BUILD_DIR}/work_dir" -o "${BUILD_DIR}/out_dir" "${BUILD_DIR}/profile" || exit sudo mkarchiso -v -w "${BUILD_DIR}/work_dir" -o "${BUILD_DIR}/out_dir" "${BUILD_DIR}/profile" || exit $?

View File

@ -2,7 +2,7 @@
_pkgname=repo _pkgname=repo
_reponame=arch _reponame=arch
pkgname="de-p1st-$_pkgname" pkgname="de-p1st-$_pkgname"
pkgver=0.2.3 pkgver=0.2.4
pkgrel=1 pkgrel=1
pkgdesc="Bash script to manage remote Arch Linux repository" pkgdesc="Bash script to manage remote Arch Linux repository"
arch=('any') arch=('any')
@ -20,5 +20,9 @@ package() {
install -Dm0555 arch-repo-receive-new.sh "$pkgdir"/usr/bin/arch-repo-receive-new install -Dm0555 arch-repo-receive-new.sh "$pkgdir"/usr/bin/arch-repo-receive-new
install -Dm0555 arch-repo-vercmp.sh "$pkgdir"/usr/bin/arch-repo-vercmp install -Dm0555 arch-repo-vercmp.sh "$pkgdir"/usr/bin/arch-repo-vercmp
install -Dm0644 lib/util.sh "$pkgdir"/usr/lib/"${pkgname}"/util.sh
install -Dm0644 lib/pkginfo.sh "$pkgdir"/usr/lib/"${pkgname}"/pkginfo.sh
install -Dm0644 lib/pkgver.sh "$pkgdir"/usr/lib/"${pkgname}"/pkgver.sh
install -Dm0644 -o0 arch-repo.cfg "$pkgdir"/etc/de-p1st-repo/arch-repo.cfg install -Dm0644 -o0 arch-repo.cfg "$pkgdir"/etc/de-p1st-repo/arch-repo.cfg
} }

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source /etc/de-p1st-repo/arch-repo.cfg || exit source /etc/de-p1st-repo/arch-repo.cfg || exit $?
# Enable nullglob for the case that not all patterns match, e.g. just *.zst but not *.xz packages exist. # Enable nullglob for the case that not all patterns match, e.g. just *.zst but not *.xz packages exist.
shopt -s nullglob shopt -s nullglob

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
source /etc/de-p1st-repo/arch-repo.cfg || exit source /usr/lib/de-p1st-repo/util.sh || exit $?
source /usr/lib/de-p1st-repo/pkgver.sh || exit $?
source /usr/lib/de-p1st-repo/pkginfo.sh || exit $?
source /etc/de-p1st-repo/arch-repo.cfg || exit $?
@ -44,36 +47,10 @@ function add_to_db(){
local PKGNAME local PKGNAME
PKGNAME="$1" PKGNAME="$1"
# # get path to latest version of $PKGNAME
# get latest version for $PKGNAME PKG=$(latest_pkgver_path "${PKGNAME}") || return $?
#
# pick one random version as starting point for the latest version # add to database
local LATEST
for PKGVER in db/"${PKGNAME}"/*; do
PKGVER=$(basename "${PKGVER}") # strip directory and suffix from filename
LATEST="$PKGVER"
break
done
local cmp
for PKGVER in db/"$PKGNAME"/*; do
PKGVER=$(basename "${PKGVER}") # strip directory and suffix from filename
# compare the currently known latest version
# with the next version
cmp=$(vercmp "$LATEST" "$PKGVER") || return $?
# if the new version is larger, save it as LATEST
if [ "$cmp" -lt "0" ]; then
LATEST="$PKGVER"
fi
done
#
# add latest version of PKGNAME to database
#
PKG=$(cat "db/${PKGNAME}/${LATEST}") || return $?
repo-add --new "${REMOTE_DB_NAME}.db.tar.gz" "${PKG}" || return $? repo-add --new "${REMOTE_DB_NAME}.db.tar.gz" "${PKG}" || return $?
} }
@ -95,7 +72,7 @@ function sort_all_pkgname_pkgver(){
# create files "db/$pkgname/$pkgver" with content "$PKG" (path to package file) # create files "db/$pkgname/$pkgver" with content "$PKG" (path to package file)
# #
function sort_new_pkgname_pkgver(){ function sort_new_pkgname_pkgver(){
# return: 0 on success; array $NEW_PKGNAMES # return: array $NEW_PKGNAMES
echo "Sorting new packages by package name and package version ..." echo "Sorting new packages by package name and package version ..."
@ -132,13 +109,13 @@ function sort_new_pkgname_pkgver(){
# #
function sort_pkgname_pkgver(){ function sort_pkgname_pkgver(){
# $1: PKG (path to package file) # $1: PKG (path to package file)
# return: 0 on success; variables $PKGINFO, $PKGNAME, $PKGVER # return: variables $PKGINFO, $PKGNAME, $PKGVER
local PKG local PKG
PKG="$1" PKG="$1"
get_pkginfo "$PKG" || { echo "get_pkginfo failed"; return 1; } get_pkginfo "$PKG" || { echo "get_pkginfo failed"; return 1; }
get_pkgname "$PKGINFO" || { echo "get_pkgname failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; } PKGNAME=$(get_pkgname "$PKGINFO") || { echo "get_pkgname failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; }
get_pkgver "$PKGINFO" || { echo "get_pkgver failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; } PKGVER=$(get_pkgver "$PKGINFO") || { echo "get_pkgver failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; }
echo "Creating file ./db/${PKGNAME}/${PKGVER} with content ${PKG} ..." echo "Creating file ./db/${PKGNAME}/${PKGVER} with content ${PKG} ..."
mkdir -p "db/${PKGNAME}" || return $? mkdir -p "db/${PKGNAME}" || return $?
@ -146,58 +123,6 @@ function sort_pkgname_pkgver(){
} }
#
# get content of .PKGINFO from package-file
#
function get_pkginfo(){
# $1: path to package file
# return: 0 on success; variable $PKGINFO
if endswith "$1" ".pkg.tar.xz"; then
PKGINFO=$(tar -xf "$1" -O .PKGINFO --force-local) || { echo "tar failed"; return 1; }
elif endswith "$1" ".pkg.tar.zst"; then
PKGINFO=$(tar -I zstd -xf "$1" -O .PKGINFO --force-local) || { echo "tar failed"; return 1; }
else
echo "$1 does not seem to be a package!"
return 1
fi
}
#
# get pkgname from $PKGINFO
#
function get_pkgname(){
# return: 0 on success; variable $PKGNAME
# remove "pkgname = " as well as tailing whitespace characters
local tmp
tmp=$(echo "${PKGINFO}" | grep '^pkgname') || { echo "grep failed"; return 1; }
PKGNAME=$(echo "${tmp}" | sed 's|^pkgname\s*=\s*||; s|\s*$||') || { echo "sed failed"; return 1; }
}
#
# get pkgver from $PKGINFO
#
function get_pkgver(){
# return: 0 on success; variable $PKGVER
# remove "pkgver = " as well as tailing whitespace characters
local tmp
tmp=$(echo "${PKGINFO}" | grep '^pkgver') || { echo "grep failed"; return 1; }
PKGVER=$(echo "${tmp}" | sed 's|^pkgver\s*=\s*||; s|\s*$||') || { echo "sed failed"; return 1; }
}
# Inspired by: https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value/18558871#18558871
#
# $1 begins with $2
#
beginswith() { case $1 in "$2"*) true;; *) false;; esac; }
#
# $1 ends with $2
#
endswith() { case $1 in *"$2") true;; *) false;; esac; }
# #
# generate index.html # generate index.html

View File

@ -5,11 +5,15 @@
# print all outdated packages # print all outdated packages
# #
source /etc/de-p1st-repo/arch-repo.cfg || exit source /usr/lib/de-p1st-repo/util.sh || exit $?
source /usr/lib/de-p1st-repo/pkgver.sh || exit $?
source /usr/lib/de-p1st-repo/pkginfo.sh || exit $?
source /etc/de-p1st-repo/arch-repo.cfg || exit $?
function main(){ function main(){
cd "${REMOTE_PKG_DIR}" || return $?
echo "Note: You may run 'arch-repo-push-new' and 'pacman -Sy' first ..." echo "Note: You may run 'arch-repo-push-new' and 'pacman -Sy' first ..."
all_pkg_vers || return $? all_pkg_vers || return $?
@ -23,6 +27,31 @@ function main(){
else else
echo "There are no pending AUR updates in repository ${REMOTE_DB_NAME}." echo "There are no pending AUR updates in repository ${REMOTE_DB_NAME}."
fi fi
get_vcs_packages || return $?
if [ "${#VCS_PKGS[@]}" -gt "0" ]; then
echo ""
echo "Note: Some VCS packages were found which are possibly outdated:"
for VCS_PKG in "${VCS_PKGS[@]}"; do
echo " ${VCS_PKG}"
done
fi
}
function get_vcs_packages(){
# return: array GIT_PKGS with all VCS packages
VCS_PKGS=()
# https://wiki.archlinux.org/title/VCS_package_guidelines#VCS_sources
# https://github.com/AladW/aurutils/pull/283/files
readonly AURVCS='.*-(bzr|git|hg|svn)$'
for PKG_VER in "${PKG_VERS[@]}"; do
PKGNAME=$(first_word "${PKG_VER}") || return $?
if echo "${PKGNAME}" | grep -E "$AURVCS"; then
VCS_PKGS+=("${PKGNAME}")
fi
done
} }
# #

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
source /etc/de-p1st-repo/arch-repo.cfg || exit source /etc/de-p1st-repo/arch-repo.cfg || exit $?
cd "${LOCAL_PKG_DIR}" || exit cd "${LOCAL_PKG_DIR}" || exit $?
match="0" match="0"
for PKG in ./*.pkg.tar.{xz,zst}; do for PKG in ./*.pkg.tar.{xz,zst}; do

View File

@ -0,0 +1,60 @@
#
# get content of .PKGINFO from package-file
#
function get_pkginfo(){
# $1: path to package file
# return: variable $PKGINFO
if endswith "$1" ".pkg.tar.xz"; then
PKGINFO=$(tar -xf "$1" -O .PKGINFO --force-local) || { echo "tar failed"; return 1; }
elif endswith "$1" ".pkg.tar.zst"; then
PKGINFO=$(tar -I zstd -xf "$1" -O .PKGINFO --force-local) || { echo "tar failed"; return 1; }
else
echo "$1 does not seem to be a package!"
return 1
fi
}
#
# get pkgname from $PKGINFO
#
function get_pkgname(){
# return: stdout: package name
# remove "pkgname = " as well as tailing whitespace characters
local tmp
tmp=$(echo "${PKGINFO}" | grep '^pkgname =') || { echo "grep failed"; return 1; }
local PKGNAME
PKGNAME=$(echo "${tmp}" | sed 's|^pkgname\s*=\s*||; s|\s*$||') || { echo "sed failed"; return 1; }
echo "${PKGNAME}"
}
#
# get pkgver from $PKGINFO
#
function get_pkgver(){
# return: stdout: package version
# remove "pkgver = " as well as tailing whitespace characters
local tmp
tmp=$(echo "${PKGINFO}" | grep '^pkgver =') || { echo "grep failed"; return 1; }
local PKGVER
PKGVER=$(echo "${tmp}" | sed 's|^pkgver\s*=\s*||; s|\s*$||') || { echo "sed failed"; return 1; }
echo "${PKGVER}"
}
#
# get url from $PKGINFO
#
function get_pkgurl(){
# return: stdout: url
# remove "url = " as well as tailing whitespace characters
local tmp
tmp=$(echo "${PKGINFO}" | grep '^url =') || { echo "grep failed"; return 1; }
local PKGURL
PKGURL=$(echo "${tmp}" | sed 's|^url\s*=\s*||; s|\s*$||') || { echo "sed failed"; return 1; }
echo "${PKGURL}"
}

View File

@ -0,0 +1,53 @@
#
# get package-file with latest version for given package name
#
function latest_pkgver_path(){
# precond: In current working directory there is a subdir "db"
# $1: package name
# return: stdout: path to package file
local PKGNAME
PKGNAME="$1"
# get latest version for $PKGNAME
local LATEST_PKGVER
LATEST_PKGVER=$(latest_pkgver "${PKGNAME}") || return $?
# get the path to package file
local PKG
PKG=$(cat "db/${PKGNAME}/${LATEST_PKGVER}") || return $?
echo "${PKG}"
}
#
# get latest version of package
#
function latest_pkgver(){
# precond: In current working directory there is a subdir "db"
# $1: package name
# return: stdout: latest pkgver
local PKGNAME
PKGNAME="$1"
# pick one random version as starting point for the latest version
local LATEST_PKGVER
for PKGVER in db/"${PKGNAME}"/*; do
PKGVER=$(basename "${PKGVER}") || return $? # strip directory and suffix from filename
LATEST_PKGVER="${PKGVER}"
break
done
local cmp
for PKGVER in db/"${PKGNAME}"/*; do
PKGVER=$(basename "${PKGVER}") || return $? # strip directory and suffix from filename
# compare the currently known latest version
# with the next version
cmp=$(vercmp "${LATEST_PKGVER}" "${PKGVER}") || return $?
# if the new version is larger, save it as LATEST_PKGVER
if [ "${cmp}" -lt "0" ]; then
LATEST_PKGVER="${PKGVER}"
fi
done
echo "${LATEST_PKGVER}"
}

View File

@ -0,0 +1,19 @@
function first_word() {
# return: The first word of $1.
# In detail: "" if $1 starts with a space. Otherwise: All characters until the first space of $1.
#
# source: https://unix.stackexchange.com/a/201744/315162
echo "${1%% *}"
}
# Inspired by: https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value/18558871#18558871
#
# $1 begins with $2
#
beginswith() { case $1 in "$2"*) true;; *) false;; esac; }
#
# $1 ends with $2
#
endswith() { case $1 in *"$2") true;; *) false;; esac; }