Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/get-package-updates
diff options
context:
space:
mode:
Diffstat (limited to 'bin/get-package-updates')
-rwxr-xr-xbin/get-package-updates145
1 files changed, 90 insertions, 55 deletions
diff --git a/bin/get-package-updates b/bin/get-package-updates
index d9dd362..9c3b266 100755
--- a/bin/get-package-updates
+++ b/bin/get-package-updates
@@ -5,12 +5,19 @@
# https://github.com/archlinux32/builder/wiki/Build-system#get-package-updates
# TODOs:
-# additional to blacklisted packages ignore any packages depending on them
# be more secure in case of update while build(s) is/are still in progress
# -> (stale) lock files, moving (or changing content of) loop lock files
. "${0%/*}/../conf/default.conf"
+# delete_package package
+# mark $package for deletion
+delete_package() {
+ echo "$1" >> \
+ "${work_dir}/deletion-list.new"
+ sed -i "/^${1//./\\.} /d" "${work_dir}/build-list.new"
+}
+
# Create a lock file for build list.
exec 9> "${build_list_lock_file}"
@@ -54,57 +61,51 @@ echo 'Check modified packages from the last update, and put them to the build li
cp "${work_dir}/build-list"{,.new}
cp "${work_dir}/deletion-list"{,.new}
-(
- for repo in "${!repo_paths[@]}"; do
- (
- # if old revision unknown, mimic "git diff"-output
- if [ "${old_repo_revisions["${repo}"]}" == "NONE" ]; then
- git -C "${repo_paths["${repo}"]}" archive --format=tar HEAD | \
- tar -t | \
- sed 's|^|A\t|'
- else
- git -C "${repo_paths["${repo}"]}" diff --no-renames --name-status "${old_repo_revisions["${repo}"]}" HEAD
- fi
- ) | \
- # only track changes in PKGBUILDs
- grep '/PKGBUILD$' | \
- if [ "${repo}" == "archlinux32" ]; then
- # modify the directory structure from the modifiaction-repository
- # to the one of an original source repository
- sed 's|^\(.\t\)\([^/]\+\)/\([^/]\+\)/\(.\+\)$|\2 \1\3/repos/\2-x86_64/\4|' | \
- while read -r pkg_repo rest; do
- echo "${new_repo_revisions["$(find_git_repository_to_package_repository "${pkg_repo}")"]} ${rest}"
- done
- else
- sed "s|^|${new_repo_revisions["${repo}"]} |"
- fi | \
- grep '^\S\+ .\s[^/]\+/repos/[^/]\+/PKGBUILD$' | \
- # ignore i686
- grep -v -- '-i686/PKGBUILD$' | \
- sed 's|^\(\S\+\) \(.\)\t\([^/]\+\)/repos/\([^/]\+\)-[^/-]\+/PKGBUILD$|\2 \3 \1 \4|' | \
- # ignore staging and testing
- grep -v '\(staging\|testing\)$'
- done | \
- sort -u
- # ignore blacklisted packages by explicitely deleting them _at_the_end_
- sed "s|^\(.*\)\$|D \1 ${new_repo_revisions["archlinux32"]} archlinux32|" "${repo_paths["archlinux32"]}/blacklist"
-) | \
+for repo in "${!repo_paths[@]}"; do
+ (
+ # if old revision unknown, mimic "git diff"-output
+ if [ "${old_repo_revisions["${repo}"]}" == "NONE" ]; then
+ git -C "${repo_paths["${repo}"]}" archive --format=tar HEAD | \
+ tar -t | \
+ sed 's|^|A\t|'
+ else
+ git -C "${repo_paths["${repo}"]}" diff --no-renames --name-status "${old_repo_revisions["${repo}"]}" HEAD
+ fi
+ ) | \
+ # only track changes in PKGBUILDs
+ grep '/PKGBUILD$' | \
+ if [ "${repo}" == "archlinux32" ]; then
+ # modify the directory structure from the modifiaction-repository
+ # to the one of an original source repository
+ sed 's|^\(.\t\)\([^/]\+\)/\([^/]\+\)/\(.\+\)$|\2 \1\3/repos/\2-x86_64/\4|' | \
+ while read -r pkg_repo rest; do
+ echo "${new_repo_revisions["$(find_git_repository_to_package_repository "${pkg_repo}")"]} ${rest}"
+ done
+ else
+ sed "s|^|${new_repo_revisions["${repo}"]} |"
+ fi | \
+ grep '^\S\+ .\s[^/]\+/repos/[^/]\+/PKGBUILD$' | \
+ # ignore i686
+ grep -v -- '-i686/PKGBUILD$' | \
+ sed 's|^\(\S\+\) \(.\)\t\([^/]\+\)/repos/\([^/]\+\)-[^/-]\+/PKGBUILD$|\2 \3 \1 \4|' | \
+ # ignore staging and testing
+ grep -v '\(staging\|testing\)$'
+done | \
+ sort -u | \
while read -r mode package git_revision repository; do
case "${mode}" in
# new or modified PKGBUILD
"A"|"M")
- sed -i "/^${package} /d" "${work_dir}/build-list"
+ sed -i "/^${package//./\\.} /d" "${work_dir}/build-list.new"
echo "${package} ${git_revision} ${new_repo_revisions["archlinux32"]} ${repository}" >> \
"${work_dir}/build-list.new"
- sed -i "/^${package}\$/d" "${work_dir}/deletion-list.new"
+ sed -i "/^${package//./\\.}\$/d" "${work_dir}/deletion-list.new"
;;
# deleted PKGBUILD
"D")
- echo "${package}" >> \
- "${work_dir}/deletion-list.new"
- sed -i "/^${package} /d" "${work_dir}/build-list.new"
+ delete_package "${package}"
;;
*)
@@ -117,14 +118,10 @@ cp "${work_dir}/deletion-list"{,.new}
echo 'Extract dependencies of packages.'
-# Put the list in the proper build order.
# First, we extract the dependencies of each package.
mkdir -p "${work_dir}/package-infos"
-rm -f "${work_dir}/build-order"
-touch "${work_dir}/build-order"
-
while read -r package git_revision mod_git_revision repository; do
file_prefix="${work_dir}/package-infos/${package}.${git_revision}.${mod_git_revision}"
@@ -136,7 +133,7 @@ while read -r package git_revision mod_git_revision repository; do
# delete cached values of old versions of this PKGBUILD
ls -1 "${file_prefix%.*.*}."* 2> /dev/null | \
sed 's|^.*/||' | \
- grep "^${package//./\\.}"'\.\([0-9a-f]\{40\}\.\)\{2\}\(builds\|needs\|packages\)$' | \
+ grep "^${package//./\\.}"'\.\([0-9a-f]\{40\}\.\)\{2\}\(builds\|needs\|packages\|SRCINFO\)$' | \
while read file; do
rm "${work_dir}/package-infos/${file}"
done
@@ -154,6 +151,9 @@ while read -r package git_revision mod_git_revision repository; do
mksrcinfo -o "${file_prefix}.SRCINFO"
)
+ # otherwise this just calls for trouble
+ sed -i '/=\s*$/d' "${file_prefix}.SRCINFO"
+
# extract "builds" = provides \cup pkgname
grep '^\('$'\t''provides\|pkgname\) = ' "${file_prefix}.SRCINFO" | \
cut -d= -f2 | \
@@ -188,15 +188,51 @@ while read -r package git_revision mod_git_revision repository; do
fi
- # add "$pkgname -> $build-target" to build-order list
- sed "s|^|${package} |" "${file_prefix}.builds" >> \
- "${work_dir}/build-order"
+done < "${work_dir}/build-list.new"
- # add "$dependency -> $pkgname" to build-order list
- sed "s|\$| ${package}|" "${file_prefix}.needs" >> \
- "${work_dir}/build-order"
+# ignore blacklisted packages and dependent packages
+# this is the first time when all the information is available and up to date
-done < "${work_dir}/build-list.new"
+black_listed=''
+black_listed_new="$(
+ cat "${repo_paths["archlinux32"]}/blacklist"
+)"
+while [ -n "${black_listed_new}" ]; do
+ black_listed="$(
+ printf '%s\n%s' "${black_listed}" "${black_listed_new}"
+ )"
+ black_listed_new="$(
+ echo "${black_listed_new}" | \
+ while read -r bl_package; do
+ echo "${bl_package}"
+ echo "${bl_package}"
+ ls "${work_dir}/package-infos/" | \
+ grep '\.needs$' | \
+ while read -r package_info; do
+ grep -q "^${bl_package//./\\.}\$" "${work_dir}/package-infos/${package_info}" && \
+ echo "${package_info%.*.*.needs}"
+ done
+ done | \
+ sort | \
+ uniq -u
+ )"
+done
+echo "${black_listed}" | \
+ while read -r package; do
+ [ -n "${package}" ] && \
+ delete_package "${package}"
+ done
+
+# Now we create the partial order.
+
+while read -r package git_revision mod_git_revision repository; do
+ # add "$pkgname -> $build-target" to build-order list
+ sed "s|\$| ${package}|" "${work_dir}/package-infos/${package}.${git_revision}.${mod_git_revision}.builds"
+ # add "$dependency -> $pkgname" to build-order list
+ sed "s|^|${package} |" "${work_dir}/package-infos/${package}.${git_revision}.${mod_git_revision}.needs"
+done \
+ < "${work_dir}/build-list.new" \
+ > "${work_dir}/build-order"
echo 'Now actually sort it.'
@@ -206,8 +242,7 @@ echo 'Now actually sort it.'
nl -ba | \
awk '{print $1 " not-git also-not-git whatever " $2}'
# this part has all the infos, but possibly the wrong order
- awk '{print "0 " $2 " " $3 " " $4 " " $1}' < \
- "${work_dir}/build-list.new"
+ awk '{print "0 " $2 " " $3 " " $4 " " $1}' "${work_dir}/build-list.new"
) | \
sort -k5,5 -k1nr | \
# now, we have the correct order and the infos, but in adjacent lines