Merge ~paelzer/ubuntu-helpers:os-import-for-focal into ~paelzer/ubuntu-helpers:master

Proposed by Christian Ehrhardt 
Status: Merged
Merge reported by: Christian Ehrhardt 
Merged at revision: c51ab9ea25f5f285d52fd2ee39551f8f7f4273b7
Proposed branch: ~paelzer/ubuntu-helpers:os-import-for-focal
Merge into: ~paelzer/ubuntu-helpers:master
Diff against target: 4962 lines (+4261/-36)
66 files modified
.gitignore (+8/-0)
README.md (+218/-0)
bryce/binit (+17/-0)
bryce/check-scripts (+100/-0)
bryce/cl-diff (+7/-0)
bryce/columns (+27/-0)
bryce/debb (+26/-0)
bryce/debian-changes (+14/-0)
bryce/dependency-tree (+59/-0)
bryce/enable-debsrc (+28/-0)
bryce/enable-proposed (+38/-0)
bryce/git-cmp-branches (+7/-0)
bryce/git-cmp-repos (+27/-0)
bryce/git-exam (+45/-0)
bryce/git-grep (+35/-0)
bryce/git-log-branch (+4/-0)
bryce/git-pop (+24/-0)
bryce/gu-set-target (+108/-0)
bryce/gu-whitelist (+119/-0)
bryce/install-build-deps (+11/-0)
bryce/json-check (+21/-0)
bryce/json-get (+43/-0)
bryce/ls-installed (+3/-0)
bryce/ls-lxc (+3/-0)
bryce/middle-paste (+14/-0)
bryce/migration-filter (+217/-0)
bryce/monday-triage (+14/-0)
bryce/mv-smart (+52/-0)
bryce/pkg-clean (+36/-0)
bryce/pkg-component (+37/-0)
bryce/pkg-depends (+39/-0)
bryce/pkg-nochange (+177/-0)
bryce/pkg-rdepends (+9/-0)
bryce/pkg-source (+27/-0)
bryce/prepend (+26/-0)
bryce/rmad (+16/-0)
bryce/shuffle (+11/-0)
cpaelzer/TrelloToJira.py (+75/-0)
cpaelzer/autopkgtests-running.sh (+6/-0)
cpaelzer/build-for-ppa.sh (+30/-0)
cpaelzer/buildpkg-qemu.sh (+4/-0)
cpaelzer/check-autopkgtest-stats.sh (+55/-15)
cpaelzer/dput (+10/-0)
cpaelzer/excuses-top-blocker.sh (+4/-0)
cpaelzer/get-packages-subscribed.py (+1/-1)
cpaelzer/git-to-dquilt.sh (+73/-17)
cpaelzer/lp-test-isrunning (+61/-0)
cpaelzer/lp-test-ppa (+395/-0)
cpaelzer/rma (+6/-0)
cpaelzer/update-git-ubuntu-urls.sh (+27/-0)
cpaelzer/versioned-rdepends.sh (+6/-0)
dev/null (+0/-3)
rbasak/adopt.py (+80/-0)
rbasak/chdist-if-migrated (+73/-0)
rbasak/standup_timer.py (+44/-0)
uscards/AUTHORS.md (+1/-0)
uscards/LICENSE.AGPL (+619/-0)
uscards/README (+1/-0)
uscards/README.md (+26/-0)
uscards/docs/design.txt (+100/-0)
uscards/install.sh (+9/-0)
uscards/scripts/sru-board (+158/-0)
uscards/scripts/uscoredev (+189/-0)
uscards/scripts/usdaily (+186/-0)
uscards/scripts/usmerges (+194/-0)
uscards/scripts/usmigration (+161/-0)
Reviewer Review Type Date Requested Status
Bryce Harrington (community) Approve
Review via email: mp+412268@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

Guessing this MP is for c51ab9e only (which LGTM, +1).

However, one suggestion for the prior commit, 857c838; I was just some wget url code myself yesterday and saw a good tip on stack exchange that when downloading single files, curl seems better to use in scripts than wget.

Anyway, if you end up using migration-filter for something I'd be keen to hear about it.

Revision history for this message
Bryce Harrington (bryce) :
review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Yeah just for that commit (merged it now) - thanks.

I can easily use curl, but I do not see a benefit of curl>wget do you have link handy why that would be "better"?

Finally migration-filter - I used "single-build-failures" to look for candidates to fix and realized to late it exists.
Otherwise excuses-top-blocker.sh might have become an extension to your tool.

If we'd be on feature requests, "at least older than" and "not older than" would be nice to add to filters. If too young then they are likely fixed by Debian, too old often is unfixable for some reason.

Revision history for this message
Bryce Harrington (bryce) wrote (last edit ):

I have a lot more experience with wget than curl, and have mostly used the former including in scripts. Guessing your experience has been similar.

wget has a definite advantage when you're downloading multiple files from a website, or doing things recursively. But for single-file downloads, the advantage I'm seeing on using curl is that it gives better low-level control and generally seems more robust when you're using in a scripted fashion. Curl seems to also be (slightly) faster, and provide more discrete error codes, which could be useful in a script.

Anyway, no biggie but just FYI that at least for my own purposes I'll probably be switching to curl over wget for scripted things myself.

