From bfbef03c657cd15230bf36d283fb18f899fbd67f Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 5 May 2017 12:36:02 +0200 Subject: bin/get-package-updates: include revision of package-modification-repository in build list (so far not compatible with get- and return-assignment) --- bin/common-functions | 24 ++++++++++++++++++ bin/get-package-updates | 67 +++++++++++++++++++++++++++++-------------------- 2 files changed, 64 insertions(+), 27 deletions(-) (limited to 'bin') diff --git a/bin/common-functions b/bin/common-functions index d6b4858..765610c 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -29,3 +29,27 @@ find_repository_with_commit() { >&2 echo "can't find repository with commit '$1'" exit 1 } + +find_git_repository_to_package_repository() { + for repository in "${!repo_paths[@]}"; do + if [ "${repository}" == "archlinux32" ]; then + continue + fi + if [ -n "$( + ( + ls "${repo_paths["${repository}"]}/"*"/repos" | \ + grep -v ':$' | \ + sed 's|-[^-]\+$||' | \ + sort -u + echo "$1" + ) | \ + sort | \ + uniq -d + )" ]; then + echo "${repository}" + return 0 + fi + done + >&2 echo "can't find git repository with package repository '$1'" + exit 1 +} diff --git a/bin/get-package-updates b/bin/get-package-updates index f6aef31..c466d8e 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -25,14 +25,17 @@ done # Read previous git revision numbers from files. declare -A old_repo_revisions +declare -A new_repo_revisions for repo in "${!repo_paths[@]}"; do old_repo_revisions["${repo}"]="$( cat "${work_dir}/${repo}.revision" 2> /dev/null || \ echo NONE )" - git -C "${repo_paths["${repo}"]}" rev-parse HEAD > \ - "${work_dir}/${repo}.revision.new" + new_repo_revisions["${repo}"]="$( + git -C "${repo_paths["${repo}"]}" rev-parse HEAD | \ + tee "${work_dir}/${repo}.revision.new" + )" done echo 'Check modified packages from the last update, and put them to the build list.' @@ -47,7 +50,6 @@ cp "${work_dir}/deletion-list"{,.new} ( for repo in "${!repo_paths[@]}"; do - current_HEAD="$(cat "${work_dir}/${repo}.revision.new")" ( # if old revision unknown, mimic "git diff"-output if [ "${old_repo_revisions["${repo}"]}" == "NONE" ]; then @@ -59,16 +61,27 @@ cp "${work_dir}/deletion-list"{,.new} fi ) | \ # only track changes in PKGBUILDs - grep '^.\s[^/]\+/repos/[^/]\+/PKGBUILD$' | \ + 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|^\(.\)\t\([^/]\+\)/repos/\([^/]\+\)-[^/-]\+/PKGBUILD$|\1 \2 '"${current_HEAD}"' \3|' | \ + 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 $(cat "${work_dir}/archlinux32.revision.new") archlinux32|" "${repo_paths["archlinux32"]}/blacklist" + sed "s|^\(.*\)\$|D \1 ${new_repo_revisions["archlinux32"]} archlinux32|" "${repo_paths["archlinux32"]}/blacklist" ) | \ while read -r mode package git_revision repository; do case "${mode}" in @@ -76,7 +89,7 @@ cp "${work_dir}/deletion-list"{,.new} # new or modified PKGBUILD "A"|"M") sed -i "/^${package} /d" "${work_dir}/build-list" - echo "${package} ${git_revision} ${repository}" >> \ + echo "${package} ${git_revision} ${new_repo_revisions["archlinux32"]} ${repository}" >> \ "${work_dir}/build-list.new" sed -i "/^${package}\$/d" "${work_dir}/deletion-list.new" ;; @@ -108,7 +121,7 @@ mkdir -p "${work_dir}/package-infos" rm -f "${work_dir}/build-order" touch "${work_dir}/build-order" -while read -r package git_revision repository; do +while read -r package git_revision mod_git_revision repository; do PKGBUILD="$(find_pkgbuild "${package}" "${repository}")" if [ ! -r "${PKGBUILD}" ]; then @@ -119,46 +132,46 @@ while read -r package git_revision repository; do # delete cached values of old versions of this PKGBUILD ls -1 "${work_dir}/package-infos/${package}-"* 2> /dev/null | \ sed 's|^.*/||' | \ - grep "^${package}"'\.[0-9a-f]\{40\}\.\(builds\|needs\)$' | \ - grep -v "^${package}\.${git_revision}"'\.\(builds\|needs\)$' | \ + grep "^${package}"'\.\([0-9a-f]\{40\}\.\)\{2\}\(builds\|needs\)$' | \ + grep -v "^${package}\.${git_revision}\.${new_repo_revisions["archlinux32"]}"'\.\(builds\|needs\)$' | \ while read file; do rm "${work_dir}/package-infos/${file}" done # extract infos from PKGBUILD if not existent yet - if [ ! -e "${work_dir}/package-infos/${package}.${git_revision}.builds" ] || \ - [ ! -e "${work_dir}/package-infos/${package}.${git_revision}.needs" ]; then + if [ ! -e "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.builds" ] || \ + [ ! -e "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.needs" ]; then ( cd "${PKGBUILD%/*}" - mksrcinfo -o "${work_dir}/package-infos/${package}.${git_revision}.SRCINFO" + mksrcinfo -o "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.SRCINFO" ) # extract "builds" = provides \cup pkgname - grep '^\('$'\t''provides\|pkgname\) = ' "${work_dir}/package-infos/${package}.${git_revision}.SRCINFO" | \ + grep '^\('$'\t''provides\|pkgname\) = ' "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.SRCINFO" | \ cut -d= -f2 | \ sed 's|^\s\+||; s|[<>]$||' | \ sort -u > \ - "${work_dir}/package-infos/${package}.${git_revision}.builds" + "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.builds" # extract "needs" = ( makedepends \cup checkdepends ) \setminus "builds" ( ( # this would include runtime dependencies, too: - # sed -n '/^pkgname = /q;/^'$'\t''depends = /p' "${work_dir}/package-infos/${package}.${git_revision}.SRCINFO" - grep '^'$'\t''\(makedepends\|checkdepends\) = ' "${work_dir}/package-infos/${package}.${git_revision}.SRCINFO" + # sed -n '/^pkgname = /q;/^'$'\t''depends = /p' "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.SRCINFO" + grep '^'$'\t''\(makedepends\|checkdepends\) = ' "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.SRCINFO" ) | \ cut -d= -f2 | \ sed 's|^\s\+||; s|[<>]$||' | \ sort -u - cat "${work_dir}/package-infos/${package}.${git_revision}.builds" | \ + cat "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.builds" | \ sed 'p' ) | \ sort | \ uniq -u > \ - "${work_dir}/package-infos/${package}.${git_revision}.needs" + "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.needs" - rm "${work_dir}/package-infos/${package}.${git_revision}.SRCINFO" + rm "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.SRCINFO" fi @@ -166,13 +179,13 @@ while read -r package git_revision repository; do while read target; do echo "${package} ${target}" >> \ "${work_dir}/build-order" - done < "${work_dir}/package-infos/${package}.${git_revision}.builds" + done < "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.builds" # add "$dependency -> $pkgname" to build-order list while read dependency; do echo "${dependency} ${package}" >> \ "${work_dir}/build-order" - done < "${work_dir}/package-infos/${package}.${git_revision}.needs" + done < "${work_dir}/package-infos/${package}.${git_revision}.${new_repo_revisions["archlinux32"]}.needs" done < "${work_dir}/build-list.new" @@ -182,18 +195,18 @@ echo 'Now actually sort it.' # this part will have the correct build order, but all the infos are missing tsort "${work_dir}/build-order" 2> "${work_dir}/tsort.error" | \ nl -ba | \ - awk '{print $1 " not-git whatever " $2}' + 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 " " $1}' < \ + awk '{print "0 " $2 " " $3 " " $4 " " $1}' < \ "${work_dir}/build-list.new" ) | \ - sort -k4,4 -k1nr | \ + sort -k5,5 -k1nr | \ # now, we have the correct order and the infos, but in adjacent lines - uniq -f3 -D | \ + uniq -f4 -D | \ sed '/^0 /d;N;s|\n| |' | \ # now in one line, each sort -k1n,1 | \ - awk '{print $4 " " $6 " " $7}' > \ + awk '{print $5 " " $7 " " $8 " " $9}' > \ "${work_dir}/build-list.new.new" rm -f "${work_dir}/build-order.loops/*" -- cgit v1.2.3-70-g09d2