From 901bb5b664986baffdce364e3ff661a036bd7227 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Wed, 7 Oct 2015 22:16:17 +0300 Subject: Create orig tarballs (prototype) --- dh_illumos_gate | 113 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/dh_illumos_gate b/dh_illumos_gate index 1d9a923..f63fc17 100755 --- a/dh_illumos_gate +++ b/dh_illumos_gate @@ -60,6 +60,10 @@ as is to L via I<--exclude=PATTERN>. Copy all extracted files into this directory, and make any changes in there instead of the current directory. +=item B<--create-orig> + +Create I<.orig> tarball. + =back =head1 EXAMPLES @@ -88,6 +92,10 @@ then add F dh_illumos_gate -- --wildcards-match-slash usr/src/uts/*.h +=item Create source tarball out of F excluding F<*.mf> files + + dh_illumos_gate --create-orig usr/src/cmd -X*.mf + =back =head1 FILES @@ -116,28 +124,18 @@ Here are things which this helper does after unpacking illumos sources. $dh{DESTDIR} = '.'; -init( options => { 'build|B' => \$dh{BUILD}, 'destdir|D=s' => \$dh{DESTDIR} } ); +init( + options => { + 'build|B' => \$dh{BUILD}, + 'destdir|D=s' => \$dh{DESTDIR}, + 'create-orig' => \$dh{CREATE_ORIG}, + } +); my %options = ( file => 'debian/changelog' ); my $changelog = changelog_parse(%options); my $version = $changelog->{'Version'}; -my $VER; -if ( $version =~ /^(\d+(\.\d+)+(\.git\w+)?).*$/ ) { - $VER = $1; -} -else { - error( "Could not determine illumos source version from changelog. " - . "It should be like 5.10.6.gitXYZ+1, but it is '$version'" ); -} -my $tarball = "/usr/src/illumos-gate/illumos-gate-$VER.tar.xz"; - -if ( !-f $tarball ) { - error( -"$tarball does not exist. You might not have package illumos-source-$VER " - . "installed or have a typo in debian/changelog" ); -} - my @tar_X = (); if ( defined( $dh{'EXCLUDE'} ) && $dh{'EXCLUDE'} ) { foreach my $x ( @{ $dh{'EXCLUDE'} } ) { @@ -146,40 +144,67 @@ if ( defined( $dh{'EXCLUDE'} ) && $dh{'EXCLUDE'} ) { } } -my @to_extract = (); -if (@ARGV) { - if ( $dh{'BUILD'} ) { - push @to_extract, - ( - 'usr/src/Makefile*', 'usr/src/common/mapfiles', - 'usr/src/tools/scripts/bldenv.sh', - ); - if ( grep { m|.*usr/src/lib/.*| } @ARGV ) { - push @to_extract, 'usr/src/lib/Makefile*'; - } - if ( grep { m|.*usr/src/cmd/.*| } @ARGV ) { - push @to_extract, 'usr/src/cmd/Makefile*'; - } - } - push @to_extract, map { m,(?:illumos-gate/)?(.*),; $1 } @ARGV; +if ( $dh{CREATE_ORIG} ) { + my $source = $changelog->{'Source'}; + my $source_version = $version =~ s!^(.*)-[^-]+$!$1!r; + my $tarball = "../${source}_${source_version}.orig.tar.xz"; + doit( 'tar', '-c', '-J', '--owner=0', '--group=0', '--mode=u=rwX,go=rX', + '-f', $tarball, @tar_X, @ARGV ); + exit; } else { - push @to_extract, 'usr'; -} -my @to_extract_real = (); -foreach my $p (@to_extract) { - if ( $p =~ /^-/ ) { - push @to_extract_real, $p; #XXX: tar option + my $VER; + if ( $version =~ /^(\d+(\.\d+)+(\.git\w+)?).*$/ ) { + $VER = $1; } else { - push @to_extract_real, 'illumos-gate/' . $p; #XXX: path + error( "Could not determine illumos source version from changelog. " + . "It should be like 5.10.6.gitXYZ+1, but it is '$version'" ); + } + my $tarball = "/usr/src/illumos-gate/illumos-gate-$VER.tar.xz"; + + if ( !-f $tarball ) { + error( +"$tarball does not exist. You might not have package illumos-source-$VER " + . "installed or have a typo in debian/changelog" ); } -} -doit( 'mkdir', '-p', $dh{DESTDIR} ); -doit( 'tar', '-C', $dh{DESTDIR}, '-x', '-f', $tarball, @tar_X, '--wildcards', - '--strip-components=1', @to_extract_real ); + my @to_extract = (); + if (@ARGV) { + if ( $dh{'BUILD'} ) { + push @to_extract, + ( + 'usr/src/Makefile*', 'usr/src/common/mapfiles', + 'usr/src/tools/scripts/bldenv.sh', + ); + if ( grep { m|.*usr/src/lib/.*| } @ARGV ) { + push @to_extract, 'usr/src/lib/Makefile*'; + } + if ( grep { m|.*usr/src/cmd/.*| } @ARGV ) { + push @to_extract, 'usr/src/cmd/Makefile*'; + } + } + push @to_extract, map { m,(?:illumos-gate/)?(.*),; $1 } @ARGV; + } + else { + push @to_extract, 'usr'; + } + + my @to_extract_real = (); + foreach my $p (@to_extract) { + if ( $p =~ /^-/ ) { + push @to_extract_real, $p; #XXX: tar option + } + else { + push @to_extract_real, 'illumos-gate/' . $p; #XXX: path + } + } + + doit( 'mkdir', '-p', $dh{DESTDIR} ); + doit( 'tar', '-C', $dh{DESTDIR}, '-x', '-f', $tarball, @tar_X, + '--wildcards', '--strip-components=1', @to_extract_real ); +} =item Saving original files -- cgit v1.2.3