Add initial support for including backports in a build

So far only tested with a single image - targeting a netinst with some
updated packages
This commit is contained in:
Steve McIntyre 2016-09-20 01:46:15 +01:00
parent 1cf9160af7
commit 66154bff85
9 changed files with 683 additions and 173 deletions

10
CONF.sh
View File

@ -68,6 +68,16 @@ export CODENAME=stretch
if [ -z "$DI_CODENAME" ]; then if [ -z "$DI_CODENAME" ]; then
export DI_CODENAME=$CODENAME export DI_CODENAME=$CODENAME
fi fi
# If you want backported d-i (e.g. by setting
# DI_CODENAME=jessie-backports, then you'll almost definitely also
# want to enable BACKPORTS below as well
# Should we include some packages from backports? If so, point at a
# file containing a list of binary packages to include here. Packages
# contained in that list will be chosen by preference from
# ${CODENAME}-backports rather than just ${CODENAME}, along with
# dependencies if they're needed as well
#export BACKPORTS=backports-list
# If set, controls where the d-i components are downloaded from. # If set, controls where the d-i components are downloaded from.
# This may be an url, or "default", which will make it use the default url # This may be an url, or "default", which will make it use the default url

View File

@ -68,6 +68,7 @@ endif
## Internal variables ## Internal variables
apt=$(BASEDIR)/tools/apt-selection apt=$(BASEDIR)/tools/apt-selection
check_backports_packages=$(BASEDIR)/tools/check_backports_packages
sort_deps=$(BASEDIR)/tools/sort_deps sort_deps=$(BASEDIR)/tools/sort_deps
md5sum=md5sum md5sum=md5sum
jigdo_cleanup=$(BASEDIR)/tools/jigdo_cleanup jigdo_cleanup=$(BASEDIR)/tools/jigdo_cleanup
@ -213,6 +214,10 @@ $(CODENAME)_status: ok init
$(Q)for ARCH in $(ARCHES_NOSRC); do \ $(Q)for ARCH in $(ARCHES_NOSRC); do \
echo "Using the provided status file for $(CODENAME)-$$ARCH ..."; \ echo "Using the provided status file for $(CODENAME)-$$ARCH ..."; \
cp $(BASEDIR)/data/$(CODENAME)/status.$$ARCH $(ADIR)/$(CODENAME)-$$ARCH/status 2>/dev/null || $(MAKE) status || $(MAKE) correctstatus ; \ cp $(BASEDIR)/data/$(CODENAME)/status.$$ARCH $(ADIR)/$(CODENAME)-$$ARCH/status 2>/dev/null || $(MAKE) status || $(MAKE) correctstatus ; \
if [ "$$BACKPORTS"x != ""x ] ; then \
echo "Using the provided status file for $(CODENAME)-backports-$$ARCH ..."; \
cp $(BASEDIR)/data/$(CODENAME)/status.$$ARCH $(ADIR)/$(CODENAME)-backports-$$ARCH/status 2>/dev/null || $(MAKE) status || $(MAKE) correctstatus ; \
fi; \
done done
# Regenerate the status file with only packages that # Regenerate the status file with only packages that
@ -222,12 +227,23 @@ $(ADIR)/status:
@echo "Generating a fake status file for apt-get and apt-cache..." @echo "Generating a fake status file for apt-get and apt-cache..."
$(Q)for ARCH in $(ARCHES); do \ $(Q)for ARCH in $(ARCHES); do \
mkdir -p $(ADIR)/$(CODENAME)-$$ARCH/apt/preferences.d; \ mkdir -p $(ADIR)/$(CODENAME)-$$ARCH/apt/preferences.d; \
if [ "$$BACKPORTS"x != ""x ] ; then \
mkdir -p $(ADIR)/$(CODENAME)-backports-$$ARCH/apt/preferences.d; \
fi; \
if [ $$ARCH = "source" -o "$(INSTALLER_CD)" = "1" -o "$(INSTALLER_CD)" = "2" -o "$(INSTALLER_CD)" = "C" -o "$(INSTALLER_CD)" = "F" ];then \ if [ $$ARCH = "source" -o "$(INSTALLER_CD)" = "1" -o "$(INSTALLER_CD)" = "2" -o "$(INSTALLER_CD)" = "C" -o "$(INSTALLER_CD)" = "F" ];then \
:> $(ADIR)/$(CODENAME)-$$ARCH/status ; \ :> $(ADIR)/$(CODENAME)-$$ARCH/status ; \
if [ "$$BACKPORTS"x != ""x ] ; then \
:> $(ADIR)/$(CODENAME)-backports-$$ARCH/status ; \
fi; \
else \ else \
zcat $(MIRROR)/dists/$(CODENAME)/main/binary-$$ARCH/Packages.gz | \ zcat $(MIRROR)/dists/$(CODENAME)/main/binary-$$ARCH/Packages.gz | \
perl -000 -ne 's/^(Package: .*)$$/$$1\nStatus: install ok installed/m; print if (/^Priority: (required|important|standard)/m or /^Section: base/m);' \ perl -000 -ne 's/^(Package: .*)$$/$$1\nStatus: install ok installed/m; print if (/^Priority: (required|important|standard)/m or /^Section: base/m);' \
>> $(ADIR)/$(CODENAME)-$$ARCH/status ; \ >> $(ADIR)/$(CODENAME)-$$ARCH/status ; \
if [ "$$BACKPORTS"x != ""x ] ; then \
zcat $(MIRROR)/dists/$(CODENAME)/main/binary-$$ARCH/Packages.gz | \
perl -000 -ne 's/^(Package: .*)$$/$$1\nStatus: install ok installed/m; print if (/^Priority: (required|important|standard)/m or /^Section: base/m);' \
>> $(ADIR)/$(CODENAME)-backports-$$ARCH/status ; \
fi; \
fi; \ fi; \
done; done;
:> $(ADIR)/status :> $(ADIR)/status
@ -239,12 +255,19 @@ $(ADIR)/status:
$(Q)for ARCH in $(ARCHES); do \ $(Q)for ARCH in $(ARCHES); do \
mkdir -p $(ADIR)/$(CODENAME)-$$ARCH/apt/trusted.gpg.d; \ mkdir -p $(ADIR)/$(CODENAME)-$$ARCH/apt/trusted.gpg.d; \
ln -s $(TDIR)/archive-keyring/$(ARCHIVE_KEYRING_FILE) $(ADIR)/$(CODENAME)-$$ARCH/apt/trusted.gpg.d; \ ln -s $(TDIR)/archive-keyring/$(ARCHIVE_KEYRING_FILE) $(ADIR)/$(CODENAME)-$$ARCH/apt/trusted.gpg.d; \
if [ "$$BACKPORTS"x != ""x ] ; then \
mkdir -p $(ADIR)/$(CODENAME)-backports-$$ARCH/apt/trusted.gpg.d; \
ln -s $(TDIR)/archive-keyring/$(ARCHIVE_KEYRING_FILE) $(ADIR)/$(CODENAME)-backports-$$ARCH/apt/trusted.gpg.d; \
fi; \
done done
# Updating the apt database # Updating the apt database
$(Q)for ARCH in $(ARCHES); do \ $(Q)for ARCH in $(ARCHES); do \
export ARCH=$$ARCH; \ export ARCH=$$ARCH; \
$(apt) update; \ $(apt) update; \
if [ "$$BACKPORTS"x != ""x ] ; then \
USE_BP=1 $(apt) update; \
fi; \
done done
# If we're doing a build using d-i from sid, we'll need sid sources too # If we're doing a build using d-i from sid, we'll need sid sources too
@ -256,6 +279,9 @@ $(ADIR)/status:
export CODENAME=$(DI_CODENAME); \ export CODENAME=$(DI_CODENAME); \
export ARCH=source; \ export ARCH=source; \
$(apt) update; \ $(apt) update; \
if [ "$$BACKPORTS"x != ""x ] ; then \
USE_BP=1 $(apt) update; \
fi; \
fi fi
# #
# Checking the consistency of the standard system # Checking the consistency of the standard system
@ -264,6 +290,9 @@ $(ADIR)/status:
$(Q)for ARCH in $(ARCHES); do \ $(Q)for ARCH in $(ARCHES); do \
export ARCH=$$ARCH; \ export ARCH=$$ARCH; \
$(apt) check || $(MAKE) correctstatus; \ $(apt) check || $(MAKE) correctstatus; \
if [ "$$BACKPORTS"x != ""x ] ; then \
USE_BP=1 $(apt) check || $(MAKE) correctstatus; \
fi; \
done done
# Only useful if the standard system is broken # Only useful if the standard system is broken
@ -282,6 +311,13 @@ correctstatus: status apt-update
perl -i -000 -ne "print unless /^Package: \Q$$i\E/m" \ perl -i -000 -ne "print unless /^Package: \Q$$i\E/m" \
$(ADIR)/$(CODENAME)-$$ARCH/status; \ $(ADIR)/$(CODENAME)-$$ARCH/status; \
done; \ done; \
if [ "$$BACKPORTS"x != ""x ] ; then \
for i in `USE_BP=1 $(apt) deselected -f install`; do \
echo $$ARCH:$$i; \
perl -i -000 -ne "print unless /^Package: \Q$$i\E/m" \
$(ADIR)/$(CODENAME)-backports-$$ARCH/status; \
done; \
fi; \
done; \ done; \
fi fi
# #
@ -296,12 +332,23 @@ correctstatus: status apt-update
"s/^(Package: .*)\$$/\$$1\nStatus: install ok installed/m;" \ "s/^(Package: .*)\$$/\$$1\nStatus: install ok installed/m;" \
>> $(ADIR)/$(CODENAME)-$$ARCH/status; \ >> $(ADIR)/$(CODENAME)-$$ARCH/status; \
done; \ done; \
if [ "$$BACKPORTS"x != ""x ] ; then \
for i in `USE_BP=1 $(apt) selected -f install`; do \
echo $$ARCH:$$i; \
USE_BP=1 $(apt) cache --no-all-versions show "$$i" | perl -000 -npe \
"s/^(Package: .*)\$$/\$$1\nStatus: install ok installed/m;" \
>> $(ADIR)/$(CODENAME)-backports-$$ARCH/status; \
done; \
fi; \
done; \ done; \
fi fi
# #
# Showing the output of apt-get check : # Showing the output of apt-get check :
$(Q)for ARCH in $(ARCHES_NOSRC); do \ $(Q)for ARCH in $(ARCHES_NOSRC); do \
ARCH=$$ARCH $(apt) check; \ ARCH=$$ARCH $(apt) check; \
if [ "$$BACKPORTS"x != ""x ] ; then \
USE_BP=1 ARCH=$$ARCH $(apt) check; \
fi; \
done done
apt-update: status apt-update: status
@ -309,6 +356,9 @@ apt-update: status
for ARCH in $(ARCHES); do \ for ARCH in $(ARCHES); do \
echo "Apt-get is updating its files ..."; \ echo "Apt-get is updating its files ..."; \
ARCH=$$ARCH $(apt) update; \ ARCH=$$ARCH $(apt) update; \
if [ "$$BACKPORTS"x != ""x ] ; then \
USE_BP=1 ARCH=$$ARCH $(apt) update; \
fi; \
done; \ done; \
fi fi
@ -402,6 +452,10 @@ $(BDIR)/list: $(BDIR)/rawlist
print "$$_\n" if not $$seen{$$_}; $$seen{$$_}++;' \ print "$$_\n" if not $$seen{$$_}; $$seen{$$_}++;' \
$(BDIR)/rawlist \ $(BDIR)/rawlist \
> $(BDIR)/list > $(BDIR)/list
# Now check to see if we've been told to use backports
# versions of any of the packages in our list.
$(check_backports_packages) $(BDIR)/list $(BDIR)/list.backports
if [ -f $(BDIR)/list.backports ]; then mv $(BDIR)/list.backports $(BDIR)/list; fi
## IMAGE BUILDING ## ## IMAGE BUILDING ##

