summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-05-01 16:28:30 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-05-01 16:48:32 (EDT)
commitd9fdee2730afa9094f966db48e51ff744d84835d (patch)
tree29dc4da492e1260e2e72d5215c52f51ff24b2f3c /lib
parent6a50a23d0a3157933d443fcf5a1a1602aca599e1 (diff)
include_changes(): Refactor to fix odd behavior.
Before: $ pro-archman -b proteanos process-incoming pro-archman: Processing changes in incoming... pro-archman: Including opkg (0.2.2-1) into dev/trunk... pro-archman: Removing package opkg from suite dev/trunk... rmdir: failed to remove `proteanos/feeds/dev/trunk/all/all//.db//info': No such file or directory /usr/bin/pro-archman: 15: cannot create proteanos/feeds/.db/dev_trunk/all_all//: Is a directory rmdir: failed to remove `proteanos/feeds/dev/trunk/amd64-linux-glibc/all//.db//info': No such file or directory /usr/bin/pro-archman: 15: cannot create proteanos/feeds/.db/dev_trunk/amd64-linux-glibc_all//: Is a directory pro-archman: Including opkg (0.2.2-1) into dev/trunk... pro-archman: Including opkg (0.2.2-1) into dev/trunk... After: $ pro-archman -b proteanos process-incoming pro-archman: Processing changes in incoming... pro-archman: Including opkg (0.2.2-1) into dev/trunk... pro-archman: Removing package opkg from suite dev/trunk... pro-archman: Including opkg (0.2.2-1) into dev/trunk... pro-archman: Including opkg (0.2.2-1) into dev/trunk...
Diffstat (limited to 'lib')
-rw-r--r--lib/include.sh69
1 files changed, 42 insertions, 27 deletions
diff --git a/lib/include.sh b/lib/include.sh
index 0b3e91b..41ae3bb 100644
--- a/lib/include.sh
+++ b/lib/include.sh
@@ -65,27 +65,55 @@ include_changes()
source="${_include_source}"
srcver="${_include_version}"
+ # List of (binver, arch, plat) tuples to be checked later.
+ script='s/[0-9][0-9]* [^ ][^ ]* [^_]*_\([^_]*\)'
+ script="${script}"'_\([^_]*\)_\([^_]*\)\.opk/\1 \2 \3/p'
+ bvaps="$(printf '%s\n' "${_include_files}" | \
+ sed -n "${script}" | LC_COLLATE='C' sort | uniq)"
+
info "$(get_msg 'include_including')" "${source}" "${srcver}" \
"${chan}" "${dist}"
- # Make sure the (binver, arch, plat) tuples ("bvaps" for short) are new.
- # Remove old binary packages of the same arch and plat from the suite.
- # Set the new binary version of packages of the arch and plat in the
- # suite.
- # Set the reference count for the (source, binver, arch, plat) tuple to
- # 1.
- script='s/[0-9][0-9]* [^ ][^ ]* [^_]*_\([^_]*\)_\([^_]*\)_\([^_]*\)'
- script="${script}"'\.opk/\1 \2 \3/p'
- bvaps="$(printf '%s\n' "${_include_files}" | sed -n "${script}" | \
- LC_COLLATE='C' sort | uniq)"
- while read -r binver arch plat; do
- old_ver="$(db_get_binver "${chan}" "${dist}" \
- "${arch}" "${plat}" "${source}")"
- if [ "x${old_ver}" != 'x' ]; then
+ # Pre-inclusion database sanity checks and updates: check for an
+ # existing version of the package in the suite.
+ old_ver="$(db_get_srcver "${chan}" "${dist}" "${source}")"
+ if [ "x${old_ver}" = 'x' ]; then
+ # New package.
+ db_set_srcver "${chan}" "${dist}" "${source}" "${srcver}"
+ elif [ "x${old_ver}" != "x${_include_version}" ]; then
+ # New source version. Remove the old source package from the
+ # suite.
+ remove_source_from_suite "${chan}" "${dist}" "${source}"
+ db_set_srcver "${chan}" "${dist}" "${source}" "${srcver}"
+ else
+ # Same source version. Hopefully different binary version,
+ # architecture, and/or platform. Make sure such "bvap" tuples
+ # are new.
+ while read -r binver arch plat; do
+ old_ver="$(db_get_binver "${chan}" "${dist}" \
+ "${arch}" "${plat}" "${source}")"
if [ "x${old_ver}" = "x${binver}" ]; then
error 2 "$(get_msg 'include_bvap_exists')" \
"${binver}" "${arch}" "${plat}"
fi
+ done <<-EOF
+ ${bvaps}
+ EOF
+ fi
+
+ # For each (binver, arch, plat) tuple in the package changes:
+ # * Remove old binary packages of the same arch and plat from the
+ # suite.
+ # * Set the new binary version of packages of the arch and plat in the
+ # suite.
+ # * Set the reference count for the tuple to 1.
+ # This is done separately from the next loop because it must be done
+ # exactly once for each bvap tuple. The next loop can hit any given
+ # bvap tuple multiple times.
+ while read -r binver arch plat; do
+ old_ver="$(db_get_binver "${chan}" "${dist}" \
+ "${arch}" "${plat}" "${source}")"
+ if [ "x${old_ver}" != 'x' ]; then
remove_packages_from_suite_archplat "${chan}" \
"${dist}" "${arch}" "${plat}" "${source}"
fi
@@ -97,19 +125,6 @@ include_changes()
${bvaps}
EOF
- # Remove the source package from the suite if the version is new.
- # Update the source package version in the suite.
- old_ver="$(db_get_srcver "${chan}" "${dist}" "${source}")"
- if [ "x${old_ver}" = 'x' ]; then
- db_set_srcver "${chan}" "${dist}" "${source}" "${srcver}"
- else
- if [ "x${old_ver}" != "x${_include_version}" ]; then
- remove_source_from_suite "${chan}" "${dist}" "${source}"
- db_set_srcver "${chan}" "${dist}" \
- "${source}" "${srcver}"
- fi
- fi
-
# Include each binary package.
files=''
while read -r size sect file; do