SBO::Lib::Build(3)

NAME
SBO::Lib::Build - Routines for building Slackware packages from SlackBuilds.org.

SYNOPSIS
  use SBO::Lib::Build qw/ perform_sbo /;

  my ($foo, $bar, $exit) = perform_sbo(LOCATION => $location);

VARIABLES

  %concluded
This is a shared hash that contains already-calculated build queues. It is used by get_build_queue() to reduce wasted time and check for circular dependencies. Note that %concluded is cleared by sbotool(1) when using the "Refresh" button.

  $env_tmp
This reflects $TMP from the environment, being "undef" if it is not set.

  @reverse_concluded
This is a shared array that tracks scripts with verified reverse dependency chains; it is used by get_full_reverse() to check for circular reverse dependencies. Note that @reverse_concluded is cleared by sbofind(1), sboremove(1) and sbotool(1) between results.

  $tempdir
This is a temporary directory created for sbotools' use. It should be removed when sbotools exits.

  $tmpd
This is the same as $TMP if it is set. Otherwise, it is "/tmp/SBo".

  @last_level_reverse
This is an array containing the last level of reverse dependencies generated by sbofind(1) with "all-reverse" and "top-reverse". It is used only by sbofind(1).

  %notices
This is a shared hash that contains per-script notification strings to display during user_prompt(); see SBO::Lib::Readme(3).

  @upcoming
This is a shared, non-exportable array that contains hashes with the source files needed by each script in the queue. Each hash drops out of the array when its corresponding script has been built.

  %warnings
This is a shared hash that contains per-script warnings. Possible warnings currently include "%README%" and "nonexistent".

SUBROUTINES

  do_convertpkg
  my ($name32, $exit) = do_convertpkg($name64);

do_convertpkg() runs "convertpkg" on the package in $name64.

On success, it returns the name of the converted package and an exit status. On failure, it returns an error message instead of the package name.

  do_slackbuild
  my ($ver, $pkg, $src, $exit) = do_slackbuild(LOCATION => $location);

do_slackbuild() makes checks and sets up the perform_sbo() call, running do_convertpkg() if needed.

A list of four values is returned if successful: version number, package name, an array with source directories and an exit code. In case of failure, the first value is an error message; the second and third values are empty.

  do_upgradepkg
  do_upgradepkg($pkg);

do_upgradepkg() runs "upgradepkg --reinstall --install-new" on $pkg.

There is no useful return value.

  get_build_queue
  my @queue = @{ get_build_queue($sbo, my @checked) };

get_build_queue() gets the prerequisites for $sbo, updating the shared $warnings hash reference with any "%README%" encountered. It returns the prerequisites and $sbo in the correct build order.

@checked and "our %concluded" are used to check for circular dependencies; the script exits with "_ERR_CIRCULAR" if any are present.

  get_full_queue
  my @revdep_queue = ($installed, @sbos);

get_full_queue() takes a list of installed SlackBuilds and an array of SlackBuilds to check. It returns a list of the checked SlackBuilds and their dependencies in reverse build order such that no SlackBuild appears after any of its dependencies.

  get_full_reverse
  my @get_full_reverse = get_full_reverse($sbo, %installed, %fulldeps, my @checked, my @list)

get_full_reverse() takes a SlackBuild, a hash of installed packages, a hash of reverse dependency relationships (from "get_reverse_reqs") and two arrays. These arrays should not be included when called from outside of the subroutine. get_full_reverse() returns an array with installed reverse dependencies.

The final level of reverse dependencies is kept in the shared array @last_level_reverse; these are displayed only by "sbofind(1) --top-reverse".

If any circular reverse dependencies are found, the script exits with "_ERR_CIRCULAR".

  get_full_reverse_queue
  my (@reverse_queue) = get_full_reverse_queue($from, $updates, $sbo ...)
  my (@reverse_queue) = get_full_reverse_queue($from, $self_include, $sbo ...)

get_full_reverse_queue() takes the name of the script it is called from and any number of SlackBuilds. The second variable is the list of available upgrades (if called from sboupgrade(1)), any true value if called from sboinstall(1) --reinstall and a false value otherwise. The subroutine returns a queue for a reverse dependency rebuild.

  get_pkg_name
  my $name = get_pkg_name($str);

get_pkg_name() searches $str for the last text matching the package name output from "makepkg". The package name is returned.

  get_src_dir
  my @dirs = @{ get_src_dir(@orig_dirs) };

get_src_dir() returns a list of those directories under "/tmp/SBo" or $TMP that are not in @orig_dirs. That is, the source directories for the script.

  get_tmp_extfn
  my ($ret, $exit) = get_tmp_extfn($fh);

