SBO::Lib::Download(3)

NAME
SBO::Lib::Download - Routines for downloading SlackBuild sources.

SYNOPSIS
  use SBO::Lib::Download qw/ check_distfiles /;

  my ($ret, $exit) = check_distfiles(LOCATION => $loc, NO_DL => $no_dl);

SUBROUTINES

  check_distfiles
  my ($ret, $exit) = check_distfiles(LOCATION => $loc, NO_DL => $no_dl);

check_distfiles() gets the list of downloads from $loc. Any previously-downloaded files have their checksums verified. Unless there is a "NO_DL" argument, missing and unverifiable files are downloaded to md5sum-designated directories and verified. Finally, prepare_staging() is run on the downloads.

In case of success, a hash of source files and destinations from prepare_staging() is returned. The subroutine returns empty if the SlackBuild did not contain any downloads. In case of failure, an error message and an exit code are returned.

If there is an argument "NO_DL", 1 is returned if all sources are verified and 0 otherwise.

  check_manual
  my $manual_file = check_manual($filename, $info_md5);

check_manual() checks for a file $filename with md5sum $info_md5 in "SBO_HOME/distfiles/manual". It returns the path to this file if it exists and 0 otherwise.

  compute_md5sum
  my $md5sum = compute_md5sum($file);

compute_md5sum() computes and returns the md5sum of the file in $file.

  get_distfile
  my ($msg, $err) = get_distfile($link, $md5);

get_distfile() downloads from the URL $link with wget(1) and compares the md5sum to $md5. The file is saved in an md5sum-designated directory. The subroutine returns a message and an error code upon failure, and 1 upon success.

  get_filename_from_link
  my $path = get_filename_from_link($link, $md5);

get_filename_from_link() returns the full path to the file downloaded from $link, given its required md5sum, $md5.

  get_sbo_downloads
  my %downloads = %{ get_sbo_downloads(LOCATION => $loc) };

get_sbo_downloads() gets the download links and md5sums for the SlackBuild in location $loc, returning them in a hash reference.

  get_hardlink_from_filename
  my $destination = get_hardlink_from_filename($path, $staging);

get_hardlink_from_filename(), given a source file at $path and a location $staging, returns the destination path for linking the file.

  prepare_staging
  my $destinations = prepare_staging({%downloads});

prepare_staging() prepares a hash of files and their proper names based on %downloads for use during the build in a staging directory.

  stage
  stage($location, $distfiles);
  stage($location, "NO_DISTFILES");

stage() takes a location and a hash of distfiles to create the staging directory for a build; the SlackBuild directory is copied over and hardlinks to the required source files are created. It returns the location of the staging directory if it can be created and 0 otherwise.

If the second argument is the string "NO_DISTFILES" (appropriate for no-download builds and failed downloads), only copy the SlackBuild directory.

The script exits if the "distfiles" directory is malformed or the source file or directory is a symlink.

  unstage
  my $res = unstage();

unstage() is a shorthand subroutine for the removal of the staging directory when building is complete or upon signal. It has no useful return value.

  verify_distfile
  my $bool = verify_distfile($link, $md5);

verify_distfile() verifies that the file downloaded from $link has an md5sum equal to $md5.

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

  _ERR_SCRIPT        2   script or module bug
  _ERR_MD5SUM        4   download verification failure
  _ERR_DOWNLOAD      5   download failure
  _ERR_OPENFH        6   failure to open file handles
  _ERR_NOINFO        7   missing download information
  _ERR_SBO_HOME      17  could not give SBO_HOME valid contents

SEE ALSO
SBO::Lib(3), SBO::Lib::Build(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), wget(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.