1
debian/changelog vendored
View File

@ -3,6 +3,7 @@ debian-cd (3.1.19) UNRELEASED; urgency=medium
[ Steve McIntyre ] [ Steve McIntyre ]
* Also fix size calculation for EFI image for arm64 * Also fix size calculation for EFI image for arm64
* Add workaround for dosfstools issue (#823881) * Add workaround for dosfstools issue (#823881)
* Add support for adding backports into a build
[ Cyril Brulebois ] [ Cyril Brulebois ]
* Only export WGET_OPTS="--ca-directory /etc/ssl/ca-debian/" when this * Only export WGET_OPTS="--ca-directory /etc/ssl/ca-debian/" when this

View File

@ -18,6 +18,7 @@ if [ -z "$CODENAME" ] || [ -z "$ARCH" ] || [ -z "$APTTMP" ]; then
echo "CODENAME=$CODENAME" echo "CODENAME=$CODENAME"
echo "ARCH=$ARCH" echo "ARCH=$ARCH"
echo "APTTMP=$APTTMP" echo "APTTMP=$APTTMP"
echo "USE_BP=$USE_BP"
fi fi
fi fi
@ -27,10 +28,16 @@ else
ADEB="deb" ADEB="deb"
fi fi
options=" -q -o Dir::State::status=$APTTMP/$CODENAME-$ARCH/status \ if [ "$USE_BP"x = "1"x ] ; then
-o Dir::State=$APTTMP/$CODENAME-$ARCH/apt-state/ \ THIS_PKGSET="$CODENAME-backports-$ARCH"
-o Dir::Cache=$APTTMP/$CODENAME-$ARCH/apt-cache/ \ else
-o Dir::Etc=$APTTMP/$CODENAME-$ARCH/apt/ \ THIS_PKGSET="$CODENAME-$ARCH"
fi
options=" -q -o Dir::State::status=$APTTMP/$THIS_PKGSET/status \
-o Dir::State=$APTTMP/$THIS_PKGSET/apt-state/ \
-o Dir::Cache=$APTTMP/$THIS_PKGSET/apt-cache/ \
-o Dir::Etc=$APTTMP/$THIS_PKGSET/apt/ \
-o APT::Cache::AllVersions=0 \ -o APT::Cache::AllVersions=0 \
-o APT::Cache::ShowVersion=1 \ -o APT::Cache::ShowVersion=1 \
-o APT::Architecture=$ARCH \ -o APT::Architecture=$ARCH \
@ -46,55 +53,67 @@ if [ "${CONTRIB:-0}" != "0" ]; then
fi fi
# Check for the necessary dirs and files ... # Check for the necessary dirs and files ...
if [ ! -d "$APTTMP/$CODENAME-$ARCH/apt-state/lists/partial" ]; then if [ ! -d "$APTTMP/$THIS_PKGSET/apt-state/lists/partial" ]; then
mkdir -p "$APTTMP/$CODENAME-$ARCH/apt-state/lists/partial" mkdir -p "$APTTMP/$THIS_PKGSET/apt-state/lists/partial"
fi fi
if [ ! -d "$APTTMP/$CODENAME-$ARCH/apt-cache/archives/partial" ]; then if [ ! -d "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial" ]; then
mkdir -p "$APTTMP/$CODENAME-$ARCH/apt-cache/archives/partial" mkdir -p "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial"
fi fi
if [ ! -d "$APTTMP/$CODENAME-$ARCH/apt" ]; then if [ ! -d "$APTTMP/$THIS_PKGSET/apt" ]; then
mkdir -p "$APTTMP/$CODENAME-$ARCH/apt" mkdir -p "$APTTMP/$THIS_PKGSET/apt"
fi fi
if [ ! -e "$APTTMP/$CODENAME-$ARCH/status" ]; then if [ ! -e "$APTTMP/$THIS_PKGSET/status" ]; then
touch "$APTTMP/$CODENAME-$ARCH/status" touch "$APTTMP/$THIS_PKGSET/status"
fi fi
if [ ! -e "$APTTMP/$CODENAME-$ARCH/apt/sources.list" ]; then if [ ! -e "$APTTMP/$THIS_PKGSET/apt/sources.list" ]; then
# Backports
if [ -n "$USE_BP" ]; then
echo "$ADEB file:$MIRROR $CODENAME-backports $sections" \
>> $APTTMP/$THIS_PKGSET/apt/sources.list
if [ $ARCH != source ] ; then
if [ -e "$MIRROR/dists/$CODENAME-backports/main/debian-installer" ]; then
echo "$ADEB file:$MIRROR $CODENAME-backports main/debian-installer" \
>> $APTTMP/$THIS_PKGSET/apt/sources.list
fi
fi
else
# Generating a correct sources.list file # Generating a correct sources.list file
echo "$ADEB file:$MIRROR $CODENAME $sections" \ echo "$ADEB file:$MIRROR $CODENAME $sections" \
> $APTTMP/$CODENAME-$ARCH/apt/sources.list > $APTTMP/$THIS_PKGSET/apt/sources.list
if [ -n "$PROPOSED_UPDATES" ]; then if [ -n "$PROPOSED_UPDATES" ]; then
echo "$ADEB file:$MIRROR $PROPOSED_UPDATES $sections" \ echo "$ADEB file:$MIRROR $PROPOSED_UPDATES $sections" \
>> $APTTMP/$CODENAME-$ARCH/apt/sources.list >> $APTTMP/$THIS_PKGSET/apt/sources.list
fi fi
# Local packages ... # Local packages ...
if [ -n "$LOCAL" ]; then if [ -n "$LOCAL" ]; then
echo "$ADEB file:${LOCALDEBS:-$MIRROR} $CODENAME local" \ echo "$ADEB file:${LOCALDEBS:-$MIRROR} $CODENAME local" \
>> $APTTMP/$CODENAME-$ARCH/apt/sources.list >> $APTTMP/$THIS_PKGSET/apt/sources.list
fi fi
# Security mirror ... # Security mirror ...
if [ -n "$SECURITY" ]; then if [ -n "$SECURITY" ]; then
echo "$ADEB file:${SECURITY:-$MIRROR} $CODENAME/updates $sections" \ echo "$ADEB file:${SECURITY:-$MIRROR} $CODENAME/updates $sections" \
>> $APTTMP/$CODENAME-$ARCH/apt/sources.list >> $APTTMP/$THIS_PKGSET/apt/sources.list
fi fi
# Debian-installer # Debian-installer
if [ $ARCH != source ] ; then if [ $ARCH != source ] ; then
if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer" ]; then if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer" ]; then
echo "$ADEB file:$MIRROR $DI_CODENAME main/debian-installer" \ echo "$ADEB file:$MIRROR $DI_CODENAME main/debian-installer" \
>> $APTTMP/$CODENAME-$ARCH/apt/sources.list >> $APTTMP/$THIS_PKGSET/apt/sources.list
fi fi
if [ -n "$LOCAL" ] && [ -e "${LOCALDEBS:-$MIRROR}/dists/$DI_CODENAME/local/debian-installer" ]; then if [ -n "$LOCAL" ] && [ -e "${LOCALDEBS:-$MIRROR}/dists/$DI_CODENAME/local/debian-installer" ]; then
echo "$ADEB file:${LOCALDEBS:-$MIRROR} $DI_CODENAME local/debian-installer" \ echo "$ADEB file:${LOCALDEBS:-$MIRROR} $DI_CODENAME local/debian-installer" \
>> $APTTMP/$CODENAME-$ARCH/apt/sources.list >> $APTTMP/$THIS_PKGSET/apt/sources.list
fi
fi fi
fi fi
fi fi
temp=$APTTMP/$CODENAME-$ARCH/temp.apt-selection temp=$APTTMP/$THIS_PKGSET/temp.apt-selection
# Launch the command # Launch the command
if [ "$1" = "update" ] || [ "$1" = "check" ]; then if [ "$1" = "update" ] || [ "$1" = "check" ]; then

68
tools/check_backports_packages Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/perl -w
use strict;
# Now check to see if we've been told to use backports versions of any
# of the packages in our list of packages.
my $listin = shift;
my $listout = shift;
my $backports_list = read_env('BACKPORTS', "");
my $codename = read_env('CODENAME', "");
my %backports;
sub read_env {
my $env_var = shift;
my $default = shift;
if (exists($ENV{$env_var})) {
return $ENV{$env_var};
}
# else
return $default;
}
# If not configured to use backports, bail
if ($backports_list =~ /^$/) {
exit 0;
}
# Read in the backports list
open (BACKPORTS, "< $backports_list") or die "ERROR: Can't read configured backports list file $backports_list: $!\n";
while (defined($_=<BACKPORTS>)) {
chomp;
# Define to 1 here to say it needs to be included
$backports{$_} = 1;
}
close BACKPORTS;
print "Checking for desired backports in $backports_list\n";
open (LISTIN, "< $listin") or die "ERROR: Can't read the current list file $listin: $!\n";
open (LISTOUT, "> $listout") or die "ERROR: Can't write to $listout: $!\n";
# For any packages in out input list that are listed in the backports
# file, switch to $pkg/backports
while (defined($_=<LISTIN>)) {
chomp;
if (exists $backports{$_}) {
delete $backports{$_};
print LISTOUT "$_/$codename-backports\n";
print " Replaced $_ with $_/$codename-backports in $listout\n";
} else {
print LISTOUT "$_\n";
}
}
close LISTIN;
# Finally, any further packages in our backports list are explicitly
# requested even if they weren't in the original list. Append to the
# output file to force inclusion. This is before sort_deps will get
# run, so dependencies will get resolved later
foreach my $p (keys %backports) {
print LISTOUT "$p/$codename-backports\n";
print " Appended $p/$codename-backports\n";
}
close LISTOUT;
exit 0;

View File

@ -19,6 +19,9 @@ OUT=$5
for ARCH in $ARCHES for ARCH in $ARCHES
do do
LOCATIONS="$MIRROR/dists/$CODENAME/ $MIRROR/dists/$DI_CODENAME/" LOCATIONS="$MIRROR/dists/$CODENAME/ $MIRROR/dists/$DI_CODENAME/"
if [ "$BACKPORTS"x != ""x ] ; then
LOCATIONS="$LOCATIONS $MIRROR/dists/$CODENAME-backports/"
fi
echo "Looking in $LOCATIONS" echo "Looking in $LOCATIONS"
for LOCATION in $LOCATIONS; do for LOCATION in $LOCATIONS; do

View File

@ -47,6 +47,11 @@ my $localdebs = read_env('LOCALDEBS', $mirror);
my $symlink_farm = read_env('SYMLINK', 0); my $symlink_farm = read_env('SYMLINK', 0);
my $link_verbose = read_env('VERBOSE', 0); my $link_verbose = read_env('VERBOSE', 0);
my $link_copy = read_env('COPYLINK', 0); my $link_copy = read_env('COPYLINK', 0);
my $backports_list = read_env('BACKPORTS', "");
my $backports = 1;
if ($backports_list =~ /^$/) {
$backports = 0;;
}
# MAXCDS is the hard limit on the MAXIMUM number of images to # MAXCDS is the hard limit on the MAXIMUM number of images to
# make. MAXJIGDOS and MAXISOS can only make this number smaller; we # make. MAXJIGDOS and MAXISOS can only make this number smaller; we
@ -100,17 +105,9 @@ foreach my $arch (split(' ', $archlist)) {
load_packages_cache($arch); load_packages_cache($arch);
} }
if (! ($archlist eq "source")) { load_all_descriptions(0);
load_descriptions("main"); if ($backports) {
if ($contrib) { load_all_descriptions(1);
load_descriptions("contrib");
}
if ($nonfree || $extranonfree) {
load_descriptions("non-free");
}
if ($use_local) {
load_descriptions("local");
}
} }
my $disknum = 1; my $disknum = 1;
@ -342,6 +339,7 @@ close(LOG);
sub load_packages_cache { sub load_packages_cache {
my $arch = shift; my $arch = shift;
my @pkglist; my @pkglist;
my @tmplist;
my ($p); my ($p);
my $num_pkgs = 0; my $num_pkgs = 0;
@ -354,7 +352,7 @@ sub load_packages_cache {
while (defined (my $pkg = <INLIST>)) { while (defined (my $pkg = <INLIST>)) {
chomp $pkg; chomp $pkg;
my ($junk, $component, $pkgname, $pkgsize) = split /:/, $pkg; my ($junk, $component, $pkgname, $pkgsize) = split /:/, $pkg;
push @pkglist, $pkgname; push @tmplist, $pkgname;
} }
close INLIST; close INLIST;
@ -362,6 +360,7 @@ sub load_packages_cache {
print LOG "Reading in package information for $arch:\n"; print LOG "Reading in package information for $arch:\n";
$/ = ''; # Browse by paragraph $/ = ''; # Browse by paragraph
@pkglist = (grep (!/\/$codename-backports$/, @tmplist));
while (@pkglist) { while (@pkglist) {
my (@pkg) = splice(@pkglist,0,200); my (@pkg) = splice(@pkglist,0,200);
if ($arch eq "source") { if ($arch eq "source") {
@ -379,24 +378,73 @@ sub load_packages_cache {
close LIST; close LIST;
print LOG "load_packages_cache: Read details of $num_pkgs packages for $arch\n"; print LOG "load_packages_cache: Read details of $num_pkgs packages for $arch\n";
} }
$/ = $old_split; # Browse by line again
print " Done: Read details of $num_pkgs packages for $arch\n"; print " Done: Read details of $num_pkgs packages for $arch\n";
if ($backports) {
$num_pkgs = 0;
@pkglist = (grep (/\/$codename-backports$/, @tmplist));
while (@pkglist) {
my (@pkg) = splice(@pkglist,0,200);
if ($arch eq "source") {
open (LIST, "USE_BP=1 $basedir/tools/apt-selection cache showsrc @pkg |")
|| die "Can't fork : $!\n";
} else {
open (LIST, "USE_BP=1 $basedir/tools/apt-selection cache show @pkg |")
|| die "Can't fork : $!\n";
}
while (defined($_ = <LIST>)) {
m/^Package: (\S+)/m and $p = $1;
push @{$pkginfo{$arch}{"$p/$codename-backports"}}, $_;
$num_pkgs++;
}
close LIST;
print LOG "load_packages_cache: Read details of $num_pkgs packages for $arch backports\n";
}
print " Done: Read details of $num_pkgs packages for $arch backports\n";
}
$/ = $old_split; # Browse by line again
}
sub load_all_descriptions {
my $use_backports = shift;
if (! ($archlist eq "source")) {
load_descriptions("main", $use_backports);
if ($contrib) {
load_descriptions("contrib", $use_backports);
}
if ($nonfree || $extranonfree) {
load_descriptions("non-free", $use_backports);
}
if ($use_local) {
load_descriptions("local", $use_backports);
}
}
} }
# Load all the translated descriptions we can find # Load all the translated descriptions we can find
sub load_descriptions { sub load_descriptions {
my $suite = shift; my $suite = shift;
my $use_backports = shift;
my $lang; my $lang;
my $dh; my $dh;
my ($p); my ($p);
my $num_total = 0; my $num_total = 0;
my $num_files = 0; my $num_files = 0;
my $dir = "$mirror/dists/$codename/$suite/i18n"; my $dir = "$mirror/dists/$codename/$suite/i18n";
if ($use_backports) {
$dir = "$mirror/dists/$codename-backports/$suite/i18n";
}
if ($suite =~ /local/) { if ($suite =~ /local/) {
$dir = "$localdebs/dists/$codename/$suite/i18n"; $dir = "$localdebs/dists/$codename/$suite/i18n";
if ($use_backports) {
$dir = "$localdebs/dists/$codename-backports/$suite/i18n";
}
} }
my @files; my @files;
if ($use_backports) {
$suite = "$suite backports";
}
if (-d $dir) { if (-d $dir) {
print "Reading in translated package descriptions for $suite:\n"; print "Reading in translated package descriptions for $suite:\n";
print LOG "Reading in translated package descriptions for $suite:\n"; print LOG "Reading in translated package descriptions for $suite:\n";
@ -413,6 +461,9 @@ sub load_descriptions {
print LOG " Parsing $file\n"; print LOG " Parsing $file\n";
while (defined($_ = <BZ>)) { while (defined($_ = <BZ>)) {
m/^Package: (\S+)/m and $p = $1; m/^Package: (\S+)/m and $p = $1;
if ($use_backports) {
$p = "$p/$codename-backports";
}
$descriptions{"$lang"}{$p}{"data"} = $_; $descriptions{"$lang"}{$p}{"data"} = $_;
$descriptions{"$lang"}{$p}{"used"} = 0; $descriptions{"$lang"}{$p}{"used"} = 0;
$num_descs++; $num_descs++;
@ -837,13 +888,19 @@ sub finish_disc {
} }
print " Finishing off the Release file\n"; print " Finishing off the Release file\n";
chdir "dists/$codename"; my @codenames = ("$codename");
if ($backports) {
push @codenames, "$codename-backports";
}
foreach my $tmpcode (@codenames) {
chdir "dists/$tmpcode";
open(RELEASE, ">>Release") or die "Failed to open Release file: $!\n"; open(RELEASE, ">>Release") or die "Failed to open Release file: $!\n";
find (\&recompress, "."); find (\&recompress, ".");
checksum_files_for_release(); checksum_files_for_release();
close(RELEASE); close(RELEASE);
find (\&remove_uncompressed, "."); find (\&remove_uncompressed, ".");
chdir("../.."); chdir("../..");
}
print " Finishing off md5sum.txt\n"; print " Finishing off md5sum.txt\n";
# Just md5 the bits we won't have seen already # Just md5 the bits we won't have seen already
@ -894,6 +951,7 @@ sub Packages_dir {
my $dir = shift; my $dir = shift;
my $file = shift; my $file = shift;
my $section = shift; my $section = shift;
my $in_backports = shift;
my ($pdir, $dist); my ($pdir, $dist);
@ -908,8 +966,13 @@ sub Packages_dir {
} }
$pdir = "$dir/dists/$codename/$dist"; $pdir = "$dir/dists/$codename/$dist";
if ($in_backports) {
$pdir = "$dir/dists/$codename-backports/$dist";
}
if ($section and $section eq "debian-installer") { if ($section and $section eq "debian-installer") {
$pdir = "$dir/dists/$codename/$dist/debian-installer"; $pdir = "$dir/dists/$codename/$dist/debian-installer";
# Don't attempt to put d-i components into backports, as d-i
# won't look for them there.
} }
return $pdir; return $pdir;
} }
@ -919,6 +982,7 @@ sub Packages_dir {
sub add_Packages_entry { sub add_Packages_entry {
my $dir = shift; my $dir = shift;
my $arch = shift; my $arch = shift;
my $in_backports = shift;
my $_ = shift; my $_ = shift;
my ($p, $file, $section, $pdir, $pkgfile, $gz, $st1, $st2, $size1, $size2); my ($p, $file, $section, $pdir, $pkgfile, $gz, $st1, $st2, $size1, $size2);
my $blocks_added = 0; my $blocks_added = 0;
@ -933,14 +997,14 @@ sub add_Packages_entry {
if (!defined($file)) { if (!defined($file)) {
die "Can't parse source file information out of $_\n"; die "Can't parse source file information out of $_\n";
} }
$pdir = Packages_dir($dir, $file, $section) . "/source"; $pdir = Packages_dir($dir, $file, $section, $in_backports) . "/source";
$pkgfile = "$pdir/Sources"; $pkgfile = "$pdir/Sources";
} else { } else {
m/^Filename: (\S+)/mi and $file = $1; m/^Filename: (\S+)/mi and $file = $1;
if (!defined($file)) { if (!defined($file)) {
die "Can't parse binary file information out of $_\n"; die "Can't parse binary file information out of $_\n";
} }
$pdir = Packages_dir($dir, $file, $section) . "/binary-$arch"; $pdir = Packages_dir($dir, $file, $section, $in_backports) . "/binary-$arch";
$pkgfile = "$pdir/Packages"; $pkgfile = "$pdir/Packages";
} }
@ -984,6 +1048,7 @@ sub add_Packages_entry {
sub add_trans_desc_entry { sub add_trans_desc_entry {
my $dir = shift; my $dir = shift;
my $arch = shift; my $arch = shift;
my $in_backports = shift;
my $_ = shift; my $_ = shift;
my ($p, $file, $section, $idir, $pkgfile, $gz, $st); my ($p, $file, $section, $idir, $pkgfile, $gz, $st);
my $size = 0; my $size = 0;
@ -995,7 +1060,7 @@ sub add_trans_desc_entry {
m/^Section: (\S+)/m and $section = $1; m/^Section: (\S+)/m and $section = $1;
m/^Filename: (\S+)/mi and $file = $1; m/^Filename: (\S+)/mi and $file = $1;
$idir = Packages_dir($dir, $file, $section) . "/i18n"; $idir = Packages_dir($dir, $file, $section, $in_backports) . "/i18n";
if (! -d $idir) { if (! -d $idir) {
system("mkdir -p $idir"); system("mkdir -p $idir");
@ -1043,13 +1108,16 @@ sub add_trans_desc_entry {
} }
} }
$blocks_added += ($new_blocks - $old_blocks); $blocks_added += ($new_blocks - $old_blocks);
if ($blocks_added != 0) {
msg_ap(0, " now $size bytes, $blocks_added blocks added\n"); msg_ap(0, " now $size bytes, $blocks_added blocks added\n");
}
return $blocks_added; return $blocks_added;
} }
sub add_md5_entry { sub add_md5_entry {
my $dir = shift; my $dir = shift;
my $arch = shift; my $arch = shift;
my $in_backports = shift;
my $_ = shift; my $_ = shift;
my ($pdir, $file, $md5, $st, $size, $p); my ($pdir, $file, $md5, $st, $size, $p);
my $md5file = "$dir/md5sum.txt"; my $md5file = "$dir/md5sum.txt";
@ -1057,7 +1125,11 @@ sub add_md5_entry {
my $old_blocks = 0; my $old_blocks = 0;
my $new_blocks = 0; my $new_blocks = 0;
if ($in_backports) {
m/^Package: (\S+)/mi and $p = "$1/$codename-backports";
} else {
m/^Package: (\S+)/mi and $p = $1; m/^Package: (\S+)/mi and $p = $1;
}
if (-e $md5file) { if (-e $md5file) {
$st = stat("$md5file"); $st = stat("$md5file");
@ -1090,6 +1162,7 @@ sub add_md5_entry {
sub remove_Packages_entry { sub remove_Packages_entry {
my $dir = shift; my $dir = shift;
my $arch = shift; my $arch = shift;
my $in_backports = shift;
my $_ = shift; my $_ = shift;
my ($p, $file, $section, $pdir, $pkgfile, $tmp_pkgfile, $match, $gz, my ($p, $file, $section, $pdir, $pkgfile, $tmp_pkgfile, $match, $gz,
$st1, $st2, $size1, $size2); $st1, $st2, $size1, $size2);
@ -1102,11 +1175,11 @@ sub remove_Packages_entry {
if ($arch eq "source") { if ($arch eq "source") {
m/^Directory: (\S+)/mi and $file = $1; m/^Directory: (\S+)/mi and $file = $1;
$pdir = Packages_dir($dir, $file, $section) . "/source"; $pdir = Packages_dir($dir, $file, $section, $in_backports) . "/source";
$pkgfile = "$pdir/Sources"; $pkgfile = "$pdir/Sources";
} else { } else {
m/^Filename: (\S+)/mi and $file = $1; m/^Filename: (\S+)/mi and $file = $1;
$pdir = Packages_dir($dir, $file, $section) . "/binary-$arch"; $pdir = Packages_dir($dir, $file, $section, $in_backports) . "/binary-$arch";
$pkgfile = "$pdir/Packages"; $pkgfile = "$pdir/Packages";
} }
@ -1158,6 +1231,7 @@ sub remove_Packages_entry {
sub remove_trans_desc_entry { sub remove_trans_desc_entry {
my $dir = shift; my $dir = shift;
my $arch = shift; my $arch = shift;
my $in_backports = shift;
my $_ = shift; my $_ = shift;
my ($p, $file, $section, $idir, $gz, $match, $st); my ($p, $file, $section, $idir, $gz, $match, $st);
my $size = 0; my $size = 0;
@ -1169,7 +1243,7 @@ sub remove_trans_desc_entry {
m/^Section: (\S+)/m and $section = $1; m/^Section: (\S+)/m and $section = $1;
m/^Filename: (\S+)/mi and $file = $1; m/^Filename: (\S+)/mi and $file = $1;
$idir = Packages_dir($dir, $file, $section) . "/i18n"; $idir = Packages_dir($dir, $file, $section, $in_backports) . "/i18n";
$/ = ''; # Browse by paragraph $/ = ''; # Browse by paragraph
foreach my $lang (keys %descriptions) { foreach my $lang (keys %descriptions) {
@ -1316,6 +1390,10 @@ sub add_packages {
msg_ap(0, "Looking at $pkg: arch $arch, package $pkgname, rollback $rollback\n"); msg_ap(0, "Looking at $pkg: arch $arch, package $pkgname, rollback $rollback\n");
foreach my $package_info (@{$pkginfo{$arch}{$pkgname}}) { foreach my $package_info (@{$pkginfo{$arch}{$pkgname}}) {
my $in_backports = 0;
if ($pkgname =~ /\/$codename-backports/) {
$in_backports = 1;
}
undef @files; undef @files;
$source = $mirror; $source = $mirror;
if ($arch eq "source") { if ($arch eq "source") {
@ -1340,10 +1418,10 @@ sub add_packages {
if ($rollback) { if ($rollback) {
# Remove the Packages entry/entries for the specified package # Remove the Packages entry/entries for the specified package
$total_blocks -= remove_Packages_entry($dir, $arch, $package_info); $total_blocks -= remove_Packages_entry($dir, $arch, $in_backports, $package_info);
$total_blocks -= remove_md5_entry($dir, $arch, $package_info); $total_blocks -= remove_md5_entry($dir, $arch, $in_backports, $package_info);
if (!($arch eq "source")) { if (!($arch eq "source")) {
$total_blocks -= remove_trans_desc_entry($dir, $arch, $package_info); $total_blocks -= remove_trans_desc_entry($dir, $arch, $in_backports, $package_info);
} }
foreach my $file (@files) { foreach my $file (@files) {
@ -1365,10 +1443,10 @@ sub add_packages {
msg_ap(0, " Rollback: removed $dir/$file\n"); msg_ap(0, " Rollback: removed $dir/$file\n");
} }
} else { } else {
$total_blocks += add_Packages_entry($dir, $arch, $package_info); $total_blocks += add_Packages_entry($dir, $arch, $in_backports, $package_info);
$total_blocks += add_md5_entry($dir, $arch, $package_info); $total_blocks += add_md5_entry($dir, $arch, $in_backports, $package_info);
if (!($arch eq "source")) { if (!($arch eq "source")) {
$total_blocks += add_trans_desc_entry($dir, $arch, $package_info); $total_blocks += add_trans_desc_entry($dir, $arch, $in_backports, $package_info);
} }
foreach my $file (@files) { foreach my $file (@files) {

View File

@ -1,6 +1,7 @@
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright 1999 Raphaël Hertzog <hertzog@debian.org> # Copyright 1999 Raphaël Hertzog <hertzog@debian.org>
# Copyright 2006-2016 Steve McIntyre <93sam@debian.org>
# See the README file for the license # See the README file for the license
# #
# This script takes 1 argument on input : # This script takes 1 argument on input :
@ -27,6 +28,12 @@ my $norecommends = read_env('NORECOMMENDS', 1);
my $nosuggests = read_env('NOSUGGESTS', 1); my $nosuggests = read_env('NOSUGGESTS', 1);
my $verbose = read_env('VERBOSE', 0); my $verbose = read_env('VERBOSE', 0);
my $max_pkg_size = read_env('MAX_PKG_SIZE', 9999999999999); my $max_pkg_size = read_env('MAX_PKG_SIZE', 9999999999999);
my $codename = $ENV{'CODENAME'};
my $backports_list = read_env('BACKPORTS', "");
my $backports = 1;
if ($backports_list =~ /^$/) {
$backports = 0;;
}
my $apt = "$ENV{'BASEDIR'}/tools/apt-selection"; my $apt = "$ENV{'BASEDIR'}/tools/apt-selection";
my $adir = "$ENV{'APTTMP'}/$ENV{'CODENAME'}-$ENV{'ARCH'}"; my $adir = "$ENV{'APTTMP'}/$ENV{'CODENAME'}-$ENV{'ARCH'}";
@ -65,6 +72,7 @@ sub msg {
my %included; my %included;
my %excluded; my %excluded;
my %packages; my %packages;
my %backport_packages;
msg(0, "Running sort_deps to sort packages for $arch:\n"); msg(0, "Running sort_deps to sort packages for $arch:\n");
msg(1, "====================================================================== msg(1, "======================================================================
@ -90,15 +98,34 @@ msg(1, "======================================================================
# Get the information on all packages # Get the information on all packages
my $oldrs = $/; my $oldrs = $/;
$/ = ''; $/ = '';
msg(1, "Parsing packages...\n");
open(AVAIL, "$apt cache dumpavail |") || die "Can't fork : $!\n"; open(AVAIL, "$apt cache dumpavail |") || die "Can't fork : $!\n";
my ($p, $re); my ($p, $re);
my $num_pkgs = 0;
while (defined($_=<AVAIL>)) { while (defined($_=<AVAIL>)) {
next if not m/^Package: (\S+)\s*$/m; next if not m/^Package: (\S+)\s*$/m;
if (!$force_unstable_tasks || $1 !~ /^task-/) { if (!$force_unstable_tasks || $1 !~ /^task-/) {
parse_package($_); parse_package(0, $_);
$num_pkgs++;
} }
} }
msg(1, "Got $num_pkgs packages\n");
close AVAIL or die "apt-cache failed : $@ ($!)\n"; close AVAIL or die "apt-cache failed : $@ ($!)\n";
if ($backports) {
$num_pkgs = 0;
msg(1, "Parsing packages from backports...\n");
open(AVAIL, "USE_BP=1 $apt cache dumpavail |") || die "Can't fork : $!\n";
my ($p, $re);
while (defined($_=<AVAIL>)) {
next if not m/^Package: (\S+)\s*$/m;
if (!$force_unstable_tasks || $1 !~ /^task-/) {
parse_package(1, $_);
$num_pkgs++;
}
}
msg(1, "Got $num_pkgs packages\n");
close AVAIL or die "apt-cache (backports) failed : $@ ($!)\n";
}
# Read in the extra (new/unstable) tasks packages # Read in the extra (new/unstable) tasks packages
if ($force_unstable_tasks) { if ($force_unstable_tasks) {
@ -111,7 +138,7 @@ if ($force_unstable_tasks) {
while (defined($_=<AVAIL>)) { while (defined($_=<AVAIL>)) {
next if not m/^Package: (\S+)\s*$/m; next if not m/^Package: (\S+)\s*$/m;
if ($1 =~ /^task-/) { if ($1 =~ /^task-/) {
parse_package($_); parse_package(0, $_);
$num++; $num++;
} }
} }
@ -158,14 +185,13 @@ my %cds;
# Generate a dependency tree for each package # Generate a dependency tree for each package
msg(0, " Generating dependency tree with apt-cache depends...\n"); msg(0, " Generating dependency tree with apt-cache depends...\n");
my (@list) = keys %packages; my (@list) = grep (!/\/$codename-backports$/, keys %packages);
while (@list) { while (@list) {
my (@pkg) = splice(@list,0,200); my (@pkg) = splice(@list,0,200);
$ENV{'LC_ALL'} = 'C'; # Required since apt is now translated $ENV{'LC_ALL'} = 'C'; # Required since apt is now translated
open (APT, "$apt cache depends @pkg |") || die "Can't fork : $!\n"; open (APT, "$apt cache depends @pkg |") || die "Can't fork : $!\n";
my (@res) = (<APT>); my (@res) = (<APT>);
close APT or die "'apt-cache depends failed ... \n" . close APT or die "'apt-cache depends failed: $! \n";
"you must have apt >= 0.3.11.1 !\n";
# Getting rid of conflicts/replaces/provides # Getting rid of conflicts/replaces/provides
my $i = 0; my $i = 0;
my $nb_lines = scalar @res; my $nb_lines = scalar @res;
@ -183,6 +209,46 @@ while (@list) {
} }
} }
# Now redo with backports packages
if ($backports) {
@list = grep (/\/$codename-backports$/, keys %packages);
while (@list) {
my (@pkg) = splice(@list,0,200);
$ENV{'LC_ALL'} = 'C'; # Required since apt is now translated
open (APT, "USE_BP=1 $apt cache depends @pkg |") || die "Can't fork : $!\n";
my (@res) = (<APT>);
close APT or die "'apt-cache depends failed: $! \n";
# Getting rid of conflicts/replaces/provides
my $i = 0;
my $nb_lines = scalar @res;
push @res, ""; # Avoid warnings ...
while ($i < $nb_lines) {
if ($res[$i] !~ m/^(\S+)\s*$/) {
msg(0, "UNEXPECTED: Line `$res[$i]' while parsing " .
"end of deptree from '$p'\n");
die "sort_deps failed! :-(\n";
}
$p = lc $1;
$i++;
msg(2, " Dependency tree of `$p/$codename-backports' ...\n");
read_depends (\$i, \@res, "$p/$codename-backports");
}
}
# Now check and maybe up our dependencies in the backports
# packages. If any of them depend on package versions not already
# in the base set, change them to be package/$codename-backports
# instead. Only need to check direct dependencies here; any
# indirects going through base packages shouldn't have any
# backports dependencies, of course. Can only do this once we've
# read *all* the packages in.
@list = grep (/\/$codename-backports$/, keys %packages);
foreach my $pkg (@list) {
msg(1, "Fixing up deps for $pkg\n");
$packages{$pkg}{"Depends"} = fix_backport_depends($packages{$pkg}{"Depends"});
$packages{$pkg}{"Recommends"} = fix_backport_depends($packages{$pkg}{"Recommends"});
$packages{$pkg}{"Suggests"} = fix_backport_depends($packages{$pkg}{"Suggests"});
}
}
msg(0, " Adding standard, required, important and base packages first\n"); msg(0, " Adding standard, required, important and base packages first\n");
# Automatically include packages listed in the status file # Automatically include packages listed in the status file
@ -198,7 +264,11 @@ while (defined($_ = <STATUS>)) {
next; next;
} }
next if $excluded{$p}; next if $excluded{$p};
add_package($p, ! $norecommends, ! $nosuggests); if ($p =~ /\/$codename-backports$/) {
add_package($p, ! $norecommends, ! $nosuggests, 1);
} else {
add_package($p, ! $norecommends, ! $nosuggests, 0);
}
} }
close STATUS; close STATUS;
msg(0, " S/R/I/B packages take $output_size bytes\n"); msg(0, " S/R/I/B packages take $output_size bytes\n");
@ -208,6 +278,7 @@ msg(0, " Adding the rest of the requested packages\n");
open (LIST, "< $listfile") || die "Can't open $listfile : $!\n"; open (LIST, "< $listfile") || die "Can't open $listfile : $!\n";
while (defined($_=<LIST>)) { while (defined($_=<LIST>)) {
chomp; chomp;
msg(1, "Looking at list, line \"$_\"\n");
next if m/^\s*$/; next if m/^\s*$/;
if (not exists $packages{$_}) { if (not exists $packages{$_}) {
msg(1, "WARNING: '$_' does not appear to be available ... " . msg(1, "WARNING: '$_' does not appear to be available ... " .
@ -225,7 +296,11 @@ while (defined($_=<LIST>)) {
if ($packages{$_}{"IsUdeb"}) { if ($packages{$_}{"IsUdeb"}) {
add_to_output($_); add_to_output($_);
} else { } else {
add_package ($_, ! $norecommends, ! $nosuggests); if ($_ =~ /\/$codename-backports$/) {
add_package($_, ! $norecommends, ! $nosuggests, 1);
} else {
add_package($_, ! $norecommends, ! $nosuggests, 0);
}
} }
} }
close LIST; close LIST;
@ -246,7 +321,11 @@ if ($complete) {
if ($packages{lc $p}{"IsUdeb"}) { if ($packages{lc $p}{"IsUdeb"}) {
msg(2, " Ignoring udeb $p ...\n"); msg(2, " Ignoring udeb $p ...\n");
} else { } else {
add_package (lc $p, 0, 0); if ($p =~ /\/$codename-backports$/i) {
add_package (lc $p, 0, 0, 1);
} else {
add_package (lc $p, 0, 0, 0);
}
} }
} }
} }
@ -268,7 +347,11 @@ if ($extranonfree and (! $nonfree))
# Include non-free packages # Include non-free packages
foreach $p (@toinclude) foreach $p (@toinclude)
{ {
add_package(lc $p, 1, 1); if ($p =~ /\/$codename-backports$/i) {
add_package (lc $p, 1, 1, 1);
} else {
add_package (lc $p, 1, 1, 0);
}
} }
# If a contrib package was listed in the list of packages to # If a contrib package was listed in the list of packages to
@ -291,7 +374,11 @@ if ($extranonfree and (! $nonfree))
if ($packages{lc $p}{"IsUdeb"}) { if ($packages{lc $p}{"IsUdeb"}) {
msg(2, " Ignoring udeb $p ...\n"); msg(2, " Ignoring udeb $p ...\n");
} else { } else {
add_package (lc $_, 1, 1); if ($_ =~ /\/$codename-backports$/i) {
add_package (lc $_, 1, 1, 1);
} else {
add_package (lc $_, 1, 1, 0);
}
} }
} }
close LIST; close LIST;
@ -308,7 +395,11 @@ if ($extranonfree and (! $nonfree))
if ($packages{lc $p}{"IsUdeb"}) { if ($packages{lc $p}{"IsUdeb"}) {
msg(2, " Ignoring udeb $p ...\n"); msg(2, " Ignoring udeb $p ...\n");
} else { } else {
add_package (lc $p, 0, 0); if ($p =~ /\/$codename-backports$/i) {
add_package (lc $p, 0, 0, 1);
} else {
add_package (lc $p, 0, 0, 0);
}
} }
} }
} }
@ -347,7 +438,11 @@ close LOG;
sub parse_package { sub parse_package {
my $p; my $p;
my $use_bp = shift;
m/^Package: (\S+)\s*$/m and $p = $1; m/^Package: (\S+)\s*$/m and $p = $1;
if ($use_bp) {
$p = "$p/$codename-backports";
}
$included{$p} = 0; $included{$p} = 0;
$packages{$p}{"Package"} = $p; $packages{$p}{"Package"} = $p;
foreach $re (qw(Version Priority Section Filename Size MD5sum)) { foreach $re (qw(Version Priority Section Filename Size MD5sum)) {
@ -552,6 +647,7 @@ sub check_versions {
# Check if a specific dependency package is installed already # Check if a specific dependency package is installed already
sub dep_pkg_included { sub dep_pkg_included {
my $p = shift; my $p = shift;
my $check_backports = shift;
my %d = %$p; my %d = %$p;
my $pn = $d{"Package"}; my $pn = $d{"Package"};
@ -563,25 +659,99 @@ sub dep_pkg_included {
msg(1, " $pn is included already, but invalid version " . $packages{$pn}{"Version"} . "\n"); msg(1, " $pn is included already, but invalid version " . $packages{$pn}{"Version"} . "\n");
} }
} }
msg(1, " $pn not included in a useful version, check_backports $check_backports\n");
if ($check_backports) {
$pn = "$pn/$codename-backports";
msg(1, " Checking $pn too:\n");
if ($included{$pn}) {
if (check_versions($d{"Version"}, $d{"CmpOp"}, $packages{$pn}{"Version"})) {
msg(1, " $pn is included already, acceptable version " . $packages{$pn}{"Version"} . "\n");
return 1;
} else {
msg(1, " $pn is included already, but invalid version " . $packages{$pn}{"Version"} . "\n");
}
msg(1, " $pn not included in a useful version\n");
}
}
# else # else
return 0; return 0;
} }
# Check backports package dependencies; update them if they are also only in backports
sub fix_backport_depends {
my $deplist = shift;
my @new_dep_list;
foreach my $thisdep (@{$deplist}) {
if ("ARRAY" eq ref($thisdep)) {
# If it's an OR list
my @new_or_list;
foreach my $pkg (@{$thisdep}) {
my %t = %$pkg;
my $pkgname = lc $t{"Package"};
# Does the package exist?
if (exists $excluded{$pkgname} &&
check_versions($t{"Version"}, $t{"CmpOp"}, $packages{$pkgname}{"Version"})) {
# Looks fine already
push (@new_or_list, $pkg);
next;
}
# Doesn't exist, or version doesn't work. Try backports
$pkgname = "$pkgname/$codename-backports";
if (exists $excluded{$pkgname} &&
check_versions($t{"Version"}, $t{"CmpOp"}, $packages{$pkgname}{"Version"})) {
my %elt;
$elt{"Package"} = $pkgname;
$elt{"CmpOp"} = $t{"CmpOp"};
$elt{"Version"} = $t{"Version"};
push @new_or_list, \%elt;
msg(1, " Upgrading dep to $pkgname\n");
next;
}
}
push (@new_dep_list, \@new_or_list);
} else {
# It's virtual or a normal package
my %t = %{$thisdep};
my $pkgname = lc $t{"Package"};
# Does the package exist?
if (exists $excluded{$pkgname} &&
check_versions($t{"Version"}, $t{"CmpOp"}, $packages{$pkgname}{"Version"})) {
# Looks fine already
push (@new_dep_list, $thisdep);
next;
}
# Doesn't exist, or version doesn't work. Try backports
$pkgname = "$pkgname/$codename-backports";
if (exists $excluded{$pkgname} &&
check_versions($t{"Version"}, $t{"CmpOp"}, $packages{$pkgname}{"Version"})) {
my %elt;
$elt{"Package"} = $pkgname;
$elt{"CmpOp"} = $t{"CmpOp"};
$elt{"Version"} = $t{"Version"};
push @new_dep_list, \%elt;
msg(1, " Upgrading dep to $pkgname\n");
next;
}
}
}
return \@new_dep_list;
}
# Check to see if a dependency is satisfied, either a direct # Check to see if a dependency is satisfied, either a direct
# dependency or any one of an OR array # dependency or any one of an OR array
sub dep_satisfied { sub dep_satisfied {
my $p = shift; my $p = shift;
my $check_backports = shift;
if ("ARRAY" eq ref $p) { if ("ARRAY" eq ref $p) {
foreach (@{$p}) { foreach (@{$p}) {
if (dep_pkg_included($_)) { if (dep_pkg_included($_, $check_backports)) {
return 1; return 1;
} }
} }
} elsif ("HASH" eq ref $p) { } elsif ("HASH" eq ref $p) {
return dep_pkg_included($p); return dep_pkg_included($p, $check_backports);
} else { } else {
die "dep_satisfied: $p is neither a hash nor an array!\n";
} }
return 0; return 0;
} }
@ -684,6 +854,7 @@ sub add_package {
my $p = shift; my $p = shift;
my $add_rec = shift; # Do we look for recommends my $add_rec = shift; # Do we look for recommends
my $add_sug = shift; # Do we look for suggests my $add_sug = shift; # Do we look for suggests
my $check_backports = shift;
my ($ok, $reasons); my ($ok, $reasons);
msg(2, "+ Trying to add $p...\n"); msg(2, "+ Trying to add $p...\n");
@ -693,7 +864,7 @@ sub add_package {
} }
# Get all dependencies (not yet included) of each package # Get all dependencies (not yet included) of each package
my (@dep) = (get_missing ($p)); my (@dep) = (get_missing ($p, $check_backports));
# Stop here if apt failed # Stop here if apt failed
if (not scalar(@dep)) { if (not scalar(@dep)) {
@ -710,7 +881,7 @@ sub add_package {
msg(3, " \@dep before checklist = " . dump_depend(\@dep) . "\n"); msg(3, " \@dep before checklist = " . dump_depend(\@dep) . "\n");
# Check if all packages are allowed (fail if one cannot) # Check if all packages are allowed (fail if one cannot)
($ok, $reasons) = check_list (\@dep, 1); ($ok, $reasons) = check_list (\@dep, 1, $check_backports);
if (not $ok) { if (not $ok) {
msg(2, "Can't add $p ... one of the packages needed has " . msg(2, "Can't add $p ... one of the packages needed has " .
"been refused. Reasons: $reasons\n"); "been refused. Reasons: $reasons\n");
@ -721,11 +892,11 @@ sub add_package {
if ($add_rec) { if ($add_rec) {
#TODO: Look for recommends (not yet included !!) #TODO: Look for recommends (not yet included !!)
add_recommends (\@dep, $p); add_recommends (\@dep, $p, $check_backports);
msg(3, " \@dep after add_recommends = " . dump_depend(\@dep) . "\n"); msg(3, " \@dep after add_recommends = " . dump_depend(\@dep) . "\n");
# Check again but doesn't fail if one of the package cannot be # Check again but doesn't fail if one of the package cannot be
# installed, just ignore it (it will be removed from @dep) # installed, just ignore it (it will be removed from @dep)
($ok, $reasons) = check_list (\@dep, 0); ($ok, $reasons) = check_list (\@dep, 0, $check_backports);
if (not $ok) { if (not $ok) {
msg(0, "UNEXPECTED: It shouldn't fail here !\n"); msg(0, "UNEXPECTED: It shouldn't fail here !\n");
return; return;
@ -735,11 +906,11 @@ sub add_package {
if ($add_sug) { if ($add_sug) {
#TODO: Look for suggests (not yet included !!) #TODO: Look for suggests (not yet included !!)
add_suggests (\@dep, $p); add_suggests (\@dep, $p, $check_backports);
msg(3, " \@dep after add_suggests = " . dump_depend(\@dep) . "\n"); msg(3, " \@dep after add_suggests = " . dump_depend(\@dep) . "\n");
# Check again but doesn't fail if one of the package cannot be # Check again but doesn't fail if one of the package cannot be
# installed, just ignore it (it will be removed from @dep) # installed, just ignore it (it will be removed from @dep)
($ok, $reasons) = check_list (\@dep, 0); ($ok, $reasons) = check_list (\@dep, 0, $check_backports);
if (not $ok) { if (not $ok) {
msg(0, "UNEXPECTED: It shouldn't fail here !\n"); msg(0, "UNEXPECTED: It shouldn't fail here !\n");
return; return;
@ -757,15 +928,17 @@ sub add_package {
sub accepted { sub accepted {
my $p = shift; my $p = shift;
return not $excluded{$p} if (exists $excluded{$p}); if (exists $excluded{$p}) {
return not $excluded{$p}
}
# Return false for a non-existent package ... # Return false for a non-existent package ...
msg(1, "WARNING: $p cannot be accepted, it doesn't exist ...\n");
return 0; return 0;
} }
sub add_suggests { sub add_suggests {
my $deps_list = shift; my $deps_list = shift;
my $pkg = shift; my $pkg = shift;
my $check_backports = shift;
my @parents = ($pkg); my @parents = ($pkg);
my $p; # = shift; my $p; # = shift;
my @copy = @{$deps_list}; # A copy is needed since I'll modify the array my @copy = @{$deps_list}; # A copy is needed since I'll modify the array
@ -773,13 +946,14 @@ sub add_suggests {
foreach $p (@copy) { foreach $p (@copy) {
my %t = %$p; my %t = %$p;
my $pkgname = $t{"Package"}; my $pkgname = $t{"Package"};
add_missing($deps_list, $packages{$pkgname}{"Suggests"}, \%t, 1, \@parents); add_missing($deps_list, $packages{$pkgname}{"Suggests"}, \%t, 1, \@parents, $check_backports);
} }
} }
sub add_recommends { sub add_recommends {
my $deps_list = shift; my $deps_list = shift;
my $pkg = shift; my $pkg = shift;
my $check_backports = shift;
my @parents = ($pkg); my @parents = ($pkg);
my $p; # = shift; my $p; # = shift;
my @copy = @{$deps_list}; # A copy is needed since I'll modify the array my @copy = @{$deps_list}; # A copy is needed since I'll modify the array
@ -787,12 +961,13 @@ sub add_recommends {
foreach $p (@copy) { foreach $p (@copy) {
my %t = %$p; my %t = %$p;
my $pkgname = $t{"Package"}; my $pkgname = $t{"Package"};
add_missing($deps_list, $packages{$pkgname}{"Recommends"}, \%t, 1, \@parents); add_missing($deps_list, $packages{$pkgname}{"Recommends"}, \%t, 1, \@parents, $check_backports);
} }
} }
sub get_missing { sub get_missing {
my $p = shift; my $p = shift;
my $check_backports = shift;
my @deps_list = (); my @deps_list = ();
my @parents = (); my @parents = ();
my %t; my %t;
@ -802,7 +977,7 @@ sub get_missing {
$t{"CmpOp"} = ""; $t{"CmpOp"} = "";
$t{"Version"} = ""; $t{"Version"} = "";
if (not add_missing (\@deps_list, $packages{$p}{"Depends"}, \%t, 0, \@parents)) { if (not add_missing (\@deps_list, $packages{$p}{"Depends"}, \%t, 0, \@parents, $check_backports)) {
return (); return ();
} }
@ -823,6 +998,7 @@ sub add_missing {
my $ok = 1; my $ok = 1;
my $soft_depend = shift; my $soft_depend = shift;
my $parents = shift; my $parents = shift;
my $check_backports = shift;
my $pkgname; my $pkgname;
my (%pkgin); my (%pkgin);
@ -858,7 +1034,7 @@ sub add_missing {
msg(3, " $pkgname Dep: $textout soft_depend $soft_depend\n"); msg(3, " $pkgname Dep: $textout soft_depend $soft_depend\n");
# Bail out early if we can! # Bail out early if we can!
if (dep_satisfied ($thisdep)) { if (dep_satisfied ($thisdep, $check_backports)) {
next; next;
} }
@ -881,7 +1057,7 @@ sub add_missing {
} }
# Already installed? # Already installed?
if (dep_satisfied($pkg)) { if (dep_satisfied($pkg, $check_backports)) {
msg(3, " OR relationship already installed: " . dump_depend($pkg) . "\n"); msg(3, " OR relationship already installed: " . dump_depend($pkg) . "\n");
$or_ok = 1; $or_ok = 1;
last; last;
@ -909,14 +1085,19 @@ sub add_missing {
# available should be good enough for all cases we care # available should be good enough for all cases we care
# about. # about.
if (not $or_ok) { if (not $or_ok) {
msg(3, " OR relationship not already satisfied, looking at alternatives in order\n"); msg(3, " OR relationship not already satisfied, looking at alternatives in order, check_backports $check_backports\n");
foreach my $pkg (@{$thisdep}) { foreach my $pkg (@{$thisdep}) {
my %t = %$pkg; my %t = %$pkg;
my $pkgname = $t{"Package"}; my $pkgname = $t{"Package"};
if (not accepted($pkgname)) { if (not accepted($pkgname)) {
if ($check_backports && accepted("$pkgname/$codename-backports")) {
$pkgname = "$pkgname/$codename-backports";
$t{"Package"} = $pkgname;
} else {
next; next;
} }
}
# Check we don't already have the package # Check we don't already have the package
if (is_in_dep_list($pkg, $list)) { if (is_in_dep_list($pkg, $list)) {
$or_ok = 1; $or_ok = 1;
@ -926,8 +1107,9 @@ sub add_missing {
# Stop after the first # Stop after the first
# package that is # package that is
# added successfully # added successfully
# FIXME! NEED TO CHECK IF VERSION DEPS ARE SATISFIED, FALL BACK TO BPO VERSION
push (@{$list}, $pkg); push (@{$list}, $pkg);
if (add_missing ($list, $packages{$pkgname}{"Depends"}, $pkg, $soft_depend, $parents)) { if (add_missing ($list, $packages{$pkgname}{"Depends"}, $pkg, $soft_depend, $parents, $check_backports)) {
$or_ok = 1; $or_ok = 1;
remove_entry($pkg, $list); remove_entry($pkg, $list);
push @{$list}, $pkg; push @{$list}, $pkg;
@ -965,7 +1147,7 @@ sub add_missing {
last; last;
} }
} }
if (dep_satisfied(\%t)) { if (dep_satisfied(\%t, $check_backports)) {
msg(1, " $pt already included\n"); msg(1, " $pt already included\n");
next; # Already included, don't worry next; # Already included, don't worry
} }
@ -974,7 +1156,7 @@ sub add_missing {
next; next;
} }
push @{$list}, \%t; push @{$list}, \%t;
if (not add_missing ($list, $packages{$t{"Package"}}{"Depends"}, \%t, $soft_depend, $parents)) { if (not add_missing ($list, $packages{$t{"Package"}}{"Depends"}, \%t, $soft_depend, $parents, $check_backports)) {
my $pkgname = $pkgin{"Package"}; my $pkgname = $pkgin{"Package"};
msg(1, "couldn't add $pt ...\n"); msg(1, "couldn't add $pt ...\n");
if ($soft_depend) { if ($soft_depend) {
@ -1051,6 +1233,7 @@ sub remove_entry {
sub check_list { sub check_list {
my $ref = shift; my $ref = shift;
my $fail = shift; my $fail = shift;
my $check_backports = shift;
my $ok = 1; my $ok = 1;
my @to_remove = (); my @to_remove = ();
my $reasons = ""; my $reasons = "";
@ -1065,7 +1248,18 @@ sub check_list {
next; next;
} }
if (not accepted($pkgname)) { if (not accepted($pkgname)) {
msg(1," $pkgname has been refused because of $excluded{$pkgname} ...\n"); my $text = $excluded{"$pkgname"};
msg(1," $pkgname has been refused because of $text ...\n");
$ok = 0;
push @to_remove, $thispkg;
$reasons = $reasons . " " . $excluded{$pkgname};
next;
}
if ($check_backports &&
($pkgname !~ /\/$codename-backports/) &&
(not accepted("$pkgname/$codename-backports"))) {
my $text = $excluded{"$pkgname/$codename-backports"};
msg(1," $pkgname/$codename-backports has been refused because of $text} ...\n");
$ok = 0; $ok = 0;
push @to_remove, $thispkg; push @to_remove, $thispkg;
$reasons = $reasons . " " . $excluded{$pkgname}; $reasons = $reasons . " " . $excluded{$pkgname};
@ -1077,6 +1271,12 @@ sub check_list {
$reasons = $reasons . " alreadyinc"; $reasons = $reasons . " alreadyinc";
next; next;
} }
if ($check_backports && $included{"$pkgname/$codename-backports"}) {
msg(1, " $pkgname/$codename-backports has already been included.\n");
push @to_remove, $thispkg;
$reasons = $reasons . " alreadyinc";
next;
}
} }
foreach my $removed (@to_remove) { foreach my $removed (@to_remove) {
my %t = %$removed; my %t = %$removed;

View File

@ -111,6 +111,11 @@ fi
if [ ! -d $CDDIR/dists/$CODENAME ] ; then if [ ! -d $CDDIR/dists/$CODENAME ] ; then
mkdir -p $CDDIR/dists/$CODENAME mkdir -p $CDDIR/dists/$CODENAME
fi fi
if [ "$BACKPORTS"x != ""x ] ; then
if [ ! -d $CDDIR/dists/$CODENAME-backports ] ; then
mkdir -p $CDDIR/dists/$CODENAME-backports
fi
fi
# Commodity link for tools which want local in dists/local/local ... # Commodity link for tools which want local in dists/local/local ...
if [ -n "$LOCAL" ] if [ -n "$LOCAL" ]
@ -376,6 +381,34 @@ else
exit 1 exit 1
fi fi
if [ "$BACKPORTS"x != ""x ]; then
if [ -e "$MIRROR/dists/$CODENAME-backports/Release" ] ; then
# Strip the MD5Sum and SHA1 fields
# Update some other information as well
sed -e "s/^Architectures: .*$/Architectures: $ARCHES/" \
$MIRROR/dists/$CODENAME-backports/Release | \
sed -e "s|^Components: .*$|Components: $SECTIONS|" | \
perl -ne 'if (/^(MD5Sum|SHA1|SHA256):/i) { $f=1; next }
if ($f) {
unless (/^ /) { print; $f=0 }
} else { print }' > dists/$CODENAME-backports/Release
if [ "$EARLY_BUILD_HACK"x = "1"x ] ; then
RDATE=`awk '/^Date:/ { print $2,$3,$4,$5}' dists/$CODENAME-backports/Release`
sed -i -e "s/^Suite: .*$/Suite: stable/" dists/$CODENAME-backports/Release
sed -i -e "s/^Description: .*$/Description: Debian $DEBVERSION Released $RDATE/" dists/$CODENAME-backports/Release
fi
# Create the suite symlink
SUITE=$(sed -n "/^Suite:/ s/.*: //p" dists/$CODENAME-backports/Release)
if [ -n "$SUITE" ] && [ x"$SUITE" != x"$CODENAME-backports" ]; then
ln -sf $CODENAME-backports dists/$SUITE
fi
else
echo "ERROR: Release file ($MIRROR/dists/$CODENAME-backports/Release) is missing !"
exit 1
fi
fi
# Copying individual release files # Copying individual release files
for ARCH in $ARCHES for ARCH in $ARCHES
do do
@ -418,6 +451,50 @@ do
fi fi
done done
# Copying individual release files for backports
if [ "$BACKPORTS"x != ""x ]; then
for ARCH in $ARCHES
do
for SECT in $SECTIONS
do
# Install the release files
if [ -e "$MIRROR/dists/$CODENAME-backports/$SECT/binary-$ARCH/Release" ] ; then
mkdir -p dists/$CODENAME-backports/$SECT/binary-$ARCH
cp $MIRROR/dists/$CODENAME-backports/$SECT/binary-$ARCH/Release \
dists/$CODENAME-backports/$SECT/binary-$ARCH/
if [ "$DEBVERSION" != "testing" ] ; then
sed -i "s/^Archive:.*$/Archive: stable/" dists/$CODENAME-backports/$SECT/binary-$ARCH/Release
fi
fi
if [ -n "$NONUS" -a -e "$NONUS/dists/$CODENAME-backports/non-US/$SECT/binary-$ARCH/Release" ] ; then
mkdir -p dists/$CODENAME-backports/non-US/$SECT/binary-$ARCH
cp $NONUS/dists/$CODENAME-backports/non-US/$SECT/binary-$ARCH/Release \
dists/$CODENAME-backports/non-US/$SECT/binary-$ARCH/
if [ "$DEBVERSION" != "testing" ] ; then
sed -i "s/^Archive:.*$/Archive: stable/" dists/$CODENAME-backports/non-US/$SECT/binary-$ARCH/Release
fi
fi
done
if [ -n "$LOCALDEBS" -a -n "$LOCAL" ] ; then
if [ -e $LOCALDEBS/dists/$CODENAME-backports/local/binary-$ARCH/Release ] ; then
mkdir -p dists/$CODENAME-backports/local/binary-$ARCH
cp $LOCALDEBS/dists/$CODENAME-backports/local/binary-$ARCH/Release \
dists/$CODENAME-backports/local/binary-$ARCH/
fi
fi
if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer/binary-$ARCH/Release" ] ; then
mkdir -p dists/$CODENAME-backports/main/debian-installer/binary-$ARCH
cp $MIRROR/dists/$DI_CODENAME/main/debian-installer/binary-$ARCH/Release \
dists/$CODENAME-backports/main/debian-installer/binary-$ARCH/
if [ "$DEBVERSION" != "testing" ] ; then
sed -i "s/^Archive:.*$/Archive: stable/" dists/$CODENAME-backports/main/debian-installer/binary-$ARCH/Release
fi
fi
done
fi
# Upgrade packages / kernels # Upgrade packages / kernels
if [ "$SOURCEONLY"x != "yes"x ] ; then if [ "$SOURCEONLY"x != "yes"x ] ; then
echo " Trying to add upgrade* directories" echo " Trying to add upgrade* directories"