Last active
March 31, 2025 02:53
-
-
Save plowsof/f50824d0c77a1c3aeb20f03d6ecc21f6 to your computer and use it in GitHub Desktop.
to be ran in a docker container - get the list of debs a list of packages installs for monero-gui Dockerfile.linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate the tuple containing required debs '"download path" "filename" "md5sum"' | |
parse_apt_uris() { | |
local packagelist=$2 | |
local formatted_strings=() | |
local tuple_name=$1 | |
# Multi line comment https://stackoverflow.com/a/43158193 | |
#: ' | |
apt-get update >/dev/null 2>&1 | |
# due to scoping issues with pipes we have to process captured_output outside of the wihle loop | |
# for some reason --no-install-recommends breaks when we build the git repos | |
captured_output=$(apt-get install --print-uris --yes --no-install-recommends \ | |
$packagelist | grep \'http | while read -r line; do | |
#' | |
#line="'http://archive.ubuntu.com/ubuntu/pool/main/m/mesa/filaneme.deb' filaname.deb size MD5Sum:hash" | |
stringarray=($line) # https://stackoverflow.com/a/13402368 | |
url=${stringarray[0]:1:-1} # remove single quotes via substring https://stackoverflow.com/a/428580 | |
# Strip the domain and depth further into the slashes (adjustable) to for mirror file path | |
# Split using https://stackoverflow.com/a/5257398 then paramater expansion magic | |
url_split=(${url//\// }) | |
depth=3 | |
rebuilt_url=$(printf "%s/" "${url_split[@]:$depth}"); rebuilt_url="${rebuilt_url:0:-1}" # remove trailing slash | |
# todo filename isnt the tail uri, use actual OS filename arg2 | |
#filename="${url##*/}" #https://stackoverflow.com/a/39823597 | |
filename=${stringarray[1]} | |
size=${stringarray[2]} | |
md5=${stringarray[3]} | |
parsed_md5=${md5#*:} # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html | |
#"pool/.../-1.5_amd64.deb" "libatm1_2.5.1-1.5_amd64.deb" "660841797374d33e8cafd0f541bea7cf" | |
# we will split later using "::" | |
printf '"%s" "%s" "%s"::' $rebuilt_url $filename $parsed_md5 | |
# append formatted string to a list for printing later | |
done) | |
#formatted_strings_list=(${formatted_strings//::/ }) | |
IFS='::' read -ra formatted_strings_list <<< "$captured_output" | |
echo "$tuple_name=(" | |
for item in "${formatted_strings_list[@]}"; do | |
# don't echo empty items | |
[[ -n "$item" ]] && echo " $item" | |
done | |
echo ")" | |
} | |
#parse_apt_uris "debs_downloader_linux" "automake autopoint bison gettext git gperf libgl1-mesa-dev libglib2.0-dev libpng-dev libpthread-stubs0-dev libsodium-dev libtool-bin libudev-dev libusb-1.0-0-dev mesa-common-dev pkg-config python wget xutils-dev" | |
parse_apt_uris "debs_gitcloner" "git ca-certificates" | |
#parse_apt_uris "debs_downloader_windows" "build-essential cmake g++-mingw-w64 gettext git libtool pkg-config python" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment