diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-10-07 19:40:16 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-10-07 19:40:48 +0300 |
commit | 520380e3e3dc2b4cef0e8d2ab26ba9c45ebd0b52 (patch) | |
tree | f072e20ade32685e85aa4f51e0c0b0e9fd577e04 | |
parent | 2a0f23cd3cb8c50ab70a9898e6d8c557947bb551 (diff) | |
download | dh-illumos-520380e3e3dc2b4cef0e8d2ab26ba9c45ebd0b52.tar.gz |
dh_illumos_gate: extracting to a directory other than the current directory
-rwxr-xr-x | dh_illumos_gate | 111 |
1 files changed, 61 insertions, 50 deletions
diff --git a/dh_illumos_gate b/dh_illumos_gate index d9c1328..1d9a923 100755 --- a/dh_illumos_gate +++ b/dh_illumos_gate @@ -13,7 +13,7 @@ use Cwd; =head1 SYNOPSIS -B<dh_illumos_gate> [S<I<debhelper options>>] [B<-B>] [B<-X>I<PATTERN>] [-- [tar options]] +B<dh_illumos_gate> [S<I<debhelper options>>] [options] [-- [tar options]] [files and/or directories to extract] =head1 DESCRIPTION @@ -55,6 +55,11 @@ 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>. +=item B<-D>I<destdir> B<--destdir=>I<destdir> + +Copy all extracted files into this directory, and +make any changes in there instead of the current directory. + =back =head1 EXAMPLES @@ -109,7 +114,9 @@ Here are things which this helper does after unpacking illumos sources. =cut -init( options => { "build|B" => \$dh{BUILD}, } ); +$dh{DESTDIR} = '.'; + +init( options => { 'build|B' => \$dh{BUILD}, 'destdir|D=s' => \$dh{DESTDIR} } ); my %options = ( file => 'debian/changelog' ); my $changelog = changelog_parse(%options); @@ -170,7 +177,8 @@ foreach my $p (@to_extract) { } } -doit( 'tar', '-x', '-f', $tarball, @tar_X, '--wildcards', +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 @@ -231,7 +239,7 @@ else { $usrlibdir64 = "usr/$libdir64"; } -my $Makefile_master = 'usr/src/Makefile.master'; +my $Makefile_master = $dh{DESTDIR} . '/usr/src/Makefile.master'; my $Makefile_master_orig = $Makefile_master . '.orig'; if ( -f $Makefile_master ) { if ( !-e $Makefile_master_orig ) { @@ -268,7 +276,7 @@ in some cases C<ROOTLIBDIR> will be overriden by C<ROOTFS_LIBDIR> within makefil =cut -my $Makefile_lib = 'usr/src/lib/Makefile.lib'; +my $Makefile_lib = $dh{DESTDIR} . '/usr/src/lib/Makefile.lib'; my $Makefile_lib_orig = $Makefile_lib . '.orig'; if ( -f $Makefile_lib ) { if ( !-e $Makefile_lib_orig ) { @@ -298,7 +306,7 @@ if ( -f $Makefile_lib ) { =cut -my $Makefile_cmd = 'usr/src/cmd/Makefile.cmd'; +my $Makefile_cmd = $dh{DESTDIR} . '/usr/src/cmd/Makefile.cmd'; my $Makefile_cmd_orig = $Makefile_cmd . '.orig'; if ( -f $Makefile_cmd ) { if ( !-e $Makefile_cmd_orig ) { @@ -349,49 +357,51 @@ to make them available from makefiles. =cut -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 CW_GCC=gcc\n"; - print ENV "export SAVEARGS=\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 +my $cwd = getcwd(); +chdir $dh{DESTDIR}; +my $codemgr_ws = getcwd(); +chdir $cwd; + +my $env = $dh{DESTDIR} . '/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='$codemgr_ws'\n"; + print ENV "export ROOT='$cwd/debian/tmp'\n"; + print ENV "export SRC='$codemgr_ws/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 CW_GCC=gcc\n"; + print ENV "export SAVEARGS=\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=\"-L\$ROOT/\$DEB_LIBDIR_32 -L\$ROOT/\$DEB_USRLIBDIR_32\"\n"; - print ENV + print ENV "export LDLIBS64=\"-L\$ROOT/\$DEB_LIBDIR_64 -L\$ROOT/\$DEB_USRLIBDIR_64\"\n"; - print ENV 'export LDLIBS_NATIVE="', - ( $bits == 64 ) ? '$LDLIBS64' : '$LDLIBS32', "\"\n"; - print ENV `dpkg-architecture -s`; + print ENV 'export LDLIBS_NATIVE="', + ( $bits == 64 ) ? '$LDLIBS64' : '$LDLIBS32', "\"\n"; + print ENV `dpkg-architecture -s`; - close(ENV); - } - else { - error("Failed to write `$env': $!"); - } + close(ENV); +} +else { + error("Failed to write `$env': $!"); } =item Create F<usr/bldenv.sh> (if not exists and F<usr/src/tools/scripts/bldenv.sh> extracted) @@ -406,14 +416,15 @@ with option C<--without-ctf>. =cut -my $bldenv_sh = 'usr/src/tools/scripts/bldenv.sh'; -if ( -f $bldenv_sh && !-f 'usr/bldenv.sh' ) { - doit( 'cp', '-f', $bldenv_sh, 'usr/bldenv.sh' ); +my $bldenv_sh_orig = $dh{DESTDIR} . '/usr/src/tools/scripts/bldenv.sh'; +my $bldenv_sh = $dh{DESTDIR} . '/usr/bldenv.sh'; +if ( -f $bldenv_sh_orig ) { + doit( 'cp', '-f', $bldenv_sh_orig, $bldenv_sh ); doit( 'sed', '-r', '-i', ' s,export +(CTF.+)="(.+)",export \1="${\1:-\2}",; s,^PATH=".+",PATH="${PATH}:/opt/onbld/bin:/opt/onbld/bin/${MACH}:.",; - ', 'usr/bldenv.sh' + ', $bldenv_sh ); } |