summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-10-23 20:07:50 +0400
committerIgor Pashev <pashev.igor@gmail.com>2012-10-23 20:07:50 +0400
commit865abe8f17562e096b1c44452bbdfdc5fab6bff4 (patch)
treee5ec052538e1bdc1a0cf8d2decd8bff220bab52c
parent84b87438edbe0ed3dd95a4e01688a0fdb93e1df9 (diff)
downloaddh-illumos-865abe8f17562e096b1c44452bbdfdc5fab6bff4.tar.gz
Allow unpacking only specified files or directories
-rw-r--r--debian/changelog6
-rwxr-xr-xdh_illumos_gate203
2 files changed, 121 insertions, 88 deletions
diff --git a/debian/changelog b/debian/changelog
index 9b6abdc..b09fb23 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+dh-illumos (9.3) UNRELEASED; urgency=low
+
+ * Allow unpacking only specified files or directories
+
+ -- Igor Pashev <pashev.igor@gmail.com> Tue, 23 Oct 2012 20:06:54 +0400
+
dh-illumos (9.2) unstable; urgency=low
* Strip illumos-gate/ to ease importing patches from Git.
diff --git a/dh_illumos_gate b/dh_illumos_gate
index fe81b08..88c9c05 100755
--- a/dh_illumos_gate
+++ b/dh_illumos_gate
@@ -13,20 +13,20 @@ use Cwd;
=head1 SYNOPSIS
-B<dh_illumos_gate> [S<I<debhelper options>>] [B<-X>I<PATTERN>]
+B<dh_illumos_gate> [S<I<debhelper options>>] [B<-X>I<PATTERN>] [files and/or directories to extract]
=head1 DESCRIPTION
C<dh_illumos_gate> is responsible for unpacking illumos sources and adjusting the sources
for Debian build environment (paths to programs, command options, linker and compiler flags, etc.).
-It unpacks illumos gate sources, creates F<bldenv.sh> and F<env.sh>
-in the root of source tree, configures build environment in F<env.sh>.
+C<dh_illumos_gate> extracts given files or directories, if any.
+Otherwise it extracts entire F<illumos-gate/usr/>.
+In any case B<-X> option can be used to exclude some files or directories,
+and top directory F<illumos-gate> is always stripped..
-Sources are always unpacked into the current directory.
-And only one - F<usr/> - top-level directory is unpacked.
-F<illumos-gate/> prefix is stripped. This allow using
-upstream patches as is directly from Git.
+If files interested to C<dh_illumos_gate> are unpacked they will be configured.
+See L</DETAILS>.
After executing C<dh_illumos_gate> one can use commands like this to configure or build
components of illumos gate:
@@ -35,33 +35,55 @@ components of illumos gate:
L<dh_illumos_make(1)> provides more convenient way to do this.
-=head1 FILES
+=head1 OPTIONS
=over 4
-=item /usr/src/illumos-gate/illumos-gate-$(VER).tar.xz
+=item B<-X>I<PATTERN> B<--exclude=>I<PATTERN>
-This file contains complete and unmodified illumos sources.
-It is provided by package I<illumos-source-$(VER)>.
+Do not extract files or directories matching I<PATTERN>.
+This option can be used multiple times. I<PATTERN> is passed
+as is to L<tar(1)> via I<--exclude=PATTERN>.
-Version C<$(VER)> is determined from F<debian/changelog>:
+=back
- (\d+\.\d+).* => \1, e. g.:
- 2.10+3 => VER = 2.10
+=head1 EXAMPLES
+
+=over 4
+
+=item Unpack and configure the whole illumos source tree (F<usr/>)
+
+ dh_illumos_gate
+
+=item Unpack and configure whole illumos source tree, but F<usr/src/uts/>
+
+ dh_illumos_gate -X usr/src/uts
+
+=item Unpack and configure whole illumos source tree, but F<usr/src/uts/>;
+then add F<usr/src/uts/common/sys/>
+
+ dh_illumos_gate -X usr/src/uts
+ dh_illumos_gate usr/src/uts/common/sys
+
+=item Unpack all Makefiles under F<usr/src/>
+
+ dh_illumos_gate usr/src/Makefile\*
=back
-=head1 OPTIONS
+=head1 FILES
=over 4
-=item B<-X>I<PATTERN> B<--exclude=>I<PATTERN>
+=item /usr/src/illumos-gate/illumos-gate-$(VER).tar.xz
-By default C<dh_illumos_gate> unpack the whole archive of illumos sources.
-Use this options to exclude some parts. For example, if you are building
-illumos kernel (F<usr/src/uts>), you do not need libraries or programs and
-use F<-XI<usr/src/lib>> F<-XI<usr/src/cmd>>. These options passed
-as is to L<tar(1)> via I<--exclude=PATTERN>.
+This file contains complete and unmodified illumos sources.
+It is provided by package I<illumos-source-$(VER)>.
+
+Version C<$(VER)> is determined from F<debian/changelog>:
+
+ (\d+\.\d+).* => \1, e. g.:
+ 2.10+3 => VER = 2.10
=back
@@ -102,8 +124,14 @@ if (defined($dh{'EXCLUDE'}) && $dh{'EXCLUDE'}) {
}
}
-# Strip "illumos-gate/", unpack only "usr/"
-doit('tar', '-x', '-f', $tarball, @tar_X, '--strip-components=1', 'illumos-gate/usr');
+my @to_extract = ();
+if (@ARGV) {
+ @to_extract = map {s,(?:illumos-gate/)?(.*),illumos-gate/$1,; $_} @ARGV;
+} else {
+ push @to_extract, 'illumos-gate/usr';
+}
+# Strip "illumos-gate/"
+doit('tar', '-x', '-f', $tarball, @tar_X, '--wildcards', '--strip-components=1', @to_extract);
=item Saving original files
@@ -114,7 +142,7 @@ to see all changes.
=cut
-=item Changes to Fusr/src/Makefile.master>:
+=item Changes to F<usr/src/Makefile.master> (if extracted):
Remove option C<-s> (strip) from install command for directories and files.
This options does not make sense for directories and GNU L<install(1)> is
@@ -150,27 +178,25 @@ if ($bits == 64) {
}
my $Makefile_master = 'usr/src/Makefile.master';
-
my $Makefile_master_orig = $Makefile_master . '.orig';
-if (! -f $Makefile_master) {
- error("Could not find `$Makefile_master'. Is it accidently excluded via -X option?");
-}
-if (! -e $Makefile_master_orig) {
- doit('cp', '-f', $Makefile_master, $Makefile_master_orig);
-}
+if (-f $Makefile_master) {
+ if (! -e $Makefile_master_orig) {
+ doit('cp', '-f', $Makefile_master, $Makefile_master_orig);
+ }
-# Be carefull with modern CPP:
-my $i386_undef = '-Uamd64 -U__amd64 -U__amd64__ -U__x86_64__ -U__x86_64 -U_LP64';
-doit('sed', '-r', '-i', '
- /^INS\.(file|dir)/ s, -s,,;
- /^INS\.file/ s, -f, -t,;
- s,^i386_XARCH\s*=.*,i386_XARCH= -m32 ' . $i386_undef . ',;
- s,^i386_AS_XARCH\s*=.*,i386_AS_XARCH= ' . $i386_undef . ',;
- ', $Makefile_master
-);
+ # Be carefull with modern CPP:
+ my $i386_undef = '-Uamd64 -U__amd64 -U__amd64__ -U__x86_64__ -U__x86_64 -U_LP64';
+ doit('sed', '-r', '-i', '
+ /^INS\.(file|dir)/ s, -s,,;
+ /^INS\.file/ s, -f, -t,;
+ s,^i386_XARCH\s*=.*,i386_XARCH= -m32 ' . $i386_undef . ',;
+ s,^i386_AS_XARCH\s*=.*,i386_AS_XARCH= ' . $i386_undef . ',;
+ ', $Makefile_master
+ );
+}
-=item Changes to F<usr/src/lib/Makefile.lib>:
+=item Changes to F<usr/src/lib/Makefile.lib> (if extracted):
Append C<CFLAGS> to C<BUILD.SO> command, because C<BUILD.SO>
by default uses C compiler to create shared library.
@@ -202,14 +228,14 @@ if (-f $Makefile_lib) {
);
}
-=item Create F<usr/env.sh>
+=item Create F<usr/env.sh> (if F<usr> exists and F<usr/env.sh> does not)
-Set C<CODEMGR_WS> to be current directry.
+Set C<CODEMGR_WS> to the current directry.
-Set C<VERSION> from F<./debian/chnagelog>.
+Set C<VERSION> from F<./debian/changelog>.
For example it can be C<2.10-3>.
-Set C<LD_ALTEXEC=/usr/bin/ld-gnu-to-sun> to call L<sunld(1)>
+Set C<LD_ALTEXEC>=F</usr/bin/ld-gnu-to-sun> to call L<sunld(1)>
instead of GNU L<ld(1)>. Default system GCC is build to use GNU L<ld(1)>,
but L<sunld(1)> is required to build most illumos components.
See L<ld-gnu-to-sun(1)>.
@@ -235,43 +261,46 @@ to make them available from makefiles.
=cut
-my $cwd = getcwd();
-my $env = 'usr/env.sh';
-my $mach = `uname -p`; chomp $mach;
-if (open (ENV, '>', $env)) {
- print ENV "# This file was generated by dh_illumos_gate(1)\n";
- print ENV "export VERSION='$version'\n";
- print ENV "export CODEMGR_WS='$cwd'\n";
- print ENV "export ROOT='$cwd/debian/tmp'\n";
- print ENV "export SRC='$cwd/usr/src'\n";
- print ENV "export MULTI_PROTO='no'\n";
- print ENV "export CW_NO_SHADOW=1\n";
- print ENV "export LD_ALTEXEC='/usr/bin/ld-gnu-to-sun'\n";
- print ENV "export BUILD_TOOLS='/opt'\n";
- print ENV "export MACH='$mach'\n";
- print ENV "export LINT=:\n";
- print ENV "export LINTLIB=''\n";
- print ENV "export __GNUC=''\n";
- print ENV "export __GNUC4=''\n";
- print ENV "export GCC_ROOT='/usr'\n";
- print ENV "export LEX='/usr/bin/flex -l'\n";
- print ENV "export STRIP=':'\n";
- print ENV "export MCS=':'\n";
- print ENV "export DEB_LIBDIR_32='/$libdir32'\n";
- print ENV "export DEB_USRLIBDIR_32='/$usrlibdir32'\n";
- print ENV "export DEB_LIBDIR_64='/$libdir64'\n";
- print ENV "export DEB_USRLIBDIR_64='/$usrlibdir64'\n";
- print ENV "export LDLIBS32=\"-YP,\$ROOT/\$DEB_LIBDIR_32:\$ROOT/\$DEB_USRLIBDIR_32\"\n";
- print ENV "export LDLIBS64=\"-YP,\$ROOT/\$DEB_LIBDIR_64:\$ROOT/\$DEB_USRLIBDIR_64\"\n";
- print ENV 'export LDLIBS_NATIVE="', ($bits == 64) ? '$LDLIBS64' : '$LDLIBS32', "\"\n";
- print ENV `dpkg-architecture -s`;
-
- close(ENV);
-} else {
- error("Failed to write `$env': $!");
+
+if ( -d 'usr' && ! -f 'usr/env.sh') {
+ my $cwd = getcwd();
+ my $env = 'usr/env.sh';
+ my $mach = `uname -p`; chomp $mach;
+ if (open (ENV, '>', $env)) {
+ print ENV "# This file was generated by dh_illumos_gate(1)\n";
+ print ENV "export VERSION='$version'\n";
+ print ENV "export CODEMGR_WS='$cwd'\n";
+ print ENV "export ROOT='$cwd/debian/tmp'\n";
+ print ENV "export SRC='$cwd/usr/src'\n";
+ print ENV "export MULTI_PROTO='no'\n";
+ print ENV "export CW_NO_SHADOW=1\n";
+ print ENV "export LD_ALTEXEC='/usr/bin/ld-gnu-to-sun'\n";
+ print ENV "export BUILD_TOOLS='/opt'\n";
+ print ENV "export MACH='$mach'\n";
+ print ENV "export LINT=:\n";
+ print ENV "export LINTLIB=''\n";
+ print ENV "export __GNUC=''\n";
+ print ENV "export __GNUC4=''\n";
+ print ENV "export GCC_ROOT='/usr'\n";
+ print ENV "export LEX='/usr/bin/flex -l'\n";
+ print ENV "export STRIP=':'\n";
+ print ENV "export MCS=':'\n";
+ print ENV "export DEB_LIBDIR_32='/$libdir32'\n";
+ print ENV "export DEB_USRLIBDIR_32='/$usrlibdir32'\n";
+ print ENV "export DEB_LIBDIR_64='/$libdir64'\n";
+ print ENV "export DEB_USRLIBDIR_64='/$usrlibdir64'\n";
+ print ENV "export LDLIBS32=\"-YP,\$ROOT/\$DEB_LIBDIR_32:\$ROOT/\$DEB_USRLIBDIR_32\"\n";
+ print ENV "export LDLIBS64=\"-YP,\$ROOT/\$DEB_LIBDIR_64:\$ROOT/\$DEB_USRLIBDIR_64\"\n";
+ print ENV 'export LDLIBS_NATIVE="', ($bits == 64) ? '$LDLIBS64' : '$LDLIBS32', "\"\n";
+ print ENV `dpkg-architecture -s`;
+
+ close(ENV);
+ } else {
+ error("Failed to write `$env': $!");
+ }
}
-=item Create F<usr/bldenv.sh>
+=item Create F<usr/bldenv.sh> (if not exists and F<usr/src/tools/scripts/bldenv.sh> extracted)
Copy F<usr/src/tools/scripts/bldenv.sh>
to F<usr/bldenv.sh>.
@@ -284,15 +313,13 @@ with option C<--without-ctf>.
=cut
my $bldenv_sh = 'usr/src/tools/scripts/bldenv.sh';
-if (! -f $bldenv_sh) {
- error("Could not find `$bldenv_sh'. Is it accidently excluded via -X option?");
+if (-f $bldenv_sh && ! -f 'usr/bldenv.sh') {
+ doit('cp', '-f', $bldenv_sh, 'usr/bldenv.sh');
+ doit('sed', '-r', '-i', '
+ s,export +(CTF.+)="(.+)",export \1="${\1:-\2}",;
+ ', 'usr/bldenv.sh'
+ );
}
-doit('cp', '-f', $bldenv_sh, 'usr/bldenv.sh');
-doit('sed', '-r', '-i', '
- s,export +(CTF.+)="(.+)",export \1="${\1:-\2}",;
- ', 'usr/bldenv.sh'
-);
-
=back
=head1 NOTES