Hello community, here is the log from the commit of package mkdud for openSUSE:Factory checked in at 2016-12-02 16:42:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mkdud (Old) and /work/SRC/openSUSE:Factory/.mkdud.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mkdud" Changes: -------- --- /work/SRC/openSUSE:Factory/mkdud/mkdud.changes 2016-11-29 12:49:19.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.mkdud.new/mkdud.changes 2016-12-02 16:42:28.000000000 +0100 @@ -1,0 +2,11 @@ +Wed Nov 30 15:21:13 UTC 2016 - snw...@suse.com + +- more readable variable names +- be more specific about dists that support DUDs as rpm +- squash dashes ('-') to match more dist name spellings +- support creating a dud in rpm format (bsc#1006175) +- adjust documentation to include rpm format +- accept driver updates packed as rpm +- 1.27 + +------------------------------------------------------------------- Old: ---- mkdud-1.26.tar.xz New: ---- mkdud-1.27.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mkdud.spec ++++++ --- /var/tmp/diff_new_pack.xTHuJX/_old 2016-12-02 16:42:29.000000000 +0100 +++ /var/tmp/diff_new_pack.xTHuJX/_new 2016-12-02 16:42:29.000000000 +0100 @@ -23,7 +23,7 @@ Summary: Create driver update from rpms License: GPL-3.0+ Group: Hardware/Other -Version: 1.26 +Version: 1.27 Release: 0 Source: %{name}-%{version}.tar.xz Url: https://github.com/wfeldt/mkdud ++++++ mkdud-1.26.tar.xz -> mkdud-1.27.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mkdud-1.26/README.md new/mkdud-1.27/README.md --- old/mkdud-1.26/README.md 2016-11-28 13:41:58.000000000 +0100 +++ new/mkdud-1.27/README.md 2016-11-30 16:20:00.000000000 +0100 @@ -118,7 +118,8 @@ ### DUD formats The DUD will be packaged into an archive and optionally compressed. The -default is a gzipped cpio archive. +default is a gzipped cpio archive. For SLE12 and later you can also +create an rpm. Situation prior to SLE12, openSUSE 13.2: @@ -131,7 +132,12 @@ > You can use either a cpio or tar archive and can compress it optionally > with either gzip or xz. All formats may be used for signed DUDs. -There is an advantage in using cpio instead of tar: because the Linux kernel +SLE12-SP1, Leap-42.1 and later versions: + +> If you create an RPM (use --format=rpm) you can sign the RPM in the usual RPM-way +> to get a signed DUD. + +There is an advantage in using cpio instead of tar or rpm: because the Linux kernel understands cpio archives, you can just append a DUD to the initrd on the boot medium to apply it (literally: 'cat my.dud >> initrd'). No need for a 'dud' boot option in this case. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mkdud-1.26/VERSION new/mkdud-1.27/VERSION --- old/mkdud-1.26/VERSION 2016-11-28 13:41:58.000000000 +0100 +++ new/mkdud-1.27/VERSION 2016-11-30 16:20:00.000000000 +0100 @@ -1 +1 @@ -1.26 +1.27 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mkdud-1.26/changelog new/mkdud-1.27/changelog --- old/mkdud-1.26/changelog 2016-11-28 13:41:58.000000000 +0100 +++ new/mkdud-1.27/changelog 2016-11-30 16:20:00.000000000 +0100 @@ -1,3 +1,11 @@ +2016-11-30: 1.27 + - more readable variable names + - be more specific about dists that support DUDs as rpm + - squash dashes ('-') to match more dist name spellings + - support creating a dud in rpm format (bsc #1006175) + - adjust documentation to include rpm format + - accept driver updates packed as rpm + 2016-11-28: 1.26 - even more more verbose message - even more verbose error message diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mkdud-1.26/mkdud new/mkdud-1.27/mkdud --- old/mkdud-1.26/mkdud 2016-11-28 13:41:58.000000000 +0100 +++ new/mkdud-1.27/mkdud 2016-11-30 16:20:00.000000000 +0100 @@ -117,6 +117,8 @@ sub get_sign_key_name; sub sign_file; sub get_obs_key; +sub repack_as_rpm; +sub sign_rpm; my %config; my $opt_create; @@ -152,8 +154,10 @@ my $use_all_archs = 0; my $format_archive = "cpio"; my $format_compr = "gz"; +my $format_rpm = 0; # re-package as rpm if set my $sign_key_dir; my $sign_key_ok; +my $sign_key_id; my $obs; my $pubkey_info; my $yast_version = 0; @@ -276,6 +280,7 @@ die "Error: distribution arg is required; use --dist.\n" if !@opt_dist; my %d; @dists = @opt_dist; + map { tr/-//d } @dists; map { s/^(tumbleweed|tw).*/tw/g } @dists; push @dists, "13.2" if grep { $_ eq "leap42.1" } @dists; @d{map { /^sle([sd]?)(\d+)/i ? $1 eq "" ? ("sles$2", "sled$2") : "sle\L$1$2" : "\L$_" } @dists} = (); @@ -418,9 +423,10 @@ installation. mkdud will normally remove those files and print a warning. This also allows you to specify distributions with --dist that mkdud does not know about. - --format FORMAT Specify archive format for DUD. FORMAT=(cpio|tar|iso)[.(gz|xz)]. + --format FORMAT Specify archive format for DUD. + FORMAT=((cpio|tar|iso)[.(gz|xz)])|rpm. Default FORMAT is cpio.gz (gzip compressed cpio archive). - Note: don't change the default. See README. + Note: please check README before changing the default. --prefix NUM First directory prefix of driver update. See README. --sign Sign the driver update. --detached-sign Sign the driver update. This creates a detached signature. @@ -444,10 +450,11 @@ To create a driver update you need SOURCES. SOURCES can contain: - - existing driver updates; either as archive or unpacked directory. All driver + - existing driver updates; either as archive, rpm, or unpacked directory. All driver updates are joined. - - RPMs. The packages are used according to the value of the --install option. + - RPMs. Packages not containing a driver update are used according to the value + of the --install option. - PGP pubic key files (ASCII). The files are added to the rpm key database for verifying RPMs during the installation process. See 'Adding RPMs notes' below. @@ -605,6 +612,17 @@ exit 1; } + # check if rpm contains a driver update + # (a directory /linux/suse/foo-bar or /<NUMBER>/linux/suse/foo-bar exists) + for my $line (`rpm --nosignature -qp -lv $_[0] 2>$tmp_err`) { + my @field = split ' ', $line; + next unless $field[0] =~ /^d/; + if($field[8] =~ m#/(\d+/)?linux/suse/\S+-\S+$#) { + $dud = 'cpio.rpm'; + last; + } + } + # Check if yast base package is to be replaced and remember its version: if($f =~ /^yast2\t(.+)\t/) { $yast_version = $1; @@ -623,18 +641,20 @@ $ft->{date} = $d; - push @files, $ft; + if(!$dud) { + push @files, $ft; - if($opt_obs_keys && $opt_install{repo}) { - my $x = `rpm --nosignature -qp -i $_[0] 2>$tmp_err`; - if($x =~ /^Signature\s*:.*Key ID/m) { - $x = `rpm --nosignature -qp --qf '%{DISTURL}' $_[0] 2>$tmp_err`; - $x = get_obs_key $x, $_[0]; - push @files, { type => 'pubkey', file => $x } if $x; + if($opt_obs_keys && $opt_install{repo}) { + my $x = `rpm --nosignature -qp -i $_[0] 2>$tmp_err`; + if($x =~ /^Signature\s*:.*Key ID/m) { + $x = `rpm --nosignature -qp --qf '%{DISTURL}' $_[0] 2>$tmp_err`; + $x = get_obs_key $x, $_[0]; + push @files, { type => 'pubkey', file => $x } if $x; + } } - } - return; + return; + } } elsif(/^ELF/) { @i = split /\s*,\s*/; @@ -774,12 +794,13 @@ my $old = sprintf "%s/%04d", $tmp_old, $dud_cnt++; die "$old: $!\n" unless mkdir $old; - if($dud =~ /^(cpio|tar)(\.(gz|xz))?$/) { - my $cmd = "cpio --quiet -dmiu"; + if($dud =~ /^(cpio|tar)(\.(gz|xz|rpm))?$/) { + my $cmd = "cpio --quiet -dmiu --no-absolute-filenames"; $cmd = "tar -xpf -" if $1 eq "tar"; my $compr = 'cat'; $compr = 'gzip -dc' if $3 eq 'gz'; $compr = 'xz -dc' if $3 eq 'xz'; + $compr = 'rpm2cpio' if $3 eq 'rpm'; if($gpg_sign) { system "$gpg $_[0] | $compr | ( cd $old ; $cmd 2>/dev/null)"; } @@ -1517,11 +1538,20 @@ system "cd $tmp_src; $cmd_archive | $compr >$tmp_archive"; + if($format_rpm) { + $tmp_archive = repack_as_rpm $tmp_archive; + } + if($opt_sign) { - sign_file $tmp_archive; - if(!$opt_sign_direct) { - system "cp ${tmp_archive}.asc ${file_name}.asc"; - print "created detached signature ${file_name}.asc\n"; + if($format_rpm) { + sign_rpm $tmp_archive; + } + else { + sign_file $tmp_archive; + if(!$opt_sign_direct) { + system "cp ${tmp_archive}.asc ${file_name}.asc"; + print "created detached signature ${file_name}.asc\n"; + } } } @@ -2149,6 +2179,10 @@ # print "format = $format_archive.$format_compr\n"; } + elsif($opt_format eq 'rpm') { + $format_archive = 'tar'; + $format_rpm = 1; + } else { die "$opt_format: unsupported format spec\n"; } @@ -2183,6 +2217,7 @@ if($priv && $date) { $sign_key_ok = 1; + $sign_key_id = $keyid; system "gpg --homedir=$sign_key_dir --import $key >/dev/null 2>&1"; @@ -2319,3 +2354,69 @@ $s2 =~ s/(\d+)/sprintf("%010d", $1)/ge; return $s1 cmp $s2; } + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# $new_file = repack_as_rpm($file) +# +# Re-pack archive $file as rpm. Returns the rpm name. +# +sub repack_as_rpm +{ + my $tmp_dir = $tmp->dir('rpm'); + my $file = $_[0]; + + mkdir "$tmp_dir/SOURCES", 0755; + link $file, "$tmp_dir/SOURCES/dud.tar" or die "$file: $!\n"; + + my $c = <<'= = = = = = = ='; +Name: dud +Summary: Driver Update +License: No License Info +Group: Other +Version: 1.0 +Release: 0 +Source: dud.tar +BuildRoot: %{_tmppath}/dud-build +BuildArch: noarch + +%description +Driver Update + +%prep +%setup -c dud -n dud +%build +%install + cp -a * %{buildroot} + +%files +%defattr(-,root,root) +/ += = = = = = = = + + open my $f, ">$tmp_dir/SOURCES/dud.spec"; + print $f $c; + close $f; + + system "rpmbuild -D '%_topdir $tmp_dir' -bb $tmp_dir/SOURCES/dud.spec >$tmp_dir/build.log 2>&1"; + + my $rpm_name = "$tmp_dir/RPMS/noarch/dud-1.0-0.noarch.rpm"; + + die "failed to create rpm\n" unless -f $rpm_name; + + return $rpm_name; +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Sign an rpm. +# +sub sign_rpm +{ + my $file = $_[0]; + + return if !$sign_key_ok; + + # note: the 'setsid' is needed because rpmsign will try to read the passphrase from /dev/tty + system "setsid rpmsign --addsign -D '%_gpg_path $sign_key_dir' -D '%_gpg_name $sign_key_id' $file </dev/null >$sign_key_dir/rpmsign.log 2>&1"; +}