diff options
author | J Pipkin <j@dawnrazor.net> | 2013-03-02 03:52:52 -0600 |
---|---|---|
committer | J Pipkin <j@dawnrazor.net> | 2013-03-02 03:52:52 -0600 |
commit | e8759a987a0bd1560cddd5d9443a4dfa2c3154fb (patch) | |
tree | 37f23ee1e7579e839d61fc7786986edd5dfbcd3c | |
parent | 5b7871d33a8f0746eb095d1cf9a2f2b306dfa562 (diff) | |
parent | 2483cc672c72ef8182035d65de1593dca8b94267 (diff) | |
download | sbotools2-e8759a987a0bd1560cddd5d9443a4dfa2c3154fb.tar.xz |
Merge branch 'tmp_fix', fixes #50
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 55 | ||||
-rw-r--r-- | man1/sboclean.1 | 4 | ||||
-rw-r--r-- | man1/sboconfig.1 | 4 | ||||
-rw-r--r-- | man1/sboinstall.1 | 4 | ||||
-rw-r--r-- | man1/sboupgrade.1 | 4 | ||||
-rw-r--r-- | man5/sbotools.conf.5 | 4 | ||||
-rwxr-xr-x | sboclean | 12 |
7 files changed, 54 insertions, 33 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 3c58a83..9b9c168 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -86,7 +86,14 @@ use File::Find; use File::Basename; use Fcntl qw(F_SETFD F_GETFD); -our $tempdir = tempdir(CLEANUP => 1); +# get $TMP from the env, if defined - we use two variables here because there +# are times when we need to no if the environment variable is set, and other +# times where it doesn't matter. +our $env_tmp; +$env_tmp = $ENV{TMP} if defined $ENV{TMP}; +our $tmpd = $env_tmp ? $env_tmp : '/tmp'; + +our $tempdir = tempdir(CLEANUP => 1, DIR => $tmpd); # define this to facilitate unit testing - should only ever be modified from # t/test.t @@ -372,7 +379,7 @@ sub get_sbo_version($) { # newer, and compile an array of hashes containing those which are sub get_available_updates() { my @updates; - my $pkg_list = get_installed_packages 'SBO'; + my $pkg_list = get_installed_packages 'SBO'; FIRST: for my $key (keys @$pkg_list) { my $location = get_sbo_location($$pkg_list[$key]{name}); # if we can't find a location, assume invalid and skip @@ -434,11 +441,11 @@ sub get_sbo_downloads { $args{LOCATION} or script_error 'get_sbo_downloads requires LOCATION.'; my $location = $args{LOCATION}; -d $location or script_error 'get_sbo_downloads given a non-directory.'; - my $arch = get_arch; + my $arch = get_arch; my $dl_info; if ($arch eq 'x86_64') { $dl_info = get_download_info(LOCATION => $location) unless $args{32}; - } + } unless (keys %$dl_info > 0) { $dl_info = get_download_info(LOCATION => $location, X64 => 0); } @@ -678,7 +685,9 @@ sub get_src_dir($) { my $fh = shift; seek $fh, 0, 0; my @src_dirs; - if (opendir(my $tsbo_dh, '/tmp/SBo')) { + # scripts use either $TMP or /tmp/SBo + my $tsbo = $env_tmp ? $env_tmp : "$tmpd/SBo"; + if (opendir(my $tsbo_dh, $tsbo)) { FIRST: while (my $ls = readdir $tsbo_dh) { next FIRST if $ls =~ /^\.[\.]{0,1}$/; next FIRST if $ls =~ /^package-/; @@ -710,7 +719,7 @@ sub get_tmp_extfn($) { # prep and run .SlackBuild sub perform_sbo { my %args = ( - OPTS => 0, + OPTS => 0, JOBS => 0, LOCATION => '', ARCH => '', @@ -726,7 +735,7 @@ sub perform_sbo { my $sbo = get_sbo_from_loc $location; my ($cmd, %changes); # set any changes we need to make to the .SlackBuild, setup the command - + $cmd = '( '; if ($args{ARCH} eq 'x86_64' and ($args{C32} || $args{X32})) { @@ -739,9 +748,10 @@ sub perform_sbo { } $cmd .= " $args{OPTS}" if $args{OPTS}; $cmd .= " MAKEOPTS=\"-j$args{JOBS}\"" if $args{JOBS}; - # we need to get a listing of /tmp/SBo, if we can, before we run the - # SlackBuild so that we can compare to a listing taken afterward. + # we need to get a listing of /tmp/SBo, or $TMP, if we can, before we run + # the SlackBuild so that we can compare to a listing taken afterward. my $src_ls_fh = tempfile(DIR => $tempdir); + my $tsbo = $env_tmp ? $env_tmp : "$tmpd/SBo"; if (opendir(my $tsbo_dh, '/tmp/SBo')) { FIRST: while (readdir $tsbo_dh) { next FIRST if /^\.[\.]{0,1}$/; @@ -752,7 +762,10 @@ sub perform_sbo { my $exit_temp = tempfile(DIR => $tempdir); my ($exit_fn, $exit) = get_tmp_extfn $exit_temp; return $exit_fn, undef, $exit if $exit; - $cmd .= " /bin/sh $location/$sbo.SlackBuild; echo \$? > $exit_fn )"; + # set TMP/OUTPUT if set in the environment + $cmd .= " TMP=$env_tmp" if $env_tmp; + $cmd .= " OUTPUT=$ENV{OUTPUT}" if defined $ENV{OUTPUT}; + $cmd .= " /bin/bash $location/$sbo.SlackBuild; echo \$? > $exit_fn )"; my $tempfh = tempfile(DIR => $tempdir); my $fn; ($fn, $exit) = get_tmp_extfn $tempfh; @@ -786,7 +799,7 @@ sub do_convertpkg($) { my $pkg = shift; my $tempfh = tempfile(DIR => $tempdir); my $fn = get_tmp_extfn $tempfh; - my $cmd = "/usr/sbin/convertpkg-compat32 -i $pkg -d /tmp | tee $fn"; + my $cmd = "/usr/sbin/convertpkg-compat32 -i $pkg -d $tmpd | tee $fn"; if (system($cmd) != 0) { return "convertpkg-compt32 returned non-zero exit status\n", _ERR_CONVERTPKG; @@ -798,7 +811,7 @@ sub do_convertpkg($) { # "public interface", sort of thing. sub do_slackbuild { my %args = ( - OPTS => 0, + OPTS => 0, JOBS => 0, LOCATION => '', COMPAT32 => 0, @@ -807,7 +820,7 @@ sub do_slackbuild { $args{LOCATION} or script_error 'do_slackbuild requires LOCATION.'; my $location = $args{LOCATION}; my $sbo = get_sbo_from_loc $location; - my $arch = get_arch; + my $arch = get_arch; my $multilib = check_multilib; my $version = get_sbo_version $location; my $x32; @@ -848,7 +861,7 @@ sub do_slackbuild { return $version, $pkg, $src; } -# remove work directories (source and packaging dirs under /tmp/SBo) +# remove work directories (source and packaging dirs under /tmp/SBo or $TMP) sub make_clean { my %args = ( SBO => '', @@ -861,15 +874,15 @@ sub make_clean { } my $src = $args{SRC}; say "Cleaning for $args{SBO}-$args{VERSION}..."; - my $tmpsbo = '/tmp/SBo'; + my $tmpsbo = $env_tmp ? $env_tmp : "$tmpd/SBo"; for my $dir (@$src) { remove_tree("$tmpsbo/$dir") if -d "$tmpsbo/$dir"; } remove_tree("$tmpsbo/package-$args{SBO}") if -d "$tmpsbo/package-$args{SBO}"; # clean up after convertpkg-compat32 - remove_tree("/tmp/package-$args{SBO}") if - -d "/tmp/package-$args{SBO}" and $args{SBO} ~~ /-compat32$/; + remove_tree("$tmpd/package-$args{SBO}") if + -d "$tmpd/package-$args{SBO}" and $args{SBO} ~~ /-compat32$/; return 1; } @@ -928,7 +941,7 @@ sub add_to_queue($) { $$sbo = $req; add_to_queue($args); } - } + } } # recursively add a sbo's requirements to the build queue. @@ -1048,7 +1061,7 @@ sub ask_opts { return unless $opts; while ($opts !~ $kv_regex) { warn "Invalid input received.\n"; - $opts = &$ask; + $opts = &$ask; } return $opts; } @@ -1156,7 +1169,7 @@ sub process_sbos { } } - do_upgradepkg $pkg unless $args{NOINSTALL}; + do_upgradepkg $pkg unless $args{NOINSTALL}; unless ($args{DISTCLEAN}) { make_clean(SBO => $sbo, SRC => $src, VERSION => $version) @@ -1178,7 +1191,7 @@ sub process_sbos { if (-d $dir) { move($pkg, $dir), say "$pkg stored in $dir"; } else { - warn "$pkg left in /tmp\n"; + warn "$pkg left in $tmpd\n"; } } elsif ($args{DISTCLEAN}) { unlink $pkg; diff --git a/man1/sboclean.1 b/man1/sboclean.1 index cf83ee6..6e65ba2 100644 --- a/man1/sboclean.1 +++ b/man1/sboclean.1 @@ -7,7 +7,7 @@ sboclean - clean files left around by sbotools. sboclean [-h|-v] [-dwi] .SH DESCRIPTION .P -sboclean is used to clean files left around by sbotools, such as downloaded source files ("distfiles"), or work directories under /tmp/SBo and, for compat32 installs, under /tmp. Note that if not run with the -i flag, sboclean will remove anything in the distfiles or /tmp/SBo folders and any /tmp/package-*-compat32 directories with extreme prejudice. One of either -d or -w must be specified for this script to do anything. +sboclean is used to clean files left around by sbotools, such as downloaded source files ("distfiles"), or work directories under /tmp/SBo (or $TMP) and, for compat32 installs, under /tmp (or $TMP). Note that if not run with the -i flag, sboclean will remove anything in the distfiles or /tmp/SBo (or $TMP) folders and any /tmp/package-*-compat32 (or $TMP/package-*-compat32) directories with extreme prejudice. One of either -d or -w must be specified for this script to do anything. .SH OPTIONS .P -h|--help @@ -27,7 +27,7 @@ Clean distfiles, by default located at /usr/sbo/distfiles. .P -w|--clean-work .RS -Clean working directories, located under /tmp/SBo and, for compat32 installs, /tmp. +Clean working directories, located, by default under /tmp/SBo and, for compat32 installs, by default, /tmp. .RE .P -i|--interactive diff --git a/man1/sboconfig.1 b/man1/sboconfig.1 index b4b62f5..66b63c8 100644 --- a/man1/sboconfig.1 +++ b/man1/sboconfig.1 @@ -27,7 +27,7 @@ List out current configuration options, including unmodified default configurati .P -c|--noclean (FALSE|TRUE) .RS -NOCLEAN: If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo. By default, these directories are removed after building an slackbuild. Setting this option to TRUE causes the working directories to not be cleaned by default. This can be overridden when running sboupgrade(1)/sboinstall(1). +NOCLEAN: If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo (or $TMP). By default, these directories are removed after building an slackbuild. Setting this option to TRUE causes the working directories to not be cleaned by default. This can be overridden when running sboupgrade(1)/sboinstall(1). .RE .P -d|--distclean (FALSE|TRUE) @@ -42,7 +42,7 @@ JOBS: If numeric (2,5,10, etc), then that number will be fed to the "-j" argumen .P -p|--pkg-dir (FALSE|/path) .RS -PKG_DIR: If set to a path, packages will be stored at the given location after building and installing. By default, packages are left where they are deposited by slackbuilds, which is typically (probably always) /tmp. If PKG_DIR is FALSE and DISTCLEAN is TRUE (either in sbotools.conf(5) or at sboupgrade/sboinstall runtime), the package will be deleted. If this option is set to a path in the filesystem, the package will be stored in that directory, regardless of any DISTCLEAN option. +PKG_DIR: If set to a path, packages will be stored at the given location after building and installing. By default, packages are left where they are deposited by slackbuilds, which is typically (probably always) /tmp (or $OUTPUT). If PKG_DIR is FALSE and DISTCLEAN is TRUE (either in sbotools.conf(5) or at sboupgrade/sboinstall runtime), the package will be deleted. If this option is set to a path in the filesystem, the package will be stored in that directory, regardless of any DISTCLEAN option. .RE .P -s|--sbo-home (/usr/sbo|/path) diff --git a/man1/sboinstall.1 b/man1/sboinstall.1 index 0911479..6abd54d 100644 --- a/man1/sboinstall.1 +++ b/man1/sboinstall.1 @@ -22,7 +22,7 @@ Show version information. .P -c|--noclean (FALSE|TRUE) .RS -If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo. By default, these directories are removed after building an slackbuild. This option leaves those directories in place. This can be set as default via the sboconfig(1) command. Also see sbotools.conf(5). This option overrides the default. +If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo (or $TMP). By default, these directories are removed after building an slackbuild. This option leaves those directories in place. This can be set as default via the sboconfig(1) command. Also see sbotools.conf(5). This option overrides the default. .RE .P -d|--distclean (FALSE|TRUE) @@ -32,7 +32,7 @@ If TRUE, then DO remove the source code after building the slackbuild. By defaul .P -i|--noinstall .RS -Do not actually install the package created at the end of the build process. So, the slackbuild will be run, and the package will be left in /tmp, or in $PKG_DIR if so defined (see sboconfig(1) and sbotools.conf(5)). +Do not actually install the package created at the end of the build process. So, the slackbuild will be run, and the package will be left in /tmp (or $OUTPUT), or in $PKG_DIR if so defined (see sboconfig(1) and sbotools.conf(5)). .RE .P -j|--jobs (FALSE|#) diff --git a/man1/sboupgrade.1 b/man1/sboupgrade.1 index 70e52f5..d0ba370 100644 --- a/man1/sboupgrade.1 +++ b/man1/sboupgrade.1 @@ -22,7 +22,7 @@ Show version information. .P -c|--noclean (FALSE|TRUE) .RS -If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo. By default, these directories are removed after building an slackbuild. This option leaves those directories in place. This can be set as default via the sboconfig(1) command. Also see sbotools.conf(5). This option overrides the default. +If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo (or $TMP). By default, these directories are removed after building an slackbuild. This option leaves those directories in place. This can be set as default via the sboconfig(1) command. Also see sbotools.conf(5). This option overrides the default. .RE .P -d|--distclean (FALSE|TRUE) @@ -37,7 +37,7 @@ Force an upgrade, even if the installed version is equal to or less than the sla .P -i|--noinstall .RS -Do not actually install the package created at the end of the build process. So, the slackbuild will be run, and the package will be left in /tmp, or in $PKG_DIR if so defined (see sboconfig(1) and sbotools.conf(5)). +Do not actually install the package created at the end of the build process. So, the slackbuild will be run, and the package will be left in /tmp (or $OUTPUT), or in $PKG_DIR if so defined (see sboconfig(1) and sbotools.conf(5)). .RE .P -j|--jobs (FALSE|#) diff --git a/man5/sbotools.conf.5 b/man5/sbotools.conf.5 index aa01c25..ceedc00 100644 --- a/man5/sbotools.conf.5 +++ b/man5/sbotools.conf.5 @@ -20,12 +20,12 @@ If numeric (2,5,10, etc), then that number will be fed to the "-j" argument to m .P NOCLEAN=(FALSE|TRUE) .RS -If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo. By default, these directories are removed after building a slackbuild. Setting this option to TRUE causes the working directories to not be cleaned by default. This can be overridden when running sboupgrade(1)/sboinstall(1). +If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo (or $TMP). By default, these directories are removed after building a slackbuild. Setting this option to TRUE causes the working directories to not be cleaned by default. This can be overridden when running sboupgrade(1)/sboinstall(1). .RE .P PKG_DIR=(FALSE|/path) .RS -If set to a path, packages will be stored at the given location after building and installing. By default, packages are left where they are deposited by SlackBuilds, which is typically (probably always) /tmp. If PKG_DIR is FALSE and DISTCLEAN is TRUE (either in sbotools.conf(5) or at sboupgrade/sboinstall runtime), the package will be deleted. If this option is set to a path in the filesystem, the package will be stored in that directory, regardless of any DISTCLEAN option. +If set to a path, packages will be stored at the given location after building and installing. By default, packages are left where they are deposited by SlackBuilds, which is typically (probably always) /tmp (or $OUTPUT). If PKG_DIR is FALSE and DISTCLEAN is TRUE (either in sbotools.conf(5) or at sboupgrade/sboinstall runtime), the package will be deleted. If this option is set to a path in the filesystem, the package will be stored in that directory, regardless of any DISTCLEAN option. .RE .P SBO_HOME=(/usr/sbo|/path) @@ -78,7 +78,7 @@ sub remove_stuff($) { } sub clean_c32() { - my $dir = '/tmp'; + my $dir = $SBO::Lib::tmpd; opendir(my $dh, $dir); FIRST: while (my $ls = readdir $dh) { next FIRST unless $ls =~ /^package-.+-compat32$/; @@ -89,7 +89,15 @@ sub clean_c32() { remove_stuff $config{SBO_HOME} .'/distfiles' if $clean_dist; if ($clean_work) { - remove_stuff '/tmp/SBo'; + my $env_tmp = $SBO::Lib::env_tmp; + my $tsbo = $env_tmp ? $env_tmp : "$SBO::Lib::tmpd/SBo"; + if ($env_tmp && !$interactive) { + warn "This will remove the entire contents of $env_tmp\n"; + print "Proceed? [y] "; + remove_stuff $tsbo if <STDIN> =~ /^[yY\n]/; + } else { + remove_stuff $tsbo; + } clean_c32; } |