Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/common-functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common-functions')
-rwxr-xr-xlib/common-functions228
1 files changed, 1 insertions, 227 deletions
diff --git a/lib/common-functions b/lib/common-functions
index e3aab4c..0a5ef1c 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -6,7 +6,7 @@
# TODO: have full information (currently in files) in database
-# TODO: remove state files / metadata files
+# TODO: remove state files
if [ -z "${base_dir}" ]; then
# just to make shellcheck happy
@@ -123,232 +123,6 @@ find_git_repository_to_package_repository() {
}
-# 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
- local file
- local 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}.${repository}"
-
- if [ -e "${file_prefix}.builds" ] && \
- [ -e "${file_prefix}.build-depends" ] && \
- [ -e "${file_prefix}.run-depends" ] && \
- [ -e "${file_prefix}.groups" ] && \
- [ -e "${file_prefix}.packages" ]; then
- return 0
- fi
-
- if ! make_source_info "${package}" "${repository}" "${git_revision}" "${mod_git_revision}" "${file_prefix}.SRCINFO"; then
- printf '"make_source_info %s %s %s %s %s" failed.\n' "${package}" "${repository}" "${git_revision}" "${mod_git_revision}" "${file_prefix}.SRCINFO"
- exit 1
- fi
- if [ ! -s "${file_prefix}.SRCINFO" ]; then
- >&2 printf '"%s" not created by "make_source_info" - eh, what?' "${file_prefix}.SRCINFO"
- exit 1
- fi
-
- # otherwise this just calls for trouble
- sed -i '
- /^[^=]*=\s*$/d
- s/_i686\(\s*=\)/\1/
- ' "${file_prefix}.SRCINFO"
-
- # extract "groups" = groups \cup provides
- grep "$(printf '^\t\\(groups\\|provides\\) = ')" "${file_prefix}.SRCINFO" | \
- cut -d= -f2 | \
- sed 's|^\s\+||; s|[<>]$||' | \
- sort -u > \
- "${file_prefix}.groups"
-
- # extract "packages" = pkgname
- grep '^pkgname = ' "${file_prefix}.SRCINFO" | \
- cut -d= -f2 | \
- sed 's|^\s\+||; s|[<>]$||' | \
- sort -u > \
- "${file_prefix}.packages"
-
- # extract "builds" = provides \cup pkgname \cup groups
- cat "${file_prefix}.groups" "${file_prefix}.packages" | \
- sort -u > \
- "${file_prefix}.builds"
-
- # extract "build-depends" = makedepends \cup depends \cup \{ base, base-devel \} \setminus "builds"
- {
- {
- printf 'all_depend = %s\n' 'base' 'base-devel'
- sed -n "$(
- printf '/^\t%s = /p\n' \
- 'depends' \
- 'makedepends'
- )" "${file_prefix}.SRCINFO"
- } | \
- cut -d= -f2 | \
- sed 's|^\s\+||; s|[<>]$||' | \
- sort -u
- sed 'p' "${file_prefix}.builds"
- } | \
- sort | \
- uniq -u > \
- "${file_prefix}.build-depends"
-
- # extract "run-depends" = depends \cup \{ base \} \setminus "builds"
- {
- {
- printf 'all_depend = %s\n' 'base'
- sed -n "$(printf '/^\tdepends = /p')" "${file_prefix}.SRCINFO"
- } | \
- cut -d= -f2 | \
- sed 's|^\s\+||; s|[<>]$||' | \
- sort -u
- sed 'p' "${file_prefix}.builds"
- } | \
- sort | \
- uniq -u > \
- "${file_prefix}.run-depends"
-
- rm "${file_prefix}.SRCINFO"
-
-}
-
-# delete_old_metadata
-# delete old (=unneeded) meta data of packages
-
-delete_old_metadata() {
-
- local current_metadata
-
- current_metadata=$(
- find "${work_dir}/package-infos" -mindepth 1 -maxdepth 1 -printf '%f\n' | \
- sed '
- s|\.[^.]\+$||
- s|\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)$| \1 \2 \3|
- ' | \
- sort -u
- )
-
- ( # the new shell is intentional
- # what we have
- echo "${current_metadata}"
-
- # package-states should stay
- find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 -printf '%f\n' | \
- sed '
- s|\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\.[^.]\+$| \1 \2 \3|
- ' | \
- sort -u | \
- sed 'p'
-
- # build-list items should stay
- sed 'p' "${work_dir}/build-list"
-
- tmp_dir=$(mktemp -d 'tmp.common-functions.delete_old_metadata.XXXXXXXXXX' --tmpdir)
- trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
-
- echo "${current_metadata}" | \
- sort -k1,1 > \
- "${tmp_dir}/current-metadata"
-
- # the newest of the following should stay:
- {
- # deletion-list items
- cat "${work_dir}/deletion-list"
- # all packages in the repos
- for repo in ${repo_names}; do
- eval 'git -C "${repo_paths__'"${repo}"'}" archive '"$(cat "${work_dir}/${repo}.revision")" | \
- tar -t | \
- sed '
- s|/$||
- /\//d
- '
- done
- } | \
- sort -u | \
- join -j 1 -o 2.2,2.3,2.4,2.1 - "${tmp_dir}/current-metadata" | \
- sort -k4,4 > \
- "${tmp_dir}/find-newest-revisions"
-
- uniq -uf3 < \
- "${tmp_dir}/find-newest-revisions" | \
- awk '{print $4 " " $1 " " $2 " " $3}' | \
- sed 'p'
-
- uniq -Df3 < \
- "${tmp_dir}/find-newest-revisions" | \
- uniq --group=append -f3 | \
- {
- revs=''
- mod_revs=''
- opkg=''
- orepo=''
- while read -r rev mod_rev repo pkg; do
-
- if [ -z "${rev}" ] && \
- [ -z "${mod_rev}" ] && \
- [ -z "${repo}" ] && \
- [ -z "${pkg}" ]; then
-
- printf '%s %s %s %s\n' \
- "$(
- printf '%s\n' ${revs} | \
- find_newest_of_git_revisions
- )" \
- "$(
- printf '%s\n' ${mod_revs} | \
- find_newest_of_git_revisions
- )" \
- "${orepo}" \
- "${opkg}"
-
- revs=''
- mod_revs=''
- orepo=''
- opkg=''
- continue
- fi
- revs=$(
- # shellcheck disable=SC2086
- printf '%s\n' ${revs} ${rev} | \
- sort -u
- )
- mod_revs=$(
- # shellcheck disable=SC2086
- printf '%s\n' ${mod_revs} ${mod_rev} | \
- sort -u
- )
- orepo="${repo}"
- opkg="${pkg}"
- done
- } | \
- awk '{print $4 " " $1 " " $2 " " $3}' | \
- sed 'p'
- ) | \
- sort | \
- uniq -u | \
- while read -r pkg rev mod_rev repo; do
- rm -f "${work_dir}/package-infos/${pkg}.${rev}.${mod_rev}.${repo}."*
- done
-}
-
# repository_of_package $package.$repo_revision.$mod_repo_revision.$repository
# print which (stable) repository a package belongs to