Some links:
  * https://unix.stackexchange.com/questions/47434/what-is-the-difference-between-curl-and-wget
  * https://daniel.haxx.se/docs/curl-vs-wget.html

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2new file mode 100644
3index 0000000..d32ac33
4--- /dev/null
5+++ b/.gitignore
6@@ -0,0 +1,8 @@
7+/build/
8+/dist/
9+
10+*.snap
11+
12+# Logs
13+*-debug.log
14+*-error.log
15diff --git a/README.md b/README.md
16new file mode 100644
17index 0000000..8ab8a50
18--- /dev/null
19+++ b/README.md
20@@ -0,0 +1,218 @@
21+# Ubuntu Server Tooling collection
22+
23+This is a collection of tools used by different team members of the
24+Ubuntu server team. The purpose of this repository is to reduce the re-creation
25+of such tools over and over again.
26+
27+We start with a per-user subdirectory as historically people have diverged
28+the very same tools. The intention is to unify some things over time.
29+
30+All tools are as-is and without any guarantees.
31+
32+This file shall give an overview what these tools actually do to allow
33+exploring and evaluating them more easily.
34+
35+## Proposed migration work
36+
37+* cpaelzer/check-autopkgtest-stats.sh
38+Check the past of a packages autopkgtest success rate and scan for a given
39+pattern in those fails. Most useful when debugging if a certain issue
40+comes back but hiding between other errors.
41+It will list which sub-test failed and visually show the frequency of those.
42+Example: `$ check-autopkgtest-stats.sh -c 40 -p libreoffice -r xenial -a amd64 -P 'gb_JunitTest_DEBUGRUN'`
43+will give you some stats plus `1 junit-subsequentcheck ( 2.50%) ....................F..................`
44+
45+* cpaelzer/check-component-mismatches.sh
46+Run this against a link to a buildlog on launchpad - e.g. where you prep
47+your shiny new package/version for main.
48+It tries to identify dependencies of that build into non-main.
49+
50+* cpaelzer/check-component-mismatches-v2.sh
51+Like the checker above, but instead of a buildlog just run it with a package
52+name. Preferrably in a container with the target release.
53+
54+* cpaelzer/lp-affects-devel
55+Mark a bug affected by a given package/release combo.
56+Example: `$ lp-affects-devel 1863108 postgresql-9.5 xenial`
57+
58+* cpaelzer/lp-test-ppa
59+Trigger and report autopkgtests on a PPA
60+Example: `$ ./lp-test-ppa ppa:ci-train-ppa-service/4318 hirsute`
61+
62+* cpaelzer/rma
63+Rmadison to Debian and Ubuntu at once to compare versions with each other.
64+
65+* cpaelzer/testify.sh
66+Insert all autopkgtest architectures into a autopkgtest retry link
67+
68+* rbasak/chdist-if-migrated
69+Simulate proposed migration for a set of packages so that you can then
70+poke apt-get to see why britney says something will become
71+uninstallable.
72+
73+## Package subscriptions by Teams
74+
75+* cpaelzer/get-packages-subscribed.py
76+List packages a team is subscribed to (e.g. for MIR processing)
77+
78+* cpaelzer/check-OS-packages-on-server-mapping.sh
79+Due to the team split in the past we have some overlap that we need to
80+clear on a regular base. Finds packages subscribed by both teams.
81+
82+* cpaelzer/packageset-subscription-mismatches.sh
83+Find packages subscribed but not in main (candiate to drop) and packages
84+in server packageset (uploads) but not subscribed (candidate to clear either)
85+
86+## Updating Packages
87+
88+* cpaelzer/dput
89+Break on common errors before uploading them
90+
91+* cpaelzer/git-to-dquilt.sh
92+Convert a git commit into a debian/patches/ entry.
93+Automatically adds dep3 headers, date and bug.
94+Can work on multiple commits at once and trivializes bug-fixing.
95+Note: you need to add the upstream remote beofre you can pick patches from
96+there.
97+Example:
98+ git-to-dquilt.sh -b 1895366 -p "ubuntu-v3.0.3-fixes" -u 'https://github.com/corosync/corosync/commit/' 7f64a1dc ec889e89 9105d94a 21e1c711 ee38d93c f31a31f9
99+
100+* cpaelzer/sbuildchroot
101+Enter an sbuild chroos without having to remember the /...../ path.
102+
103+* cpaelzer/localrepo.sh
104+If you have a bunch of local debs e.g. from a sbuild run this will create
105+and sign the necesary files to include it as a local repository.
106+
107+* cpaelzer/pull-uca-source.py
108+Like pull-lp-source but for Ubuntu cloud archive
109+
110+## Virtualization stack special cases
111+
112+* cpaelzer/locallibvirt.sh
113+Helps to build libvirt locally close to what we usually build for Ubuntu
114+releases.
115+
116+* cpaelzer/buildpkg-qemu.sh
117+Qemu had some serious mismatches between git and tarballs prior to Eoan.
118+This helps to clean up before build and restore the proper content.
119+
120+## Packaging VCS management
121+
122+* rbasak/adopt.py
123+Adopt non-VCS uploads made by other Ubuntu developers into your package
124+maintenance VCS by making use of the synthesized git-ubuntu view.
125+
126+## Packaging/Container related tools:
127+
128+* bryce/ls-installed - dump list of what unique packages are installed
129+* bryce/ls-lxc - list all lxc containers
130+* bryce/rmad - look up debian and ubuntu versions of a package
131+* bryce/dependency-tree - organize list of packages in revdep order
132+* bryce/enable-debsrc - uncomments deb-src entries in sources.list*
133+
134+## Git branch review related tools:
135+
136+I don't find myself using these for Ubuntu packaging, but they proved
137+handy when doing upstream maintenance work, esp. for reviewing large git
138+branch MP's.
139+
140+* bryce/git-cmp-branches - diff branches
141+* bryce/git-cmp-repos - diff entire repos
142+* bryce/git-exam - dump git changes to a given file
143+* bryce/git-grep - greps for a string within a range of commits
144+* git-log-branch - pretty formatted log graph
145+* bryce/git-pop - removes top commit (saved to /tmp/)
146+
147+## X11 / Desktop cli's:
148+
149+* bryce/middle-paste - I map this to ctrl+alt+v to simulate middle-paste
150+
151+## Basic Unix-style commands I've added to my workflow:
152+
153+* bryce/binit - Symlink a script into ~/bin, but keeps actual file in whatever
154+ VCS I'm using.
155+* bryce/columns - Extract columns from text tables. (I have a python version
156+ of this but it's still a WIP.)
157+* bryce/mv-smart - avoid clobbering existing files unless they're identical
158+* bryce/prepend - Inserts file content at top of files
159+* bryce/shuffle - Randomizes lines using python's random.shuffle()
160+
161+
162+## Externally hosted things:
163+
164+* bryce/post-discourse: CLI tool for interacting with Discourse
165+ - https://gitlab.com/bryceharrington/post-discourse
166+
167+* bryce/launchpad-gm-scripts: Firefox enhancements for bug report triaging and
168+ other launchpad-related work.
169+ - https://launchpad.net/launchpad-gm-scripts
170+
171+* bryce/php-ubuntu-tools: CLI for preparing for packageset transitions.
172+ - https://code.launchpad.net/~php-ubuntu/+git/php-ubuntu-tools
173+ - Currently pretty specific to PHP but could be repurposeable for
174+ other kinds of transitions.
175+ - Honestly is kind of a mess because transitions involve so many
176+ different parts which change on a daily basis, so it's tough to
177+ engineer a general solution.
178+ - I'm thinking instead of trying to automate the full process, to
179+ break it down into smaller helper scripts...
180+
181+## Misc
182+
183+* rbasak/standup_timer.py: used to time our standups.
184+
185+## Experiments / WIP:
186+
187+These are some side projects I own or help maintain, which aren't
188+currently in an immediately useful state, but may be worth mentioning if
189+others have similar needs/interests.
190+
191+* ppa-dev-tools: CLI for creating PPAs.
192+ - Create, list, delete, etc. PPAs
193+ - https://launchpad.net/ppa-dev-tools
194+
195+* bryce/diskwatch: Displays status of collection of hdd's, including their
196+ serial numbers, bus location, raid details, etc. Doesn't handle a
197+ wide enough breadth of hardware, so still rather WIPish.
198+ - https://gitlab.com/bryceharrington/diskwatch
199+
200+* bryce/python-fstab: Python module for managing fstab contents.
201+ - Originally written by Lars Wirzenius, but seems unmaintained now.
202+ - My hope was to use something off-the-shelf but what I've found
203+ unfortunately doesn't meet my requirements. This came closest.
204+ - Note: I've ported it to python3 but still buggy, not quite ready
205+ for prime time.
206+ - https://code.launchpad.net/~bryce/python-fstab/+git/python-fstab
207+
208+* bryce/python-bullettree: Python module for managing Debian-changelog style
209+ bullet lists (* / - / +). Super early in development.
210+ - https://gitlab.com/bryceharrington/bullet-tree
211+
212+* bryce/usmerges: Email service to look for merge opportunities.
213+ - Not posted publically yet
214+ - Kind of an agglomeration of quick hacks; I want to rewrite it with
215+ test cases, proper python modules, and a less organic structure.
216+
217+* bryce/usdaily: A CLI for interacting with the ubuntu server team's trello
218+ board.
219+ - I've got some POC code implemented, but nothing shareable yet.
220+
221+
222+## Wishlist:
223+
224+These are ideas for tools that I'd like, but haven't found anywhere, and
225+am considering creating some day, maybe.
226+
227+* bryce/excuses-kicker: Tool for mass-retargeting autopkgtest runs, similar in
228+ concept to retry-autopkgtest-regressions, but in bash.
229+ - Handles acquisition of credentials through SSO/2FA, but is pretty
230+ hacky.
231+ - Planning to rewrite this in python
232+ - Planning to build on top of retry-autopkgtest-regressions
233+
234+* bryce/python-apt-sources: Python module for managing /etc/apt/sources.list
235+ and sources.list.d/
236+ - There are chunks of code that parse or write these. I need
237+ something that can read *and* write, and that is packaged in a
238+ discrete python module.
239diff --git a/bryce/binit b/bryce/binit
240new file mode 100755
241index 0000000..47bb24e
242--- /dev/null
243+++ b/bryce/binit
244@@ -0,0 +1,17 @@
245+#!/bin/bash
246+
247+for item in $* ; do
248+ if [ ! -e ${item} ]; then
249+ echo "Error: No such file '${item}'"
250+ continue
251+ fi
252+ path=$(realpath ${item})
253+ tool=$(basename ${path})
254+ if [ -e ~/bin/$tool ]; then
255+ echo "Error: $tool already in ~/bin"
256+ continue
257+ fi
258+ ln -s $path ~/bin/$tool
259+ echo "linked ~/bin/$tool"
260+done
261+
262diff --git a/bryce/check-scripts b/bryce/check-scripts
263new file mode 100755
264index 0000000..ef656f3
265--- /dev/null
266+++ b/bryce/check-scripts
267@@ -0,0 +1,100 @@
268+#!/bin/bash
269+# -*- coding: utf-8; mode: sh -*-
270+
271+# Do some basic compile/lint style checks on scripts of various
272+# programming languages.
273+
274+# Copyright (C) 2020 Bryce W. Harrington <bryce@bryceharrington.org>
275+#
276+# This program is free software: you can redistribute it and/or
277+# modify it under the terms of the GNU Affero General Public
278+# License as published by the Free Software Foundation, either
279+# version 3 of the License, or (at your option) any later
280+# version.
281+#
282+# This program is distributed in the hope that it will be useful,
283+# but WITHOUT ANY WARRANTY; without even the implied warranty of
284+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285+# GNU Affero General Public License for more details.
286+#
287+# You should have received a copy of the GNU Affero General Public License
288+# along with this program. If not, see <http://www.gnu.org/licenses/>.
289+
290+progname=$(basename "${0}")
291+
292+usage() {
293+ cat >&2 <<EOF
294+Usage: ${progname} [scripts]
295+EOF
296+ exit "${1}"
297+}
298+
299+warn() {
300+ echo "Warning: $1" 1>&2
301+}
302+
303+die() {
304+ echo "Error: $1" 1>&2
305+ exit 1
306+}
307+
308+function check_script_bash() {
309+ local code_file="${1}"
310+
311+ bash -n "${code_file}"
312+ shellcheck "${code_file}"
313+}
314+
315+function check_script_python() {
316+ local code_file="${1}"
317+
318+ python3 -m py_compile "${code_file}"
319+ if [ -e "${code_file}c" ]; then
320+ rm "${code_file}c"
321+ fi
322+ pyflakes3 "${code_file}"
323+ pylint "${code_file}"
324+}
325+
326+function check_code_c() {
327+ local code_file="${1}"
328+ die "${FUNCNAME[0]}: Unimplemented"
329+}
330+
331+function check_code_cpp() {
332+ local code_file="${1}"
333+ die "${FUNCNAME[0]}: Unimplemented"
334+}
335+
336+main() {
337+ # TODO: If no args given, check all scripts in CWD
338+
339+ for code_file in "${@}"; do
340+ code_file=$(realpath "${code_file}")
341+ file_type=$(file -b "${code_file}")
342+
343+ case ${file_type,,} in
344+ *bash*)
345+ check_script_bash "${code_file}"
346+ ;;
347+ *bourne*)
348+ check_script_bash "${code_file}"
349+ ;;
350+ *python*script*)
351+ check_script_python "${code_file}"
352+ ;;
353+ *c++*source*)
354+ check_code_cpp "${code_file}"
355+ ;;
356+ *c*source*)
357+ check_code_c "${code_file}"
358+ ;;
359+ *)
360+ warn "Unknown script type '${file_type}' for ${code_file}"
361+ esac
362+ done
363+}
364+
365+if [[ "${0}" == "${BASH_SOURCE[0]}" ]]; then
366+ main "$@"
367+fi
368diff --git a/bryce/cl-diff b/bryce/cl-diff
369new file mode 100755
370index 0000000..f87b174
371--- /dev/null
372+++ b/bryce/cl-diff
373@@ -0,0 +1,7 @@
374+#!/usr/bin/env bash
375+
376+git diff debian/changelog \
377+ | grep '^+ ' \
378+ | sed 's/^../ /' \
379+ | sed 's/ \* / - /' \
380+ | sed 's/ \- / + /'
381diff --git a/bryce/columns b/bryce/columns
382new file mode 100755
383index 0000000..b36455f
384--- /dev/null
385+++ b/bryce/columns
386@@ -0,0 +1,27 @@
387+#!/usr/bin/perl -w
388+# -*- coding: utf-8 -*-
389+
390+my @fields = grep { $_ =~ /^\d+\+?$/ } sort @ARGV;
391+
392+while (<STDIN>) {
393+ chomp;
394+ $_ =~ s/^\s+//;
395+ my @cols = split /\s+/, $_;
396+ my $show_after = undef;
397+ foreach my $field (@fields) {
398+ if ($field =~ /\+$/) {
399+ $field =~ s/\+//;
400+ $show_after = $field;
401+ }
402+ next unless $field && $cols[$field-1];
403+ print $cols[$field-1], ' ';
404+ }
405+ if ($show_after) {
406+ $field = $show_after;
407+ while ($field < $#cols+1) {
408+ $field += 1;
409+ print $cols[$field-1], ' ';
410+ }
411+ }
412+ print "\n";
413+}
414diff --git a/bryce/debb b/bryce/debb
415new file mode 100755
416index 0000000..c16456e
417--- /dev/null
418+++ b/bryce/debb
419@@ -0,0 +1,26 @@
420+#!/bin/bash
421+
422+# This is a convenience script for Ubuntu packagers to submit bug
423+# reports to Debian, skipping some unnecessary steps, or checks that are
424+# inappropriate for packagers (such as whether the package is
425+# installed).
426+
427+attachments=
428+package="${1}"
429+if [ -n "${2}" ]; then
430+ attachments="-A ${2}"
431+fi
432+
433+reportbug ${attachments} \
434+ --bts debian \
435+ --email "${DEBEMAIL}" \
436+ --no-query-bts \
437+ --no-check-available \
438+ --no-check-installed \
439+ --no-config-files \
440+ --no-verify \
441+ --mutt \
442+ --source "${package}"
443+
444+# TODO: Provide version number as whatever the current debian version is
445+# TODO: Allow linking to a launchpad bug report, that is being forwarded
446diff --git a/bryce/debian-changes b/bryce/debian-changes
447new file mode 100755
448index 0000000..0393d59
449--- /dev/null
450+++ b/bryce/debian-changes
451@@ -0,0 +1,14 @@
452+#!/bin/bash
453+
454+package="${1}"
455+p="${package:0:1}"
456+
457+# TODO: This misses lib*
458+# (I seem to recall seeing a script that handled this lookup logic...)
459+
460+wget -q -O- https://metadata.ftp-master.debian.org/changelogs//main/${p}/${package}/unstable_changelog | head -n 100 | less
461+
462+# TODO: Only show entries since whatever is in Ubuntu
463+
464+# TODO: Somehow provide way to view the diff for a given version
465+# (seems like a job for git-ubuntu?)
466diff --git a/bryce/dependency-tree b/bryce/dependency-tree
467new file mode 100755
468index 0000000..ffb7012
469--- /dev/null
470+++ b/bryce/dependency-tree
471@@ -0,0 +1,59 @@
472+#!/bin/bash
473+
474+# Usage: cat my-packages.txt | dependency-tree
475+#
476+# - my-packages.txt could be generated via a command like:
477+#
478+# $ apt-cache policy "php-horde-*" | grep "^[a-z]" | cut -d: -f1 > my-packages.txt
479+
480+# Note: This only works for php-horde. To make it more generally usable
481+# would need to give it a better way to filter dependencies (see TODO-1
482+# and TODO-2).
483+
484+# Slurp in our package list from stdin
485+unsorted_packages=
486+while read pkg; do
487+ # Also add the package's dependencies
488+ # TODO-1: Need better way to extract the relevant rdepends without hardcoding "php-horde"
489+ rdepends=$(apt-cache rdepends "${pkg}" --recurse \
490+ --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances \
491+ | grep "^ php-horde-" | grep -v php-horde-core | sort | uniq)
492+ unsorted_packages="${unsorted_packages} ${pkg} ${rdepends}"
493+done < "${1:-/dev/stdin}"
494+
495+# Sort ${package_list} to unique items
496+package_list=$(echo -e "${unsorted_packages// /\\n}" | sort -u)
497+
498+seen_file=$(mktemp)
499+level=0
500+
501+while [ -n "${package_list}" ]; do
502+ echo "### Dependency Level ${level} ###"
503+ remaining_packages=
504+ for pkg in ${package_list}; do
505+ apt-cache show "$pkg" 2>&1 | grep -q ^Package: || continue
506+
507+ # TODO-2: Ignore non-php-horde packages
508+ depends=$(apt-cache rdepends "${pkg}" \
509+ --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances \
510+ | grep "^ php-horde-" | sort | uniq \
511+ | grep -vwFf "${seen_file}")
512+ if [ -z "${depends}" ]; then
513+ echo "${pkg}"
514+ echo "${pkg}" >> "${seen_file}"
515+ else
516+ remaining_packages="${remaining_packages} ${pkg}"
517+ fi
518+
519+ done
520+ if [ "${package_list}" = "${remaining_packages}" ]; then
521+ echo
522+ echo "### Error - Could not untangle dependencies: ###"
523+ echo "${remaining_packages}"
524+ exit 1
525+ fi
526+ package_list="${remaining_packages}"
527+ level=$(( level + 1 ))
528+ echo
529+ echo
530+done
531diff --git a/bryce/enable-debsrc b/bryce/enable-debsrc
532new file mode 100755
533index 0000000..eda532a
534--- /dev/null
535+++ b/bryce/enable-debsrc
536@@ -0,0 +1,28 @@
537+#!/usr/bin/env python3
538+
539+import os
540+import sys
541+from softwareproperties.SoftwareProperties import SoftwareProperties
542+
543+"""
544+This script enables all deb-src entries in sources.list if the
545+corresponding deb line has been enabled.
546+"""
547+
548+if __name__ == "__main__":
549+ sp = SoftwareProperties(options=None)
550+ enabled_deb_entry = None
551+ for entry in sp.sourceslist.list:
552+ if entry.type == 'deb' and not entry.disabled:
553+ enabled_deb_entry = entry
554+ elif (entry.type == 'deb-src'
555+ and entry.architectures == enabled_deb_entry.architectures
556+ and entry.trusted == enabled_deb_entry.trusted
557+ and entry.uri == enabled_deb_entry.uri
558+ and entry.dist == enabled_deb_entry.dist
559+ and entry.comps == enabled_deb_entry.comps):
560+ entry.set_enabled(True)
561+ sp.sourceslist.save()
562+
563+ os.execvp("apt-get", ["apt-get", "update"])
564+ sys.exit(0)
565diff --git a/bryce/enable-proposed b/bryce/enable-proposed
566new file mode 100755
567index 0000000..e5f7006
568--- /dev/null
569+++ b/bryce/enable-proposed
570@@ -0,0 +1,38 @@
571+#!/usr/bin/env python3
572+
573+import os
574+import sys
575+import aptsources
576+from softwareproperties.SoftwareProperties import SoftwareProperties
577+
578+"""
579+This script enables -proposed in sources.list for the current distro.
580+"""
581+
582+def main_archive_uri(sp):
583+ for entry in sp.sourceslist.list:
584+ if (entry.type == 'deb'
585+ and not entry.invalid
586+ and not entry.disabled
587+ and entry.dist == sp.distro.codename
588+ and entry.file == '/etc/apt/sources.list'
589+ and 'main' in entry.comps
590+ and 'ppa.launchpad.net' not in entry.line):
591+ return entry.uri
592+
593+if __name__ == "__main__":
594+ sp = SoftwareProperties(options=None)
595+ distro = aptsources.distro.get_distro()
596+ distro.get_sources(sp.sourceslist)
597+ dist = '{}-proposed'.format(sp.distro.codename)
598+ uri = main_archive_uri(sp)
599+ comps = list(distro.enabled_comps)
600+ for t in 'deb', 'deb-src':
601+ if not sp.sourceslist.add(type=t, uri=uri, dist=dist, orig_comps=comps):
602+ print(_("Error: '%s' invalid") % line)
603+ sys.exit(1)
604+
605+ sp.sourceslist.save()
606+
607+ os.execvp("apt-get", ["apt-get", "update"])
608+ sys.exit(0)
609diff --git a/bryce/git-cmp-branches b/bryce/git-cmp-branches
610new file mode 100755
611index 0000000..0f12e8c
612--- /dev/null
613+++ b/bryce/git-cmp-branches
614@@ -0,0 +1,7 @@
615+#!/bin/bash
616+# -*- coding: utf-8; mode: sh -*-
617+
618+a="${1}"
619+b="${2}"
620+
621+git log "${a}" "^${b}" --no-merges
622diff --git a/bryce/git-cmp-repos b/bryce/git-cmp-repos
623new file mode 100755
624index 0000000..f40bd69
625--- /dev/null
626+++ b/bryce/git-cmp-repos
627@@ -0,0 +1,27 @@
628+#!/bin/bash
629+# -*- coding: utf-8; mode: sh -*-
630+
631+# Given two repositories, show the commits that differ
632+
633+a="${1}"
634+b="${2}"
635+
636+cd "${a}"
637+git log | grep "^commit " | cut -d' ' -f2 > /tmp/git-cmp-a.commits
638+cd ..
639+
640+cd "${b}"
641+i=0
642+for commit in $(cat /tmp/git-cmp-a.commits); do
643+ git show "${commit}" > /dev/null 2>&1
644+ if [ $? != 0 ]; then
645+ echo "${commit}"
646+ id=$(printf "head-%03d_%s" "${i}" "${commit}")
647+ cd ..
648+ cd "${a}"
649+ git show "${commit}" > "../${id}.patch"
650+ cd ..
651+ cd "${b}"
652+ i=$(( i + 1 ))
653+ fi
654+done
655diff --git a/bryce/git-exam b/bryce/git-exam
656new file mode 100755
657index 0000000..83ccaf6
658--- /dev/null
659+++ b/bryce/git-exam
660@@ -0,0 +1,45 @@
661+#!/bin/bash
662+# -*- coding: utf-8; mode: sh -*-
663+
664+# For a given file, review the past changes to just that file
665+
666+FILENAME="${1}"
667+
668+# lexer = diff
669+# formatters = raw, svg, terminal, terminal256, text
670+# filters = whitespace, highlight
671+# styles = monokai, manni, borland, colorful, default, murphy, trac, tango, fruity, autumn, bw, emacs, vim, pastie, friendly, native
672+
673+## diff.py lexer:
674+# (r' .*\n', Text),
675+# (r'\+.*\n', Generic.Inserted),
676+# (r'-.*\n', Generic.Deleted),
677+# (r'!.*\n', Generic.Strong),
678+# (r'@.*\n', Generic.Subheading),
679+# (r'([Ii]ndex|diff).*\n', Generic.Heading),
680+# (r'=.*\n', Generic.Heading),
681+# (r'.*\n', Text),
682+
683+## terminal.py formatter:
684+# Generic.Deleted: ('red', 'red'),
685+# Generic.Inserted: ('darkgreen', 'green'),
686+# Generic.Heading: ('**', '**'),
687+# Generic.Subheading: ('*purple*', '*fuchsia*'),
688+# Generic.Prompt: ('**', '**'),
689+
690+## native.py style:
691+# Generic.Heading: 'bold #ffffff',
692+# Generic.Subheading: 'underline #ffffff',
693+# Generic.Deleted: '#d22323',
694+# Generic.Inserted: '#589819',
695+# Generic.Error: '#d22323',
696+
697+PYG_OPTS="-O style=gitdiff"
698+
699+for commit in $(git rev-list HEAD -- "${FILENAME}"); do
700+ git show "${commit}" -- follow "${FILENAME}" | cat
701+done | pygmentize "${PYG_OPTS}" -f terminal256 -l "diff" | less -QR
702+
703+#done | highlight --out-format=xterm256 --src-lang=diff -s moria | less -QR
704+#done | source-highlight -s diff -f | less -QR
705+
706diff --git a/bryce/git-grep b/bryce/git-grep
707new file mode 100755
708index 0000000..f9ae166
709--- /dev/null
710+++ b/bryce/git-grep
711@@ -0,0 +1,35 @@
712+#!/bin/bash
713+# -*- coding: utf-8; mode: sh -*-
714+
715+# Greps for a string within a range of commits
716+
717+progname=$(basename ${0})
718+
719+usage() {
720+ cat >&2 <<EOF
721+Usage: ${progname} <pattern> <range>
722+EOF
723+}
724+
725+if [ "${1}" = "-h" ] || [ "${1}" = "--help" ]; then
726+ usage
727+ exit 0
728+elif [[ ${#} -lt 2 ]]; then
729+ usage
730+ exit 1
731+fi
732+
733+PATTERN="${1}"
734+RANGE="${2}"
735+
736+for commit in $(git rev-list "${RANGE}"); do
737+ matches=$(git show "${commit}" | grep "${PATTERN}")
738+ if [ -z "${matches}" ]; then
739+ continue
740+ fi
741+ echo
742+ git show -s --oneline "${commit}" | cat
743+ echo "$matches" | grep "${PATTERN}"
744+ echo
745+done
746+
747diff --git a/bryce/git-log-branch b/bryce/git-log-branch
748new file mode 100755
749index 0000000..8f696c0
750--- /dev/null
751+++ b/bryce/git-log-branch
752@@ -0,0 +1,4 @@
753+#!/bin/bash
754+# -*- coding: utf-8; mode: sh -*-
755+
756+git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative master..HEAD
757diff --git a/bryce/git-pop b/bryce/git-pop
758new file mode 100755
759index 0000000..98b0c07
760--- /dev/null
761+++ b/bryce/git-pop
762@@ -0,0 +1,24 @@
763+#!/bin/bash
764+# -*- coding: utf-8; mode: sh -*-
765+
766+progname=$(basename "${0}")
767+
768+usage() {
769+ cat >&2 <<EOF
770+Usage: ${progname}
771+EOF
772+}
773+
774+if [ "${1}" = "-h" ] || [ "${1}" = "--help" ]; then
775+ usage
776+ exit 0
777+fi
778+
779+# TODO: Check if we're on a branch with no upstream defined,
780+# and if so bail with an appropriate error. Otherwise,
781+# the git reset will fail
782+
783+git format-patch -o /tmp master
784+git reset --hard @{u}
785+git status
786+
787diff --git a/bryce/gu-set-target b/bryce/gu-set-target
788new file mode 100755
789index 0000000..2e53726
790--- /dev/null
791+++ b/bryce/gu-set-target
792@@ -0,0 +1,108 @@
793+#!/usr/bin/python3
794+# -*- coding: utf-8 -*-
795+
796+# Makes the imported repository the default for that Ubuntu package in
797+# Launchpad. This will allow git ubuntu clone to find the repository,
798+# since it looks for the default.
799+#
800+# Process for handling an import request:
801+# https://docs.google.com/document/d/1LimtZjV4ldeIK_IY9GngumacljhqRdiwIcgWlI1TFiY/edit#heading=h.x44nuoia544z
802+
803+from os.path import join
804+import asyncio
805+import tenacity
806+import argparse
807+from functools import lru_cache
808+from launchpadlib.launchpad import Launchpad
809+from xdg.BaseDirectory import xdg_config_home
810+
811+class Config:
812+ HOME = xdg_config_home
813+
814+class Lp:
815+ # Extraction of bileto's lp class.
816+ # (See Pdbq for a more thorough implementation.)
817+ _real_instance = None
818+
819+ def __init__(self, application_name, service=Launchpad, config=Config):
820+ """Create a Launchpad service object."""
821+ self._app_name = application_name
822+ self._service = service
823+ self._config = config
824+
825+ def _get_instance(self):
826+ """Authenticate to Launchpad."""
827+ return self._service.login_with(
828+ application_name=self._app_name,
829+ service_root='production',
830+ allow_access_levels=['WRITE_PRIVATE'],
831+ version='devel', # Need devel for copyPackage.
832+ credentials_file=join(self._config.HOME, '.launchpad.credentials'),
833+ )
834+
835+ @property
836+ def _instance(self):
837+ """Cache LP object."""
838+ if not self._real_instance:
839+ self._real_instance = self._get_instance()
840+ return self._real_instance
841+
842+ @property
843+ @lru_cache()
844+ def _api_root(self):
845+ """Identify the root URL of the launchpad API."""
846+ return self._instance.resource_type_link.split('#')[0]
847+
848+ def __getattr__(self, attr):
849+ """Wrap launchpadlib so tightly you can't tell the difference."""
850+ assert not attr.startswith('_'), "Can't getattr for %s" %(attr)
851+ instance = super(Lp, self).__getattribute__('_instance')
852+ return getattr(instance, attr)
853+
854+
855+def create_parser():
856+ """Sets up the command line parser object.
857+
858+ :rtype: argparse.ArgumentParser
859+ :returns: parser object, ready to run <parser>.parse_args().
860+ """
861+ parser = argparse.ArgumentParser(
862+ description='Makes an imported repository the default in Launchpad',
863+ )
864+ parser.add_argument(
865+ 'packages',
866+ nargs=argparse.REMAINDER)
867+ return parser
868+
869+@tenacity.retry(
870+ retry=tenacity.retry_if_exception_type(KeyError),
871+ wait=tenacity.wait_fixed(300),
872+ )
873+async def set_git_ubuntu_default_target(pkg):
874+ """
875+ Sets the default target for the given package.
876+
877+ :param str pkg: Name of source package.
878+ """
879+ lp = Lp('git-ubuntu')
880+ repository = lp.git_repositories.getByPath(
881+ path=f'~git-ubuntu-import/ubuntu/+source/{pkg}',
882+ )
883+ if repository is None:
884+ print(f"{pkg} does not exist yet. Waiting...")
885+ raise KeyError(f"Repository for {pkg} not found")
886+ lp.git_repositories.setDefaultRepository(
887+ repository=repository,
888+ target=lp.distributions['ubuntu'].getSourcePackage(name=pkg),
889+ )
890+ print(f"{pkg} set successfully")
891+
892+async def set_all_async_with_wait(pkgs):
893+ await asyncio.gather(*[set_git_ubuntu_default_target(pkg) for pkg in pkgs])
894+
895+if __name__ == "__main__":
896+ # Option handling
897+ parser = create_parser()
898+ args = parser.parse_args()
899+
900+ asyncio.run(set_all_async_with_wait(args.packages))
901diff --git a/bryce/gu-whitelist b/bryce/gu-whitelist
902new file mode 100755
903index 0000000..c0608f7
904--- /dev/null
905+++ b/bryce/gu-whitelist
906@@ -0,0 +1,119 @@
907+#!/bin/bash
908+
909+# Process for handling an import request:
910+# https://docs.google.com/document/d/1LimtZjV4ldeIK_IY9GngumacljhqRdiwIcgWlI1TFiY/edit#heading=h.x44nuoia544z
911+
912+remote_user="${GU_REMOTE_USER:-ubuntu}"
913+remote_host="${GU_REMOTE_HOST}"
914+cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
915+usd_git_repo="${GU_GIT_REPO:-$cache_dir/usd-importer-whitelist}"
916+priority="${GU_PRIORITY:-5}"
917+
918+## Prints to stderr
919+function info() {
920+ echo "${@}" 1>&2
921+}
922+
923+## Prints to stderr, prefixed by 'Error:'
924+function error() {
925+ echo "Error: ${@}" 1>&2
926+}
927+
928+## Prints to stderr, prefixed by 'Fatal:', and terminates with non-zero exit code
929+function die() {
930+ echo "Fatal: ${@}" 1>&2
931+ exit ${2:-1}
932+}
933+
934+function remote_exec() {
935+ local cmd="${1}"
936+
937+ # Send command via ssh to remote server
938+ info "ssh ${remote_user}@${remote_host} ${cmd}"
939+ ssh "${remote_user}@${remote_host}" "${cmd}"
940+}
941+
942+# Verify the VPN is activated. If not, error & suggest enabling it.
943+info "Checking if VPN is enabled"
944+if ! ping -c1 "${remote_host}"; then
945+ die "Could not ping ${remote_host}. Is VPN enabled?"
946+fi
947+
948+# If repo doesn't exist, check it out
949+if [ ! -d "${usd_git_repo}" ]; then
950+ lp_user=$(git config gitubuntu.lpuser)
951+ if [ $? != 0 ] || [ -z "${lp_user}" ]; then
952+ die "Could not determine LP username (set via git config gitubuntu.lpuser=<username>)"
953+ fi
954+ git clone "git+ssh://${lp_user}@git.launchpad.net/usd-importer" "${usd_git_repo}" \
955+ || die "Could not clone usd-importer from launchpad"
956+elif [ ! -d "${usd_git_repo}/.git" ]; then
957+ die "${usd_git_repo} already exists but is not a valid git repository"
958+fi
959+
960+cd "${usd_git_repo}" \
961+ || die "Could not chdir ${usd_git_repo}"
962+
963+# Check for any local changes
964+if [ -n "$(git diff --name-only)" ]; then
965+ die "There are uncommitted changes in ${usd_git_repo}"
966+elif [ -n "$(git log origin/master..HEAD)" ]; then
967+ die "There are unpushed changes in ${usd_git_repo}"
968+fi
969+
970+git pull \
971+ || die "Could not fetch from remote"
972+
973+# TODO: Add option to pull changes from a merge proposal. E.g.:
974+# https://code.launchpad.net/~brian-murray/usd-importer/+git/usd-importer/+merge/406471
975+
976+# See if last entry appears to be from current user. If not, add comment
977+# with attribution for the new entries.
978+name=$(git config user.name)
979+last_section=$(grep ^# gitubuntu/source-package-whitelist.txt | tail -n 1)
980+if [ "${last_section}" != "Requested by ${name}" ]; then
981+ echo "" >> gitubuntu/source-package-whitelist.txt
982+ echo "# Requested by ${name}" >> gitubuntu/source-package-whitelist.txt
983+fi
984+
985+num_added=0
986+for package_name in ${@}; do
987+ info "Whitelisting ${package_name}"
988+ # Check if package is already in the whitelist
989+ if grep "^${package_name}$" gitubuntu/source-package-whitelist.txt; then
990+ info "+ ${package_name} is already in the whitelist."
991+ else
992+ # Append packages to whitelist
993+ echo "${package_name}" >> gitubuntu/source-package-whitelist.txt
994+ num_added=$(( num_added + 1 ))
995+ fi
996+done
997+
998+if [ ${num_added} -gt 0 ]; then
999+ git commit -am "Add ${package_name} to the whitelist."
1000+ git show HEAD | cat
1001+ echo "Make any changes to HEAD locally, and commit."
1002+ echo "${usd_git_repo}"
1003+ echo -n "Push changes [yn]? "
1004+ read ANSWER
1005+ [ "${ANSWER}" = 'y' ] || exit 1
1006+ git push
1007+else
1008+ info "+ No packages needed added to whitelist"
1009+ # Discard the request comment
1010+ git checkout gitubuntu/source-package-whitelist.txt
1011+fi
1012+
1013+remote_exec 'cd ~ubuntu/live-whitelist-blacklist-source/ && git pull'
1014+remote_exec 'sudo systemctl --no-block restart git-ubuntu-importer-service-poller'
1015+
1016+for package_name in ${@}; do
1017+ info "Requesting ${package_name} import"
1018+ sql="INSERT INTO request (srcpkg, timestamp, priority) VALUES ('${package_name}', $(date +%s), ${priority})"
1019+ info "+ Executing: '${sql}'"
1020+ if ! remote_exec "sqlite3 /var/local/git-ubuntu/db \"${sql}\""; then
1021+ error "importing ${package_name}"
1022+ fi
1023+ sleep 1
1024+ info ""
1025+done
1026diff --git a/bryce/install-build-deps b/bryce/install-build-deps
1027new file mode 100755
1028index 0000000..73a19f6
1029--- /dev/null
1030+++ b/bryce/install-build-deps
1031@@ -0,0 +1,11 @@
1032+#!/bin/bash
1033+
1034+sudo apt-get install -y equivs
1035+sudo mk-build-deps \
1036+ --install \
1037+ --remove \
1038+ --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' \
1039+ ./debian/control
1040+
1041+sudo rm -f *-build-deps_*_amd64.buildinfo
1042+sudo rm -f *-build-deps_*_amd64.changes
1043diff --git a/bryce/json-check b/bryce/json-check
1044new file mode 100755
1045index 0000000..69e4a0f
1046--- /dev/null
1047+++ b/bryce/json-check
1048@@ -0,0 +1,21 @@
1049+#!/usr/bin/env python
1050+
1051+# Copyright (C) 2012 Bryce Harrington
1052+# License: http://www.opensource.org/licenses/mit-license.php
1053+
1054+import sys
1055+import json
1056+
1057+filename = sys.argv[1]
1058+s = open(filename).read()
1059+try:
1060+ j = json.loads(s)
1061+ errcode = 0
1062+ sys.stderr.write("PASS\n")
1063+except:
1064+ errcode = 1
1065+ sys.stderr.write("FAIL: Invalid json\n")
1066+ raise
1067+sys.exit(errcode)
1068+
1069+
1070diff --git a/bryce/json-get b/bryce/json-get
1071new file mode 100755
1072index 0000000..c667a64
1073--- /dev/null
1074+++ b/bryce/json-get
1075@@ -0,0 +1,43 @@
1076+#!/usr/bin/python3
1077+
1078+import sys
1079+import json
1080+import pprint
1081+
1082+if len(sys.argv) < 3:
1083+ print("usage: json-get <json-filename> [ALL|<path.in.data.structure>]")
1084+ sys.exit(1)
1085+
1086+filename = sys.argv[1]
1087+json_path = sys.argv[2]
1088+
1089+with open(filename) as json_data:
1090+ data = json.load(json_data)
1091+
1092+path_elements = json_path.split('.')
1093+
1094+if json_path != "ALL":
1095+ for i in path_elements:
1096+ if type(data) is dict:
1097+ data = data.get(i, None)
1098+ elif type(data) is list:
1099+ if i.isdigit():
1100+ data = data[int(i)]
1101+ elif '=' in i:
1102+ (key,value) = i.split('=', 2)
1103+ found = False
1104+ for item in data:
1105+ if item[key] == value:
1106+ data = item
1107+ found = True
1108+ break
1109+ else:
1110+ print(type(i))
1111+ else:
1112+ print(type(data))
1113+
1114+if type(data) is list or type(data) is hash:
1115+ pp = pprint.PrettyPrinter()
1116+ pp.pprint(data)
1117+else:
1118+ print(data)
1119diff --git a/bryce/ls-installed b/bryce/ls-installed
1120new file mode 100755
1121index 0000000..98737e0
1122--- /dev/null
1123+++ b/bryce/ls-installed
1124@@ -0,0 +1,3 @@
1125+#!/bin/bash
1126+
1127+dpkg --get-selections | cut -f 1
1128diff --git a/bryce/ls-lxc b/bryce/ls-lxc
1129new file mode 100755
1130index 0000000..0b569ea
1131--- /dev/null
1132+++ b/bryce/ls-lxc
1133@@ -0,0 +1,3 @@
1134+#!/bin/bash
1135+
1136+lxc list -c ns4b | grep -v '^\+'
1137diff --git a/bryce/middle-paste b/bryce/middle-paste
1138new file mode 100755
1139index 0000000..10786e2
1140--- /dev/null
1141+++ b/bryce/middle-paste
1142@@ -0,0 +1,14 @@
1143+#!/bin/bash
1144+
1145+## This works, but results in system getting
1146+#xdotool type --clearmodifiers "$(xsel)"
1147+
1148+xdotool mousedown --clearmodifiers 2
1149+xdotool mouseup 2
1150+xdotool keyup alt
1151+xdotool keyup ctrl
1152+xdotool keyup shift
1153+
1154+# --delay milliseconds
1155+
1156+
1157diff --git a/bryce/migration-filter b/bryce/migration-filter
1158new file mode 100755
1159index 0000000..e772244
1160--- /dev/null
1161+++ b/bryce/migration-filter
1162@@ -0,0 +1,217 @@
1163+#!/usr/bin/env python3
1164+# -*- coding: utf-8 -*-
1165+
1166+# Author: Bryce Harrington <bryce@canonical.com>
1167+#
1168+# Copyright (C) 2020 Bryce W. Harrington
1169+#
1170+# Released under GNU AGPL or later, read the file 'LICENSE.AGPL' for
1171+# more information.
1172+
1173+import json
1174+import lzma
1175+import os
1176+import urllib.request
1177+import re
1178+import sys
1179+import yaml
1180+
1181+if '__file__' in globals():
1182+ sys.path.insert(0, os.path.realpath(
1183+ os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")))
1184+
1185+URL = 'https://people.canonical.com/~ubuntu-archive/proposed-migration/update_excuses.yaml'
1186+
1187+def strip_html(raw_html):
1188+ re_html = re.compile('<.*?>')
1189+ return re.sub(re_html, '', raw_html)
1190+
1191+def excuses_to_issues(excuses):
1192+ for issue in excuses:
1193+ # Exclude administrivia text
1194+ if (issue.startswith("Migration status for") or
1195+ issue.startswith("Issues preventing migration:") or
1196+ issue.startswith("Additional info:") or
1197+ issue.endswith("days old") or
1198+ issue.endswith("autopkgtest delayed")):
1199+ continue
1200+ yield issue
1201+
1202+def arches_for_issue(issue):
1203+ re_arch = re.compile(r'\&arch=([^\&]*)\&')
1204+ for item in issue.split(','):
1205+ m = re_arch.search(item)
1206+ if m:
1207+ yield m.group(1)
1208+
1209+def filter_only_test_complete(sources):
1210+ """Exclude sources that still have 'Test in progress' status."""
1211+ for source in sources:
1212+ in_progress = False
1213+ for issue in excuses_to_issues(source['excuses']):
1214+ if 'Test in progress' in issue:
1215+ in_progress = True
1216+ if not in_progress:
1217+ yield source
1218+
1219+def filter_only_build_failures(sources):
1220+ """Exclude sources that have issues other than build failures."""
1221+ for source in sources:
1222+ has_build_issue = False
1223+ has_non_build_issue = False
1224+ source['suggested-actions'] = []
1225+ for issue in excuses_to_issues(source['excuses']):
1226+ # Valid build issues
1227+ if issue.startswith("missing build on"):
1228+ has_build_issue = True
1229+ url = issue.split('"')[1]
1230+ arch = url.split('/')[-1]
1231+ source['suggested-actions'].append({
1232+ 'command': None,
1233+ 'description': "Retry build for {}".format(arch),
1234+ 'url': url
1235+ })
1236+
1237+ # Other sorts of issues
1238+ else:
1239+ has_non_build_issue = True
1240+ if has_build_issue and not has_non_build_issue:
1241+ yield source
1242+
1243+def filter_only_autopkgtest_failures(sources):
1244+ """Exclude sources that have issues other than autopkgtest regressions"""
1245+ for source in sources:
1246+ has_autopkgtest_issue = False
1247+ has_non_autopkgtest_issue = False
1248+ source['suggested-actions'] = []
1249+ for issue in excuses_to_issues(source['excuses']):
1250+ # Valid test regressions
1251+ if issue.startswith("autopkgtest for"):
1252+ package = issue.split(' ')[2].rstrip(':').split('/')[0]
1253+
1254+ regressions = ' '.join(issue.split(' ')[3:])
1255+ for r in regressions.split(', '):
1256+ test_link_html = r.split(': ')[0].rstrip(': ')
1257+ test_url = test_link_html.split('"')[1]
1258+ test_arch = strip_html(test_link_html)
1259+
1260+ test_status_html = r.split(': ', 1)[1]
1261+ test_status_url = test_status_html.split('"')[1]
1262+ test_status = strip_html(test_status_html)
1263+
1264+ if test_status.startswith('Regression'):
1265+ source['suggested-actions'].append({
1266+ 'command': "excuses-kicker --architecture {} {}".format(test_arch, package),
1267+ 'description': "Retry test(s) for {} on {}".format(package, test_arch),
1268+ 'arch': test_arch,
1269+ 'url': test_url,
1270+ 'status': test_status
1271+ })
1272+ has_autopkgtest_issue = True
1273+
1274+ # Other sorts of issues
1275+ else:
1276+ has_non_autopkgtest_issue = True
1277+ if has_autopkgtest_issue and not has_non_autopkgtest_issue:
1278+ yield source
1279+
1280+def filter_single_issue(sources):
1281+ """Excludes sources that have more than one issue listed."""
1282+ for source in sources:
1283+ num_issues = 0
1284+ for issue in excuses_to_issues(source['excuses']):
1285+ num_issues += 1
1286+ if num_issues > 1:
1287+ break
1288+ if num_issues == 1:
1289+ yield source
1290+
1291+def filter_single_arch(sources):
1292+ """Excludes sources that affect more than a single architecture."""
1293+ arch_sources = []
1294+ for source in sources:
1295+ arch = None
1296+ for issue in excuses_to_issues(source['excuses']):
1297+ arches = list(arches_for_issue(issue))
1298+ if arch is None and len(arches) == 1:
1299+ arch = arches[0]
1300+ arch_sources.append(source)
1301+ elif arches == [arch]:
1302+ arch_sources.append(source)
1303+
1304+ return arch_sources
1305+
1306+def main():
1307+ import sys
1308+ import argparse
1309+
1310+ # Option handling
1311+ parser = argparse.ArgumentParser(description='Query subsets of the proposed migration update excuses')
1312+ parser.add_argument(
1313+ '-j', '--json',
1314+ action='store_true',
1315+ help='Output a JSON data file',
1316+ default=False
1317+ )
1318+ parser.add_argument(
1319+ '-T', '--total',
1320+ action='store_true',
1321+ help='Print the total count of source packages satisfying filter criteria',
1322+ default=False
1323+ )
1324+ parser.add_argument(
1325+ 'filter', nargs=argparse.REMAINDER,
1326+ help='Name of the filter to run'
1327+ )
1328+ args = parser.parse_args()
1329+
1330+ # TODO: Load from cached JSON file (query-
1331+ with urllib.request.urlopen(URL) as f:
1332+ # Use C implementation of the SafeLoader, which is faster for
1333+ # large files like this one.
1334+ migrations = yaml.load(lzma.decompress(f.read()), Loader=yaml.CSafeLoader)
1335+
1336+ generation_timestamp = migrations['generated-date']
1337+ sources = migrations['sources']
1338+
1339+ results = []
1340+ if 'all' in args.filter or args.filter == []:
1341+ results = sources
1342+ elif 'single-build-failures' in args.filter:
1343+ results = list(
1344+ filter_single_issue(
1345+ filter_only_build_failures(sources)
1346+ )
1347+ )
1348+ elif 'single-test-regressions' in args.filter:
1349+ results = list(
1350+ filter_single_arch(
1351+ filter_single_issue(
1352+ filter_only_autopkgtest_failures(
1353+ filter_only_test_complete(sources)
1354+ )
1355+ )
1356+ )
1357+ )
1358+ else:
1359+ print("Error: Unknown filters")
1360+ sys.exit(1)
1361+
1362+ if args.json:
1363+ print(json.dumps(
1364+ results,
1365+ sort_keys=True,
1366+ indent=4,
1367+ ))
1368+ elif args.total:
1369+ print("{} update excuse records found".format(len(results)))
1370+ else:
1371+ for result in results:
1372+ print("* {}:".format(result.get('item-name')))
1373+ for action in result.get('suggested-actions', []):
1374+ print(" - {}".format(action.get('description')))
1375+ print(" {}".format(action.get('url')))
1376+ print(" $ {}".format(action.get('command')))
1377+
1378+if __name__ == '__main__':
1379+ main()
1380diff --git a/bryce/monday-triage b/bryce/monday-triage
1381new file mode 100755
1382index 0000000..248489c
1383--- /dev/null
1384+++ b/bryce/monday-triage
1385@@ -0,0 +1,14 @@
1386+#!/bin/bash
1387+
1388+triagers=(paelzer bryce paride utkarsh rbasak lucas sergio)
1389+num_triagers=7
1390+week=$(($(date +%V) + 1))
1391+week=${week##0}
1392+week=${week##+(0)}
1393+current=$((week % num_triagers))
1394+echo "Current: " ${triagers[${current}]}
1395+echo "Next week: " ${triagers[$(( (current + 1) % num_triagers))]}
1396+echo "2 weeks: " ${triagers[$(( (current + 2) % num_triagers))]}
1397+echo "3 weeks: " ${triagers[$(( (current + 3) % num_triagers))]}
1398+echo "4 weeks: " ${triagers[$(( (current + 4) % num_triagers))]}
1399+echo "5 weeks: " ${triagers[$(( (current + 5) % num_triagers))]}
1400diff --git a/bryce/mv-smart b/bryce/mv-smart
1401new file mode 100755
1402index 0000000..f1cc987
1403--- /dev/null
1404+++ b/bryce/mv-smart
1405@@ -0,0 +1,52 @@
1406+#!/bin/bash
1407+
1408+progname=$(basename $0)
1409+
1410+usage() {
1411+ cat >&2 <<EOF
1412+Usage: ${progname} <file> [file [...]] <dest>
1413+
1414+Options:
1415+ -h, --help This help listing
1416+EOF
1417+}
1418+
1419+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
1420+ usage
1421+ exit 0
1422+elif [[ $# -lt 2 ]]; then
1423+ usage
1424+ exit 1
1425+fi
1426+
1427+
1428+DEST=${@: -1}
1429+FILES=${@:1:$(($#-1))}
1430+
1431+for file_path in ${FILES} ; do
1432+ file=$(basename $file_path)
1433+ dest_file=${DEST}/${file}
1434+ if [ ! -e ${dest_file} ]; then
1435+ echo ${file}
1436+ mv -i ${file_path} ${dest_file}
1437+ continue
1438+ fi
1439+
1440+ if [ -d "${file_path}" ]; then
1441+ echo "directory ${file_path} already exists"
1442+ continue
1443+ fi
1444+
1445+ a=$(md5sum $file_path | cut -d' ' -f1)
1446+ b=$(md5sum $dest_file | cut -d' ' -f1)
1447+
1448+ if [ "$a" = "$b" ]; then
1449+ # files are the same; keep destination copy
1450+ #echo "$file is already in $DEST - $a = $b"
1451+ rm $file_path
1452+ else
1453+ echo "$dest_file exists and differs from $file. Skipping."
1454+ fi
1455+done
1456+
1457+# for dir in *; do diff --brief --recursive --no-dereference --new-file --no-ignore-file-name-case ~/src/$dir $dir > /dev/null 2>&1; if [ $? == 0 ]; then echo $dir; fi; done
1458diff --git a/bryce/pkg-clean b/bryce/pkg-clean
1459new file mode 100755
1460index 0000000..81a487f
1461--- /dev/null
1462+++ b/bryce/pkg-clean
1463@@ -0,0 +1,36 @@
1464+#!/bin/bash
1465+
1466+# This script removes uncommitted changes from a checked out git repository.
1467+
1468+INTERACTIVE=${INTERACTIVE:-"no"}
1469+
1470+# TODO: Check for any changes in debian/patches/*
1471+# Check for changes to debian/control or debian/changelog
1472+deb_changes=$(git diff --name-only debian/changelog debian/control*)
1473+if [ -n "${deb_changes}" ]; then
1474+ if [ "${INTERACTIVE}" = "yes" ]; then
1475+ while true; do
1476+ read -p "Discard uncommitted changes? (Y/n)" answer
1477+ case "${answer}" in
1478+ [Yy]* )
1479+ echo "Discarding changes to ${deb_changes}" ;;
1480+ [Nn]* )
1481+ exit 1 ;;
1482+ * )
1483+ echo "Please answer yes or no." \\
1484+ esac
1485+ done
1486+ else
1487+ # TODO: Allow --force
1488+ echo "Uncommitted changes exist"
1489+ echo "${deb_changes}"
1490+ exit 1
1491+ fi
1492+fi
1493+
1494+git checkout .
1495+git clean -fxd
1496+
1497+# TODO: maybe use -e to exclude stuff?
1498+
1499+# TODO: Maybe git restore or git reset?
1500diff --git a/bryce/pkg-component b/bryce/pkg-component
1501new file mode 100755
1502index 0000000..9cf91f5
1503--- /dev/null
1504+++ b/bryce/pkg-component
1505@@ -0,0 +1,37 @@
1506+#!/bin/bash
1507+
1508+# Given a package name, print what component it's in
1509+show_binary() {
1510+ local binary_package="${1}"
1511+
1512+ echo -n "${binary_package}: "
1513+ section=$(apt-cache show "${binary_package}" \
1514+ | grep Section: \
1515+ | cut -d: -f2)
1516+ if [[ "${section}" =~ "/" ]]; then
1517+ echo "${section}" \
1518+ | cut -d/ -f1 \
1519+ | sort -u \
1520+ | xargs echo
1521+ else
1522+ echo "main"
1523+ fi
1524+}
1525+
1526+for pkg in "${@}"; do
1527+ if apt-cache show "${pkg}" 2>&1 | grep Package: > /dev/null; then
1528+ show_binary "${pkg}"
1529+ continue
1530+ fi
1531+
1532+ pkg_details=$(apt-cache showsrc "${pkg}")
1533+ if [ -z "${pkg_details}" ]; then
1534+ echo " - Could not find a component for ${pkg}"
1535+ exit 1
1536+ fi
1537+
1538+ binaries=$(echo "${pkg_details}" | grep Binary: | cut -d: -f2 | sed -e "s/,//g")
1539+ for binary_package in ${binaries}; do
1540+ show_binary "${binary_package}"
1541+ done
1542+done
1543diff --git a/bryce/pkg-depends b/bryce/pkg-depends
1544new file mode 100755
1545index 0000000..4bf4cd1
1546--- /dev/null
1547+++ b/bryce/pkg-depends
1548@@ -0,0 +1,39 @@
1549+#!/bin/bash
1550+
1551+# Looks up the install-time dependencies for the given package
1552+
1553+list_package_depends() {
1554+ binary_package="${1}"
1555+ apt-cache depends "${binary_package}" \
1556+ --recurse --no-recommends --no-suggests --no-conflicts \
1557+ --no-breaks --no-replaces --no-enhances \
1558+ | grep "^\w" \
1559+ | sort -u
1560+}
1561+
1562+if [ $# -ge 1 ]; then
1563+ input="printf %s\n ${@}"
1564+else
1565+ input="cat -"
1566+fi
1567+
1568+# TODO: read -r disables backslashes
1569+# See https://unix.stackexchange.com/questions/192786/what-is-the-meaning-of-read-r
1570+while read requested_package; do
1571+ echo "${requested_package}"
1572+
1573+ # Find all dependencies recursively
1574+ for depend in $(list_package_depends "${requested_package}"); do
1575+ # Don't repeat our own package
1576+ if [ "${depend}" = "${requested_package}" ]; then
1577+ continue
1578+ fi
1579+
1580+ # Skip things in main
1581+ component=$(pkg-component "${depend}")
1582+ if [ "${component}" = "main" ]; then
1583+ continue
1584+ fi
1585+ echo " ${depend}"
1586+ done
1587+done < <(${input})
1588diff --git a/bryce/pkg-nochange b/bryce/pkg-nochange
1589new file mode 100755
1590index 0000000..61d98fe
1591--- /dev/null
1592+++ b/bryce/pkg-nochange
1593@@ -0,0 +1,177 @@
1594+#!/bin/bash
1595+# -*- coding: utf-8; mode: sh -*-
1596+
1597+# Easy tool for quickly creating no-change rebuild packages
1598+
1599+# No-change rebuilds are necessary when one of the package's
1600+# dependencies has been updated to a new ABI level.
1601+
1602+progname=$(basename "${0}")
1603+
1604+rationale="${RATIONALE:-No change rebuild}"
1605+codename="${CODENAME:-$(distro-info --devel)}"
1606+
1607+usage() {
1608+ cat >&2 <<EOF
1609+Usage: ${progname} [package-name] [changelog rationale]
1610+
1611+Options:
1612+ -h, --help This help text.
1613+EOF
1614+ exit "${1}"
1615+}
1616+
1617+## Prints given message to stderr if DEBUG is enabled
1618+##
1619+## @param str 1: String to be displayed.
1620+dbg() {
1621+ [ -n "${DEBUG}" ] && echo "${@}" 1>&2
1622+}
1623+
1624+## Prints to stderr
1625+##
1626+## @param str 1: String to be displayed.
1627+info() {
1628+ echo "${@}" 1>&2
1629+}
1630+
1631+## Prints to stderr, prefixed by 'Warning:'
1632+##
1633+## @param str 1: String to be displayed.
1634+warn() {
1635+ echo "Warning: ${@}" 1>&2
1636+}
1637+
1638+## Prints to stderr, prefixed by 'Error:'
1639+##
1640+## @param str 1: String to be displayed.
1641+error() {
1642+ echo "Error: ${@}" 1>&2
1643+}
1644+
1645+## Prints to stderr, prefixed by 'Fatal:', and terminates with non-zero exit code
1646+##
1647+## @param str 1: String to be displayed.
1648+## @param str 2: Exit error code.
1649+die() {
1650+ echo "Fatal: ${@}" 1>&2
1651+ exit ${2:-1}
1652+}
1653+
1654+## Strip leading and trailing whitespace
1655+trim() {
1656+ local trimmed
1657+
1658+ trimmed="${@}"
1659+ if [ -z "${trimmed}" ]; then
1660+ read trimmed
1661+ fi
1662+
1663+ # Strip leading spaces.
1664+ while [[ ${trimmed} == ' '* ]]; do
1665+ trimmed="${trimmed## }"
1666+ done
1667+
1668+ # Strip trailing spaces.
1669+ while [[ ${trimmed} == *' ' ]]; do
1670+ trimmed="${trimmed%% }"
1671+ done
1672+
1673+ echo "${trimmed}"
1674+}
1675+
1676+get_pkgsys() {
1677+ if [ -d ".git" ]; then
1678+ if git remote -v | grep -P "^pkg\t"; then
1679+ echo "git-ubuntu"
1680+ return 0
1681+ fi
1682+ fi
1683+ echo "apt"
1684+ return 0
1685+}
1686+
1687+get_version_from_changelog() {
1688+ dpkg-parsechangelog | grep ^Version | cut -d: -f2 | trim
1689+}
1690+
1691+get_upstream_version_from_changelog() {
1692+ get_version_from_changelog "${@}" | cut -d- -f1 | trim
1693+}
1694+
1695+install_build_dependencies() {
1696+ local package_name="${1}"
1697+
1698+ # Install build dependencies for package
1699+ if which install-build-deps; then
1700+ install-build-deps || return 1
1701+ elif [ -n "${package_name}" ]; then
1702+ sudo apt-get -y build-dep "${package_name}" || return 1
1703+ else
1704+ return 1
1705+ fi
1706+
1707+ return 0
1708+}
1709+
1710+rev_package_for_nochange() {
1711+ local codename="${1}"
1712+ local rationale="${2}"
1713+
1714+ echo "version: $(get_version_from_changelog)"
1715+ if [[ "$(get_version_from_changelog)" == *"ubuntu"* ]]; then
1716+ # If current version has ubuntuN, then just increment it.
1717+ dch -i --distribution "${codename}" "${rationale}"
1718+ else
1719+ # append build1
1720+ dch -l "build" --distribution "${codename}" "${rationale}"
1721+ fi
1722+}
1723+
1724+main() {
1725+ # Determine package name
1726+ if [ -d './debian' ]; then
1727+ # We're already in a source package tree, so use it preferentially
1728+ package_name=$(dpkg-parsechangelog | grep ^Source: | cut -d' ' -f2)
1729+ elif [ -n "${1}" ] || [ -n "${PACKAGE}" ]; then
1730+ # Package was specified on commandline
1731+ package_name="${1:-${PACKAGE}}"
1732+ package_dir=$(pkg-get "${package_name}") || {
1733+ warn "Could not get package source"
1734+ exit 1
1735+ }
1736+ cd "${package_dir}" || {
1737+ warn "Could not chdir '${package_dir}'"
1738+ exit 1
1739+ }
1740+ else
1741+ usage 1
1742+ fi
1743+
1744+ install_build_dependencies "${package_name}" || {
1745+ warn "Could not install build dependencies"
1746+ }
1747+
1748+ rev_package_for_nochange "${codename}" "${rationale}" || {
1749+ warn "Could not rev package version"
1750+ }
1751+
1752+ if [ "$(get_pkgsys)" = "git-ubuntu" ]; then
1753+ warn "tbd"
1754+ # TODO: If git-ubuntu, use push-for-upload
1755+ debuild -S
1756+ else
1757+ debuild -S
1758+ fi
1759+
1760+ # TODO: Look at pitt job for code to detect the right source.changes
1761+
1762+ ls -l ../*source.changes
1763+
1764+ info "Ready to upload:"
1765+ info " \$ dput ubuntu ../<whatever>source.changes"
1766+}
1767+
1768+if [[ "${0}" == "${BASH_SOURCE[0]}" ]]; then
1769+ main "${@}"
1770+fi
1771diff --git a/bryce/pkg-rdepends b/bryce/pkg-rdepends
1772new file mode 100755
1773index 0000000..25ba63f
1774--- /dev/null
1775+++ b/bryce/pkg-rdepends
1776@@ -0,0 +1,9 @@
1777+#!/bin/bash
1778+
1779+# See also cpaelzer's versioned-rdepends.sh
1780+
1781+# TODO: --recurse?
1782+# TODO: --recommends?
1783+apt-cache --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances rdepends "${@}"
1784+
1785+# TODO: This should list whether the rdep is a Recommends or Depends
1786diff --git a/bryce/pkg-source b/bryce/pkg-source
1787new file mode 100755
1788index 0000000..2385e22
1789--- /dev/null
1790+++ b/bryce/pkg-source
1791@@ -0,0 +1,27 @@
1792+#!/bin/bash
1793+
1794+for pkg in "${@}"; do
1795+ if ! pkg_details=$(apt-cache show "${pkg}"); then
1796+ if ! pkg_details=$(apt-cache showsrc "${pkg}"); then
1797+ echo " - Can't find ${pkg} in archive"
1798+ continue
1799+ fi
1800+ fi
1801+
1802+ if [ $? -ne 0 ]; then
1803+ echo " - Could not find source for ${pkg}"
1804+ exit 1
1805+ fi
1806+ source_package=$(echo "${pkg_details}" \
1807+ | grep Source: \
1808+ | cut -d: -f2 \
1809+ | sort -u \
1810+ | xargs echo)
1811+ if [ -z "${source_package}" ]; then
1812+ echo "Couldn't find source for ${pkg}"
1813+ echo "${pkg_details}"
1814+ else
1815+ echo "${source_package}"
1816+ fi
1817+
1818+done
1819diff --git a/bryce/prepend b/bryce/prepend
1820new file mode 100755
1821index 0000000..abdc1e1
1822--- /dev/null
1823+++ b/bryce/prepend
1824@@ -0,0 +1,26 @@
1825+#!/bin/bash
1826+
1827+progname=$(basename $0)
1828+
1829+usage() {
1830+ cat >&2 <<EOF
1831+Usage: ${progname} <insert-file> <target-file>
1832+EOF
1833+}
1834+
1835+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
1836+ usage
1837+ exit 0
1838+elif [[ $# -lt 2 ]]; then
1839+ usage
1840+ exit 1
1841+fi
1842+
1843+insert_file=$1
1844+target_file=$2
1845+dummy=/tmp/${target_file}.dummy
1846+
1847+cat $target_file > $dummy
1848+mv ${target_file} ${target_file}.old
1849+cat $insert_file $dummy > $target_file
1850+
1851diff --git a/bryce/rmad b/bryce/rmad
1852new file mode 100755
1853index 0000000..d689b18
1854--- /dev/null
1855+++ b/bryce/rmad
1856@@ -0,0 +1,16 @@
1857+#!/bin/bash
1858+
1859+package_name="${1}"
1860+
1861+if [ -z "${package_name}" ]; then
1862+ # TODO: Is the directory we're in a valid package name?
1863+ echo "Usage: rmad <package-name>"
1864+ exit 1
1865+fi
1866+stable=$(distro-info --stable)
1867+codename=$(distro-info --devel 2>/dev/null)
1868+rmadison -s "${stable},${stable}-security,${stable}-updates,${codename},${codename}-proposed" -a "source" "${package_name}" | sed -e "s/ | source//"
1869+echo
1870+rmadison -u "debian" -a "source" "${package_name}" | grep -v oldstable | grep -v "\-(backports|debug)" | sed -e "s/ | source//"
1871+
1872+# Filter out *stable* and *testing*
1873diff --git a/bryce/shuffle b/bryce/shuffle
1874new file mode 100755
1875index 0000000..6ad1453
1876--- /dev/null
1877+++ b/bryce/shuffle
1878@@ -0,0 +1,11 @@
1879+#!/usr/bin/env python3
1880+
1881+import sys
1882+import random
1883+
1884+filename = sys.argv[1]
1885+a = open(filename).read().strip().split("\n")
1886+
1887+random.shuffle(a)
1888+for i in a:
1889+ print(i)
1890diff --git a/check-before-lib-update.sh b/check-before-lib-update.sh
1891deleted file mode 100755
1892index 971496c..0000000
1893--- a/check-before-lib-update.sh
1894+++ /dev/null
1895@@ -1,57 +0,0 @@
1896-#!/bin/bash
1897-set -ue
1898-
1899-if [ $# -ne 2 ];then
1900- echo "invalid number of arguments"
1901- exit 1
1902-fi
1903-REL=${1}
1904-PKG=${2}
1905-
1906-TDIR=$(mktemp -d)
1907-
1908-getchdist () {
1909- local name=${1}
1910- chdist --data-dir=${TDIR} create ${REL}-${name} 1>/dev/null
1911- cat << EOF > ${TDIR}/${REL}-${name}/etc/apt/sources.list
1912-deb http://de.archive.ubuntu.com/ubuntu/ ${REL} main restricted universe multiverse
1913-deb-src http://de.archive.ubuntu.com/ubuntu/ ${REL} main restricted universe multiverse
1914-deb http://de.archive.ubuntu.com/ubuntu/ ${REL}-updates main restricted universe multiverse
1915-deb-src http://de.archive.ubuntu.com/ubuntu/ ${REL}-updates main restricted universe multiverse
1916-deb http://de.archive.ubuntu.com/ubuntu/ ${REL}-backports main restricted universe multiverse
1917-deb-src http://de.archive.ubuntu.com/ubuntu/ ${REL}-backports main restricted universe multiverse
1918-
1919-deb http://de.archive.ubuntu.com/ubuntu/ ${REL}-proposed main restricted universe multiverse
1920-deb-src http://de.archive.ubuntu.com/ubuntu/ ${REL}-proposed main restricted universe multiverse
1921-
1922-deb-src http://archive.canonical.com/ubuntu ${REL} partner
1923-
1924-deb http://security.ubuntu.com/ubuntu ${REL}-security main restricted
1925-deb-src http://security.ubuntu.com/ubuntu ${REL}-security main restricted
1926-deb http://security.ubuntu.com/ubuntu ${REL}-security universe
1927-deb-src http://security.ubuntu.com/ubuntu ${REL}-security universe
1928-deb http://security.ubuntu.com/ubuntu ${REL}-security multiverse
1929-deb-src http://security.ubuntu.com/ubuntu ${REL}-security multiverse
1930-EOF
1931-}
1932-
1933-getchdist "proposed-only"
1934-sed -i -e '/proposed/!d' ${TDIR}/${REL}-proposed-only/etc/apt/sources.list
1935-getchdist "proposed"
1936-
1937-chdist --data-dir=${TDIR} apt ${REL}-proposed-only update 1>/dev/null
1938-chdist --data-dir=${TDIR} apt ${REL}-proposed update 1>/dev/null
1939-
1940-chdist --data-dir=${TDIR} apt-cache ${REL}-proposed rdepends ${PKG} > ${TDIR}/rdepends
1941-cat ${TDIR}/rdepends |xargs -n1 chdist --data-dir=${TDIR} bin2src ${REL}-proposed | sort | uniq > ${TDIR}/rdepends-src
1942-cat ${TDIR}/rdepends-src |xargs -n1 chdist --data-dir=${TDIR} apt-cache ${REL}-proposed-only showsrc 2>/dev/null | grep-dctrl -nsPackage . > ${TDIR}/overlap
1943-
1944-ls -ltr ${TDIR}
1945-
1946-printf "\n\nYou might need to rebuild (*currently in proposed)\n"
1947-while read -r line; do
1948- if grep -q -e "^$line$" ${TDIR}/overlap; then
1949- printf "* "
1950- fi
1951- echo "$line"
1952-done < ${TDIR}/rdepends-src
1953diff --git a/cpaelzer/TrelloToJira.py b/cpaelzer/TrelloToJira.py
1954new file mode 100755
1955index 0000000..9267d9b
1956--- /dev/null
1957+++ b/cpaelzer/TrelloToJira.py
1958@@ -0,0 +1,75 @@
1959+#!/usr/bin/env python3
1960+"""
1961+Convert trello (CSV) Data to Jira entries
1962+
1963+One might wonder that there is no better way, but even the pro products
1964+that exist seem more complex. If you just want to migrate a bunch of cards
1965+this appeared to be the most simple way and worked quite well.
1966+
1967+It should be a good start to derive other solutions from, if needed.
1968+"""
1969+
1970+import argparse
1971+import csv
1972+from jira import JIRA
1973+
1974+def main(filename, token, accountid, tag, user, server):
1975+ jiracon = JIRA(basic_auth=(user, token), server=server)
1976+
1977+ with open(filename, "r", newline='', encoding="utf-8") as csvfile:
1978+ reader = csv.reader(csvfile, delimiter=',', quotechar='"')
1979+ for row in reader:
1980+
1981+ # Header of the card
1982+ summary = row[1]
1983+ # Body of the card
1984+ description = row[3]
1985+
1986+ archived = row[18]
1987+ if archived == "true":
1988+ print("Skip Archived '%s'" % summary)
1989+ continue
1990+
1991+ new_tags = []
1992+ new_tags.append(tag)
1993+ # add any special tag conditions here to the list - you can process
1994+ # tags = row[4]
1995+ # which is the lost of tags from trello
1996+
1997+ print("Create %s with tags '%s'" % (summary, new_tags))
1998+
1999+ new_issue = jiracon.create_issue(project='SD',
2000+ summary=summary,
2001+ description=description,
2002+ issuetype={'name': 'Story'})
2003+ for new_tag in new_tags:
2004+ new_issue.fields.labels.append(new_tag)
2005+ new_issue.update(fields={"labels": new_issue.fields.labels})
2006+
2007+ print(" Done - new ID %s" % (new_issue))
2008+
2009+
2010+if __name__ == '__main__':
2011+ PARSER = argparse.ArgumentParser()
2012+ # Trello CSV export is rather readable and static
2013+ # Worst case one can easily manually edit it (mcuh easier than the json).
2014+ # json is more complete as it has all the object hierarchy and even history
2015+ # but that also makes it hard to process for simple use cases.
2016+ # Get it via "Show Menu" - "more" - "Print and export" - "export as CSV"
2017+ PARSER.add_argument('filename',
2018+ help='CVS File to read data from (exported from Trello)')
2019+ PARSER.add_argument('--token',
2020+ help='Token from https://id.atlassian.com/manage-profile/security/api-tokens')
2021+ PARSER.add_argument('--accountid',
2022+ help='ID of the person to assign items, fetched to from https://warthogs.atlassian.net/rest/api/3/user/search?query=<email>')
2023+ PARSER.add_argument('--tag',
2024+ help='A tag to be able to differentiate these from the many other items in the backlog')
2025+ PARSER.add_argument('--user',
2026+ help='Username (email) to log into Jira')
2027+ PARSER.add_argument('--server',
2028+ help='Jira Server to connect to',
2029+ default='https://warthogs.atlassian.net')
2030+ ARGS = PARSER.parse_args()
2031+
2032+ main(ARGS.filename, ARGS.token, ARGS.accountid, ARGS.tag, ARGS.user,
2033+ ARGS.server)
2034diff --git a/cpaelzer/autopkgtests-running.sh b/cpaelzer/autopkgtests-running.sh
2035new file mode 100755
2036index 0000000..12877aa
2037--- /dev/null
2038+++ b/cpaelzer/autopkgtests-running.sh
2039@@ -0,0 +1,6 @@
2040+#!/bin/bash
2041+wget -O - -q http://autopkgtest.ubuntu.com/running \
2042+ | grep -e '<tr><th>Architecture:</th><td>.*</td></tr>' - \
2043+ | sed 's/<tr><th>Architecture:<\/th><td>//' \
2044+ | sed 's/<\/td><\/tr>//' \
2045+ | sort | uniq -c | sort -rn
2046diff --git a/cpaelzer/build-for-ppa.sh b/cpaelzer/build-for-ppa.sh
2047new file mode 100755
2048index 0000000..fb7f15e
2049--- /dev/null
2050+++ b/cpaelzer/build-for-ppa.sh
2051@@ -0,0 +1,30 @@
2052+#!/bin/bash
2053+# linked as `bp` in ~/bin/ for quick access
2054+set -uxe
2055+
2056+cver=$(dpkg-parsechangelog --show-field Version)
2057+crel=$(dpkg-parsechangelog --show-field Distribution)
2058+clbckp=$(mktemp)
2059+cp debian/changelog "${clbckp}"
2060+
2061+if [[ "${cver}" =~ "ppa" ]]; then
2062+ # already has a ppa string, only increment
2063+ dch -i --preserve "PPA build"
2064+else
2065+ # find non existing ppa suffix
2066+ for i in {1..100}; do
2067+ newver="${cver}~${crel}ppa${i}"
2068+ nonepoch=$(echo "${newver}" | sed 's/[0-9]://')
2069+ if ! ls ../*${nonepoch}* 1>/dev/null 2>&1; then
2070+ break
2071+ fi
2072+ done
2073+ sed -i -e "1 s/ (.*) / (${newver}) /" debian/changelog
2074+fi
2075+
2076+# build source
2077+dpkg-buildpackage -S -nc -d -sa
2078+
2079+# Restore/Clean
2080+cp "${clbckp}" debian/changelog
2081+rm -f debian/files
2082diff --git a/buildpkg-qemu.sh b/cpaelzer/buildpkg-qemu.sh
2083similarity index 96%
2084rename from buildpkg-qemu.sh
2085rename to cpaelzer/buildpkg-qemu.sh
2086index c9f3d10..9c6772f 100755
2087--- a/buildpkg-qemu.sh
2088+++ b/cpaelzer/buildpkg-qemu.sh
2089@@ -37,5 +37,9 @@ rm -f debian/control
2090 ./debian/rules debian/control
2091 chmod +w debian/control
2092
2093+# Old qemu had empty dirs, but that will end up in the tarball and
2094+# complain about mismatches
2095+find -name ..git -exec rm -f {} \;
2096+
2097 # Build pkg and add any extra arguments
2098 dpkg-buildpackage -S -nc -d $@
2099diff --git a/check-OS-packages-on-server-mapping.sh b/cpaelzer/check-OS-packages-on-server-mapping.sh
2100similarity index 100%
2101rename from check-OS-packages-on-server-mapping.sh
2102rename to cpaelzer/check-OS-packages-on-server-mapping.sh
2103diff --git a/check-autopkgtest-stats.sh b/cpaelzer/check-autopkgtest-stats.sh
2104similarity index 72%
2105rename from check-autopkgtest-stats.sh
2106rename to cpaelzer/check-autopkgtest-stats.sh
2107index be40820..d0ae31d 100755
2108--- a/check-autopkgtest-stats.sh
2109+++ b/cpaelzer/check-autopkgtest-stats.sh
2110@@ -1,17 +1,18 @@
2111 #!/bin/bash
2112 RELEASES="$(distro-info --supported | xargs)"
2113-ARCHES="amd64 i386 ppc64el s390x armhf"
2114+ARCHES="amd64 i386 ppc64el s390x armhf arm64"
2115 PACKAGE="systemd"
2116 PATTERN=""
2117 COUNT=20
2118 VERBOSE=0
2119+NOCLEAN=0
2120 WDIR=""
2121 PATTERNLOG="custom-pattern.log"
2122
2123-while getopts "hp:P:a:r:c:v" opt; do
2124+while getopts "hp:P:a:r:c:vC" opt; do
2125 case "$opt" in
2126 h|\?)
2127- echo "$0 [-p <src:package>] [-r 'list of releases'] [-a 'list of architectures'] [-v] [-P 'pattern' to be summed up] [-c <count> to check (default 20)]"
2128+ echo "$0 [-p <src:package>] [-r 'list of releases'] [-a 'list of architectures'] [-v] [-C] [-P 'pattern' to be summed up] [-c <count> to check (default 20)]"
2129 exit 0
2130 ;;
2131 p) PACKAGE=$OPTARG
2132@@ -24,6 +25,8 @@ while getopts "hp:P:a:r:c:v" opt; do
2133 ;;
2134 c) COUNT=$OPTARG
2135 ;;
2136+ C) NOCLEAN=1
2137+ ;;
2138 v) VERBOSE=1
2139 ;;
2140 esac
2141@@ -32,7 +35,7 @@ done
2142 echo "Check last ${COUNT} test results for src:${PACKAGE} on releases '${RELEASES}' on architectures '${ARCHES}'"
2143
2144 cleanup() {
2145- if [[ -n "${WDIR}" && -d "${WDIR}" && ${WDIR} == /tmp/* ]]; then
2146+ if [[ ${NOCLEAN} -ne 1 && -n "${WDIR}" && -d "${WDIR}" && ${WDIR} == /tmp/* ]]; then
2147 rm -Rf "${WDIR}"
2148 fi
2149 }
2150@@ -47,22 +50,37 @@ WDIR=$(mktemp -d) || { echo "failed to make tempdir"; exit 1; }
2151 trap cleanup EXIT
2152 cd ${WDIR}
2153
2154-echo "Fetch Data to ${WDIR}"
2155+if [ ${VERBOSE} -eq 1 ]; then
2156+ echo "Fetch Data to ${WDIR}"
2157+fi
2158+
2159 for arch in ${ARCHES}; do
2160 debug "A: ${arch}"
2161 for release in ${RELEASES}; do
2162 debug " R: ${arch}-${release}"
2163 wget --quiet "http://autopkgtest.ubuntu.com/packages/${PACKAGE:0:1}/${PACKAGE}/${release}/${arch}" -O "${release}-${arch}.history"
2164+ debug " U: http://autopkgtest.ubuntu.com/packages/${PACKAGE:0:1}/${PACKAGE}/${release}/${arch}"
2165 logs=$(awk -F '"' '/>log<\/a>/ {print $2}' "${release}-${arch}.history" | head -n "${COUNT}")
2166 i=0
2167 for log in ${logs}; do
2168- debug " L: ${release}-${arch}.$((++i))"
2169+ debug " L: ${release}-${arch}.$((++i)) => ${log}"
2170 wget --quiet "${log}" -O "${release}-${arch}.${i}" &
2171 done
2172 done
2173 done
2174 wait
2175
2176+badtest() {
2177+ for testname in "${!FAILLOG[@]}"; do
2178+ FAILLOG["${testname}"]="${FAILLOG["${testname}"]}B"
2179+ done
2180+}
2181+
2182+timeouttest() {
2183+ for testname in "${!FAILLOG[@]}"; do
2184+ FAILLOG["${testname}"]="${FAILLOG["${testname}"]}T"
2185+ done
2186+}
2187 tracefaillog() {
2188 tlist="${1}"
2189 symbol="${2}"
2190@@ -81,10 +99,14 @@ for release in ${RELEASES}; do
2191 failures=""
2192 unset FAILLOG
2193 declare -A FAILLOG
2194- for log in $(ls ${release}-${arch}.[0-9]*); do
2195- newfail="$(zcat "${log}" | sed -n -e '/^autopkgtest.*summary/,$p' | awk '/FAIL/ {print $1}')"
2196- newpass="$(zcat "${log}" | sed -n -e '/^autopkgtest.*summary/,$p' | awk '/PASS/ {print $1}')"
2197- newskip="$(zcat "${log}" | sed -n -e '/^autopkgtest.*summary/,$p' | awk '/SKIP/ {print $1}')"
2198+ for log in $(ls -v ${release}-${arch}.[0-9]*); do
2199+ # some aborts have what seems like results in between (recursive runs), ignore all but the last 100 lines
2200+ # furthermore some results get reported twice
2201+ zcat "${log}" | tail -n 150 | sed -ne '/^autopkgtest.*@@.*summary$/,$ p' | sort | uniq > "${log}.results"
2202+ newfail="$(awk '/\sFAIL\s/ {print $1}' ${log}.results)"
2203+ newpass="$(awk '/\sPASS$/ {print $1}' ${log}.results)"
2204+ newskip="$(awk '/\sSKIP\s/ {print $1}' ${log}.results)"
2205+ newflak="$(awk '/\sFLAKY\s/ {print $1}' ${log}.results)"
2206 if [ -n "${PATTERN}" ]; then
2207 zcat "${log}" | grep -e "${PATTERN}" >> "${PATTERNLOG}"
2208 fi
2209@@ -94,14 +116,32 @@ for release in ${RELEASES}; do
2210 tracefaillog "${newfail}" "F"
2211 tracefaillog "${newpass}" "."
2212 tracefaillog "${newskip}" "S"
2213+ tracefaillog "${newflak}" "f"
2214+ if [[ -z "${newfail}${newpass}${newskip}${newflak}" ]]; then
2215+ if zcat "${log}" | grep -q '<VirtSubproc>: failure: Timed out on waiting for ssh connection'; then
2216+ timeouttest
2217+ else
2218+ badtest
2219+ fi
2220+ fi
2221 done
2222 printf " ${arch}\n"
2223 if [ -n "${failures}" ]; then
2224- countedfails=$(echo "${failures}" | sed -r '/^\s*$/d' | sort | uniq -c | awk --assign count=${COUNT} '{ percent=($1/count)*100; printf("%-40s (%6.2lf%%)\n", $0, percent)}')
2225- while read -r line; do
2226- testname=$(echo ${line} | awk '{print $2}' | tr -d .)
2227- printf "%50s %s\n" "${line}" ${FAILLOG["${testname}"]}
2228- done <<< "${countedfails}"
2229+ for testname in "${!FAILLOG[@]}"; do
2230+ countfail=$(echo ${FAILLOG["${testname}"]} | tr -cd 'F' | wc -c)
2231+ countskip=$(echo ${FAILLOG["${testname}"]} | tr -cd 'S' | wc -c)
2232+ countpass=$(echo ${FAILLOG["${testname}"]} | tr -cd '.' | wc -c)
2233+ countflak=$(echo ${FAILLOG["${testname}"]} | tr -cd 'f' | wc -c)
2234+ countbad=$(echo ${FAILLOG["${testname}"]} | tr -cd 'B' | wc -c)
2235+ if [ $COUNT -ne $((countpass+countbad)) ]; then
2236+ printf " %-30s (F %2u%% f %2u%% S %2u%% B %2u%% => P %2u%%/) %s\n" \
2237+ "${testname}" \
2238+ "$((countfail*100/COUNT))" "$((countflak*100/COUNT))" \
2239+ "$((countskip*100/COUNT))" \
2240+ "$((countbad*100/COUNT))" "$((countpass*100/COUNT))" \
2241+ ${FAILLOG["${testname}"]}
2242+ fi
2243+ done
2244 else
2245 echo " no failures"
2246 fi
2247diff --git a/check-component-mismatches-v2.sh b/cpaelzer/check-component-mismatches-v2.sh
2248similarity index 100%
2249rename from check-component-mismatches-v2.sh
2250rename to cpaelzer/check-component-mismatches-v2.sh
2251diff --git a/check-component-mismatches.sh b/cpaelzer/check-component-mismatches.sh
2252similarity index 100%
2253rename from check-component-mismatches.sh
2254rename to cpaelzer/check-component-mismatches.sh
2255diff --git a/dput b/cpaelzer/dput
2256similarity index 84%
2257rename from dput
2258rename to cpaelzer/dput
2259index 54aedcf..4523488 100755
2260--- a/dput
2261+++ b/cpaelzer/dput
2262@@ -5,6 +5,16 @@ CMD="/usr/bin/dput"
2263 # Checker for silly mistakes (I seem to have others than other people)
2264 # So I need to check mine on my own
2265
2266+if [ "$#" -ne 2 ]; then
2267+ echo "Usage with two args: ubuntu/ftp-master .changes-file, got $@"
2268+ exit 1
2269+fi
2270+
2271+if grep "LP:.*9999" $2; then
2272+ echo "Likely left a placeholder in the changelog"
2273+ err=1
2274+fi
2275+
2276 if [ -z "$2" ]; then
2277 echo "Only one Arg is unsafe (and would break later)"
2278 err=1
2279diff --git a/cpaelzer/excuses-top-blocker.sh b/cpaelzer/excuses-top-blocker.sh
2280new file mode 100755
2281index 0000000..5941819
2282--- /dev/null
2283+++ b/cpaelzer/excuses-top-blocker.sh
2284@@ -0,0 +1,4 @@
2285+f=$(mktemp)
2286+wget https://people.canonical.com/~ubuntu-archive/proposed-migration/update_excuses.html -O $f
2287+awk '/not considered/ {gsub(".*a href=\"#",""); gsub("\">.*",""); print $0}' $f | sort | uniq -c | sort -n
2288+rm $f
2289diff --git a/get-packages-subscribed.py b/cpaelzer/get-packages-subscribed.py
2290similarity index 98%
2291rename from get-packages-subscribed.py
2292rename to cpaelzer/get-packages-subscribed.py
2293index ae14b7f..9ac37bc 100755
2294--- a/get-packages-subscribed.py
2295+++ b/cpaelzer/get-packages-subscribed.py
2296@@ -1,4 +1,4 @@
2297-#! /usr/bin/python
2298+#! /usr/bin/python3
2299 """
2300 Derived from ubuntu-archive-tools package-subscribers to detemine
2301 the list of subscribers for a Team
2302diff --git a/git-to-dquilt.sh b/cpaelzer/git-to-dquilt.sh
2303similarity index 62%
2304rename from git-to-dquilt.sh
2305rename to cpaelzer/git-to-dquilt.sh
2306index 0296191..3855bb3 100755
2307--- a/git-to-dquilt.sh
2308+++ b/cpaelzer/git-to-dquilt.sh
2309@@ -5,6 +5,12 @@ set -uxe
2310 # git-to-dquilt.sh <bugnumber>|none git-base-url commit[, ...]
2311 # will apply commits in order and convert to d/p/ entries with dep3 headers
2312
2313+if [ -e "${HOME}/.quiltrc-dpkg" ]; then
2314+ QUILTRC="${HOME}/.quiltrc-dpkg"
2315+else
2316+ QUILTRC="${HOME}/.quiltrc"
2317+fi
2318+
2319 insert_patch_template() {
2320 local patch=${1}
2321 local commiturl=${2}
2322@@ -15,7 +21,11 @@ insert_patch_template() {
2323 then
2324 echo ""
2325 echo "Origin: upstream, ${commiturl}"
2326- if [[ ${BUG} != "none" ]]; then
2327+ if [[ ${BUG} == SF* ]]; then
2328+ echo "Bug-SF: ${BUG}"
2329+ elif [[ ${BUG} == CVE* ]]; then
2330+ echo "CVE: https://ubuntu.com/security/${BUG}"
2331+ elif [[ ${BUG} != "none" ]]; then
2332 echo "Bug-Ubuntu: https://bugs.launchpad.net/bugs/${BUG}"
2333 fi
2334 echo "Last-Update: $(date +%F)"
2335@@ -48,17 +58,28 @@ get_commit_id() {
2336 }
2337
2338 apply_commit() {
2339- commit=${1}
2340+ local commit=${1}
2341+ local suffix=""
2342+ local patch=""
2343+ local prefix="${PREFIX}"
2344
2345 patch=$(git format-patch -1 "${commit}")
2346- if [ $(pwd) == *libvirt* || $(pwd) == *qemu* ]; then
2347- prefix="ubuntu"
2348- else
2349- prefix=""
2350+ # auto prefix detection for some projects if not set externally
2351+ if [ -z "${PREFIX}" ]; then
2352+ if [[ $(pwd) == *libvirt* || $(pwd) == *qemu* ]]; then
2353+ prefix="ubuntu/"
2354+ else
2355+ prefix=""
2356+ fi
2357 fi
2358+ [[ -n "${prefix}" && "${prefix}" != */ ]] && prefix="${prefix}/"
2359
2360 if [[ ${BUG} == "none" ]]; then
2361 patch=$(rename -v "s/000[0-9]-//" "${patch}" | awk '{print $NF}')
2362+ elif [[ ${BUG} == SF* ]]; then
2363+ patch=$(rename -v "s/000[0-9]/sf-${BUG}/" "${patch}" | awk '{print $NF}')
2364+ elif [[ ${BUG} == CVE* ]]; then
2365+ patch=$(rename -v "s/000[0-9]/${BUG}/" "${patch}" | awk '{print $NF}')
2366 else
2367 patch=$(rename -v "s/000[0-9]/lp-${BUG}/" "${patch}" | awk '{print $NF}')
2368 fi
2369@@ -66,14 +87,52 @@ apply_commit() {
2370
2371 insert_patch_template "${patch}" "${URL}${commit}"
2372
2373- quilt --quiltrc=/home/paelzer/.quiltrc-dpkg import "${patch}" -P "${prefix}${patch}"
2374- quilt --quiltrc=/home/paelzer/.quiltrc-dpkg push --fuzz=0
2375+ if [ -e "debian/patches/${prefix}${patch}" ]; then
2376+ suffix="1"
2377+ while [ -e "debian/patches/${prefix}${patch}-${suffix}" ]; do
2378+ suffix=$((suffix + 1))
2379+ done
2380+ suffix="-${suffix}"
2381+ fi
2382+
2383+ quilt --quiltrc="${QUILTRC}" import "${patch}" -P "${prefix}${patch}${suffix}"
2384+ quilt --quiltrc="${QUILTRC}" push --fuzz=0
2385 rm "${patch}"
2386 }
2387
2388 if [ $# -lt 3 ]; then
2389- echo "usage $0 <bugnumber>|none git-base-url commit[, ...]"
2390- echo "remember ; in URls will end the command string"
2391+ echo "usage $0 [-b <bugnumber>] -u git-base-url [-p prefix] commit[, ...]"
2392+ echo "-b bug number for dep-3 headers"
2393+ echo "-p prefix for the patch name"
2394+ echo "-u URL to reach the commit"
2395+ echo "remember ; in URls will often include an &, best use '' around it"
2396+ exit 1
2397+fi
2398+
2399+BUG="none"
2400+URL=""
2401+PREFIX=""
2402+
2403+while getopts ":b:u:p:" opt; do
2404+ case ${opt} in
2405+ b )
2406+ BUG=${OPTARG}
2407+ ;;
2408+ u )
2409+ URL=${OPTARG}
2410+ ;;
2411+ p )
2412+ PREFIX=${OPTARG}
2413+ ;;
2414+ \? ) echo "Usage: $0 [-b <bugno>] -u <base-git-URL> [-p <prefix>] git-hash..."
2415+ ;;
2416+ esac
2417+done
2418+shift $((OPTIND-1))
2419+
2420+
2421+if [ -z "${URL}" ]; then
2422+ echo "You must set an URL"
2423 exit 1
2424 fi
2425
2426@@ -85,16 +144,13 @@ fi
2427
2428 # might be the first, can't push in that case
2429 if [ -s debian/patches/series ]; then
2430- quilt --quiltrc=/home/paelzer/.quiltrc-dpkg push -a --fuzz=0
2431+ quilt --quiltrc="${QUILTRC}" push -a --fuzz=0
2432 fi
2433
2434-BUG=${1:-none}
2435-URL=${2:-""}
2436-
2437-for commitid in "${@:3}"; do
2438+for commitid in "${@}"; do
2439 apply_commit "${commitid}"
2440 done
2441
2442-quilt --quiltrc=/home/paelzer/.quiltrc-dpkg pop -a
2443-
2444+# report final status
2445+quilt --quiltrc="${QUILTRC}" pop -a
2446 git status
2447diff --git a/locallibvirt.sh b/cpaelzer/locallibvirt.sh
2448similarity index 100%
2449rename from locallibvirt.sh
2450rename to cpaelzer/locallibvirt.sh
2451diff --git a/localrepo.sh b/cpaelzer/localrepo.sh
2452similarity index 100%
2453rename from localrepo.sh
2454rename to cpaelzer/localrepo.sh
2455diff --git a/lp-affects-devel b/cpaelzer/lp-affects-devel
2456similarity index 100%
2457rename from lp-affects-devel
2458rename to cpaelzer/lp-affects-devel
2459diff --git a/cpaelzer/lp-test-isrunning b/cpaelzer/lp-test-isrunning
2460new file mode 100755
2461index 0000000..fc36d6c
2462--- /dev/null
2463+++ b/cpaelzer/lp-test-isrunning
2464@@ -0,0 +1,61 @@
2465+#!/usr/bin/python3
2466+# Credit goes to APW who shared this with me - thanks!
2467+
2468+import datetime
2469+import os
2470+import sys
2471+
2472+import urllib.request
2473+import json
2474+
2475+#urllib.request.urlcleanup()
2476+request = urllib.request.Request('http://autopkgtest.ubuntu.com/static/running.json')
2477+request.add_header('Cache-Control', 'max-age=0')
2478+with urllib.request.urlopen(request) as response:
2479+ data = response.read()
2480+ jobs = json.loads(data.decode('utf-8'))
2481+
2482+
2483+running = []
2484+for pkg in jobs:
2485+ for handle in jobs[pkg]:
2486+ for series in jobs[pkg][handle]:
2487+ for arch in jobs[pkg][handle][series]:
2488+ jobinfo = jobs[pkg][handle][series][arch]
2489+ triggers = ','.join(jobinfo[0].get('triggers', '-'))
2490+ ppas = ','.join(jobinfo[0].get('ppas', '-'))
2491+ time = jobinfo[1]
2492+ env = jobinfo[0].get('env', '-')
2493+ time = str(datetime.timedelta(seconds=jobinfo[1]))
2494+ try:
2495+ running.append((jobinfo[1], "R {6:6} {0:30} {5:10} {1:8} {2:8} {3:31} {4} {7}".format(pkg, series, arch, ppas, triggers, '-', time, env)))
2496+ except BrokenPipeError:
2497+ sys.exit(1)
2498+
2499+for (time, row) in sorted(running, reverse=True):
2500+ print(row)
2501+
2502+request = urllib.request.Request('http://autopkgtest.ubuntu.com/queues.json')
2503+request.add_header('Cache-Control', 'max-age=0')
2504+with urllib.request.urlopen(request) as response:
2505+ data = response.read()
2506+ queues = json.loads(data.decode('utf-8'))
2507+
2508+ for origin in queues:
2509+ for series in queues[origin]:
2510+ for arch in queues[origin][series]:
2511+ n = 0
2512+ for key in queues[origin][series][arch]:
2513+ (pkg, json_data) = key.split(maxsplit=1)
2514+ jobinfo = json.loads(json_data)
2515+
2516+ triggers = ','.join(jobinfo.get('triggers', '-'))
2517+ ppas = ','.join(jobinfo.get('ppas', '-'))
2518+
2519+ n = n + 1
2520+ try:
2521+ print("Q{5:04d} {7:>6} {0:30} {6:10} {1:8} {2:8} {3:31} {4}".format(pkg, series, arch, ppas, triggers, n, origin, '-:--'))
2522+ except BrokenPipeError:
2523+ sys.exit(1)
2524+
2525+ # /Running for:/ { printf("%-30s %-8s %-8s%-31s%s\n", pkg, release, arch, ppas, triggers); next }
2526diff --git a/cpaelzer/lp-test-ppa b/cpaelzer/lp-test-ppa
2527new file mode 100755
2528index 0000000..b467f2d
2529--- /dev/null
2530+++ b/cpaelzer/lp-test-ppa
2531@@ -0,0 +1,395 @@
2532+#!/usr/bin/env python3
2533+# Thanks to APW for the part around getRunning
2534+
2535+import argparse
2536+import datetime
2537+import gzip
2538+import json
2539+import os
2540+import re
2541+import urllib.request
2542+import urllib.parse
2543+import sys
2544+import time
2545+
2546+from launchpadlib.credentials import UnencryptedFileCredentialStore
2547+from launchpadlib.launchpad import Launchpad
2548+
2549+
2550+def getRunning():
2551+ request = urllib.request.Request('http://autopkgtest.ubuntu.com/static/running.json')
2552+ request.add_header('Cache-Control', 'max-age=0')
2553+ with urllib.request.urlopen(request) as response:
2554+ data = response.read()
2555+ jobs = json.loads(data.decode('utf-8'))
2556+
2557+ running = []
2558+ for pkg in jobs:
2559+ for handle in jobs[pkg]:
2560+ for series in jobs[pkg][handle]:
2561+ for arch in jobs[pkg][handle][series]:
2562+ jobinfo = jobs[pkg][handle][series][arch]
2563+ triggers = ','.join(jobinfo[0].get('triggers', '-'))
2564+ ppas = ','.join(jobinfo[0].get('ppas', '-'))
2565+ time = str(datetime.timedelta(seconds=jobinfo[1]))
2566+ running.append({"time": time,
2567+ "pkg": pkg,
2568+ "release": series,
2569+ "arch": arch,
2570+ "ppa": ppas,
2571+ "trigger": triggers})
2572+
2573+ return sorted(running, key=lambda k: k['time'])
2574+
2575+
2576+def getWaiting():
2577+ request = urllib.request.Request('http://autopkgtest.ubuntu.com/queues.json')
2578+ request.add_header('Cache-Control', 'max-age=0')
2579+ with urllib.request.urlopen(request) as response:
2580+ data = response.read()
2581+ queues = json.loads(data.decode('utf-8'))
2582+
2583+ waiting = []
2584+ for origin in queues:
2585+ for series in queues[origin]:
2586+ for arch in queues[origin][series]:
2587+ n = 0
2588+ for key in queues[origin][series][arch]:
2589+ (pkg, json_data) = key.split(maxsplit=1)
2590+ jobinfo = json.loads(json_data)
2591+
2592+ triggers = ','.join(jobinfo.get('triggers', '-'))
2593+ ppas = ','.join(jobinfo.get('ppas', '-'))
2594+
2595+ n = n + 1
2596+ waiting.append({"number": n,
2597+ "pkg": pkg,
2598+ "release": series,
2599+ "arch": arch,
2600+ "ppa": ppas,
2601+ "trigger": triggers})
2602+
2603+ return waiting
2604+
2605+
2606+def getLink(url, text, end='\n'):
2607+ return f"\u001b]8;;{url}\u001b\\{text}\u001b]8;;\u001b\\"
2608+
2609+
2610+def showTriggers(trigger_name, trigger_version, release,
2611+ ppa_user, ppa_name, test_name):
2612+ urlfmt = ("https://autopkgtest.ubuntu.com/request.cgi?release=%s" +
2613+ "&arch=%s&package=%s&ppa=%s/%s&trigger=%s/%s")
2614+ req_url = urlfmt % (release, "%s", test_name,
2615+ ppa_user, ppa_name, trigger_name,
2616+ "%s")
2617+ enc_version = urllib.parse.quote_plus(trigger_version)
2618+
2619+ # Triggers for all Architectures
2620+ for arch in ARCHES:
2621+ # list src@arch header + triggers
2622+ print(" %20s @ %-7s for %s/%s" % (test_name, arch, trigger_name,
2623+ trigger_version), end='')
2624+ arch_req_url = req_url % (arch, enc_version)
2625+ print(" %s" % getLink(arch_req_url, "Trigger @%s ♻️ " % arch),
2626+ end='')
2627+ print(" %s" % getLink("%s&all-proposed=1" % arch_req_url,
2628+ "Trigger all proposed @%s ♻️ 💍" % arch))
2629+
2630+
2631+def showActive(release, ppa_user, ppa_name):
2632+ target = "%s/%s" % (ppa_user, ppa_name)
2633+ rformat = " %-8s %-40s %-8s %-8s %-40s %s"
2634+
2635+ print("Running:")
2636+ running = getRunning()
2637+ running = [e for e in running if e['release'] == release]
2638+ running = [e for e in running if e['ppa'] == target]
2639+ if running:
2640+ print(rformat % ("time", "pkg", "release", "arch", "ppa", "trigger"))
2641+ for e in running:
2642+ print(rformat % (e['time'], e['pkg'], e['release'], e['arch'],
2643+ e['ppa'], e['trigger']))
2644+
2645+ print("Waiting:")
2646+ waiting = getWaiting()
2647+ waiting = [e for e in waiting if e['release'] == release]
2648+ waiting = [e for e in waiting if e['ppa'] == target]
2649+ if waiting:
2650+ print(rformat % ("Q-num", "pkg", "release", "arch", "ppa", "trigger"))
2651+ for e in waiting:
2652+ print(rformat % (e['number'], e['pkg'], e['release'], e['arch'],
2653+ e['ppa'], e['trigger']))
2654+
2655+
2656+def showResults(release, ppa_user, ppa_name, published):
2657+ resfmt = ("https://autopkgtest.ubuntu.com/results/" +
2658+ "autopkgtest-%s-%s-%s/?format=plain")
2659+ result_list = resfmt % (release, ppa_user, ppa_name)
2660+
2661+ base_resultfmt = ("https://autopkgtest.ubuntu.com/results/" +
2662+ "autopkgtest-%s-%s-%s/")
2663+ base_result = base_resultfmt % (release, ppa_user, ppa_name)
2664+
2665+ print("Results from %s:" % result_list)
2666+ results_web = []
2667+ try:
2668+ with urllib.request.urlopen(result_list) as response:
2669+ html = response.read()
2670+ results_web = html.split(b'\n')
2671+ except urllib.error.HTTPError:
2672+ print(" No results published yet")
2673+
2674+ # gather results
2675+ result_data = {}
2676+ for result in results_web:
2677+ if result == b'' or not result.endswith(b"log.gz"):
2678+ continue
2679+ res_url = base_result + result.decode("utf-8")
2680+ res_elements = res_url.split("/")
2681+ res_time = time.strptime(res_elements[9][:-7], "%Y%m%d_%H%M%S")
2682+ res_arch = res_elements[6]
2683+ res_source = res_elements[8]
2684+ if (res_source, res_arch) not in result_data:
2685+ result_data[(res_source, res_arch)] = []
2686+ result_data[(res_source, res_arch)].append((res_time, res_url))
2687+
2688+ # report
2689+ for source_arch in result_data:
2690+ # skip non selected architectures
2691+ if source_arch[1] not in ARCHES:
2692+ continue
2693+ # if packagestoshow is set, skip all others
2694+ if args.packagestoshow:
2695+ if source_arch[0] not in args.packagestoshow[0]:
2696+ continue
2697+
2698+ # header
2699+ print(" %s @ %s:" % (source_arch[0], source_arch[1]))
2700+ if args.showonlylast:
2701+ result_data[source_arch] = [result_data[source_arch][-1]]
2702+ for result in result_data[source_arch]:
2703+ showResult(result, published)
2704+
2705+
2706+def showResultID(result):
2707+ print(" %10s" % time.strftime("%d.%m.%y %H:%M:%S", result[0]), end='')
2708+ print(" %s" % getLink(result[1], "Log 🗒️"), end='')
2709+
2710+
2711+def showResult(result, published):
2712+ with urllib.request.urlopen(result[1]) as result_response:
2713+ result_gzip = result_response.read()
2714+ try:
2715+ result_log = gzip.decompress(result_gzip).decode("utf-8")
2716+ except UnicodeDecodeError:
2717+ showResultID(result)
2718+ print("\n Broken Test Log ⚪")
2719+ return
2720+
2721+ trigger = []
2722+ res_trigger = re.search("--env=ADT_TEST_TRIGGERS=.* -- ", result_log)
2723+ if not res_trigger:
2724+ report_txt = " Trigger not listed in log ⚪"
2725+ else:
2726+ res_trigger = res_trigger.group(0)
2727+ res_trigger = res_trigger[len("--env=ADT_TEST_TRIGGERS="):]
2728+ res_trigger = res_trigger[:res_trigger.find(" -- ")]
2729+ res_trigger = res_trigger.strip("'")
2730+ trigger = res_trigger.split()
2731+ if args.trigger and args.trigger not in trigger:
2732+ return
2733+ report_txt = (" Triggers: %s" % trigger)
2734+
2735+ PublishedInTrigger = False
2736+ if args.selecttrigger == "published":
2737+ for pubpkg in published:
2738+ published_trigger = "%s/%s" % (pubpkg['pkg'], pubpkg['vers'])
2739+ if published_trigger in trigger:
2740+ PublishedInTrigger = True
2741+ elif args.selecttrigger is not None:
2742+ if args.selecttrigger in trigger:
2743+ PublishedInTrigger = True
2744+ else:
2745+ PublishedInTrigger = True
2746+ if not PublishedInTrigger:
2747+ return
2748+
2749+ showResultID(result)
2750+ result_split = result_log.split("@@@@@@@@@@@@@@@@@@@@ summary", 1)
2751+ if len(result_split) < 2:
2752+ print("\t⚪ %s\n" % report_txt, end='')
2753+ print(" %-50s" % ("No valid results"))
2754+ return
2755+ result_sum = result_split[1]
2756+ result_lines = re.findall("(.*PASS|.*SKIP|.*FAIL|.*BAD)", result_sum)
2757+
2758+ for line in result_lines:
2759+ report_result = True
2760+ overall_status = "✅"
2761+ status = "⚪"
2762+ if args.subtest and not line.startswith(args.subtest):
2763+ report_result = False
2764+ if line.endswith("SKIP"):
2765+ status = "🟧"
2766+ if not args.showskip:
2767+ report_result = False
2768+ if line.endswith("PASS"):
2769+ status = "✅"
2770+ if not args.showpass:
2771+ report_result = False
2772+ if line.endswith("FAIL"):
2773+ status = "🟥"
2774+ overall_status = "🟥"
2775+ if report_result:
2776+ report_txt += ("\n %-50s %s " % (line, status))
2777+
2778+ print("\t%s %s" % (overall_status, report_txt))
2779+
2780+
2781+# Argument parsing
2782+parser = argparse.ArgumentParser()
2783+parser.add_argument('ppa',
2784+ default=None,
2785+ help='name of the ppa to test in ppa:user/name format')
2786+parser.add_argument('-r', '--release',
2787+ default=None,
2788+ action='append',
2789+ nargs='+',
2790+ dest="releases",
2791+ help='release(s) to test')
2792+parser.add_argument('-a', '--arch',
2793+ default=None,
2794+ action='append',
2795+ nargs='+',
2796+ dest="arches",
2797+ help='Architectures to process (default = all)')
2798+parser.add_argument('-t', '--testpackage',
2799+ default=None,
2800+ action='append',
2801+ nargs='+',
2802+ dest="testpackages",
2803+ help='Additional packages to list trigger links for')
2804+parser.add_argument('-p', '--package',
2805+ default=None,
2806+ action='append',
2807+ nargs='+',
2808+ dest="packagestoshow",
2809+ help='Only interested in the results of <package>')
2810+parser.add_argument('-s', '--subtest',
2811+ default=None,
2812+ dest="subtest",
2813+ help='Only report (sub)tests with the given name')
2814+parser.add_argument('--trigger',
2815+ default=None,
2816+ dest="trigger",
2817+ help='Only report results that contain this trigger')
2818+parser.add_argument('--showpass',
2819+ default=False,
2820+ dest="showpass",
2821+ action="store_true",
2822+ help='Show passing subtests'
2823+ ' (overall status is always shown)')
2824+parser.add_argument('--showskip',
2825+ default=False,
2826+ dest="showskip",
2827+ action="store_true",
2828+ help='Show skipped subtests'
2829+ ' (overall status is always shown)')
2830+parser.add_argument('-l', '--last',
2831+ default=False,
2832+ dest="showonlylast",
2833+ action="store_true",
2834+ help='Show only the last test result per test')
2835+parser.add_argument('-f', '--select-trigger',
2836+ default=None,
2837+ dest="selecttrigger",
2838+ help='Show only results which trigger contains this string'
2839+ '; Special value "published" only shows if any of the'
2840+ ' currently published source/versions are in the'
2841+ ' triggers.')
2842+args = parser.parse_args()
2843+
2844+ppa_user = args.ppa.split(":")[1].split("/")[0]
2845+ppa_name = args.ppa.split(":")[1].split("/")[1]
2846+
2847+# log in
2848+cred_location = os.path.expanduser('~/.lp_creds')
2849+credential_store = UnencryptedFileCredentialStore(cred_location)
2850+lp = Launchpad.login_with('affectrelease', 'production', version='devel')
2851+
2852+# project/person owning the PPA
2853+person = lp.people[ppa_user]
2854+
2855+if args.arches:
2856+ ARCHES = args.arches[0]
2857+else:
2858+ ARCHES = ["amd64", "s390x", "ppc64el", "arm64", "armhf", "riscv64"]
2859+
2860+# get ppa
2861+ppa = person.getPPAByName(name=ppa_name)
2862+if ppa is not None:
2863+ print("Tests for %s" % getLink(ppa.web_link, "PPA %s" % ppa_name))
2864+ for release in args.releases[0]:
2865+ print("---- ---- ---- ----")
2866+ print("Release: %s" % release)
2867+ series = "https://api.launchpad.net/1.0/ubuntu/%s" % release
2868+ ppa_sources = ppa.getPublishedSources(distro_series=series)
2869+ if not ppa_sources:
2870+ print("Warning: no sources present for %s" % release)
2871+ else:
2872+ print("Sources:")
2873+ for source in ppa_sources:
2874+ print(" SRC: %s @ %s - %s" % (source.source_package_name,
2875+ source.source_package_version,
2876+ source.status))
2877+ print("Triggers on published Sources:")
2878+ published = []
2879+ for source in ppa_sources:
2880+ if source.status != "Published":
2881+ continue
2882+
2883+ showTriggers(source.source_package_name,
2884+ source.source_package_version,
2885+ release, ppa_user, ppa_name,
2886+ source.source_package_name)
2887+ published.append({"pkg": source.source_package_name,
2888+ "vers": source.source_package_version})
2889+
2890+ if args.testpackages:
2891+ for test_name in args.testpackages[0]:
2892+ print("Requested tests triggered vs published sources:")
2893+ showTriggers(source.source_package_name,
2894+ source.source_package_version, release,
2895+ ppa_user, ppa_name, test_name)
2896+
2897+ showResults(release, ppa_user, ppa_name, published)
2898+ showActive(release, ppa_user, ppa_name)
2899+else:
2900+ print("Error: PPA %s not found" % ppa_name)
2901+ sys.exit(1)
2902+
2903+
2904+# FYI - Bryce has a tool for the earlier steps that does:
2905+# - open and configure a PPA
2906+# - upload changes and build
2907+# - wait for the buidl to be complete
2908+# it is yet unpublished, but I'll remove my former todo's for this stages
2909+
2910+# TODO
2911+# - get release from PPA (if not set on cmdline)
2912+# - cmdline: restart-all-failed (and only those)
2913+# - cmdline: trigger-tests-for-all-not-yet-sucess-tested-sources-in-ppa
2914+# - if tests results are present, then also show triggers for them (even if we
2915+# have no source of it)
2916+# - do not show header and log is "skipshow" is set and all results are good
2917+# - split "showResult" into "parseResult" filling an object/struct to then
2918+# have much more clear logic control flow on that and eventually print it
2919+# in "showResult"
2920+# - a ppa can have multiple revisions of a package. Usually one is only
2921+# interested in the tests of the last one, provide an option to filter
2922+# out the others
2923+# - let all show* functions support filtering per selected Architecture
2924+# We don't open anything automatically yet, if we want (e.g. retry all failed)
2925+# import webbrowser
2926+# webbrowser.open(url[, new=0[, autoraise=True]])
2927diff --git a/packageset-subscription-mismatches.sh b/cpaelzer/packageset-subscription-mismatches.sh
2928similarity index 100%
2929rename from packageset-subscription-mismatches.sh
2930rename to cpaelzer/packageset-subscription-mismatches.sh
2931diff --git a/pull-uca-source.py b/cpaelzer/pull-uca-source.py
2932similarity index 100%
2933rename from pull-uca-source.py
2934rename to cpaelzer/pull-uca-source.py
2935diff --git a/cpaelzer/rma b/cpaelzer/rma
2936new file mode 100755
2937index 0000000..4ccbc3b
2938--- /dev/null
2939+++ b/cpaelzer/rma
2940@@ -0,0 +1,6 @@
2941+#!/bin/bash
2942+for p in $@; do
2943+ rmadison -u debian $p &
2944+ rmadison $p &
2945+done
2946+wait
2947diff --git a/sbuildchroot b/cpaelzer/sbuildchroot
2948similarity index 100%
2949rename from sbuildchroot
2950rename to cpaelzer/sbuildchroot
2951diff --git a/testify.sh b/cpaelzer/testify.sh
2952similarity index 100%
2953rename from testify.sh
2954rename to cpaelzer/testify.sh
2955diff --git a/cpaelzer/update-git-ubuntu-urls.sh b/cpaelzer/update-git-ubuntu-urls.sh
2956new file mode 100755
2957index 0000000..f121417
2958--- /dev/null
2959+++ b/cpaelzer/update-git-ubuntu-urls.sh
2960@@ -0,0 +1,27 @@
2961+#!/bin/bash
2962+checked=0
2963+updated=0
2964+found=0
2965+for repo in $(find ~/ -name .git -type d 2>/dev/null); do
2966+ ((checked++))
2967+ path="$(dirname $repo)"
2968+ cd "$path"
2969+ if git remote -v | grep '^pkg\s' | grep -q usd-import-team; then
2970+ echo "Repo $repo uses the old style, updating"
2971+ ((found++))
2972+ pkg1=$(git show pkg/ubuntu/devel:debian/control 2>/dev/null | awk '/^Source:/{print $2}')
2973+ if [ -z "$pkg1" ]; then
2974+ # local import
2975+ pkg1=$(git show importer/ubuntu/devel:debian/control 2>/dev/null | awk '/^Source:/{print $2}')
2976+ fi
2977+ pkg2=$(git remote -v | grep '^pkg\s' | grep usd-import-team | awk --field-separator '/' '{gsub(" .*$","",$7); print $7}' | uniq)
2978+ if [ "$pkg1" != "$pkg2" ]; then
2979+ echo "Fail: Source $pkg1 and repo $pkg2 mismatch, unsure what to do"
2980+ continue
2981+ fi
2982+ ((updated++))
2983+ git remote set-url pkg https://git.launchpad.net/ubuntu/+source/$pkg1
2984+ git remote set-url pkg --push ssh://paelzer@git.launchpad.net/ubuntu/+source/$pkg1
2985+ fi
2986+done
2987+echo "Updated $updated of $found repositories (checked: $checked)"
2988diff --git a/cpaelzer/versioned-rdepends.sh b/cpaelzer/versioned-rdepends.sh
2989new file mode 100644
2990index 0000000..f306c7a
2991--- /dev/null
2992+++ b/cpaelzer/versioned-rdepends.sh
2993@@ -0,0 +1,6 @@
2994+#!/bin/bash
2995+# example only
2996+# TODO
2997+# replace perl with variable
2998+# run it in an traget environment e.g. via LXD
2999+for p in $(apt-cache rdepends perl | tr -d '|'); do apt-cache show $p | awk -v p="$p" '/^(Depends|Recommends):.* perl \(/ {gsub("^.* perl "," perl "); gsub(", .*",""); gsub("\\| .*",""); printf("%s %s\n",$0,p)}'; done 2>/dev/null | sort -n
3000diff --git a/hcdist b/hcdist
3001deleted file mode 100755
3002index 015e51a..0000000
3003--- a/hcdist
3004+++ /dev/null
3005@@ -1,9 +0,0 @@
3006-#!/bin/sh
3007-set -e
3008-
3009-b=$1
3010-a=$2
3011-
3012-shift 2
3013-
3014-exec chdist "$a" "$b" "$@"
3015diff --git a/packages-per-repo.sh b/packages-per-repo.sh
3016deleted file mode 100755
3017index 1343956..0000000
3018--- a/packages-per-repo.sh
3019+++ /dev/null
3020@@ -1,7 +0,0 @@
3021-#!/bin/bash
3022-tmp=$(mktemp)
3023-# or from dpkg --get-selections
3024-packages=$(dpkg -l | awk '/^ii/ {gsub(":.*",""); print $2}' | xargs)
3025-apt-cache policy ${packages} | awk '/^[a-zA-Z1-9-]*:/ {gsub(":",""); pkg=$1} /archive/ {printf("%s\t%s\n", $3, pkg)}' | sort | uniq > ${tmp}
3026-cat ${tmp}
3027-cut -f 1 ${tmp} | uniq -c
3028diff --git a/rbasak/adopt.py b/rbasak/adopt.py
3029new file mode 100644
3030index 0000000..a9078cb
3031--- /dev/null
3032+++ b/rbasak/adopt.py
3033@@ -0,0 +1,80 @@
3034+# adopt.py
3035+# Author: Robie Basak
3036+
3037+# When working in a git repository that contains both maintainer branches and a
3038+# git-ubuntu branch, this script allows you to "adopt" a non-VCS Ubuntu upload
3039+# into your maintainer branch.
3040+#
3041+# Usage: adopt.py [-p <commit-ish>]... <commit-ish>
3042+#
3043+# This will add a new commit to your current branch whose tree is identical to
3044+# the given git-ubuntu synthesized commit. The author metadata will be taken
3045+# from the git-ubuntu commit, like a cherry-pick. Changelog entries will be
3046+# added to the commit message automatically taken from the git-ubuntu changelog
3047+# notes.
3048+#
3049+# Note that this isn't a cherry-pick: the tree in the commit supplied is taken
3050+# arbitrarily as-is.
3051+#
3052+# Example:
3053+#
3054+# An Ubuntu developer has uploaded a new upstream version to Ubuntu. You
3055+# maintain the packaging using the gbp workflow, but your VCS hasn't been
3056+# updated. You already have the "pkg" remote pointing to the git-ubuntu view of
3057+# your package. Now you can do:
3058+#
3059+# $ git fetch pkg
3060+# $ git checkout master
3061+# $ gbp import-orig --no-merge ../<new orig tarball>
3062+# $ adopt.py -p upstream pkg/ubuntu/devel
3063+#
3064+# Now your master branch is updated correctly and future merges of the upstream
3065+# branch will continue to work.
3066+#
3067+# Rough edges:
3068+#
3069+# The working tree is not updated, so you probably want "git reset --hard"
3070+# after running this command. But since this throws things away, I didn't want
3071+# to have the script do this automatically.
3072+#
3073+# Undescriptive error handling - just assertions and stacktraces.
3074+
3075+import argparse
3076+
3077+import debian.changelog
3078+import pygit2
3079+
3080+parser = argparse.ArgumentParser()
3081+parser.add_argument('-p', '--parent', action='append')
3082+parser.add_argument('commit')
3083+args = parser.parse_args()
3084+
3085+repo = pygit2.Repository(pygit2.discover_repository('.'))
3086+source_commit, _ = repo.resolve_refish(args.commit)
3087+assert len(source_commit.parents) == 1
3088+
3089+parents = [repo.head.peel(pygit2.Commit).id]
3090+if args.parent:
3091+ parents.extend(repo.resolve_refish(parent)[0].id for parent in args.parent)
3092+
3093+# Ideally this would use gitubuntu.git_repository.follow_symlinks_to_blob() to
3094+# cover various edge cases but this will do for now.
3095+changelog = debian.changelog.Changelog(
3096+ source_commit.peel(pygit2.Tree)['debian']['changelog'].data,
3097+)
3098+
3099+note = repo.lookup_note(str(source_commit.id), 'refs/notes/changelog')
3100+
3101+message = f'''Import {changelog.version!s} from Ubuntu
3102+
3103+New changelog entries:
3104+{note.message}'''
3105+
3106+repo.create_commit(
3107+ repo.head.name,
3108+ source_commit.author,
3109+ pygit2.Signature(repo.config['user.name'], repo.config['user.email']),
3110+ message,
3111+ source_commit.tree.id,
3112+ parents,
3113+)
3114diff --git a/rbasak/chdist-if-migrated b/rbasak/chdist-if-migrated
3115new file mode 100755
3116index 0000000..dfd7778
3117--- /dev/null
3118+++ b/rbasak/chdist-if-migrated
3119@@ -0,0 +1,73 @@
3120+#!/bin/sh
3121+set -e
3122+
3123+# Author: Robie Basak <robie.basak@canonical.com>
3124+
3125+# Usage:
3126+# $0 <release> <try_file> apt-get|apt-cache <parameter...>
3127+#
3128+# Where try_file is the output line from update_output.txt starting
3129+# "Trying easy from autohinter:" specifying a list of source packages we
3130+# propose to migrate to the release pocket.
3131+#
3132+# Example use:
3133+#
3134+# Get apt to try simulating the installation of <package> following the
3135+# proposed migration:
3136+# $0 try-file apt-get -s install <package>
3137+
3138+# Prerequisites:
3139+# chdist configured and updated with the following dists:
3140+# ${release}: only the release pocket included
3141+# ${release}-proposed: both release and proposed pockets included
3142+# ${release}-proposed-only: only the proposed pocket included
3143+
3144+# For debian-installer support, add to each of
3145+# ~/.chdist/${release}{,-proposed,-proposed-only}/sources.list:
3146+#
3147+# deb http://archive.ubuntu.com/ubuntu ${release} main/debian-installer
3148+#
3149+# then update all chdists, and use something like:
3150+# $0 try-file apt-get -s install debian-installer-udebs
3151+
3152+
3153+release=$1
3154+try_file=$2
3155+command=$3
3156+shift 3
3157+
3158+tmpdir=`mktemp -d`
3159+cleanup() { rm -rf "$tmpdir"; }
3160+trap cleanup EXIT
3161+
3162+binaries() {
3163+ chdist_dist=$1
3164+ cat "$try_file"|sed 's/^Trying easy from autohinter: //g'|tr ' ' "\n"|cut -d/ -f1|xargs -P32 -n1 sh -c 'for p in "$@"; do chdist apt-cache '$chdist_dist' showsrc --only-source $p|grep-dctrl -nsPackage-List .|awk '\''{print $1}'\''|sed '\''/^$/d'\'';done' --
3165+}
3166+
3167+proposed_single_line_binaries=`binaries $release-proposed-only|tr "\n" ' '`
3168+release_single_line_binaries=`binaries $release|tr "\n" ' '`
3169+
3170+cat > "$tmpdir/preferences" <<EOT
3171+Package: *
3172+Pin: release a=${release}-proposed
3173+Pin-Priority: -1
3174+Explanation: cannot install from proposed except where we say so
3175+
3176+Package: $release_single_line_binaries
3177+Pin: release a=${release}
3178+Pin-Priority: -1
3179+Explanation: binaries produced by the release pocket version of the source package would be removed and therefore not available
3180+
3181+Package: $proposed_single_line_binaries
3182+Pin: release a=${release}
3183+Pin-Priority: -1
3184+Explanation: binaries being migrated into the release pocket would be elided by their replacements and therefore not available
3185+
3186+Package: $proposed_single_line_binaries
3187+Pin: release a=${release}-proposed
3188+Pin-Priority: 999
3189+Explanation: these binaries are proposed to be migrated into the release pocket so would be available
3190+EOT
3191+
3192+chdist "$command" ${release}-proposed -o "Dir::Etc::Preferences=$tmpdir/preferences" "$@"
3193diff --git a/rbasak/standup_timer.py b/rbasak/standup_timer.py
3194new file mode 100644
3195index 0000000..638952b
3196--- /dev/null
3197+++ b/rbasak/standup_timer.py
3198@@ -0,0 +1,44 @@
3199+import tkinter
3200+import tkinter.font
3201+
3202+
3203+WINDOW_Y_SCALE = 0.90
3204+
3205+
3206+class StandupTimer(tkinter.Frame):
3207+ ALLOTTED_TIME = 60
3208+
3209+ def __init__(self, master=None):
3210+ super().__init__(master)
3211+ self._remaining_time = 0
3212+
3213+ self._label_font = tkinter.font.Font(self.master)
3214+ self._label = tkinter.Label(self, text=str(self._remaining_time))
3215+ self._label.config(font=self._label_font, bg="#ffffff")
3216+ self._label.pack(fill=tkinter.BOTH, expand=tkinter.YES)
3217+ self.pack()
3218+ self.master.bind("<Configure>", self._resize)
3219+ self.master.bind("<Key-space>", self._reset)
3220+ self.winfo_toplevel().after(1000, self._decrement)
3221+
3222+ def _decrement(self):
3223+ if self._remaining_time > 0:
3224+ self._remaining_time -= 1
3225+ self._label.config(text=str(self._remaining_time))
3226+ self.winfo_toplevel().after(1000, self._decrement)
3227+
3228+ def _resize(self, event):
3229+ self._label_font["size"] = int(
3230+ self._label.winfo_height() * WINDOW_Y_SCALE
3231+ )
3232+
3233+ def _reset(self, event):
3234+ self._remaining_time = self.ALLOTTED_TIME
3235+ self._label.config(text=str(self._remaining_time))
3236+
3237+
3238+if __name__ == "__main__":
3239+ root = tkinter.Tk()
3240+ root.config(bg="#ffffff")
3241+ app = StandupTimer(master=root)
3242+ app.mainloop()
3243diff --git a/rma b/rma
3244deleted file mode 100755
3245index 7d455e2..0000000
3246--- a/rma
3247+++ /dev/null
3248@@ -1,3 +0,0 @@
3249-#!/bin/bash
3250-rmadison -u debian $1 &
3251-rmadison $1
3252diff --git a/uscards/AUTHORS.md b/uscards/AUTHORS.md
3253new file mode 100644
3254index 0000000..9712ae3
3255--- /dev/null
3256+++ b/uscards/AUTHORS.md
3257@@ -0,0 +1 @@
3258+Bryce Harrington <bryce@canonical.com>
3259diff --git a/uscards/LICENSE.AGPL b/uscards/LICENSE.AGPL
3260new file mode 100644
3261index 0000000..4ec8c3f
3262--- /dev/null
3263+++ b/uscards/LICENSE.AGPL
3264@@ -0,0 +1,619 @@
3265+ GNU AFFERO GENERAL PUBLIC LICENSE
3266+ Version 3, 19 November 2007
3267+
3268+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
3269+ Everyone is permitted to copy and distribute verbatim copies
3270+ of this license document, but changing it is not allowed.
3271+
3272+ Preamble
3273+
3274+ The GNU Affero General Public License is a free, copyleft license for
3275+software and other kinds of works, specifically designed to ensure
3276+cooperation with the community in the case of network server software.
3277+
3278+ The licenses for most software and other practical works are designed
3279+to take away your freedom to share and change the works. By contrast,
3280+our General Public Licenses are intended to guarantee your freedom to
3281+share and change all versions of a program--to make sure it remains free
3282+software for all its users.
3283+
3284+ When we speak of free software, we are referring to freedom, not
3285+price. Our General Public Licenses are designed to make sure that you
3286+have the freedom to distribute copies of free software (and charge for
3287+them if you wish), that you receive source code or can get it if you
3288+want it, that you can change the software or use pieces of it in new
3289+free programs, and that you know you can do these things.
3290+
3291+ Developers that use our General Public Licenses protect your rights
3292+with two steps: (1) assert copyright on the software, and (2) offer
3293+you this License which gives you legal permission to copy, distribute
3294+and/or modify the software.
3295+
3296+ A secondary benefit of defending all users' freedom is that
3297+improvements made in alternate versions of the program, if they
3298+receive widespread use, become available for other developers to
3299+incorporate. Many developers of free software are heartened and
3300+encouraged by the resulting cooperation. However, in the case of
3301+software used on network servers, this result may fail to come about.
3302+The GNU General Public License permits making a modified version and
3303+letting the public access it on a server without ever releasing its
3304+source code to the public.
3305+
3306+ The GNU Affero General Public License is designed specifically to
3307+ensure that, in such cases, the modified source code becomes available
3308+to the community. It requires the operator of a network server to
3309+provide the source code of the modified version running there to the
3310+users of that server. Therefore, public use of a modified version, on
3311+a publicly accessible server, gives the public access to the source
3312+code of the modified version.
3313+
3314+ An older license, called the Affero General Public License and
3315+published by Affero, was designed to accomplish similar goals. This is
3316+a different license, not a version of the Affero GPL, but Affero has
3317+released a new version of the Affero GPL which permits relicensing under
3318+this license.
3319+
3320+ The precise terms and conditions for copying, distribution and
3321+modification follow.
3322+
3323+ TERMS AND CONDITIONS
3324+
3325+ 0. Definitions.
3326+
3327+ "This License" refers to version 3 of the GNU Affero General Public License.
3328+
3329+ "Copyright" also means copyright-like laws that apply to other kinds of
3330+works, such as semiconductor masks.
3331+
3332+ "The Program" refers to any copyrightable work licensed under this
3333+License. Each licensee is addressed as "you". "Licensees" and
3334+"recipients" may be individuals or organizations.
3335+
3336+ To "modify" a work means to copy from or adapt all or part of the work
3337+in a fashion requiring copyright permission, other than the making of an
3338+exact copy. The resulting work is called a "modified version" of the
3339+earlier work or a work "based on" the earlier work.
3340+
3341+ A "covered work" means either the unmodified Program or a work based
3342+on the Program.
3343+
3344+ To "propagate" a work means to do anything with it that, without
3345+permission, would make you directly or secondarily liable for
3346+infringement under applicable copyright law, except executing it on a
3347+computer or modifying a private copy. Propagation includes copying,
3348+distribution (with or without modification), making available to the
3349+public, and in some countries other activities as well.
3350+
3351+ To "convey" a work means any kind of propagation that enables other
3352+parties to make or receive copies. Mere interaction with a user through
3353+a computer network, with no transfer of a copy, is not conveying.
3354+
3355+ An interactive user interface displays "Appropriate Legal Notices"
3356+to the extent that it includes a convenient and prominently visible
3357+feature that (1) displays an appropriate copyright notice, and (2)
3358+tells the user that there is no warranty for the work (except to the
3359+extent that warranties are provided), that licensees may convey the
3360+work under this License, and how to view a copy of this License. If
3361+the interface presents a list of user commands or options, such as a
3362+menu, a prominent item in the list meets this criterion.
3363+
3364+ 1. Source Code.
3365+
3366+ The "source code" for a work means the preferred form of the work
3367+for making modifications to it. "Object code" means any non-source
3368+form of a work.
3369+
3370+ A "Standard Interface" means an interface that either is an official
3371+standard defined by a recognized standards body, or, in the case of
3372+interfaces specified for a particular programming language, one that
3373+is widely used among developers working in that language.
3374+
3375+ The "System Libraries" of an executable work include anything, other
3376+than the work as a whole, that (a) is included in the normal form of
3377+packaging a Major Component, but which is not part of that Major
3378+Component, and (b) serves only to enable use of the work with that
3379+Major Component, or to implement a Standard Interface for which an
3380+implementation is available to the public in source code form. A
3381+"Major Component", in this context, means a major essential component
3382+(kernel, window system, and so on) of the specific operating system
3383+(if any) on which the executable work runs, or a compiler used to
3384+produce the work, or an object code interpreter used to run it.
3385+
3386+ The "Corresponding Source" for a work in object code form means all
3387+the source code needed to generate, install, and (for an executable
3388+work) run the object code and to modify the work, including scripts to
3389+control those activities. However, it does not include the work's
3390+System Libraries, or general-purpose tools or generally available free
3391+programs which are used unmodified in performing those activities but
3392+which are not part of the work. For example, Corresponding Source
3393+includes interface definition files associated with source files for
3394+the work, and the source code for shared libraries and dynamically
3395+linked subprograms that the work is specifically designed to require,
3396+such as by intimate data communication or control flow between those
3397+subprograms and other parts of the work.
3398+
3399+ The Corresponding Source need not include anything that users
3400+can regenerate automatically from other parts of the Corresponding
3401+Source.
3402+
3403+ The Corresponding Source for a work in source code form is that
3404+same work.
3405+
3406+ 2. Basic Permissions.
3407+
3408+ All rights granted under this License are granted for the term of
3409+copyright on the Program, and are irrevocable provided the stated
3410+conditions are met. This License explicitly affirms your unlimited
3411+permission to run the unmodified Program. The output from running a
3412+covered work is covered by this License only if the output, given its
3413+content, constitutes a covered work. This License acknowledges your
3414+rights of fair use or other equivalent, as provided by copyright law.
3415+
3416+ You may make, run and propagate covered works that you do not
3417+convey, without conditions so long as your license otherwise remains
3418+in force. You may convey covered works to others for the sole purpose
3419+of having them make modifications exclusively for you, or provide you
3420+with facilities for running those works, provided that you comply with
3421+the terms of this License in conveying all material for which you do
3422+not control copyright. Those thus making or running the covered works
3423+for you must do so exclusively on your behalf, under your direction
3424+and control, on terms that prohibit them from making any copies of
3425+your copyrighted material outside their relationship with you.
3426+
3427+ Conveying under any other circumstances is permitted solely under
3428+the conditions stated below. Sublicensing is not allowed; section 10
3429+makes it unnecessary.
3430+
3431+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
3432+
3433+ No covered work shall be deemed part of an effective technological
3434+measure under any applicable law fulfilling obligations under article
3435+11 of the WIPO copyright treaty adopted on 20 December 1996, or
3436+similar laws prohibiting or restricting circumvention of such
3437+measures.
3438+
3439+ When you convey a covered work, you waive any legal power to forbid
3440+circumvention of technological measures to the extent such circumvention
3441+is effected by exercising rights under this License with respect to
3442+the covered work, and you disclaim any intention to limit operation or
3443+modification of the work as a means of enforcing, against the work's
3444+users, your or third parties' legal rights to forbid circumvention of
3445+technological measures.
3446+
3447+ 4. Conveying Verbatim Copies.
3448+
3449+ You may convey verbatim copies of the Program's source code as you
3450+receive it, in any medium, provided that you conspicuously and
3451+appropriately publish on each copy an appropriate copyright notice;
3452+keep intact all notices stating that this License and any
3453+non-permissive terms added in accord with section 7 apply to the code;
3454+keep intact all notices of the absence of any warranty; and give all
3455+recipients a copy of this License along with the Program.
3456+
3457+ You may charge any price or no price for each copy that you convey,
3458+and you may offer support or warranty protection for a fee.
3459+
3460+ 5. Conveying Modified Source Versions.
3461+
3462+ You may convey a work based on the Program, or the modifications to
3463+produce it from the Program, in the form of source code under the
3464+terms of section 4, provided that you also meet all of these conditions:
3465+
3466+ a) The work must carry prominent notices stating that you modified
3467+ it, and giving a relevant date.
3468+
3469+ b) The work must carry prominent notices stating that it is
3470+ released under this License and any conditions added under section
3471+ 7. This requirement modifies the requirement in section 4 to
3472+ "keep intact all notices".
3473+
3474+ c) You must license the entire work, as a whole, under this
3475+ License to anyone who comes into possession of a copy. This
3476+ License will therefore apply, along with any applicable section 7
3477+ additional terms, to the whole of the work, and all its parts,
3478+ regardless of how they are packaged. This License gives no
3479+ permission to license the work in any other way, but it does not
3480+ invalidate such permission if you have separately received it.
3481+
3482+ d) If the work has interactive user interfaces, each must display
3483+ Appropriate Legal Notices; however, if the Program has interactive
3484+ interfaces that do not display Appropriate Legal Notices, your
3485+ work need not make them do so.
3486+
3487+ A compilation of a covered work with other separate and independent
3488+works, which are not by their nature extensions of the covered work,
3489+and which are not combined with it such as to form a larger program,
3490+in or on a volume of a storage or distribution medium, is called an
3491+"aggregate" if the compilation and its resulting copyright are not
3492+used to limit the access or legal rights of the compilation's users
3493+beyond what the individual works permit. Inclusion of a covered work
3494+in an aggregate does not cause this License to apply to the other
3495+parts of the aggregate.
3496+
3497+ 6. Conveying Non-Source Forms.
3498+
3499+ You may convey a covered work in object code form under the terms
3500+of sections 4 and 5, provided that you also convey the
3501+machine-readable Corresponding Source under the terms of this License,
3502+in one of these ways:
3503+
3504+ a) Convey the object code in, or embodied in, a physical product
3505+ (including a physical distribution medium), accompanied by the
3506+ Corresponding Source fixed on a durable physical medium
3507+ customarily used for software interchange.
3508+
3509+ b) Convey the object code in, or embodied in, a physical product
3510+ (including a physical distribution medium), accompanied by a
3511+ written offer, valid for at least three years and valid for as
3512+ long as you offer spare parts or customer support for that product
3513+ model, to give anyone who possesses the object code either (1) a
3514+ copy of the Corresponding Source for all the software in the
3515+ product that is covered by this License, on a durable physical
3516+ medium customarily used for software interchange, for a price no
3517+ more than your reasonable cost of physically performing this
3518+ conveying of source, or (2) access to copy the
3519+ Corresponding Source from a network server at no charge.
3520+
3521+ c) Convey individual copies of the object code with a copy of the
3522+ written offer to provide the Corresponding Source. This
3523+ alternative is allowed only occasionally and noncommercially, and
3524+ only if you received the object code with such an offer, in accord
3525+ with subsection 6b.
3526+
3527+ d) Convey the object code by offering access from a designated
3528+ place (gratis or for a charge), and offer equivalent access to the
3529+ Corresponding Source in the same way through the same place at no
3530+ further charge. You need not require recipients to copy the
3531+ Corresponding Source along with the object code. If the place to
3532+ copy the object code is a network server, the Corresponding Source
3533+ may be on a different server (operated by you or a third party)
3534+ that supports equivalent copying facilities, provided you maintain
3535+ clear directions next to the object code saying where to find the
3536+ Corresponding Source. Regardless of what server hosts the
3537+ Corresponding Source, you remain obligated to ensure that it is
3538+ available for as long as needed to satisfy these requirements.
3539+
3540+ e) Convey the object code using peer-to-peer transmission, provided
3541+ you inform other peers where the object code and Corresponding
3542+ Source of the work are being offered to the general public at no
3543+ charge under subsection 6d.
3544+
3545+ A separable portion of the object code, whose source code is excluded
3546+from the Corresponding Source as a System Library, need not be
3547+included in conveying the object code work.
3548+
3549+ A "User Product" is either (1) a "consumer product", which means any
3550+tangible personal property which is normally used for personal, family,
3551+or household purposes, or (2) anything designed or sold for incorporation
3552+into a dwelling. In determining whether a product is a consumer product,
3553+doubtful cases shall be resolved in favor of coverage. For a particular
3554+product received by a particular user, "normally used" refers to a
3555+typical or common use of that class of product, regardless of the status
3556+of the particular user or of the way in which the particular user
3557+actually uses, or expects or is expected to use, the product. A product
3558+is a consumer product regardless of whether the product has substantial
3559+commercial, industrial or non-consumer uses, unless such uses represent
3560+the only significant mode of use of the product.
3561+
3562+ "Installation Information" for a User Product means any methods,
3563+procedures, authorization keys, or other information required to install
3564+and execute modified versions of a covered work in that User Product from
3565+a modified version of its Corresponding Source. The information must
3566+suffice to ensure that the continued functioning of the modified object
3567+code is in no case prevented or interfered with solely because
3568+modification has been made.
3569+
3570+ If you convey an object code work under this section in, or with, or
3571+specifically for use in, a User Product, and the conveying occurs as
3572+part of a transaction in which the right of possession and use of the
3573+User Product is transferred to the recipient in perpetuity or for a
3574+fixed term (regardless of how the transaction is characterized), the
3575+Corresponding Source conveyed under this section must be accompanied
3576+by the Installation Information. But this requirement does not apply
3577+if neither you nor any third party retains the ability to install
3578+modified object code on the User Product (for example, the work has
3579+been installed in ROM).
3580+
3581+ The requirement to provide Installation Information does not include a
3582+requirement to continue to provide support service, warranty, or updates
3583+for a work that has been modified or installed by the recipient, or for
3584+the User Product in which it has been modified or installed. Access to a
3585+network may be denied when the modification itself materially and
3586+adversely affects the operation of the network or violates the rules and
3587+protocols for communication across the network.
3588+
3589+ Corresponding Source conveyed, and Installation Information provided,
3590+in accord with this section must be in a format that is publicly
3591+documented (and with an implementation available to the public in
3592+source code form), and must require no special password or key for
3593+unpacking, reading or copying.
3594+
3595+ 7. Additional Terms.
3596+
3597+ "Additional permissions" are terms that supplement the terms of this
3598+License by making exceptions from one or more of its conditions.
3599+Additional permissions that are applicable to the entire Program shall
3600+be treated as though they were included in this License, to the extent
3601+that they are valid under applicable law. If additional permissions
3602+apply only to part of the Program, that part may be used separately
3603+under those permissions, but the entire Program remains governed by
3604+this License without regard to the additional permissions.
3605+
3606+ When you convey a copy of a covered work, you may at your option
3607+remove any additional permissions from that copy, or from any part of
3608+it. (Additional permissions may be written to require their own
3609+removal in certain cases when you modify the work.) You may place
3610+additional permissions on material, added by you to a covered work,
3611+for which you have or can give appropriate copyright permission.
3612+
3613+ Notwithstanding any other provision of this License, for material you
3614+add to a covered work, you may (if authorized by the copyright holders of
3615+that material) supplement the terms of this License with terms:
3616+
3617+ a) Disclaiming warranty or limiting liability differently from the
3618+ terms of sections 15 and 16 of this License; or
3619+
3620+ b) Requiring preservation of specified reasonable legal notices or
3621+ author attributions in that material or in the Appropriate Legal
3622+ Notices displayed by works containing it; or
3623+
3624+ c) Prohibiting misrepresentation of the origin of that material, or
3625+ requiring that modified versions of such material be marked in
3626+ reasonable ways as different from the original version; or
3627+
3628+ d) Limiting the use for publicity purposes of names of licensors or
3629+ authors of the material; or
3630+
3631+ e) Declining to grant rights under trademark law for use of some
3632+ trade names, trademarks, or service marks; or
3633+
3634+ f) Requiring indemnification of licensors and authors of that
3635+ material by anyone who conveys the material (or modified versions of
3636+ it) with contractual assumptions of liability to the recipient, for
3637+ any liability that these contractual assumptions directly impose on
3638+ those licensors and authors.
3639+
3640+ All other non-permissive additional terms are considered "further
3641+restrictions" within the meaning of section 10. If the Program as you
3642+received it, or any part of it, contains a notice stating that it is
3643+governed by this License along with a term that is a further
3644+restriction, you may remove that term. If a license document contains
3645+a further restriction but permits relicensing or conveying under this
3646+License, you may add to a covered work material governed by the terms
3647+of that license document, provided that the further restriction does
3648+not survive such relicensing or conveying.
3649+
3650+ If you add terms to a covered work in accord with this section, you
3651+must place, in the relevant source files, a statement of the
3652+additional terms that apply to those files, or a notice indicating
3653+where to find the applicable terms.
3654+
3655+ Additional terms, permissive or non-permissive, may be stated in the
3656+form of a separately written license, or stated as exceptions;
3657+the above requirements apply either way.
3658+
3659+ 8. Termination.
3660+
3661+ You may not propagate or modify a covered work except as expressly
3662+provided under this License. Any attempt otherwise to propagate or
3663+modify it is void, and will automatically terminate your rights under
3664+this License (including any patent licenses granted under the third
3665+paragraph of section 11).
3666+
3667+ However, if you cease all violation of this License, then your
3668+license from a particular copyright holder is reinstated (a)
3669+provisionally, unless and until the copyright holder explicitly and
3670+finally terminates your license, and (b) permanently, if the copyright
3671+holder fails to notify you of the violation by some reasonable means
3672+prior to 60 days after the cessation.
3673+
3674+ Moreover, your license from a particular copyright holder is
3675+reinstated permanently if the copyright holder notifies you of the
3676+violation by some reasonable means, this is the first time you have
3677+received notice of violation of this License (for any work) from that
3678+copyright holder, and you cure the violation prior to 30 days after
3679+your receipt of the notice.
3680+
3681+ Termination of your rights under this section does not terminate the
3682+licenses of parties who have received copies or rights from you under
3683+this License. If your rights have been terminated and not permanently
3684+reinstated, you do not qualify to receive new licenses for the same
3685+material under section 10.
3686+
3687+ 9. Acceptance Not Required for Having Copies.
3688+
3689+ You are not required to accept this License in order to receive or
3690+run a copy of the Program. Ancillary propagation of a covered work
3691+occurring solely as a consequence of using peer-to-peer transmission
3692+to receive a copy likewise does not require acceptance. However,
3693+nothing other than this License grants you permission to propagate or
3694+modify any covered work. These actions infringe copyright if you do
3695+not accept this License. Therefore, by modifying or propagating a
3696+covered work, you indicate your acceptance of this License to do so.
3697+
3698+ 10. Automatic Licensing of Downstream Recipients.
3699+
3700+ Each time you convey a covered work, the recipient automatically
3701+receives a license from the original licensors, to run, modify and
3702+propagate that work, subject to this License. You are not responsible
3703+for enforcing compliance by third parties with this License.
3704+
3705+ An "entity transaction" is a transaction transferring control of an
3706+organization, or substantially all assets of one, or subdividing an
3707+organization, or merging organizations. If propagation of a covered
3708+work results from an entity transaction, each party to that
3709+transaction who receives a copy of the work also receives whatever
3710+licenses to the work the party's predecessor in interest had or could
3711+give under the previous paragraph, plus a right to possession of the
3712+Corresponding Source of the work from the predecessor in interest, if
3713+the predecessor has it or can get it with reasonable efforts.
3714+
3715+ You may not impose any further restrictions on the exercise of the
3716+rights granted or affirmed under this License. For example, you may
3717+not impose a license fee, royalty, or other charge for exercise of
3718+rights granted under this License, and you may not initiate litigation
3719+(including a cross-claim or counterclaim in a lawsuit) alleging that
3720+any patent claim is infringed by making, using, selling, offering for
3721+sale, or importing the Program or any portion of it.
3722+
3723+ 11. Patents.
3724+
3725+ A "contributor" is a copyright holder who authorizes use under this
3726+License of the Program or a work on which the Program is based. The
3727+work thus licensed is called the contributor's "contributor version".
3728+
3729+ A contributor's "essential patent claims" are all patent claims
3730+owned or controlled by the contributor, whether already acquired or
3731+hereafter acquired, that would be infringed by some manner, permitted
3732+by this License, of making, using, or selling its contributor version,
3733+but do not include claims that would be infringed only as a
3734+consequence of further modification of the contributor version. For
3735+purposes of this definition, "control" includes the right to grant
3736+patent sublicenses in a manner consistent with the requirements of
3737+this License.
3738+
3739+ Each contributor grants you a non-exclusive, worldwide, royalty-free
3740+patent license under the contributor's essential patent claims, to
3741+make, use, sell, offer for sale, import and otherwise run, modify and
3742+propagate the contents of its contributor version.
3743+
3744+ In the following three paragraphs, a "patent license" is any express
3745+agreement or commitment, however denominated, not to enforce a patent
3746+(such as an express permission to practice a patent or covenant not to
3747+sue for patent infringement). To "grant" such a patent license to a
3748+party means to make such an agreement or commitment not to enforce a
3749+patent against the party.
3750+
3751+ If you convey a covered work, knowingly relying on a patent license,
3752+and the Corresponding Source of the work is not available for anyone
3753+to copy, free of charge and under the terms of this License, through a
3754+publicly available network server or other readily accessible means,
3755+then you must either (1) cause the Corresponding Source to be so
3756+available, or (2) arrange to deprive yourself of the benefit of the
3757+patent license for this particular work, or (3) arrange, in a manner
3758+consistent with the requirements of this License, to extend the patent
3759+license to downstream recipients. "Knowingly relying" means you have
3760+actual knowledge that, but for the patent license, your conveying the
3761+covered work in a country, or your recipient's use of the covered work
3762+in a country, would infringe one or more identifiable patents in that
3763+country that you have reason to believe are valid.
3764+
3765+ If, pursuant to or in connection with a single transaction or
3766+arrangement, you convey, or propagate by procuring conveyance of, a
3767+covered work, and grant a patent license to some of the parties
3768+receiving the covered work authorizing them to use, propagate, modify
3769+or convey a specific copy of the covered work, then the patent license
3770+you grant is automatically extended to all recipients of the covered
3771+work and works based on it.
3772+
3773+ A patent license is "discriminatory" if it does not include within
3774+the scope of its coverage, prohibits the exercise of, or is
3775+conditioned on the non-exercise of one or more of the rights that are
3776+specifically granted under this License. You may not convey a covered
3777+work if you are a party to an arrangement with a third party that is
3778+in the business of distributing software, under which you make payment
3779+to the third party based on the extent of your activity of conveying
3780+the work, and under which the third party grants, to any of the
3781+parties who would receive the covered work from you, a discriminatory
3782+patent license (a) in connection with copies of the covered work
3783+conveyed by you (or copies made from those copies), or (b) primarily
3784+for and in connection with specific products or compilations that
3785+contain the covered work, unless you entered into that arrangement,
3786+or that patent license was granted, prior to 28 March 2007.
3787+
3788+ Nothing in this License shall be construed as excluding or limiting
3789+any implied license or other defenses to infringement that may
3790+otherwise be available to you under applicable patent law.
3791+
3792+ 12. No Surrender of Others' Freedom.
3793+
3794+ If conditions are imposed on you (whether by court order, agreement or
3795+otherwise) that contradict the conditions of this License, they do not
3796+excuse you from the conditions of this License. If you cannot convey a
3797+covered work so as to satisfy simultaneously your obligations under this
3798+License and any other pertinent obligations, then as a consequence you may
3799+not convey it at all. For example, if you agree to terms that obligate you
3800+to collect a royalty for further conveying from those to whom you convey
3801+the Program, the only way you could satisfy both those terms and this
3802+License would be to refrain entirely from conveying the Program.
3803+
3804+ 13. Remote Network Interaction; Use with the GNU General Public License.
3805+
3806+ Notwithstanding any other provision of this License, if you modify the
3807+Program, your modified version must prominently offer all users
3808+interacting with it remotely through a computer network (if your version
3809+supports such interaction) an opportunity to receive the Corresponding
3810+Source of your version by providing access to the Corresponding Source
3811+from a network server at no charge, through some standard or customary
3812+means of facilitating copying of software. This Corresponding Source
3813+shall include the Corresponding Source for any work covered by version 3
3814+of the GNU General Public License that is incorporated pursuant to the
3815+following paragraph.
3816+
3817+ Notwithstanding any other provision of this License, you have
3818+permission to link or combine any covered work with a work licensed
3819+under version 3 of the GNU General Public License into a single
3820+combined work, and to convey the resulting work. The terms of this
3821+License will continue to apply to the part which is the covered work,
3822+but the work with which it is combined will remain governed by version
3823+3 of the GNU General Public License.
3824+
3825+ 14. Revised Versions of this License.
3826+
3827+ The Free Software Foundation may publish revised and/or new versions of
3828+the GNU Affero General Public License from time to time. Such new versions
3829+will be similar in spirit to the present version, but may differ in detail to
3830+address new problems or concerns.
3831+
3832+ Each version is given a distinguishing version number. If the
3833+Program specifies that a certain numbered version of the GNU Affero General
3834+Public License "or any later version" applies to it, you have the
3835+option of following the terms and conditions either of that numbered
3836+version or of any later version published by the Free Software
3837+Foundation. If the Program does not specify a version number of the
3838+GNU Affero General Public License, you may choose any version ever published
3839+by the Free Software Foundation.
3840+
3841+ If the Program specifies that a proxy can decide which future
3842+versions of the GNU Affero General Public License can be used, that proxy's
3843+public statement of acceptance of a version permanently authorizes you
3844+to choose that version for the Program.
3845+
3846+ Later license versions may give you additional or different
3847+permissions. However, no additional obligations are imposed on any
3848+author or copyright holder as a result of your choosing to follow a
3849+later version.
3850+
3851+ 15. Disclaimer of Warranty.
3852+
3853+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
3854+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
3855+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
3856+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
3857+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3858+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
3859+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
3860+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
3861+
3862+ 16. Limitation of Liability.
3863+
3864+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
3865+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
3866+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
3867+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
3868+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
3869+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
3870+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
3871+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
3872+SUCH DAMAGES.
3873+
3874+ 17. Interpretation of Sections 15 and 16.
3875+
3876+ If the disclaimer of warranty and limitation of liability provided
3877+above cannot be given local legal effect according to their terms,
3878+reviewing courts shall apply local law that most closely approximates
3879+an absolute waiver of all civil liability in connection with the
3880+Program, unless a warranty or assumption of liability accompanies a
3881+copy of the Program in return for a fee.
3882+
3883+ END OF TERMS AND CONDITIONS
3884diff --git a/uscards/README b/uscards/README
3885new file mode 120000
3886index 0000000..42061c0
3887--- /dev/null
3888+++ b/uscards/README
3889@@ -0,0 +1 @@
3890+README.md
3891\ No newline at end of file
3892diff --git a/uscards/README.md b/uscards/README.md
3893new file mode 100644
3894index 0000000..3f25112
3895--- /dev/null
3896+++ b/uscards/README.md
3897@@ -0,0 +1,26 @@
3898+# USCARDS #
3899+
3900+Ubuntu Server Trello Cards CLI
3901+
3902+This collection of scripts provide convenience CLIs to the Ubuntu Server
3903+team's trello boards. Each script maps to a specific board and
3904+implements the team's particular policy logic for that board.
3905+
3906+## Use cases ##
3907+
3908+ - Get authenticated
3909+ - List all my open merge cards
3910+ - List all cards for a specified board and/or list
3911+ - Add a new card to the TODO list on the roadmap
3912+ - Create triage and migration duty cards for a given user
3913+ - Move your triage and migration duty tasks from TODO to Doing
3914+ - Move your triage and migration duty tasks from Doing to Done
3915+ - Update the label on a package's card in Roadmap: merges
3916+ - Append to the description of a card in Roadmap: merges
3917+
3918+## Configuration ##
3919+
3920+Create ~/.config/uscards.conf with contents such as:
3921+
3922+ # USCards configuration
3923+ TRELLO_USERNAME="myusername"
3924diff --git a/uscards/docs/design.txt b/uscards/docs/design.txt
3925new file mode 100644
3926index 0000000..0fe9708
3927--- /dev/null
3928+++ b/uscards/docs/design.txt
3929@@ -0,0 +1,100 @@
3930+ # Design of Usdaily #
3931+
3932+The purpose of usdaily is to give a super convenient way for the server
3933+team's "Squeaky Wheel" squad to interact with the Trello cards that make
3934+up the main part of their workflow, from the command line. In
3935+particular, it's envisioned this will facilitate further scripting and
3936+automation of workflows such as merges, SRUs, proposed migration and so
3937+on.
3938+
3939+This is not intended to be a general utility, just be a convenience
3940+wrapper around the actual general utility, 'so-trello'. As well, we're
3941+not intending to implement the full range of the Trello web
3942+functionality, and accept that certain tasks may just be a lot simpler
3943+or more convenient to do from the Trello website.
3944+
3945+
3946+### Boards ###
3947+
3948+The server team maintains a number of Trello boards, but we're mainly
3949+concerned with these boards:
3950+
3951+ - Daily
3952+ - [Groovy] Merges Schedule (and Package Merge Status board)
3953+ - Proposed Migration
3954+ - SRU
3955+
3956+These boards have repetitive aspects to their workflows, which could be
3957+ameniable to adding trello board update calls as part of a script.
3958+Development-focused boards like the git-ubuntu roadmap board, that don't
3959+have repetitive workflow aspects, may not benefit as much from CLI tools
3960+and for this reason are not included. Backlog boards are by definition
3961+rarely interacted with, and thus not included for similar reasons.
3962+
3963+Each board is implemented as a separate script. This is for two
3964+reasons: First, it avoids needing to have the user specify the board to
3965+operate on; and second, each board may have some unique elements to how
3966+they're used which is best to encapsulate.
3967+
3968+Note that there are actually two boards for merges - one that acts more
3969+like a schedule to plan when merges should happen, and a second that
3970+registers when merges are available to be done. In this case, the two
3971+boards work like different facets on the same workflow - i.e. when
3972+updating a card on one merge board there may be a corresponding card on
3973+the other board that would need similarly updated, so a single script is
3974+designed to interact with both boards.
3975+
3976+
3977+### Operations ###
3978+
3979+All of the scripts will support certain core operations:
3980+
3981+ - List cards
3982+ - Add a card
3983+ - Start a card
3984+ - Mark a card as ready for review
3985+ - Add a comment to a card
3986+ - Finish a card
3987+
3988+In some cases, these operations result in moving a card from one list to
3989+another; in other cases it is achieved via labels.
3990+
3991+Except for the 'list' command, all operations will take a card-id.
3992+so-trello expects the card to be identified by it's textual title, which
3993+makes sense from a user perspective, but given that the title can be
3994+edited and changed at will, it may be difficult to rely on so commands
3995+should also accept card-id's derived from the card URL. Or if no
3996+card-id is specified, the operation should prompt the user with a list
3997+of plausible choices to select from.
3998+
3999+There are also some board-specific functionality, that the scripts are
4000+intended to facilitate:
4001+
4002+ - The Merges Schedule are organized with a list of cards per month, so
4003+ being able to see still-active merges for a range of months
4004+ (e.g. current month and before) is useful.
4005+
4006+ - The Proposed Migration board uses the first card in some lists as
4007+ documentation for the list.
4008+
4009+
4010+### Coding Approach ###
4011+
4012+'uscards' is kept in Bash deliberately, both to keep implementation
4013+more accessible to team members, and to encourage keeping implementation
4014+streamlined and simple. Apart from 'so-trello' (which can be easily
4015+installed via snap), there are no installation dependencies, and the
4016+individual scripts can be self-contained as single files.
4017+
4018+The use of 'so-trello' was motivated by these design constraints,
4019+however other options were considered including coding in python and
4020+using the python-trello module. An earlier effort, 'postcard' was
4021+written purely in Python, but its attempt to provide both the frontend
4022+CLI and the backend Trello interfacing, resulted in unnecessary
4023+complexity.
4024+
4025+Another option considered was Report2Trello, a python toolset built
4026+around the python-trello module, focused on bulk-update use cases to
4027+generate and update boards based off of external data sources; 'uscards'
4028+focuses more on a command-line interface way of interacting with the
4029+boards.
4030diff --git a/uscards/install.sh b/uscards/install.sh
4031new file mode 100755
4032index 0000000..c9bbaa3
4033--- /dev/null
4034+++ b/uscards/install.sh
4035@@ -0,0 +1,9 @@
4036+#!/bin/bash
4037+
4038+dest="${1:-/usr/local/bin/}"
4039+
4040+for script in scripts/*; do
4041+ if [ -x "${script}" ]; then
4042+ cp -v "${script}" "${dest}"
4043+ fi
4044+done
4045diff --git a/uscards/scripts/sru-board b/uscards/scripts/sru-board
4046new file mode 100755
4047index 0000000..59eaef6
4048--- /dev/null
4049+++ b/uscards/scripts/sru-board
4050@@ -0,0 +1,158 @@
4051+#!/bin/bash
4052+# -*- coding: utf-8; mode: sh -*-
4053+
4054+# This script uses so-trello to update cards on the Ubuntu SRU
4055+# Trello board.
4056+#
4057+# Copyright (C) 2020 Bryce W. Harrington <bryce@bryceharrington.org>
4058+#
4059+# This program is free software: you can redistribute it and/or
4060+# modify it under the terms of the GNU Affero General Public
4061+# License as published by the Free Software Foundation, either
4062+# version 3 of the License, or (at your option) any later
4063+# version.
4064+#
4065+# This program is distributed in the hope that it will be useful,
4066+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4067+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4068+# GNU Affero General Public License for more details.
4069+#
4070+# You should have received a copy of the GNU Affero General Public License
4071+# along with this program. If not, see <http://www.gnu.org/licenses/>.
4072+
4073+progname=$(basename "${0}")
4074+progdir=$(dirname "$(readlink -f "${0}")")
4075+scriptsdir="${progdir}/../scripts"
4076+
4077+usage() {
4078+ cat >&2 <<EOF
4079+Usage: ${progname} [options] <command [params]>
4080+
4081+Commands:
4082+ list Display your open cards
4083+ finish <card-title> Move card to Done column
4084+
4085+Options:
4086+ -h, --help This help listing
4087+EOF
4088+ exit $1
4089+}
4090+
4091+warn() {
4092+ echo "Warning: $1" 1>&2
4093+}
4094+
4095+die() {
4096+ echo "Error: $1" 1>&2
4097+ exit 1
4098+}
4099+
4100+card_id() {
4101+ local card="${1}"
4102+
4103+ if [[ "${card}" =~ "https://trello.com/"* ]]; then
4104+ # Looks like a card URL
4105+ echo "${card##*/}"
4106+ return 0
4107+ else
4108+ echo "${card}"
4109+ return 0
4110+ fi
4111+
4112+ warn "Could not parse card id from '${card}'"
4113+ return 1
4114+}
4115+
4116+
4117+#####################
4118+### Parse Options ###
4119+#####################
4120+
4121+parse_args() {
4122+ # Transform long options to short ones
4123+ for arg in "$@"; do
4124+ shift
4125+ case "${arg}" in
4126+ "--help") set -- "$@" "-h" ;;
4127+ "--*") usage 1 ;;
4128+ *) set -- "$@" "${arg}"
4129+ esac
4130+ done
4131+
4132+ # Parse short options
4133+ OPTIND=1
4134+ while getopts "h\?" opt $*; do
4135+ case "${opt}" in
4136+ h | \?) usage 0; ;;
4137+ * ) die "Unknown option '${opt}'" ;;
4138+ esac
4139+ done
4140+ shift $(expr ${OPTIND} - 1)
4141+}
4142+
4143+############
4144+### Main ###
4145+############
4146+
4147+function main() {
4148+ # Parse options
4149+ parse_args "$@" \
4150+ || die "Could not process options"
4151+ command="${1}" && shift
4152+ [ -n "${command}" ] || usage 1
4153+
4154+ if [ -e ~/.config/uscards.conf ]; then
4155+ source ~/.config/uscards.conf
4156+ elif [ -z "${TRELLO_USERNAME}" ]; then
4157+ die "TRELLO_USERNAME env var needs to be set to your trello account name"
4158+ fi
4159+
4160+ my_boards=$(so-trello member-boards)
4161+ sru_board_id=$(echo "${my_boards}" | grep "SRU" | cut -d' ' -f1)
4162+ sru_lists=$(so-trello board-lists --board "${sru_board_id}")
4163+
4164+ list_languishing=$(echo "${sru_lists}" | grep "Languishing" | cut -d' ' -f1)
4165+ list_todo=$(echo "${sru_lists}" | grep "To *Do" | cut -d' ' -f1)
4166+ list_doing=$(echo "${sru_lists}" | grep "Doing" | cut -d' ' -f1)
4167+ list_done=$(echo "${sru_lists}" | grep "Done" | cut -d' ' -f1)
4168+
4169+ case "${command}" in
4170+ list)
4171+ echo "Languishing:"
4172+ so-trello list-cards --list "${list_languishing}" | cut -d' ' -f2- | sed -e 's/^/* /'
4173+ echo
4174+
4175+ echo "To Do:"
4176+ so-trello list-cards --list "${list_todo}" | cut -d' ' -f2- | sed -e 's/^/* /'
4177+ echo
4178+
4179+ echo "Doing:"
4180+ so-trello list-cards --list "${list_doing}" | cut -d' ' -f2- | sed -e 's/^/* /'
4181+ echo
4182+ ;;
4183+
4184+ finish)
4185+ card=$(card_id "${1}")
4186+ [ -n "${card}" ] || usage 1
4187+
4188+ so-trello card-update --board "${sru_board_id}" \
4189+ --update-board "${sru_board_id}" --update-list "${list_done}" \
4190+ --card "${card}"
4191+ ;;
4192+
4193+ help)
4194+ usage 0
4195+ ;;
4196+ *)
4197+ usage 1
4198+ ;;
4199+ esac
4200+
4201+ # Subcommands to add:
4202+ # * start <card> # Moves from TODO column to the Doing column
4203+ # * finish <card> # Moves to the DONE column
4204+}
4205+
4206+if [[ "${0}" == "${BASH_SOURCE}" ]]; then
4207+ main "$@"
4208+fi
4209diff --git a/uscards/scripts/uscoredev b/uscards/scripts/uscoredev
4210new file mode 100755
4211index 0000000..1f2688b
4212--- /dev/null
4213+++ b/uscards/scripts/uscoredev
4214@@ -0,0 +1,189 @@
4215+#!/bin/bash
4216+# -*- coding: utf-8; mode: sh -*-
4217+
4218+# This script uses so-trello to dump cards from a prospective
4219+# core-dev applicant's Trello board.
4220+#
4221+# Copyright (C) 2021 Bryce W. Harrington <bryce@canonical.com>
4222+#
4223+# This program is free software: you can redistribute it and/or
4224+# modify it under the terms of the GNU Affero General Public
4225+# License as published by the Free Software Foundation, either
4226+# version 3 of the License, or (at your option) any later
4227+# version.
4228+#
4229+# This program is distributed in the hope that it will be useful,
4230+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4231+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4232+# GNU Affero General Public License for more details.
4233+#
4234+# You should have received a copy of the GNU Affero General Public License
4235+# along with this program. If not, see <http://www.gnu.org/licenses/>.
4236+
4237+progname=$(basename "${0}")
4238+progdir=$(dirname "$(readlink -f "${0}")")
4239+scriptsdir="${progdir}/../scripts"
4240+
4241+usage() {
4242+ cat >&2 <<EOF
4243+Usage: ${progname} [options]
4244+
4245+Commands:
4246+ list Generate a Moinmoin-style dump of cards from Trello
4247+ help This help listing
4248+
4249+Parameters:
4250+ <name> First part of board title, i.e. "<name> Core Dev Roadmap"
4251+
4252+Options:
4253+ -h, --help This help listing
4254+EOF
4255+ exit $1
4256+}
4257+
4258+warn() {
4259+ echo "Warning: $1" 1>&2
4260+}
4261+
4262+die() {
4263+ echo "Error: $1" 1>&2
4264+ exit 1
4265+}
4266+
4267+card_id() {
4268+ local card="${1}"
4269+
4270+ if [[ "${card}" =~ ${re_number} ]]; then
4271+ # Treat as the card id directly
4272+ echo "${card}"
4273+ return 0
4274+ elif [[ "${card}" =~ "https://trello.com/"* ]]; then
4275+ # Looks like a card URL
4276+ echo "${card##*/}"
4277+ return 0
4278+ fi
4279+
4280+ warn "Could not parse card id from '${card}'"
4281+ return 1
4282+}
4283+
4284+#####################
4285+### Parse Options ###
4286+#####################
4287+
4288+parse_args() {
4289+ # Transform long options to short ones
4290+ for arg in "$@"; do
4291+ shift
4292+ case "${arg}" in
4293+ "--help") set -- "$@" "-h" ;;
4294+ "--*") usage 1 ;;
4295+ *) set -- "$@" "${arg}"
4296+ esac
4297+ done
4298+
4299+ # Parse short options
4300+ OPTIND=1
4301+ while getopts "h\?" opt $*; do
4302+ case "${opt}" in
4303+ h | \?) usage 0; ;;
4304+ * ) die "Unknown option '${opt}'" ;;
4305+ esac
4306+ done
4307+ shift $(expr ${OPTIND} - 1)
4308+}
4309+
4310+############
4311+### Main ###
4312+############
4313+
4314+function main() {
4315+ # Parse options
4316+ parse_args "$@" \
4317+ || die "Could not process options"
4318+
4319+ if [ -e ~/.config/uscards.conf ]; then
4320+ source ~/.config/uscards.conf
4321+ elif [ -z "${TRELLO_USERNAME}" ]; then
4322+ die "TRELLO_USERNAME env var needs to be set to your trello account name"
4323+ fi
4324+
4325+ # Command to execute
4326+ command="${1}" && shift
4327+ [ -n "${command}" ] || usage 1
4328+
4329+ # Name and ID of the trello board
4330+ name="${@}"
4331+ my_boards=$(so-trello member-boards)
4332+ if [ -z "${name}" ]; then
4333+ num_boards=$(echo "${my_boards}" | grep -i "Core Dev Roadmap" | grep -v "Example" | wc -l)
4334+ if [ "${num_boards}" = 0 ]; then
4335+ # User has no core-dev roadmaps, so use the example
4336+ coredev_board_id=$(echo "${my_boards}" | grep -i "Example Core Dev Roadmap" | cut -d' ' -f1)
4337+ elif [ "${num_boards}" = "1" ]; then
4338+ # User has exactly one board (common case)
4339+ coredev_board_id=$(echo "${my_boards}" | grep -i "Core Dev Roadmap" | grep -v "Example" | cut -d' ' -f1)
4340+ else
4341+ # TODO: Present user with list to choose from
4342+ usage 1
4343+ fi
4344+ else
4345+ coredev_board_id=$(echo "${my_boards}" | grep -i "${name} Core Dev Roadmap" | cut -d' ' -f1)
4346+ fi
4347+ coredev_board_name=$(echo "${my_boards}" | grep -i "^${coredev_board_id}" | cut -d' ' -f2-)
4348+
4349+ # Column names
4350+ coredev_lists=$(so-trello board-lists --board "${coredev_board_id}")
4351+ selected_lists=$(echo "${coredev_lists}" | grep -v TODO | grep -v Doing)
4352+
4353+ case "${command}" in
4354+ list)
4355+ echo "== ${coredev_board_name/Core Dev Roadmap/Involvement} =="
4356+ echo
4357+ echo "=== Examples of my work ==="
4358+ echo
4359+ for list in $(echo "${selected_lists}" | cut -d' ' -f1); do
4360+ list_name=$(so-trello list --board "${coredev_board_id}" --list "${list}" | cut -d' ' -f2-)
4361+ cards=$(so-trello list-cards --list "${list}")
4362+ if [ -n "${cards}" ]; then
4363+ echo "${list_name}:"
4364+ for card_id in $(echo "${cards}" | cut -d' ' -f1); do
4365+ # Get the card's title
4366+ card_title=$(echo "${cards}" | grep "^${card_id}" | cut -d' ' -f2-)
4367+
4368+ # Extract work item link from card description
4369+ #echo "so-trello card --board \"${coredev_board_id}\" --card \"${card_id}\" --raw json | jq .desc"
4370+ card_desc=$(so-trello card --board "${coredev_board_id}" --card "${card_id}" --raw json | jq .desc)
4371+ link=$(echo "${card_desc//\"/}" | egrep -o 'https?://[^ ]+')
4372+ if [ -z "${link}" ]; then
4373+ echo " * ${card_title}"
4374+ else
4375+ link_number=$(echo "${link}" | egrep -o '[0-9]+$')
4376+ if [ -z "${link_number}" ]; then
4377+ link_text="link"
4378+ elif [[ "${link}" == *"+bug"* ]]; then
4379+ link_text="LP: #${link_number}"
4380+ elif [[ "${link}" == *"+merge"* ]]; then
4381+ link_text="MP: #${link_number}"
4382+ fi
4383+ echo " * ${card_title} - [[${link}|${link_text}]]"
4384+ fi
4385+ done
4386+ fi
4387+ echo
4388+ done
4389+ ;;
4390+
4391+ help)
4392+ usage 0
4393+ ;;
4394+ *)
4395+ usage 1
4396+ ;;
4397+ esac
4398+ exit
4399+}
4400+
4401+if [[ "${0}" == "${BASH_SOURCE}" ]]; then
4402+ main "$@"
4403+fi
4404diff --git a/uscards/scripts/usdaily b/uscards/scripts/usdaily
4405new file mode 100755
4406index 0000000..04e156c
4407--- /dev/null
4408+++ b/uscards/scripts/usdaily
4409@@ -0,0 +1,186 @@
4410+#!/bin/bash
4411+# -*- coding: utf-8; mode: sh -*-
4412+#
4413+# This script uses so-trello to update cards on the Ubuntu Server team's
4414+# Daily Trello board.
4415+#
4416+# Copyright (C) 2020 Bryce W. Harrington <bryce@bryceharrington.org>
4417+#
4418+# This program is free software: you can redistribute it and/or
4419+# modify it under the terms of the GNU Affero General Public
4420+# License as published by the Free Software Foundation, either
4421+# version 3 of the License, or (at your option) any later
4422+# version.
4423+#
4424+# This program is distributed in the hope that it will be useful,
4425+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4426+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4427+# GNU Affero General Public License for more details.
4428+#
4429+# You should have received a copy of the GNU Affero General Public License
4430+# along with this program. If not, see <http://www.gnu.org/licenses/>.
4431+
4432+progname=$(basename "${0}")
4433+progdir=$(dirname "$(readlink -f "${0}")")
4434+scriptsdir="${progdir}/../scripts"
4435+
4436+usage() {
4437+ cat >&2 <<EOF
4438+Usage: ${progname} [options] <command [params]>
4439+
4440+Commands:
4441+ list Display your open cards
4442+ add <card-title> Adds card with given title to TODO list
4443+ finish <card-id> Move card to Done column
4444+
4445+Options:
4446+ -h, --help This help listing
4447+EOF
4448+ exit $1
4449+}
4450+
4451+warn() {
4452+ echo "Warning: $1" 1>&2
4453+}
4454+
4455+die() {
4456+ echo "Error: $1" 1>&2
4457+ exit 1
4458+}
4459+
4460+card_id() {
4461+ local card="${1}"
4462+
4463+ if [[ "${card}" =~ "https://trello.com/"* ]]; then
4464+ # Looks like a card URL
4465+ echo "${card##*/}"
4466+ return 0
4467+ else
4468+ echo "${card}"
4469+ return 0
4470+ fi
4471+
4472+ warn "Could not parse card id from '${card}'"
4473+ return 1
4474+}
4475+
4476+#####################
4477+### Parse Options ###
4478+#####################
4479+
4480+parse_args() {
4481+ # Transform long options to short ones
4482+ for arg in "$@"; do
4483+ shift
4484+ case "${arg}" in
4485+ "--help") set -- "$@" "-h" ;;
4486+ "--*") usage 1 ;;
4487+ *) set -- "$@" "${arg}"
4488+ esac
4489+ done
4490+
4491+ # Parse short options
4492+ OPTIND=1
4493+ while getopts "h\?" opt $*; do
4494+ case "${opt}" in
4495+ h | \?) usage 0; ;;
4496+ * ) die "Unknown option '${opt}'" ;;
4497+ esac
4498+ done
4499+ shift $(expr ${OPTIND} - 1)
4500+}
4501+
4502+
4503+############
4504+### Main ###
4505+############
4506+
4507+function main() {
4508+ # Parse options and command
4509+ parse_args $@ \
4510+ || die "Could not process options"
4511+ command="${1}" && shift
4512+ [ -n "${command}" ] || usage 1
4513+
4514+ if [ -e ~/.config/uscards.conf ]; then
4515+ source ~/.config/uscards.conf
4516+ elif [ -z "${TRELLO_USERNAME}" ]; then
4517+ die "TRELLO_USERNAME env var needs to be set to your trello account name"
4518+ fi
4519+
4520+ my_boards=$(so-trello member-boards)
4521+ daily_board_id=$(echo "${my_boards}" | grep -i "Daily Ubuntu Server" | cut -d' ' -f1)
4522+ daily_lists=$(so-trello board-lists --board "${daily_board_id}")
4523+
4524+ list_todo=$(echo "${daily_lists}" | grep "TODO" | cut -d' ' -f1)
4525+ list_doing=$(echo "${daily_lists}" | grep -i "Doing" | cut -d' ' -f1)
4526+ list_review=$(echo "${daily_lists}" | grep -i "Review" | cut -d' ' -f1)
4527+ list_external_dependency=$(echo "${daily_lists}" | grep -i "EXTERNAL DEPENDENCY" | cut -d' ' -f1)
4528+ list_done=$(echo "${daily_lists}" | grep "Done" | cut -d' ' -f1)
4529+
4530+ # TODO: Verify the above actually exist
4531+
4532+ case "${command}" in
4533+ list)
4534+ echo "TODO:"
4535+ so-trello list-cards --list "${list_todo}" --is-member "${TRELLO_USERNAME}" | cut -d' ' -f2- | sed -e 's/^/* /'
4536+ echo
4537+
4538+ echo "Doing:"
4539+ so-trello list-cards --list "${list_doing}" --is-member "${TRELLO_USERNAME}" | cut -d' ' -f2- | sed -e 's/^/* /'
4540+ echo
4541+
4542+ echo "Reviews:"
4543+ so-trello list-cards --list "${list_review}" --is-member "${TRELLO_USERNAME}" | cut -d' ' -f2- | sed -e 's/^/* /'
4544+ echo
4545+ ;;
4546+
4547+ add)
4548+ local name="${@}"
4549+ [ -n "${name}" ] || usage 1
4550+
4551+ # By default, use the "TODO" list
4552+ local list="TODO"
4553+
4554+ # Check if stdin comes from terminal or a pipe
4555+ if [ -t 0 ]; then
4556+ # Terminal. Just add card with title.
4557+ so-trello list-addcard \
4558+ --board "${daily_board_id}" \
4559+ --list "${list}" \
4560+ --card-name "${name}"
4561+ echo "${name}:\n${description}"
4562+ else
4563+ # Pipe. Use stdin as the description.
4564+ local description=$(cat <&0)
4565+ so-trello list-addcard \
4566+ --board "${daily_board_id}" \
4567+ --list "${list}" \
4568+ --card-name "${name}" \
4569+ --card-desc "${description}"
4570+ echo "${name}:"
4571+ echo "${description}"
4572+ fi
4573+ ;;
4574+
4575+ finish)
4576+ card=$(card_id "${1}")
4577+ [ -n "${card}" ] || usage 1
4578+
4579+ so-trello card-update --board "${daily_board_id}" \
4580+ --update-board "${daily_board_id}" --update-list "${list_done}" \
4581+ --card "${card}"
4582+ ;;
4583+
4584+ help)
4585+ usage 0
4586+ ;;
4587+ *)
4588+ usage 1
4589+ ;;
4590+ esac
4591+}
4592+
4593+if [[ "${0}" == "${BASH_SOURCE}" ]]; then
4594+ main "$@"
4595+fi
4596diff --git a/uscards/scripts/usmerges b/uscards/scripts/usmerges
4597new file mode 100755
4598index 0000000..0aa4d6a
4599--- /dev/null
4600+++ b/uscards/scripts/usmerges
4601@@ -0,0 +1,194 @@
4602+#!/bin/bash
4603+# -*- coding: utf-8; mode: sh -*-
4604+
4605+# This script uses so-trello to update cards on the Ubuntu Server team's
4606+# Merges Trello board.
4607+#
4608+# Copyright (C) 2020 Bryce W. Harrington <bryce@bryceharrington.org>
4609+#
4610+# This program is free software: you can redistribute it and/or
4611+# modify it under the terms of the GNU Affero General Public
4612+# License as published by the Free Software Foundation, either
4613+# version 3 of the License, or (at your option) any later
4614+# version.
4615+#
4616+# This program is distributed in the hope that it will be useful,
4617+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4618+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4619+# GNU Affero General Public License for more details.
4620+#
4621+# You should have received a copy of the GNU Affero General Public License
4622+# along with this program. If not, see <http://www.gnu.org/licenses/>.
4623+
4624+progname=$(basename "${0}")
4625+progdir=$(dirname "$(readlink -f "${0}")")
4626+scriptsdir="${progdir}/../scripts"
4627+
4628+usage() {
4629+ cat >&2 <<EOF
4630+Usage: ${progname} [options]
4631+
4632+Commands:
4633+ list Display your open cards
4634+ add <card-title) Add card with given title to current month
4635+ finish <card-id> Move card to Done column
4636+
4637+Options:
4638+ -h, --help This help listing
4639+EOF
4640+ exit $1
4641+}
4642+
4643+warn() {
4644+ echo "Warning: $1" 1>&2
4645+}
4646+
4647+die() {
4648+ echo "Error: $1" 1>&2
4649+ exit 1
4650+}
4651+
4652+card_id() {
4653+ local card="${1}"
4654+
4655+ if [[ "${card}" =~ "https://trello.com/"* ]]; then
4656+ # Looks like a card URL
4657+ echo "${card##*/}"
4658+ return 0
4659+ else
4660+ echo "${card}"
4661+ return 0
4662+ fi
4663+
4664+ warn "Could not parse card id from '${card}'"
4665+ return 1
4666+}
4667+
4668+#####################
4669+### Parse Options ###
4670+#####################
4671+
4672+parse_args() {
4673+ # Transform long options to short ones
4674+ for arg in "$@"; do
4675+ shift
4676+ case "${arg}" in
4677+ "--help") set -- "$@" "-h" ;;
4678+ "--*") usage 1 ;;
4679+ *) set -- "$@" "${arg}"
4680+ esac
4681+ done
4682+
4683+ # Parse short options
4684+ OPTIND=1
4685+ while getopts "h\?" opt $*; do
4686+ case "${opt}" in
4687+ h | \?) usage 0; ;;
4688+ * ) die "Unknown option '${opt}'" ;;
4689+ esac
4690+ done
4691+ shift $(expr ${OPTIND} - 1)
4692+}
4693+
4694+############
4695+### Main ###
4696+############
4697+
4698+function main() {
4699+ # Parse options
4700+ parse_args "$@" \
4701+ || die "Could not process options"
4702+ command="${1}" && shift
4703+ [ -n "${command}" ] || usage 1
4704+
4705+ if [ -e ~/.config/uscards.conf ]; then
4706+ source ~/.config/uscards.conf
4707+ elif [ -z "${TRELLO_USERNAME}" ]; then
4708+ die "TRELLO_USERNAME env var needs to be set to your trello account name"
4709+ fi
4710+
4711+ my_boards=$(so-trello member-boards)
4712+ merges_board_id=$(echo "${my_boards}" | grep -i "Merges Schedule" | cut -d' ' -f1)
4713+ merges_board_name=$(echo "${my_boards}" | grep -i "Merges Schedule" | cut -d' ' -f2-)
4714+ merges_lists=$(so-trello board-lists --board "${merges_board_id}")
4715+
4716+ backlog_lists=$(echo "${merges_lists}" | grep -i backlog)
4717+ active_lists=$(echo "${merges_lists}" | grep -iv backlog)
4718+
4719+ selected_lists="${active_lists}"
4720+
4721+ case "${command}" in
4722+ list)
4723+ echo "${merges_board_name}:"
4724+ for list in $(echo "${selected_lists}" | cut -d' ' -f1); do
4725+ list_name=$(so-trello list --list "${list}" | cut -d' ' -f2-)
4726+ cards=$(so-trello list-cards --list "${list}" --is-member "${TRELLO_USERNAME}")
4727+ if [ -n "${cards}" ]; then
4728+ echo "* ${list_name}:"
4729+ for card in "${cards}"; do
4730+ card_id=$(echo "${card}" | cut -d' ' -f1)
4731+ card_title=$(echo "${card}" | cut -d' ' -f2-)
4732+ echo "${card_title}" | sed -e 's/^/ - /'
4733+ # TODO: Get some card properties we want to display
4734+ # echo so-trello card --board "${merges_board_id}" --card "${card_id}" --raw json
4735+ done
4736+ fi
4737+ done
4738+ ;;
4739+
4740+ add)
4741+ local name="${@}"
4742+ [ -n "${name}" ] || usage 1
4743+
4744+ # By default, use the list for the current month
4745+ local list=$(date +%y.%m)
4746+ # TODO: Verify the list exists
4747+
4748+ # Check if stdin comes from terminal or a pipe
4749+ if [ -t 0 ]; then
4750+ # Terminal. Just add card with title.
4751+ so-trello list-addcard \
4752+ --board "${merges_board_id}" \
4753+ --list "${list}" \
4754+ --card-name "${name}"
4755+ echo "${name}:"
4756+ echo "${description}"
4757+ else
4758+ # Pipe. Use stdin as the description.
4759+ local description=$(cat <&0)
4760+ so-trello list-addcard \
4761+ --board "${merges_board_id}" \
4762+ --list "${list}" \
4763+ --card-name "${name}" \
4764+ --card-desc "${description}"
4765+ echo "${name}:"
4766+ echo "${description}"
4767+ fi
4768+ ;;
4769+
4770+ finish)
4771+ card=$(card_id "${1}")
4772+ [ -n "${card}" ] || usage 1
4773+
4774+ # TODO: Need to set 'DONE' on card
4775+ #so-trello card-update --board "${merges_board_id}" \
4776+ # --update-board "${merges_board_id}" --update-list "${list_done}" \
4777+ # --card "${card}"
4778+ ;;
4779+
4780+ help)
4781+ usage 0
4782+ ;;
4783+ *)
4784+ usage 1
4785+ ;;
4786+ esac
4787+
4788+ # Subcommands to add:
4789+ # * start <card> # Moves from TODO column to the Doing column
4790+ # * submit <card> # Moves to the Review column
4791+}
4792+
4793+if [[ "${0}" == "${BASH_SOURCE}" ]]; then
4794+ main "$@"
4795+fi
4796diff --git a/uscards/scripts/usmigration b/uscards/scripts/usmigration
4797new file mode 100755
4798index 0000000..feadefd
4799--- /dev/null
4800+++ b/uscards/scripts/usmigration
4801@@ -0,0 +1,161 @@
4802+#!/bin/bash
4803+# -*- coding: utf-8; mode: sh -*-
4804+#
4805+# Proposed migration trello board CLI
4806+#
4807+# Copyright (C) 2020 Bryce W. Harrington <bryce@bryceharrington.org>
4808+#
4809+# This program is free software: you can redistribute it and/or
4810+# modify it under the terms of the GNU Affero General Public
4811+# License as published by the Free Software Foundation, either
4812+# version 3 of the License, or (at your option) any later
4813+# version.
4814+#
4815+# This program is distributed in the hope that it will be useful,
4816+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4817+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4818+# GNU Affero General Public License for more details.
4819+#
4820+# You should have received a copy of the GNU Affero General Public License
4821+# along with this program. If not, see <http://www.gnu.org/licenses/>.
4822+
4823+progname=$(basename "${0}")
4824+progdir=$(dirname "$(readlink -f "${0}")")
4825+scriptsdir="${progdir}/../scripts"
4826+
4827+usage() {
4828+ cat >&2 <<EOF
4829+Usage: ${progname} [options]
4830+
4831+Commands:
4832+ list Display migration issues that need attention
4833+ finish <card-title> Move card to Done column
4834+
4835+Options:
4836+ -h, --help This help listing
4837+EOF
4838+ exit $1
4839+}
4840+
4841+warn() {
4842+ echo "Warning: $1" 1>&2
4843+}
4844+
4845+die() {
4846+ echo "Error: $1" 1>&2
4847+ exit 1
4848+}
4849+
4850+card_id() {
4851+ local card="${1}"
4852+
4853+ if [[ "${card}" =~ "https://trello.com/"* ]]; then
4854+ # Looks like a card URL
4855+ echo "${card##*/}"
4856+ return 0
4857+ else
4858+ echo "${card}"
4859+ return 0
4860+ fi
4861+
4862+ warn "Could not parse card id from '${card}'"
4863+ return 1
4864+}
4865+
4866+
4867+#####################
4868+### Parse Options ###
4869+#####################
4870+
4871+parse_args() {
4872+ # Transform long options to short ones
4873+ for arg in "$@"; do
4874+ shift
4875+ case "${arg}" in
4876+ "--help") set -- "$@" "-h" ;;
4877+ "--*") usage 1 ;;
4878+ *) set -- "$@" "${arg}"
4879+ esac
4880+ done
4881+
4882+ # Parse short options
4883+ OPTIND=1
4884+ while getopts "h\?" opt $*; do
4885+ case "${opt}" in
4886+ h | \?) usage 0; ;;
4887+ * ) die "Unknown option '${opt}'" ;;
4888+ esac
4889+ done
4890+ shift $(expr ${OPTIND} - 1)
4891+}
4892+
4893+
4894+
4895+############
4896+### Main ###
4897+############
4898+
4899+function main() {
4900+ # Parse options
4901+ parse_args "$@" \
4902+ || die "Could not process options"
4903+
4904+ command="${1}" && shift
4905+ [ -n "${command}" ] || usage 1
4906+
4907+ if [ -e ~/.config/uscards.conf ]; then
4908+ source ~/.config/uscards.conf
4909+ elif [ -z "${TRELLO_USERNAME}" ]; then
4910+ die "TRELLO_USERNAME env var needs to be set to your trello account name"
4911+ fi
4912+
4913+ my_boards=$(so-trello member-boards)
4914+ migration_board_id=$(echo "${my_boards}" | grep -i "Proposed Migration" | cut -d' ' -f1)
4915+ migration_lists=$(so-trello board-lists --board "${migration_board_id}")
4916+
4917+ list_languishing=$(echo "${migration_lists}" | grep "Languishing" | cut -d' ' -f1)
4918+ list_todo=$(echo "${migration_lists}" | egrep "To *Do" | cut -d' ' -f1)
4919+ list_doing=$(echo "${migration_lists}" | egrep "Doing" | cut -d' ' -f1)
4920+ list_blocked=$(echo "${migration_lists}" | egrep "Blocked" | cut -d' ' -f1)
4921+ list_done=$(echo "${migration_lists}" | egrep "Done" | cut -d' ' -f1)
4922+ list_pending=$(echo "${migration_lists}" | egrep "Pending" | cut -d' ' -f1)
4923+
4924+ # TODO: Verify the above actually exist
4925+
4926+ case "${command}" in
4927+ list)
4928+ echo "Languishing:"
4929+ so-trello list-cards --list "${list_languishing}" --is-unassigned | cut -d' ' -f2- | sed -e 's/^/* /'
4930+ echo
4931+
4932+ echo "TODO:"
4933+ so-trello list-cards --list "${list_todo}" --is-unassigned | cut -d' ' -f2- | sed -e 's/^/* /'
4934+ echo
4935+
4936+ echo "Doing:"
4937+ so-trello list-cards --list "${list_doing}" --is-unassigned | cut -d' ' -f2- | sed -e 's/^/* /'
4938+ echo
4939+ ;;
4940+
4941+ finish)
4942+ card=$(card_id "${1}")
4943+ [ -n "${card}" ] || usage 1
4944+
4945+ so-trello card-update --board "${migration_board_id}" \
4946+ --update-board "${migration_board_id}" --update-list "${list_done}" \
4947+ --card "${card}"
4948+ ;;
4949+
4950+ help)
4951+ usage 0
4952+ ;;
4953+ *)
4954+ usage 1
4955+ ;;
4956+
4957+ esac
4958+}
4959+
4960+if [[ "${0}" == "${BASH_SOURCE}" ]]; then
4961+ main "$@"
4962+fi

Subscribers

People subscribed via source and target branches

to all changes: