Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple packages on a single Aptfile line #124

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
7 changes: 6 additions & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ while IFS= read -r PACKAGE; do
curl --silent --show-error --fail -L -z "$PACKAGE_FILE" -o "$PACKAGE_FILE" "$PACKAGE" 2>&1 | indent
else
topic "Fetching .debs for $PACKAGE"
apt-get "${APT_OPTIONS[@]}" -y "${APT_FORCE_YES[@]}" -d install --reinstall "$PACKAGE" | indent
# while this is not documented behavior, the Aptfile format technically
# did allow for multiple packages separated by spaces to be specified
# on a single line due to how the download command was implemented so we
# should respect that behavior since users are doing this
IFS=$' \t' read -ra PACKAGE_NAMES <<< "$PACKAGE"
apt-get "${APT_OPTIONS[@]}" -y "${APT_FORCE_YES[@]}" -d install --reinstall "${PACKAGE_NAMES[@]}" | indent
fi
done < <(grep --invert-match -e "^#" -e "^\s*$" -e "^:repo:" "${BUILD_DIR}/Aptfile")

Expand Down
3 changes: 0 additions & 3 deletions bin/report
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ while IFS= read -r line; do
elif [[ $line == *deb ]]; then
custom_packages+=("${line}")
else
# while this is not documented behavior, the Aptfile format technically
# does allow for multiple packages separated by spaces to be specified
# on a single line due to how the download command is implemented
IFS=$' \t' read -ra package_names <<< "${line}"
for package_name in "${package_names[@]}"; do
packages+=("${package_name}")
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/package-names/Aptfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ xmlsec1

# globbed package
mysql-client-*

# multiple packages on single line
s3cmd wget
5 changes: 4 additions & 1 deletion test/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ testCompilePackageNames() {
compile "package-names"
assertCaptured "Updating apt caches"
assertCaptured "Fetching .debs for xmlsec1"
assertCaptured "Fetching .debs for s3cmd wget"
assertCaptured "Fetching .debs for mysql-client-*"
assertCaptured "Installing xmlsec1"
assertCaptured "Installing s3cmd"
assertCaptured "Installing wget"
assertCaptured "Installing mysql-client"
assertCaptured "Installing mysql-client-core"
assertCaptured "Writing profile script"
Expand All @@ -15,7 +18,7 @@ testCompilePackageNames() {

testReportPackageNames() {
report "package-names"
assertCaptured "packages: \"mysql-client-*,xmlsec1\""
assertCaptured "packages: \"mysql-client-*,s3cmd,wget,xmlsec1\""
assertNotCaptured "custom_packages"
assertNotCaptured "custom_repositories"
assertCapturedSuccess
Expand Down