Commit
David Kalnischkies pointed out in bug #714877 a clever way to make apt-get update only affect a single sources.list-format file, using various apt options to override the sources.list and sources.list.d locations, and keep the lists for existing sources. This works "in any apt version", and is cleaner than faking the list operations ourselves.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,45 +188,26 @@ sub update_archive { | |
DIR => '/' }); | ||
return $?; | ||
} else { | ||
# Example archive list names: | ||
#_tmp_resolver-XXXXXX_apt%5farchive_._Packages | ||
#_tmp_resolver-XXXXXX_apt%5farchive_._Release | ||
#_tmp_resolver-XXXXXX_apt%5farchive_._Release.gpg | ||
#_tmp_resolver-XXXXXX_apt%5farchive_._Sources | ||
|
||
# Update lists directly; only updates local archive | ||
|
||
# Filename quoting for safety taken from apt URItoFileName and | ||
# QuoteString. | ||
my $session = $self->get('Session'); | ||
my $dummy_dir = $self->get('Dummy package path'); | ||
my $dummy_archive_dir = $session->strip_chroot_path($dummy_dir.'/apt_archive/./'); | ||
my @chars = split('', $dummy_archive_dir); | ||
|
||
foreach(@chars) { | ||
if (index('\\|{}[]<>"^~_=!@#$%^&*', $_) != -1 || # "Bad" characters | ||
!m/[[:print:]]/ || # Not printable | ||
ord($_) == 0x25 || # Percent '%' char | ||
ord($_) <= 0x20 || # Control chars | ||
ord($_) >= 0x7f) { # Control chars | ||
$_ = sprintf("%%%02x", ord($_)); | ||
} | ||
my $dummy_archive_list_file = $self->get('Dummy archive list file'); | ||
# We need an empty sources.list.d directory, so that we have an option | ||
# to pass in to skip the real one. | ||
my $dummy_sources_list_d = $self->get('Dummy package path') . '/sources.list.d'; | ||
if (!(-d $dummy_sources_list_d || mkdir $dummy_sources_list_d, 0700)) { | ||
$self->log_warning('Could not create build-depends dummy sources.list directory ' . $dummy_sources_list_d . ': ' . $!); | ||
$self->cleanup_apt_archive(); | ||
return 0; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
geofft
Owner
|
||
} | ||
|
||
my $uri = join('', @chars); | ||
$uri =~ s;/;_;g; # Escape slashes | ||
|
||
foreach my $file ("Packages", "Release", "Release.gpg", "Sources") { | ||
$session->run_command( | ||
{ COMMAND => ['cp', $dummy_archive_dir . '/' . $file, | ||
'/var/lib/apt/lists/' . $uri . $file], | ||
USER => 'root', | ||
PRIORITY => 0 }); | ||
if ($?) { | ||
$self->log("Failed to copy file from dummy archive to apt lists.\n"); | ||
return 1; | ||
} | ||
} | ||
$self->run_apt_command( | ||
{ COMMAND => [$self->get_conf('APT_GET'), 'update', | ||
'-o', 'Dir::Etc::sourcelist=' . $session->strip_chroot_path($dummy_archive_list_file), | ||
'-o', 'Dir::Etc::sourceparts=' . $session->strip_chroot_path($dummy_sources_list_d), | ||
This comment has been minimized.
Sorry, something went wrong.
em-
|
||
'-o', 'APT::List-Cleanup=0'], | ||
This comment has been minimized.
Sorry, something went wrong.
geofft
Owner
|
||
ENV => {'DEBIAN_FRONTEND' => 'noninteractive'}, | ||
USER => 'root', | ||
DIR => '/' }); | ||
return $? if $?; | ||
|
||
$self->run_apt_command( | ||
{ COMMAND => [$self->get_conf('APT_CACHE'), 'gencaches'], | ||
This comment has been minimized.
Sorry, something went wrong.
em-
|
||
|
6 comments
on commit 557d394
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geofft, do you have the chance to check the issues highlighted in the previous comments? I'd like to start poking people around to get this stuff merged once the patchset is ready. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm meaning to get to it but work's been keeping me busy. I'm at a conference this week, but I'll try to get to it this weekend at latest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! No need to hurry though, I was just pinging to prevent this stuff from going out of your radar (and mine). :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping! :D
More seriously, would you prefer having me polish up the branch a bit so you can review it and submit it upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@em-, thanks for the pings. I've pushed a new version to the extra-package branch (partly 'cause I renamed the option, partly 'cause I wasn't sure where the comments on this branch would go). Let me know if you have thoughts.
Do you want to rebase this on top of your refactoring, or should I just send this to the bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@em-, thanks for the pings. I've pushed a new version to the extra-package branch (partly 'cause I renamed the option, partly 'cause I wasn't sure where the comments on this branch would go). Let me know if you have thoughts.
Yup, I too find how github comments are bound to the commit hash a bit confusing when you're rebasing a branch.
Do you want to rebase this on top of your refactoring, or should I just send this to the bug?
No, keep your stuff simple and easier to merge, I'll rebase my refactoring on top of your changes once they enter the upstream repo.
Thanks!
AIUI this is not needed, just pass
/dev/null
asDir::Etc::sourceparts
.