get_tmp_extfn() gets the "/dev/fd/X" filename for the file handle $fh passed in, setting flats to make it usable from other processes.

It returns the filename if successful, and "undef" otherwise.

  make_clean
  make_clean(SBO => $sbo, SRC => $src, VERSION => $ver);

make_clean() removes source, package and compat32 directories left after running a SlackBuild.

It has no useful return value.

  make_distclean
  make_distclean(SRC => $src, VERSION => $ver, LOCATION => $loc);

make_distclean() removes any downloaded source tarballs and the completed package archive. These files are not removed if they are needed by a script later in the queue; this is mostly relevant for compat32 and some Rust-based scripts.

It has no useful return value.

  merge_queues
  my @merged = @{ merge_queues([@queue1], [@queue2]) };

merge_queues() takes two array references and merges them such that @queue1 is in front, followed by any non-redundant items in @queue2. This is returned as an array reference.

  perform_sbo
  my ($pkg, $src, $exit) = perform_sbo(LOCATION => $location);

perform_sbo() prepares and runs a SlackBuild. It returns the package name, an array with source directories and an exit code if successful. If unsuccessful, the first value is instead an error message.

Network access is blocked with unshare(1) if the "NONET" setting is "TRUE".

  process_sbos
  my (@failures, $exit) = process_sbos(TODO => [@queue]);

process_sbos() processes a @queue of SlackBuilds and returns an array reference with failed builds and the exit status. If there is an argument "GET_ONLY", the array reference contains failed downloads instead of builds.

In case of a mass rebuild, process_sbos() updates the resume file "resume.temp" when a build fails. If the "NICENESS" or "IDLE_BUILD" settings are not "FALSE", they are also handled here with renice(1) and ionice(1), respectively.

  rationalize_queue
  my $queue = rationalize_queue($queue)

rationalize_queue() takes a build queue and rearranges it such that no script appears before any of its dependencies. The order is predictable given the scripts included and favors keeping dependency chains together, especially beyond the first level; this makes output and build orders more intuitive.

Currently, this is only useful when the queue has been constructed with reference to reverse dependencies, or, in the case of sbotest(1), a full repository test or archive rebuild is needed.

sbotest(1) has a separate subroutine that reduces the number of expected package installations and removals during test runs. Intuitiveness is not to be expected in sbotest(1) queues.

The rearranged queue is returned.

  run_tee
  my ($output, $exit) = run_tee($cmd, $log_name);

run_tee() runs $cmd under tee(1) to display STDOUT and return it as a string. The second return value is the exit status. If "LOG_DIR" is set, STDOUT and STDERR are saved to a timestamped log file named $log_name. Otherwise, STDOUT only is saved to the temporary directory.

If the bash interpreter cannot be run, the first return value is "undef" and the exit status holds a non-zero value.

  write_resume($todo, $opts, $cmds, $mtemp_resume, @builds);

write_resume() takes $todo, $opts, $cmds and $mtemp_resume from perform_sbos() and a list of builds to ignore. This should generally include failed and succeeded builds. It writes all non-ignored builds into a new resume file using JSON::PP(3). There is no useful return value.

EXIT CODES
Build.pm subroutines can return the following exit codes:

  _ERR_SCRIPT        2   script or module bug
  _ERR_BUILD         3   errors when executing a SlackBuild
  _ERR_OPENFH        6   failure to open file handles
  _ERR_NOMULTILIB    9   lacking multilib capabilities when needed
  _ERR_CONVERTPKG    10  convertpkg-compat32 failure
  _ERR_NOCONVERTPKG  11  lacking convertpkg-compat32 when needed
  _ERR_INST_SIGNAL   12  the script was interrupted while building
  _ERR_CIRCULAR      13  attempted to calculate a circular dependency
  _ERR_STDIN         16  reading keyboard input failed

SEE ALSO
SBO::Lib(3), SBO::Lib::Download(3), SBO::Lib::Info(3), SBO::Lib::Pkgs(3), SBO::Lib::Readme(3), SBO::Lib::Repo(3), SBO::Lib::Solibs(3), SBO::Lib::Tree(3), SBO::Lib::Util(3), ionice(1), JSON::PP(3), renice(1), unshare(1)

AUTHORS
SBO::Lib was originally written by Jacob Pipkin <jacob.pipkin@icloud.com> with contributions from Luke Williams <xocel@iquidus.org> and Andreas Guldstrand <andreas.guldstrand@gmail.com>.

MAINTAINER
SBO::Lib is maintained by K. Eugene Carlson <kvngncrlsn@gmail.com>.

LICENSE
The sbotools are licensed under the MIT License.

Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.

Copyright (C) 2024-2026, K. Eugene Carlson.

Copyright (C) 2026, K. Eugene Carlson, Jacob Pipkin.