Skip to content

Commit

Permalink
assemble: add support for remote manifest files
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Jun 28, 2024
1 parent fcc2972 commit 860ead8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 16 additions & 4 deletions distrobox-assemble
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ root_flag=""
# tmpfile will be used as a little buffer to pass variables without messing up
# quoting and escaping
tmpfile="$(mktemp -u)"
tmp_download_file="$(mktemp -u)"
verbose=0
version="1.7.2.1"
# initializing block of variables used in the manifest
Expand Down Expand Up @@ -63,7 +64,7 @@ exported_bins=""
exported_bins_path="${HOME}/.local/bin"

# Cleanup tmpfiles on exit
trap 'rm -f ${tmpfile}' EXIT
trap 'rm -f ${tmpfile} ${tmp_download_file}' EXIT

# Despite of running this script via SUDO/DOAS being not supported (the
# script itself will call the appropriate tool when necessary), we still want
Expand Down Expand Up @@ -133,7 +134,7 @@ Usage:
Options:
--file: path to the distrobox manifest/ini file
--file: path or URL to the distrobox manifest/ini file
--name/-n: run against a single entry in the manifest/ini file
--replace/-R: replace already existing distroboxes with matching names
--dry-run/-d: only print the container manager command generated
Expand Down Expand Up @@ -233,8 +234,19 @@ fi

# Check if file effectively exists
if [ ! -e "${input_file}" ]; then
printf >&2 "File %s does not exist.\n" "${input_file}"
exit 1

if command -v curl > /dev/null 2>&1; then
download="curl --connect-timeout 3 --retry 1 -sLo"
elif command -v wget > /dev/null 2>&1; then
download="wget --timeout=3 --tries=1 -qO"
fi

if ! ${download} - "${input_file}" > "${tmp_download_file}"; then
printf >&2 "File %s does not exist.\n" "${input_file}"
exit 1
else
input_file="${tmp_download_file}"
fi
fi

# run_distrobox will create distrobox with parameters parsed from ini file.
Expand Down
6 changes: 5 additions & 1 deletion docs/usage/distrobox-assemble.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The manifest file by default is `./distrobox.ini`, but can be specified using th

**distrobox assemble**

--file: path to the distrobox manifest/ini file
--file: path or URL to the distrobox manifest/ini file
--name/-n: run against a single entry in the manifest/ini file
--replace/-R: replace already existing distroboxes with matching names
--dry-run/-d: only print the container manager command generated
Expand Down Expand Up @@ -63,6 +63,10 @@ You can specify a custom path for the file using

distrobox assemble create --file /my/custom/path.ini

Or even specify a remote file, by using an URL:

distrobox-assemble create --file https://raw.githubusercontent.com/89luca89/dotfiles/master/distrobox.ini

**Replace**

By default, `distrobox assemble` will replace a container only if `replace=true`
Expand Down

0 comments on commit 860ead8

Please sign in to comment.