Hello community, here is the log from the commit of package mksusecd for openSUSE:Factory checked in at 2015-06-30 10:16:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mksusecd (Old) and /work/SRC/openSUSE:Factory/.mksusecd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mksusecd" Changes: -------- --- /work/SRC/openSUSE:Factory/mksusecd/mksusecd.changes 2015-06-23 11:58:18.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.mksusecd.new/mksusecd.changes 2015-06-30 10:16:16.000000000 +0200 @@ -1,0 +2,6 @@ +Thu Jun 25 13:06:04 CEST 2015 - snw...@suse.com + +- keep /content file up-to-date even when new files are added to the iso +- 1.25 + +------------------------------------------------------------------- Old: ---- mksusecd-1.24.tar.xz New: ---- mksusecd-1.25.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mksusecd.spec ++++++ --- /var/tmp/diff_new_pack.k8yHzd/_old 2015-06-30 10:16:17.000000000 +0200 +++ /var/tmp/diff_new_pack.k8yHzd/_new 2015-06-30 10:16:17.000000000 +0200 @@ -18,7 +18,7 @@ Name: mksusecd -Version: 1.24 +Version: 1.25 Release: 0 Summary: Create SUSE Linux installation ISOs License: GPL-3.0+ ++++++ mksusecd-1.24.tar.xz -> mksusecd-1.25.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mksusecd-1.24/VERSION new/mksusecd-1.25/VERSION --- old/mksusecd-1.24/VERSION 2015-06-19 15:09:28.000000000 +0200 +++ new/mksusecd-1.25/VERSION 2015-06-25 13:03:04.000000000 +0200 @@ -1 +1 @@ -1.24 +1.25 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mksusecd-1.24/changelog new/mksusecd-1.25/changelog --- old/mksusecd-1.24/changelog 2015-06-19 15:09:28.000000000 +0200 +++ new/mksusecd-1.25/changelog 2015-06-25 13:03:04.000000000 +0200 @@ -1,3 +1,6 @@ +2015-06-25: 1.25 + - keep /content file up-to-date even when new files are added to the iso + 2015-06-19: 1.24 - ensure '/content' is re-signed when necessary diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mksusecd-1.24/mksusecd new/mksusecd-1.25/mksusecd --- old/mksusecd-1.24/mksusecd 2015-06-19 15:09:28.000000000 +0200 +++ new/mksusecd-1.25/mksusecd 2015-06-25 13:03:04.000000000 +0200 @@ -174,6 +174,7 @@ sub prepare_nano; sub prepare_pico; sub set_mkisofs_metadata; +sub add_to_content_file; sub update_content; sub create_sign_key; sub add_sign_key; @@ -2129,6 +2130,37 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Add a file's check sum to /content. +# +# add_to_content_file($content, $type, $file_name, $pattern) +# +sub add_to_content_file +{ + my $cont = shift; + my $type = shift; + my $name = shift; + my $pattern = shift; + + my $match = $name; + $name =~ s#.*/## if $type eq "META"; + + if($match =~ m#$pattern# && !$cont->{$type}{$name}{new}) { + my $digest = Digest::SHA->new($cont->{bits}); + my $f = fname($type eq "META" ? "suse/setup/descr/$name" : $name); + if(-f $f) { + # print "$name\n"; + $digest->addfile($f); + my $sum = $digest->hexdigest; + $cont->{$type}{$name}{new} = "$cont->{bits} $sum"; + } + } +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Create a new /content file and return 1 if it is different from the +# existing one. +# sub update_content { my $changed = 0; @@ -2136,46 +2168,76 @@ # don't modify content if we're not going to re-sign it return $changed if !$opt_sign; - my $content = fname "content"; + my $content_file = fname "content"; - return unless defined $content; + return unless defined $content_file; - my $content_old; - my $content_new; + my $cont; - if(open(my $f, $content)) { + # first, read file + if(open(my $f, $content_file)) { while(<$f>) { - $content_old .= $_; + next if /^\s*$/; if(/^((META|HASH|KEY)\s+SHA(\d+)\s+)(\S+)(\s+(\S+))/) { - my $bits = "\L$3"; - my $val = "\L$4"; - my $name = "$6"; - my $part1 = $1; - my $part2 = $5; - # print "bits = $bits, val = $val, name = $name\n"; - # print "($part1)($part2)\n"; - my $digest = Digest::SHA->new($bits); - my $f = fname $name; - if(defined $f) { - $digest->addfile($f); - $val = $digest->hexdigest; - } - $content_new .= "$part1$val$part2\n"; + my $type = $2; + my $bits = $3; + my $sum = "\L$4"; + my $name = $6; + $cont->{bits} = $bits if !$cont->{bits}; + $cont->{$type}{$name}{old} = "$bits $sum"; + + add_to_content_file $cont, $type, $name, '^'; } else { - $content_new .= $_; + $cont->{head} .= $_; } } close $f; } - if($content_new ne $content_old) { - $changed = 1; + $cont->{bits} = 256 if !$cont->{bits}; + + # then, adjust file list + for (sort keys %$files) { + next if m#directory\.yast$#; + + add_to_content_file $cont, "KEY", $_, '^gpg-pubkey-'; + add_to_content_file $cont, "HASH", $_, '^boot/[^/]+/[^/]+$'; + add_to_content_file $cont, "HASH", $_, '^boot/.+/initrd[^/.]*$'; + add_to_content_file $cont, "HASH", $_, '^boot/.+/linux[^/.]*$'; + add_to_content_file $cont, "HASH", $_, '^docu/RELEASE-NOTES[^/]*$'; + add_to_content_file $cont, "META", $_, '^suse/setup/descr/[^/]+$'; + } + + # print Dumper($cont); + + # compare new and old file checksums + for my $type (qw (META HASH KEY)) { + for (keys %{$cont->{$type}}) { + if($cont->{$type}{$_}{new} ne $cont->{$type}{$_}{old}) { + # print "changed: $_\n"; + $changed = 1; + last; + } + } + last if $changed; + } + + # if something changed, write new file + if($changed) { my $n = copy_file "content"; if($n) { if(open my $f, ">", $n) { - print $f $content_new; + print $f $cont->{head}; + + for my $type (qw (META HASH KEY)) { + for (sort keys %{$cont->{$type}}) { + next if !$cont->{$type}{$_}{new}; + printf $f "%-4s SHA%s %s\n", $type, $cont->{$type}{$_}{new}, $_; + } + } + close $f; } }