Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-06-12 20:42:32 +0200
committerErich Eckner <git@eckner.net>2017-06-12 20:42:32 +0200
commita64b0be23127cc06ad2aa41c608b8f4ea15deb97 (patch)
treea7fd08c683c66ce46e0d9c89cc7a311a5ce4930d /bin/common-functions
parent06cd37e72a019696f30f009e3a260655023edb3b (diff)
do not delete cached package meta data (yet)
Diffstat (limited to 'bin/common-functions')
-rwxr-xr-xbin/common-functions111
1 files changed, 109 insertions, 2 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 4e875f9..f5e1d39 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -55,8 +55,7 @@ apply_package_customizations() {
exit 1
fi
- local repo
- local package
+ local repo package
repo="$(pwd)"
package="${repo%/*/*}"
@@ -141,3 +140,111 @@ package_locked_broken_or_blocked() {
[ -f "${work_dir}/package-states/$1.$2.$3.$4.broken" ] || \
[ -f "${work_dir}/package-states/$1.$2.$3.$4.blocked" ]
}
+
+# generate_package_metadata $package $git_revision $mod_git_revision $repository
+# or
+# generate_package_metadata $package.$git_revision.$mod_git_revision.$repository
+# generate the meta data files of a package (dependencies, built packages, ...)
+
+generate_package_metadata() {
+
+ local package="$1"
+ local git_revision="$2"
+ local mod_git_revision="$3"
+ local repository="$4"
+ local file_prefix file PKGBUILD
+
+ if [ $# -eq 1 ]; then
+ # second form
+ repository="${package##*.}"
+ package="${package%.*}"
+ mod_git_revision="${package##*.}"
+ package="${package%.*}"
+ git_revision="${package##*.}"
+ package="${package%.*}"
+ fi
+
+ file_prefix="${work_dir}/package-infos/${package}.${git_revision}.${mod_git_revision}"
+
+ if [ -e "${file_prefix}.builds" ] && \
+ [ -e "${file_prefix}.depends" ] && \
+ [ -e "${file_prefix}.needs" ] && \
+ [ -e "${file_prefix}.packages" ]; then
+ return 0
+ fi
+
+ git -C "${repo_paths["$(find_repository_with_commit "${git_revision}")"]}" checkout "${git_revision}"
+ git -C "${repo_paths["$(find_repository_with_commit "${mod_git_revision}")"]}" checkout "${mod_git_revision}"
+
+ PKGBUILD="$(find_pkgbuild "${package}" "${repository}")"
+
+ if [ ! -r "${PKGBUILD}" ]; then
+ echo "can't find PKGBUILD to package '${package}' from repository '${repository}': '${PKGBUILD}'"
+ exit 1
+ fi
+
+ (
+ cd "${PKGBUILD%/*}"
+ apply_package_customizations
+ grep -q '\$CARCH' 'PKGBUILD' && \
+ CARCH=i686 makepkg --printsrcinfo > \
+ "${file_prefix}.SRCINFO" || \
+ 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 | \
+ sed 's|^\s\+||; s|[<>]$||' | \
+ sort -u > \
+ "${file_prefix}.builds"
+
+ # extract "packages" = pkgname
+ grep '^pkgname = ' "${file_prefix}.SRCINFO" | \
+ cut -d= -f2 | \
+ sed 's|^\s\+||; s|[<>]$||' | \
+ sort -u > \
+ "${file_prefix}.packages"
+
+ # extract "needs" = ( makedepends \cup checkdepends ) \setminus "builds"
+ (
+ grep '^'$'\t''\(makedepends\|checkdepends\) = ' "${file_prefix}.SRCINFO" | \
+ cut -d= -f2 | \
+ sed 's|^\s\+||; s|[<>]$||' | \
+ sort -u
+ sed 'p' "${file_prefix}.builds"
+ ) | \
+ sort | \
+ uniq -u > \
+ "${file_prefix}.needs"
+
+ # extract "depends" = makedepends \cup checkdepends \cup depends
+ (
+ sed -n '/^pkgname = /q;/^'$'\t''depends = /p' "${file_prefix}.SRCINFO"
+ grep '^'$'\t''\(makedepends\|checkdepends\) = ' "${file_prefix}.SRCINFO"
+ ) | \
+ cut -d= -f2 | \
+ sed 's|^\s\+||; s|[<>]$||' | \
+ sort -u > \
+ "${file_prefix}.depends"
+
+ rm "${file_prefix}.SRCINFO"
+
+}
+
+# delete_old_metadata
+# delete old (=unneeded) meta data of packages
+
+delete_old_metadata()
+{
+ true
+# ls -1 "${file_prefix%.*.*}."* 2> /dev/null | \
+# sed 's|^.*/||' | \
+# grep "^${package//./\\.}"'\.\([0-9a-f]\{40\}\.\)\{2\}\(builds\|depends\|needs\|packages\|SRCINFO\)$' | \
+# while read file; do
+# rm "${work_dir}/package-infos/${file}"
+# done
+}