Merge lp:~juliank/software-properties/add-apt-repository-run-update into lp:software-properties

Proposed by Julian Andres Klode
Status: Merged
Approved by: Balint Reczey
Approved revision: 1006
Merged at revision: 1004
Proposed branch: lp:~juliank/software-properties/add-apt-repository-run-update
Merge into: lp:software-properties
Diff against target: 58 lines (+25/-2)
2 files modified
add-apt-repository (+19/-2)
debian/changelog (+6/-0)
To merge this branch: bzr merge lp:~juliank/software-properties/add-apt-repository-run-update
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Balint Reczey Approve
Review via email: mp+336137@code.launchpad.net

Description of the change

This automatically runs apt-get update after adding repositories. While SoftwareProperties can already do updates, it only does them for shortcuts, not for enabling components. It also shows no progress or anything.

We could modify it to run always and show progress, but this seems like it could cause potential problems when the same code is used elsewhere, for example in the dbus client.

Also, the Python text progress implementation might have problems not in the C++ version, so it's best to just execvp() apt-get when we're done.

To post a comment you must log in.
1005. By Julian Andres Klode

releasing package software-properties version 0.96.24.20

Revision history for this message
Julian Andres Klode (juliank) wrote :

Optimally we would only update the source we have added. But this is problematic if the source shares the same Release file with an existing source (everything with the same Release file needs to be updated together). Figuring out which entries share the same Release file, and then creating a temporary sources.list to update only them would be possible, but it seems a bit too fragile.

Revision history for this message
Balint Reczey (rbalint) :
review: Needs Information
Revision history for this message
Julian Andres Klode (juliank) :
Revision history for this message
Balint Reczey (rbalint) :
1006. By Julian Andres Klode

Address review comments

Revision history for this message
Balint Reczey (rbalint) :
review: Approve
Revision history for this message
Steve Langasek (vorlon) wrote :

Should we execvp() without a path? That is generally consistent with Debian policy.

review: Approve
Revision history for this message
Julian Andres Klode (juliank) wrote :

Ugh, forgot about the path thing. sigh. Will commit for someone else to pick up :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'add-apt-repository'
2--- add-apt-repository 2017-09-06 22:36:49 +0000
3+++ add-apt-repository 2018-01-16 11:38:23 +0000
4@@ -69,10 +69,22 @@
5 parser.add_option("-y", "--yes", action="store_true",
6 dest="assume_yes", default=False,
7 help=_("Assume yes to all queries"))
8+ parser.add_option("-n", "--no-update", action="store_false",
9+ dest="update", default=True,
10+ help=_("Do not update package cache after adding"))
11 parser.add_option("-u", "--update", action="store_true",
12- dest="update", default=False,
13- help=_("Update package cache after adding"))
14+ dest="update", default=True,
15+ help=_("Update package cache after adding (legacy option)"))
16 (options, args) = parser.parse_args()
17+
18+ # We prefer to run apt-get update here. The built-in update support
19+ # does not have any progress, and only works for shortcuts. Moving
20+ # it to something like save() and using apt.progress.text would
21+ # solve the problem, but the new errors might cause problems with
22+ # the dbus server or other users of the API. Also, it's unclear
23+ # how good the text progress is or how to pass it best.
24+ update = options.update
25+ options.update = False
26
27 if os.geteuid() != 0:
28 print(_("Error: must run as root"))
29@@ -114,6 +126,8 @@
30 print(_("'%s' distribution component is already enabled for all sources.") % line)
31 sys.exit(0)
32 sp.sourceslist.save()
33+ if update and not options.remove:
34+ os.execvp("/usr/bin/apt-get", ["apt-get", "update"])
35 sys.exit(0)
36
37 # this wasn't a component name ('multiverse', 'backports'), so its either
38@@ -177,3 +191,6 @@
39 sys.exit(1)
40
41 sp.sourceslist.save()
42+ if update and not options.remove:
43+ os.execvp("/usr/bin/apt-get", ["apt-get", "update"])
44+ sys.exit(0)
45
46=== modified file 'debian/changelog'
47--- debian/changelog 2017-12-20 20:55:27 +0000
48+++ debian/changelog 2018-01-16 11:38:23 +0000
49@@ -1,3 +1,9 @@
50+software-properties (0.96.24.20) bionic; urgency=medium
51+
52+ * add-apt-repository: Run apt-get update after adding sources.
53+
54+ -- Julian Andres Klode <juliank@ubuntu.com> Tue, 16 Jan 2018 09:58:55 +0100
55+
56 software-properties (0.96.24.19) bionic; urgency=medium
57
58 * tests: Clear configuration before running init() again

Subscribers

People subscribed via source and target branches

to status/vote changes: