mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 06:01:15 +00:00
* rpm-closure.pl: add possibility to use multiple repositories
* default.nix: do not assume fixed filesystem type when mounting, to allow using other filesystems svn path=/nixpkgs/trunk/; revision=29757
This commit is contained in:
parent
a1f9b6f7b6
commit
40f1e4e289
|
@ -127,7 +127,7 @@ rec {
|
|||
if test -z "$mountDisk"; then
|
||||
mount -t tmpfs none /fs
|
||||
else
|
||||
mount -t ext2 /dev/${hd} /fs
|
||||
mount /dev/${hd} /fs
|
||||
fi
|
||||
|
||||
mkdir -p /fs/dev
|
||||
|
@ -166,7 +166,6 @@ rec {
|
|||
halt -d -p -f
|
||||
'';
|
||||
|
||||
|
||||
initrd = makeInitrd {
|
||||
contents = [
|
||||
{ object = stage1Init;
|
||||
|
@ -303,7 +302,7 @@ rec {
|
|||
'';
|
||||
|
||||
|
||||
createRootFS = ''
|
||||
defaultCreateRootFS = ''
|
||||
mkdir /mnt
|
||||
${e2fsprogs}/sbin/mke2fs -F /dev/${hd}
|
||||
${utillinux}/bin/mount -t ext2 /dev/${hd} /mnt
|
||||
|
@ -486,12 +485,12 @@ rec {
|
|||
|
||||
fillDiskWithRPMs =
|
||||
{ size ? 4096, rpms, name, fullName, preInstall ? "", postInstall ? ""
|
||||
, runScripts ? true
|
||||
, runScripts ? true, createRootFS ? defaultCreateRootFS
|
||||
}:
|
||||
|
||||
runInLinuxVM (stdenv.mkDerivation {
|
||||
inherit name preInstall postInstall rpms;
|
||||
|
||||
memSize = 512;
|
||||
preVM = createEmptyImage {inherit size fullName;};
|
||||
|
||||
buildCommand = ''
|
||||
|
@ -526,10 +525,10 @@ rec {
|
|||
eval "$postInstall"
|
||||
|
||||
rm /mnt/.debug
|
||||
|
||||
${utillinux}/bin/umount /mnt/nix/store
|
||||
${utillinux}/bin/umount /mnt/tmp
|
||||
${utillinux}/bin/umount /mnt
|
||||
|
||||
${utillinux}/bin/umount /mnt/nix/store
|
||||
${utillinux}/bin/umount /mnt/tmp
|
||||
${utillinux}/bin/umount /mnt
|
||||
'';
|
||||
|
||||
passthru = { inherit fullName; };
|
||||
|
@ -631,7 +630,7 @@ rec {
|
|||
strongly connected components. See deb/deb-closure.nix. */
|
||||
|
||||
fillDiskWithDebs =
|
||||
{ size ? 4096, debs, name, fullName, postInstall ? null }:
|
||||
{ size ? 4096, debs, name, fullName, postInstall ? null, createRootFS ? defaultCreateRootFS }:
|
||||
|
||||
runInLinuxVM (stdenv.mkDerivation {
|
||||
inherit name postInstall;
|
||||
|
@ -712,12 +711,15 @@ rec {
|
|||
`primary.xml.gz' file of a Fedora or openSUSE distribution. */
|
||||
|
||||
rpmClosureGenerator =
|
||||
{name, packagesList, urlPrefix, packages, archs ? []}:
|
||||
|
||||
{name, packagesLists, urlPrefixes, packages, archs ? []}:
|
||||
assert (builtins.length packagesLists) == (builtins.length urlPrefixes) ;
|
||||
runCommand "${name}.nix" {buildInputs = [perl perlPackages.XMLSimple]; inherit archs;} ''
|
||||
gunzip < ${packagesList} > ./packages.xml
|
||||
${lib.concatImapStrings (i: pl: ''
|
||||
gunzip < ${pl} > ./packages_${toString i}.xml
|
||||
'') packagesLists}
|
||||
perl -w ${rpm/rpm-closure.pl} \
|
||||
./packages.xml ${urlPrefix} ${toString packages} > $out
|
||||
${lib.concatImapStrings (i: pl: "./packages_${toString i}.xml ${pl.snd} " ) (lib.zipLists packagesLists urlPrefixes)} \
|
||||
${toString packages} > $out
|
||||
'';
|
||||
|
||||
|
||||
|
@ -726,15 +728,17 @@ rec {
|
|||
names. */
|
||||
|
||||
makeImageFromRPMDist =
|
||||
{ name, fullName, size ? 4096, urlPrefix, packagesList
|
||||
{ name, fullName, size ? 4096
|
||||
, urlPrefix ? "", urlPrefixes ? [urlPrefix]
|
||||
, packagesList ? "", packagesLists ? [packagesList]
|
||||
, packages, extraPackages ? []
|
||||
, preInstall ? "", postInstall ? "", archs ? ["noarch" "i386"]
|
||||
, runScripts ? true }:
|
||||
, runScripts ? true, createRootFS ? defaultCreateRootFS }:
|
||||
|
||||
fillDiskWithRPMs {
|
||||
inherit name fullName size preInstall postInstall runScripts;
|
||||
inherit name fullName size preInstall postInstall runScripts createRootFS;
|
||||
rpms = import (rpmClosureGenerator {
|
||||
inherit name packagesList urlPrefix archs;
|
||||
inherit name packagesLists urlPrefixes archs;
|
||||
packages = packages ++ extraPackages;
|
||||
}) { inherit fetchurl; };
|
||||
};
|
||||
|
|
|
@ -1,34 +1,52 @@
|
|||
use strict;
|
||||
use XML::Simple;
|
||||
|
||||
my $packagesFile = shift @ARGV;
|
||||
my $urlPrefix = shift @ARGV;
|
||||
my @packagesFiles = ();
|
||||
my @urlPrefixes = ();
|
||||
|
||||
# rpm-closure.pl (<package-file> <url-prefix>)+ <toplevel-pkg>+
|
||||
|
||||
while(-f $ARGV[0]) {
|
||||
my $packagesFile = shift @ARGV;
|
||||
my $urlPrefix = shift @ARGV;
|
||||
push(@packagesFiles, $packagesFile);
|
||||
push(@urlPrefixes, $urlPrefix);
|
||||
}
|
||||
|
||||
my @toplevelPkgs = @ARGV;
|
||||
|
||||
my @archs = split ' ', ($ENV{'archs'} or "");
|
||||
|
||||
print STDERR "parsing packages...\n";
|
||||
|
||||
my $xml = XMLin($packagesFile, ForceArray => ['package', 'rpm:entry', 'file'], KeyAttr => []) or die;
|
||||
|
||||
print STDERR "file contains $xml->{packages} packages\n";
|
||||
|
||||
|
||||
my %pkgs;
|
||||
foreach my $pkg (@{$xml->{'package'}}) {
|
||||
if (scalar @archs > 0) {
|
||||
my $arch = $pkg->{arch};
|
||||
my $found = 0;
|
||||
foreach my $a (@archs) { $found = 1 if $arch eq $a; }
|
||||
next if !$found;
|
||||
}
|
||||
if (defined $pkgs{$pkg->{name}}) {
|
||||
print STDERR "WARNING: duplicate occurrence of package $pkg->{name}\n";
|
||||
next;
|
||||
}
|
||||
$pkgs{$pkg->{name}} = $pkg;
|
||||
}
|
||||
for (my $i = 0; $i < scalar(@packagesFiles); $i++) {
|
||||
my $packagesFile = $packagesFiles[$i];
|
||||
print STDERR "parsing packages in $packagesFile...\n";
|
||||
|
||||
my $xml = XMLin($packagesFile, ForceArray => ['package', 'rpm:entry', 'file'], KeyAttr => []) or die;
|
||||
|
||||
print STDERR "$packagesFile contains $xml->{packages} packages\n";
|
||||
|
||||
foreach my $pkg (@{$xml->{'package'}}) {
|
||||
if (scalar @archs > 0) {
|
||||
my $arch = $pkg->{arch};
|
||||
my $found = 0;
|
||||
foreach my $a (@archs) { $found = 1 if $arch eq $a; }
|
||||
next if !$found;
|
||||
}
|
||||
if (defined $pkgs{$pkg->{name}}) {
|
||||
my $earlierPkg = $pkgs{$pkg->{name}};
|
||||
print STDERR "WARNING: duplicate occurrence of package $pkg->{name}\n";
|
||||
if ($earlierPkg->{'time'}->{file} <= $pkg->{'time'}->{file}) {
|
||||
print STDERR "WARNING: replaced package $pkg->{name} with newer one\n";
|
||||
$pkg->{urlPrefix} = $urlPrefixes[$i];
|
||||
$pkgs{$pkg->{name}} = $pkg;
|
||||
}
|
||||
next;
|
||||
}
|
||||
$pkg->{urlPrefix} = $urlPrefixes[$i];
|
||||
$pkgs{$pkg->{name}} = $pkg;
|
||||
}
|
||||
}
|
||||
|
||||
my %provides;
|
||||
foreach my $pkgName (keys %pkgs) {
|
||||
|
@ -104,7 +122,7 @@ print "[\n\n";
|
|||
foreach my $pkgName (@needed) {
|
||||
my $pkg = $pkgs{$pkgName};
|
||||
print " (fetchurl {\n";
|
||||
print " url = $urlPrefix/$pkg->{location}->{href};\n";
|
||||
print " url = $pkg->{urlPrefix}/$pkg->{location}->{href};\n";
|
||||
if ($pkg->{checksum}->{type} eq "sha") {
|
||||
print " sha1 = \"$pkg->{checksum}->{content}\";\n";
|
||||
} elsif ($pkg->{checksum}->{type} eq "sha256") {
|
||||
|
|
Loading…
Reference in a new issue