From d44ce5005d4b5e8de141a4069aca118404225b6f Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 28 Sep 2024 10:14:06 +0200 Subject: update: check tag revisions and update if we do not find the revision --- bin/check | 3 --- bin/setup | 2 -- bin/update | 34 +++++++++++++++++++++++++++------- doc/TODOS | 1 + 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/bin/check b/bin/check index 46e9212..c50ab19 100755 --- a/bin/check +++ b/bin/check @@ -115,6 +115,3 @@ for pkg in `find "${state_dir}"/{core,extra}-{any,x86_64} -type f | \ echo "${pkg}\tno git repo" >> "${data_dir}/missing_package_repo" fi done - -# TODO: update all single package directories -# TODO: update all AUR package directories diff --git a/bin/setup b/bin/setup index fcb8c87..a74c088 100755 --- a/bin/setup +++ b/bin/setup @@ -47,5 +47,3 @@ if test ! -d "${aur_state_dir}"; then else echo "AUR state information directory exists." fi - -# TODO: AUR directory diff --git a/bin/update b/bin/update index 1d317ed..f7b7c44 100755 --- a/bin/update +++ b/bin/update @@ -98,25 +98,45 @@ if test "${UPDATE_UPSTREAM}" = 1; then IFS=" " while read pkgname pkgver tag revision; do if test "${VERBOSE}" = 1; then - echo "${repo} ${pkgname}" + echo -n "${repo} ${pkgname}" fi if test ! -d "${packages_dir}/${repo}/${pkgname}"; then + if test "${VERBOSE}" = 1; then + echo ".. cloning .." + fi cd "${packages_dir}/${repo}" || exit 1 pkgctl repo clone --protocol=https "${pkgname}" sleep 10 else - true -# TODO: find a way to find out whether the reference revision is in out -# current state repo and update only when we miss it. We can still -# do a full update when we need it, but here it just creates a lot -# of load.. -# git -C "${packages_dir}/${repo}/${pkgname}" pull + # get all revisions from the package repo, check if + # we find the state sha in there, if not, do an + # update of the repo. Doing a full git pull on + # every update is not acceptable as it creates too + # much load + cd "${packages_dir}/${repo}/${pkgname}" || exit 1 + git show-ref --tags > /tmp/update_package_revisions.$$ + grep -F "${revision}" "/tmp/update_package_revisions.$$" 2>&1 >/tmp/update_package_revision_found.$$ + if test $? = 0; then + if test "${VERBOSE}"; then + tag=`cat /tmp/update_package_revision_found.$$ | cut -d ' ' -f 2` + echo ".. ${revision} (${tag}) exists in package history .." + fi + else + if test "${VERBOSE}"; then + echo ".. updating .." + fi + git -C "${packages_dir}/${repo}/${pkgname}" pull + sleep 10 + fi + rm -f /tmp/update_package_revisions.$$ /tmp/update_package_revision_found.$$ fi done < $pkgfile IFS="$OLDIFS" done fi +rm -f /tmp/update_packages.$$ + if test "${UPDATE_AUR}" = 1; then echo "Updating AUR state.." diff --git a/doc/TODOS b/doc/TODOS index b9c6d46..2c76c01 100644 --- a/doc/TODOS +++ b/doc/TODOS @@ -11,3 +11,4 @@ - check for all tags if they appear in the packages for every package - integrate https://git.archlinux32.org/devops/tree/generate-bug-report +- update all AUR package directories -- cgit v1.2.3-70-g09d2