NAME

App::instopt - Download and install software

VERSION

This document describes version 0.012 of App::instopt (from Perl distribution App-instopt), released on 2019-10-09.

SYNOPSIS

See instopt script.

FUNCTIONS

cleanup_download_dir

Usage:

 cleanup_download_dir(%args) -> [status, msg, payload, meta]

Remove older versions of downloaded software.

This function is not exported.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Special arguments:

  • -dry_run => bool

    Pass -dry_run=>1 to enable simulation mode.

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

cleanup_install_dir

Usage:

 cleanup_install_dir(%args) -> [status, msg, payload, meta]

Remove inactive versions of installed software.

This function is not exported.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Special arguments:

  • -dry_run => bool

    Pass -dry_run=>1 to enable simulation mode.

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

compare_versions

Usage:

 compare_versions(%args) -> [status, msg, payload, meta]

Compare installed vs downloaded vs latest versions of installed software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

download

Usage:

 download(%args) -> [status, msg, payload, meta]

Download latest version of one or more software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • arch => software::arch

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

  • softwares_or_patterns* => array[str]

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

download_all

Usage:

 download_all(%args) -> [status, msg, payload, meta]

Download latest version of all known software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • arch => software::arch

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

list_downloaded

Usage:

 list_downloaded(%args) -> [status, msg, payload, meta]

List all downloaded software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • detail => bool

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

list_downloaded_versions

Usage:

 list_downloaded_versions(%args) -> [status, msg, payload, meta]

List all downloaded versions of a software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • arch => software::arch

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

  • software* => str

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

list_installed

Usage:

 list_installed(%args) -> [status, msg, payload, meta]

List all installed software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • detail => true

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

list_installed_versions

Usage:

 list_installed_versions(%args) -> [status, msg, payload, meta]

List all installed versions of a software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • download_dir => dirname

  • install_dir => dirname

  • program_dir => dirname

  • software* => str

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

update

Usage:

 update(%args) -> [status, msg, payload, meta]

Update a software to the latest version.

This function is not exported.

Arguments ('*' denotes required arguments):

  • download => bool (default: 1)

    Whether to download latest version from URLor just find from download dir.

  • download_dir => dirname

  • install_dir => dirname

  • make_latest_dir_as_symlink => bool (default: 1)

    Whether to use symlink to create the latest version directory.

    The default is to use symlink. This will create a symlink to the latest version directory, e.g.:

     firefox -> firefox-69.0.2

    Then the program will be symlinked from this directory, e.g.:

     /usr/local/bin/firefox -> /opt/firefox/firefox

    Another alternative (when this option is set to false) is to use hardlink. A directory (firefox) will be copied from the latest version directory (e.g. firefox-69.0.2). Then a file (firefox/instopt.version) will be written to contain the version number (69.0.2). Then, as usual, the program will be symlinked from this directory, e.g.:

     /usr/local/bin/firefox -> /opt/firefox/firefox

    Currently hardlinking is performed using the cp command (with the option -la), so you need to have this on your system (normally present on all Unix systems).

  • program_dir => dirname

  • softwares_or_patterns* => array[str]

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

update_all

Usage:

 update_all(%args) -> [status, msg, payload, meta]

Update all installed software.

This function is not exported.

Arguments ('*' denotes required arguments):

  • download => bool (default: 1)

    Whether to download latest version from URLor just find from download dir.

  • download_dir => dirname

  • install_dir => dirname

  • make_latest_dir_as_symlink => bool (default: 1)

    Whether to use symlink to create the latest version directory.

    The default is to use symlink. This will create a symlink to the latest version directory, e.g.:

     firefox -> firefox-69.0.2

    Then the program will be symlinked from this directory, e.g.:

     /usr/local/bin/firefox -> /opt/firefox/firefox

    Another alternative (when this option is set to false) is to use hardlink. A directory (firefox) will be copied from the latest version directory (e.g. firefox-69.0.2). Then a file (firefox/instopt.version) will be written to contain the version number (69.0.2). Then, as usual, the program will be symlinked from this directory, e.g.:

     /usr/local/bin/firefox -> /opt/firefox/firefox

    Currently hardlinking is performed using the cp command (with the option -la), so you need to have this on your system (normally present on all Unix systems).

  • program_dir => dirname

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-instopt.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-instopt.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-instopt

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019, 2018 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.