Merge ubuntu-archive-tools:update-output-helper into ubuntu-archive-tools:main

Proposed by Steve Langasek
Status: Merged
Merged at revision: 8ddd29fcd6cf20675a644f20c8727ad9b81a88de
Proposed branch: ubuntu-archive-tools:update-output-helper
Merge into: ubuntu-archive-tools:main
Diff against target: 135 lines (+129/-0)
1 file modified
update-output-helper (+129/-0)
Reviewer Review Type Date Requested Status
Julian Andres Klode Pending
Ubuntu Release Team Pending
Ubuntu Package Archive Administrators Pending
Review via email: mp+460549@code.launchpad.net

Description of the change

This supersedes https://code.launchpad.net/~laney/ubuntu-archive-tools/update-output-helper/+merge/267970 which is so old it predates the migration to git. Much thanks to Laney for the initial implementation of this tool, which I was never entirely happy with in terms of UI but also it was the best available tool for untangling certain large messy transitions.

Then I tried to use it on the current perl transition and it broke because there were too many packages and it overflowed grep-dctrl's pattern matching capabilities.

Significantly rewritten implementation now uses chdist instead of bespoke apt env handling, and uses package pinning to remove the need for digging up specific package versions out of proposed.

This should really go to ubuntu-dev-tools instead of ubuntu-archive-tools, but since this was the target of the original MP I'm parking it here for now so that it doesn't get lost!

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

Oh also I have no idea where the choice of ~/.cache/brapt originally came from, so somebody please poke holes in this and suggest something better

Revision history for this message
Steve Langasek (vorlon) wrote :

Well it seems this implementation doesn't actually *work*, so I'm tagging Julian to see if maybe he can figure out how I'm managing to drive chdist+apt+preferences wrong.

Revision history for this message
Steve Langasek (vorlon) wrote :

How I'm trying to use it:

$ update-output-helper $(wcat https://ubuntu-archive-team.ubuntu.com/proposed-migration/update_output.txt | sed -n -e'/[[:space:]]perl[[:space:]]/ { s/^trying: //p }' | head -n1)
$ chdist -d "/home/vorlon/.cache/brapt" apt u-a-h --dry-run install accerciser

and this succeeds where, based on update_output, I expect it to fail.

Revision history for this message
Steve Langasek (vorlon) wrote :

getting useful output with the latest commit so maybe this is fixed now. apt-cache(8) doesn't explain what order the records will be shown in, maybe this is undefined.

Revision history for this message
Steve Langasek (vorlon) :
Revision history for this message
Julian Andres Klode (juliank) wrote (last edit ):

apt-cache showsrc --only-source is really bad if you have a binary name it becomes a lot more reliable, but even then it doesn't support `package/newest` sadly, or any of the / or = modifiers. I think with --only-source it literally just iterates over all Sources files in order.

But it should show you all versions, and you can use `sort-dctrl -k Version:v` from dctrl-tools to sort them by version.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/update-output-helper b/update-output-helper
2new file mode 100755
3index 0000000..4fd2e1a
4--- /dev/null
5+++ b/update-output-helper
6@@ -0,0 +1,129 @@
7+#!/bin/bash
8+
9+# Author: Iain Lane <laney@ubuntu.com>,
10+# Steve Langasek <steve.langasek@canonical.com>
11+# Copyright: 2015-2024 Canonical Ltd
12+# License: GPLv3
13+
14+# Run me like this:
15+# Download all the Packages files:
16+# * update-output-helper -u
17+# Create a worldview that britney is trying to mutate us to
18+# * update-output-helper package package2 ...
19+# outputs a chdist apt-get commandline to use
20+# Then call apt with this world view
21+# * <apt-get command> --dry-run install <some uninstallable package>
22+# and you can drill down as normal to find which package(s) need fixing
23+
24+# maybe you want to do something like this:
25+# $ update-output-helper $(wget -O - -q \
26+# https://ubuntu-archive-team.ubuntu.com/proposed-migration/update_output.txt \
27+# | sed -n -e'/[[:space:]]perl[[:space:]]/ { s/^trying: //p }' | head -n1)
28+
29+
30+set -e
31+
32+GETOPT=$(getopt --options uhf: --long update,help -n "${0}" -- "$@")
33+
34+eval set -- "${GETOPT}"
35+
36+ARCH=${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)}
37+CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}/brapt"
38+APTDIR="$CACHEDIR"/u-a-h
39+RELEASE=$(ubuntu-distro-info --devel)
40+PREFERENCES="${APTDIR}"/etc/apt/preferences.d/proposed-migration
41+
42+[ ! -d "${CACHEDIR}" ] && mkdir -p "${CACHEDIR}"
43+
44+update() {
45+ case ${ARCH} in
46+ i386|amd64)
47+ local MIRROR="http://archive.ubuntu.com/ubuntu"
48+ ;;
49+ *)
50+ local MIRROR="http://ports.ubuntu.com"
51+ ;;
52+ esac
53+ # wipe it out in case the existing chdist is for a stale distribution
54+ rm -rf "$APTDIR"
55+
56+ chdist -d "$CACHEDIR" -a "$ARCH" create u-a-h $MIRROR $RELEASE \
57+ "main universe multiverse restricted"
58+
59+ # becomes invalid when chdist switches to deb822
60+ sed -e"s/\b$RELEASE\b/&-proposed/" "$APTDIR"/etc/apt/sources.list \
61+ >> "$APTDIR"/etc/apt/sources.list
62+
63+ chdist -d "$CACHEDIR" apt-get u-a-h update
64+
65+}
66+
67+while true; do
68+ case "$1" in
69+ -u|--update)
70+ update
71+ shift
72+ ;;
73+ -h|--help)
74+ echo "Usage: $0 [-u] package [...]"
75+ shift
76+ ;;
77+ -f)
78+ input_file="$2"
79+ shift 2
80+ ;;
81+ --)
82+ shift
83+ break
84+ ;;
85+ *)
86+ echo "Error"
87+ exit 1;
88+ ;;
89+ esac
90+done
91+
92+if [ $# -eq 0 ] && [ -z "$input_file" ]; then
93+ exit 0
94+fi
95+
96+cat > "$PREFERENCES" <<EOF
97+Package: *
98+Pin: release a=*-proposed
99+Pin-Priority: -1
100+
101+EOF
102+
103+# inner loop. Can be called one of two ways, with lines from an input file
104+# or commandline arg list.
105+package_loop() {
106+ PKG=$1
107+
108+ cat >> "$PREFERENCES" <<EOF
109+Package: src:$PKG
110+Pin: release a=*-proposed
111+Pin-Priority: 990
112+
113+Package: src:$PKG
114+Pin: release a=$RELEASE
115+Pin-Priority: -1
116+
117+EOF
118+
119+}
120+
121+
122+while [ $# -gt 0 ]; do
123+ package_loop $1
124+ shift
125+done
126+
127+if [ -n "$input_file" ]; then
128+ while read pkg; do
129+ package_loop $pkg
130+ done < "$input_file"
131+
132+fi
133+chdist -d "$CACHEDIR" apt-get u-a-h update
134+
135+echo "chdist -d \"$CACHEDIR\" apt u-a-h --dry-run install <some broken package> ..."

Subscribers

People subscribed via source and target branches