Skip to content

Commit 338a3ba

Browse files
committed
optimize setup
1 parent ff33ae4 commit 338a3ba

File tree

6 files changed

+202
-183
lines changed

6 files changed

+202
-183
lines changed

.github/workflows/matrix_builds.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,13 @@ jobs:
287287
exit 1
288288
fi
289289
#get build system
290-
if yq '.x_exec.bsys' "./SBUILD_INPUT" | grep -v '^#' | grep -qi "docker://"; then
290+
BUILD_SYS="$(yq '.x_exec.bsys' "./SBUILD_INPUT" | grep -v '^#' | tr -d '"'\''[:space:]')"
291+
export BUILD_SYS
292+
echo "BUILD_SYS=${BUILD_SYS}" >> "${GITHUB_ENV}"
293+
if echo "${BUILD_SYS}" | grep -qi "docker://"; then
291294
echo "BUILD_ON_HOST=FALSE" >> "${GITHUB_ENV}"
292295
echo "BUILD_SYSTEM=DOCKER" >> "${GITHUB_ENV}"
293-
elif yq '.x_exec.bsys' "./SBUILD_INPUT" | grep -v '^#' | grep -qi "host://"; then
296+
elif echo "${BUILD_SYS}" | grep -qi "host://"; then
294297
echo "BUILD_ON_HOST=TRUE" >> "${GITHUB_ENV}"
295298
echo "BUILD_SYSTEM=HOST" >> "${GITHUB_ENV}"
296299
fi

scripts/runner/builder.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ sbuild_builder()
313313
fi
314314
fi
315315
#} 2>&1 | ts '[%Y-%m-%dT%Hh%Mm%Ss]➜ ' | tee "${TEMP_LOG}"
316-
} 2>&1 | ts -s '[%H:%M:%S]➜ ' | tee "${TEMP_LOG}"
316+
#} 2>&1 | ts -s '[%H:%M:%S]➜ ' | tee "${TEMP_LOG}"
317+
} 2>&1 | tss --format "[%H:%M:%S.%3f]➜ " --relative --output "${TEMP_LOG}" --force-overwrite
317318
#Common No-Nos
318319
if grep -m1 -Eqi "wrappe.*version.*available.*required" "${TEMP_LOG}" &>/dev/null; then
319320
echo -e "\n[✗] FATAL: Found Potential Outlier in Logs\n"

