Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
- name: "Check if packages were installed"
shell: bash
run: |
$GAP -A -q <<GAPInput
$GAP --bare -q <<GAPInput
chck := function( pkg, ver )
local test;
test := TestPackageAvailability( pkg, ver );
Print(test,"\n");
Print( "Package ", pkg, " ", ver, ": ", test, "\n" );
return test <> fail;
end;;
bool := [
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ notable changes. Packages will **not** be built, this has to be done by a subseq
The following input is mandatory:

- `packages`:
- Space-separated or newline-separated list of packages to install. Packages are either
given as `package`, as `package@version`, or by an URL pointing to a release archive.
Here, `package` can either be the name of a package in the GAP package distribution or
the name of a GitHub repository (of the form "org/repo"). The optional suffix `version`
is either `latest`, `devel`, or a version number.
- Space-separated or newline-separated list of packages to install. Packages are given by
one of three formats:
- `packagename`: the name of a package in the [GAP package distribution](https://github.com/gap-system/PackageDistro).
- `user/repo`: the name of a GitHub repository containing the package.
- `https://url.to/archive.tar.gz`: an URL leading to a `.tar.gz`, `.tar.bz` or `.zip`
archive.

The first two formats can be followed by a suffix `@version`, where `version` is either
`latest`, `devel`, or a version number. If no version is given, this defaults to `latest`.

- default: `''`

### Examples
Expand Down
26 changes: 20 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ runs:
echo "::group::Installing ${pkg}"

version="latest"
repo=""
distro_ver=""

# Split off version, if present
if [[ "${pkg}" == *@* ]]; then
Expand All @@ -57,32 +59,44 @@ runs:

if [[ "${pkg}" =~ ^https?://.*\.(tar\.gz|tar\.bz2|zip)$ ]]; then
echo "Input is an archive"

download_and_extract "${pkg}" "${pkgdir}"
else
# Set the $repo variable
use_repo=true
if [[ "${pkg}" =~ .*/.* ]]; then
echo "Input is a package repository"
repo="${pkg}"
else
echo "Input is a package name"
get_repo_from_name "${name}"
get_pkg_info_from_name "${name}"
echo "Package distribution contains version ${distro_ver}"
# If the desired version is the one available in the package distribution,
# we use the info there instead of going to the package repository
if [[ "${version}" = "latest" ]] || [[ "${version}" = "${distro_ver}" ]]; then
echo "Using package distribution"
version="${distro_ver}"
use_repo=false
else
echo "Using repository ${repo}"
fi
fi

if [[ "${version}" = "devel" ]]; then
echo "Cloning development branch of ${repo} to ${pkgdir}"
clear_dest "${pkgdir}"
git clone -q --depth=1 --single-branch "https://github.com/${repo}.git" "${pkgdir}"
else
# Set the $archive_url variable and update the $version variable
get_archive_url "${repo}" "${version}"
# Update the $archive_url and $version variables
if [[ ${use_repo} = true ]]; then
echo "Getting archive url from repository"
get_archive_url "${repo}" "${version}"
fi

# Check if package version is already available
if check_pkg_availability "${name}" "${version}"; then
echo "Package ${name} ${version} is already available, skipping."
continue
fi

download_and_extract "${archive_url}" "${pkgdir}"
fi
fi
Expand Down
19 changes: 13 additions & 6 deletions install-pkg-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ get_package_distro() {
}

# Get repository name from package name using PackageDistro
get_repo_from_name() {
get_pkg_info_from_name() {
local name="$1"

# Create the required file at $PKG_DISTRO
Expand All @@ -135,13 +135,20 @@ get_repo_from_name() {
exit 1
fi

# Don't try to get URL from PackageDistro - latest version not be merged yet!
local repo_url
repo_url=$(echo "${pkg}" | jq -r '.SourceRepository.URL') || {
echo "::error::Package ${name} not found in PackageDistro"
exit 1
}
repo_url=$(echo "${pkg}" | jq -r '.SourceRepository.URL')
repo=${repo_url#https://github.com/}

local formats
formats=$(echo "${pkg}" | jq -r '.ArchiveFormats')
formats=$(echo "${formats}" | tr ' ' '\n')

local archive_base
archive_base=$(echo "${pkg}" | jq -r '.ArchiveURL')

combine_url "${archive_base}" "${formats}"

distro_ver=$(echo "${pkg}" | jq -r '.Version')
}

# Use GAP to check if package-version combination is already installed
Expand Down
Loading