scripts/runner/functions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ setup_env()
2121
{
2222
##Version
2323
SBF_VERSION="1.7.1" && echo -e "[+] SBUILD Functions Version: ${SBF_VERSION}" ; unset SBF_VERSION
24+
echo -e "[+] HOST: $(uname -a)"
2425
##Input
2526
INPUT_SBUILD="${1:-$(echo "$@" | tr -d '[:space:]')}"
2627
INPUT_SBUILD_PATH="$(realpath ${INPUT_SBUILD})" ; export INPUT_SBUILD="${INPUT_SBUILD_PATH}"

scripts/runner/setup_aarch64-Linux.sh

Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ else
8787
##Install Needed CMDs
8888
bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/main/Linux/install_bins_curl.sh")
8989
##Check Needed CMDs
90-
for DEP_CMD in eget gh glab minisign oras rclone shellcheck soar zstd; do
90+
for DEP_CMD in eget gh glab minisign oras rclone shellcheck soar tss zstd; do
9191
case "$(command -v "${DEP_CMD}" 2>/dev/null)" in
9292
"") echo -e "\n[✗] FATAL: ${DEP_CMD} is NOT INSTALLED\n"
9393
export CONTINUE="NO"
@@ -212,43 +212,45 @@ if [ "${CONTINUE}" == "YES" ]; then
212212
##Langs
213213
#----------------------#
214214
#Docker
215-
install_docker ()
216-
{
217-
#Install
218-
curl -qfsSL "https://get.docker.com" | sed 's/sleep 20//g' | sudo bash
219-
sudo groupadd docker 2>/dev/null ; sudo usermod -aG docker "${USER}" 2>/dev/null
220-
sudo service docker restart 2>/dev/null && sleep 10
221-
sudo service docker status 2>/dev/null
222-
sudo systemctl status "docker.service" --no-pager
223-
#Test
224-
if ! command -v docker &> /dev/null; then
225-
echo -e "\n[-] docker NOT Found\n"
226-
export CONTINUE="NO"
227-
return 1 || exit 1
228-
else
215+
if [[ "${BUILD_SYSTEM}" == "DOCKER" ]]; then
216+
install_docker ()
217+
{
218+
#Install
219+
curl -qfsSL "https://get.docker.com" | sed 's/sleep 20//g' | sudo bash
220+
sudo groupadd docker 2>/dev/null ; sudo usermod -aG docker "${USER}" 2>/dev/null
221+
sudo service docker restart 2>/dev/null && sleep 10
222+
sudo service docker status 2>/dev/null
223+
sudo systemctl status "docker.service" --no-pager
224+
#Test
225+
if ! command -v docker &> /dev/null; then
226+
echo -e "\n[-] docker NOT Found\n"
227+
export CONTINUE="NO"
228+
return 1 || exit 1
229+
else
230+
if ! sudo systemctl is-active --quiet docker; then
231+
sudo service docker restart >/dev/null 2>&1 ; sleep 10
232+
fi
233+
sudo systemctl status "docker.service" --no-pager
234+
docker --version ; sudo docker run hello-world
235+
sudo ldconfig && sudo ldconfig -p
236+
#newgrp 2>/dev/null
237+
fi
238+
}
239+
export -f install_docker
240+
if command -v docker &> /dev/null; then
241+
if [ "$(curl -qfsSL "https://endoflife.date/api/docker-engine.json" | jq -r '.[0].latest')" != "$(docker --version | grep -oP '(?<=version )(\d+\.\d+\.\d+)')" ]; then
242+
install_docker
243+
else
244+
echo -e "\n[+] Latest Docker seems to be already Installed"
245+
docker --version
229246
if ! sudo systemctl is-active --quiet docker; then
230247
sudo service docker restart >/dev/null 2>&1 ; sleep 10
231248
fi
232249
sudo systemctl status "docker.service" --no-pager
233-
docker --version ; sudo docker run hello-world
234-
sudo ldconfig && sudo ldconfig -p
235-
#newgrp 2>/dev/null
236-
fi
237-
}
238-
export -f install_docker
239-
if command -v docker &> /dev/null; then
240-
if [ "$(curl -qfsSL "https://endoflife.date/api/docker-engine.json" | jq -r '.[0].latest')" != "$(docker --version | grep -oP '(?<=version )(\d+\.\d+\.\d+)')" ]; then
241-
install_docker
242-
else
243-
echo -e "\n[+] Latest Docker seems to be already Installed"
244-
docker --version
245-
if ! sudo systemctl is-active --quiet docker; then
246-
sudo service docker restart >/dev/null 2>&1 ; sleep 10
250+
fi
251+
else
252+
install_docker
247253
fi
248-
sudo systemctl status "docker.service" --no-pager
249-
fi
250-
else
251-
install_docker
252254
fi
253255
#----------------------#
254256
##Crystal
@@ -315,37 +317,39 @@ if [ "${CONTINUE}" == "YES" ]; then
315317
sudo ldconfig && sudo ldconfig -p
316318
#----------------------#
317319
##Nix
318-
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
319-
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
320-
hash -r &>/dev/null
321-
if ! command -v nix >/dev/null 2>&1; then
322-
pushd "$(mktemp -d)" &>/dev/null
323-
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_nix.sh" -o "./install_nix.sh"
324-
dos2unix --quiet "./install_nix.sh" ; chmod +x "./install_nix.sh"
325-
bash "./install_nix.sh"
326-
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
327-
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
328-
[[ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]] && source "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
329-
rm -rf "./install_nix.sh" 2>/dev/null ; popd &>/dev/null
320+
if [[ "${BUILD_SYS}" == "host://nix" ]]; then
321+
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
322+
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
323+
hash -r &>/dev/null
324+
if ! command -v nix >/dev/null 2>&1; then
325+
pushd "$(mktemp -d)" &>/dev/null
326+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_nix.sh" -o "./install_nix.sh"
327+
dos2unix --quiet "./install_nix.sh" ; chmod +x "./install_nix.sh"
328+
bash "./install_nix.sh"
329+
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
330+
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
331+
[[ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]] && source "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
332+
rm -rf "./install_nix.sh" 2>/dev/null ; popd &>/dev/null
333+
fi
334+
#Test
335+
if ! command -v nix &> /dev/null; then
336+
echo -e "\n[-] nix NOT Found\n"
337+
export CONTINUE="NO"
338+
return 1 || exit 1
339+
else
340+
#Add Env vars
341+
export NIXPKGS_ALLOW_BROKEN="1"
342+
export NIXPKGS_ALLOW_INSECURE="1"
343+
export NIXPKGS_ALLOW_UNFREE="1"
344+
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1"
345+
#Add Tokens
346+
echo "access-tokens = github.com=${GITHUB_TOKEN}" | sudo tee -a "/etc/nix/nix.conf" >/dev/null 2>&1
347+
#Update Channels
348+
nix --version && nix-channel --list && nix-channel --update
349+
#Seed Local Data
350+
nix derivation show "nixpkgs#hello" --impure --refresh --quiet >/dev/null 2>&1
351+
fi
330352
fi
331-
#Test
332-
if ! command -v nix &> /dev/null; then
333-
echo -e "\n[-] nix NOT Found\n"
334-
export CONTINUE="NO"
335-
return 1 || exit 1
336-
else
337-
#Add Env vars
338-
export NIXPKGS_ALLOW_BROKEN="1"
339-
export NIXPKGS_ALLOW_INSECURE="1"
340-
export NIXPKGS_ALLOW_UNFREE="1"
341-
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1"
342-
#Add Tokens
343-
echo "access-tokens = github.com=${GITHUB_TOKEN}" | sudo tee -a "/etc/nix/nix.conf" >/dev/null 2>&1
344-
#Update Channels
345-
nix --version && nix-channel --list && nix-channel --update
346-
#Seed Local Data
347-
nix derivation show "nixpkgs#hello" --impure --refresh --quiet >/dev/null 2>&1
348-
fi
349353
#----------------------#
350354
#rust & cargo
351355
bash <(curl -qfsSL "https://sh.rustup.rs") --no-modify-path -y

scripts/runner/setup_riscv64-Linux.sh

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ else
8989
sudo curl -qfsSL "https://github.com/pkgforge/bin/releases/download/riscv64-Linux/trufflehog" -o "/usr/local/bin/trufflehog"
9090
sudo chmod +x "/usr/local/bin/trufflehog"
9191
##Check Needed CMDs
92-
for DEP_CMD in eget gh glab minisign oras rclone shellcheck soar zstd; do
92+
for DEP_CMD in eget gh glab minisign oras rclone shellcheck soar tss zstd; do
9393
case "$(command -v "${DEP_CMD}" 2>/dev/null)" in
9494
"") echo -e "\n[✗] FATAL: ${DEP_CMD} is NOT INSTALLED\n"
9595
export CONTINUE="NO"
@@ -164,65 +164,71 @@ pushd "$(mktemp -d)" &>/dev/null
164164
echo -e "[+] PATH = ${PATH}\n"
165165
#----------------------#
166166
#Docker
167-
if [[ "${INSIDE_PODMAN}" != "TRUE" ]]; then
168-
#Doesn't work inside podman
169-
if ! command -v docker &> /dev/null; then
170-
sudo apt install "docker.io" -y
171-
else
172-
docker --version
173-
fi
174-
#Test
175-
if ! command -v docker &> /dev/null; then
176-
echo -e "\n[-] docker NOT Found\n"
177-
export CONTINUE="NO"
178-
return 1 || exit 1
179-
else
180-
sudo systemctl status "docker.service" --no-pager
181-
if ! sudo systemctl is-active --quiet docker; then
182-
sudo service docker restart &>/dev/null ; sleep 10
167+
if [[ "${BUILD_SYSTEM}" == "DOCKER" ]]; then
168+
if [[ "${INSIDE_PODMAN}" != "TRUE" ]]; then
169+
#Doesn't work inside podman
170+
if ! command -v docker &> /dev/null; then
171+
sudo apt install "docker.io" -y
172+
else
173+
docker --version
183174
fi
184-
sudo systemctl status "docker.service" --no-pager
185-
fi
186-
if ! command -v podman &> /dev/null; then
187-
sudo apt install podman -y
175+
#Test
176+
if ! command -v docker &> /dev/null; then
177+
echo -e "\n[-] docker NOT Found\n"
178+
export CONTINUE="NO"
179+
return 1 || exit 1
180+
else
181+
sudo groupadd docker 2>/dev/null ; sudo usermod -aG docker "${USER}" 2>/dev/null
182+
sudo service docker restart 2>/dev/null && sleep 10
183+
sudo service docker status 2>/dev/null
184+
if ! sudo systemctl is-active --quiet docker; then
185+
sudo service docker restart &>/dev/null ; sleep 10
186+
fi
187+
sudo systemctl status "docker.service" --no-pager
188+
fi
189+
if ! command -v podman &> /dev/null; then
190+
sudo apt install podman -y
191+
fi
192+
sudo apt install aardvark-dns iproute2 jq iptables netavark -y
193+
sudo mkdir -p "/etc/containers"
194+
echo "[engine]" | sudo tee -a "/etc/containers/containers.conf"
195+
echo "lock_type = \"file\"" | sudo tee -a "/etc/containers/containers.conf"
188196
fi
189-
sudo apt install aardvark-dns iproute2 jq iptables netavark -y
190-
sudo mkdir -p "/etc/containers"
191-
echo "[engine]" | sudo tee -a "/etc/containers/containers.conf"
192-
echo "lock_type = \"file\"" | sudo tee -a "/etc/containers/containers.conf"
193197
fi
194198
#----------------------#
195199
##Nix
196-
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
197-
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
198-
hash -r &>/dev/null
199-
if ! command -v nix >/dev/null 2>&1; then
200-
pushd "$(mktemp -d)" &>/dev/null
201-
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_nix.sh" -o "./install_nix.sh"
202-
dos2unix --quiet "./install_nix.sh" ; chmod +x "./install_nix.sh"
203-
bash "./install_nix.sh"
204-
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
205-
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
206-
rm -rf "./install_nix.sh" 2>/dev/null ; popd &>/dev/null
200+
if [[ "${BUILD_SYS}" == "host://nix" ]]; then
201+
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
202+
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
203+
hash -r &>/dev/null
204+
if ! command -v nix >/dev/null 2>&1; then
205+
pushd "$(mktemp -d)" &>/dev/null
206+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_nix.sh" -o "./install_nix.sh"
207+
dos2unix --quiet "./install_nix.sh" ; chmod +x "./install_nix.sh"
208+
bash "./install_nix.sh"
209+
[[ -f "${HOME}/.bash_profile" ]] && source "${HOME}/.bash_profile"
210+
[[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] && source "${HOME}/.nix-profile/etc/profile.d/nix.sh"
211+
rm -rf "./install_nix.sh" 2>/dev/null ; popd &>/dev/null
212+
fi
213+
#Test
214+
if ! command -v nix &> /dev/null; then
215+
echo -e "\n[-] nix NOT Found\n"
216+
export CONTINUE="NO"
217+
return 1 || exit 1
218+
else
219+
#Add Env vars
220+
export NIXPKGS_ALLOW_BROKEN="1"
221+
export NIXPKGS_ALLOW_INSECURE="1"
222+
export NIXPKGS_ALLOW_UNFREE="1"
223+
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1"
224+
#Add Tokens
225+
echo "access-tokens = github.com=${GITHUB_TOKEN}" | sudo tee -a "/etc/nix/nix.conf" >/dev/null 2>&1
226+
#Update Channels
227+
nix --version && nix-channel --list && nix-channel --update
228+
#Seed Local Data
229+
nix derivation show "nixpkgs#hello" --impure --refresh --quiet >/dev/null 2>&1
230+
fi
207231
fi
208-
#Test
209-
if ! command -v nix &> /dev/null; then
210-
echo -e "\n[-] nix NOT Found\n"
211-
export CONTINUE="NO"
212-
return 1 || exit 1
213-
else
214-
#Add Env vars
215-
export NIXPKGS_ALLOW_BROKEN="1"
216-
export NIXPKGS_ALLOW_INSECURE="1"
217-
export NIXPKGS_ALLOW_UNFREE="1"
218-
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1"
219-
#Add Tokens
220-
echo "access-tokens = github.com=${GITHUB_TOKEN}" | sudo tee -a "/etc/nix/nix.conf" >/dev/null 2>&1
221-
#Update Channels
222-
nix --version && nix-channel --list && nix-channel --update
223-
#Seed Local Data
224-
nix derivation show "nixpkgs#hello" --impure --refresh --quiet >/dev/null 2>&1
225-
fi
226232
##Clean
227233
if [ "${CONTINUE}" == "YES" ]; then
228234
echo "INITIALIZED" > "${SYSTMP}/INITIALIZED"

0 commit comments

Comments
 (0)