Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Azathothas committed Jan 5, 2025
1 parent b0865d5 commit 3c113ef
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions scripts/runner/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setup_env()
{
##Version
SBF_VERSION="1.5.0" && echo -e "[+] SBUILD Functions Version: ${SBF_VERSION}" ; unset SBF_VERSION
SBF_VERSION="1.5.1" && echo -e "[+] SBUILD Functions Version: ${SBF_VERSION}" ; unset SBF_VERSION
##Input
INPUT_SBUILD="${1:-$(echo "$@" | tr -d '[:space:]')}"
INPUT_SBUILD_PATH="$(realpath ${INPUT_SBUILD})" ; export INPUT_SBUILD="${INPUT_SBUILD_PATH}"
Expand Down Expand Up @@ -402,18 +402,13 @@ if [[ "${SBUILD_SUCCESSFUL}" == "YES" ]]; then
unset PROG ; for PROG in "${SBUILD_PKGS[@]}"; do
if [[ -s "${SBUILD_OUTDIR}/${PROG}" && $(stat -c%s "${SBUILD_OUTDIR}/${PROG}") -gt 10 ]]; then
export PROG SBUILD_PKGVER
if [ -n "${GHCRPKG+x}" ] && [ -n "${GHCRPKG##*[[:space:]]}" ]; then
DOWNLOAD_URL="$(echo "${GHCRPKG}/${PROG}" | sed 's|^ghcr.io|https://api.ghcr.pkgforge.dev|' | sed ':a; s/\/\//\//g; ta')?tag=${SBUILD_PKGVER}-${HOST_TRIPLET,,}&download=${PROG}"
BUILD_LOG="$(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/download='"${PROG}"'.log/')"
elif [ -n "${GHCRPKG_URL+x}" ] && [ -n "${GHCRPKG_URL##*[[:space:]]}" ]; then
DOWNLOAD_URL="$(echo "${GHCRPKG_URL}" | sed 's|^ghcr.io|https://api.ghcr.pkgforge.dev|' | sed ':a; s/\/\//\//g; ta')?tag=${SBUILD_PKGVER}-${HOST_TRIPLET,,}&download=${PROG}"
BUILD_LOG="$(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/download='"${PROG}"'.log/')"
fi
export BUILD_LOG DOWNLOAD_URL
#Initial ENV
GHCR_PKG="$(realpath ${SBUILD_OUTDIR}/${PROG})"
PKG_DATE="$(date --utc +%Y-%m-%dT%H:%M:%S)Z"
PKG_DESCRIPTION="$(jq -r '(env.PKG_DESCRIPTION // (if type == "object" and has("description") and (.description | type == "object") then (if env.PROG != null and (.description[env.PROG] != null) then .description[env.PROG] else .description["_default"] end) else .description end // ""))' ${TMPJSON})"
PKG_NAME="$(echo "${PROG}" | tr -d '[:space:]')"
PKG_ICON="$(jq -r '.icon' "${TMPJSON}" | tr -d '[:space:]')"
PKG_ID="$(jq -r '.pkg_id' "${TMPJSON}" | tr -d '[:space:]')"
PKG_BSUM="$(b3sum "${GHCR_PKG}" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]')"
PKG_SHASUM="$(sha256sum "${GHCR_PKG}" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]')"
PKG_SIZE_RAW="$(stat --format="%s" "${GHCR_PKG}" | tr -d '[:space:]')"
Expand All @@ -422,6 +417,19 @@ if [[ "${SBUILD_SUCCESSFUL}" == "YES" ]]; then
PKG_WEBPAGE="https://pkgs.pkgforge.dev/repo/${PKG_REPO}/${HOST_TRIPLET,,}/${PKG_FAMILY:-${PROG}}/${PROG}"
SBUILD_PKGVER="$(cat "${SBUILD_OUTDIR}/${SBUILD_PKG}.version" | tr -d '[:space:]')" ; export SBUILD_PKGVER
export GHCR_PKG PROG PKG_BSUM PKG_DATE PKG_ICON PKG_SIZE PKG_SIZE_RAW PKG_SHASUM PKG_WEBPAGE SBUILD_PKGVER
#ghcrpkgurl
unset GHCRPKG_URL SNAPSHOT_JSON SNAPSHOT_TAGS TAG_URL
generate_ghcrpkgurl
echo "export GHCRPKG_URL='${GHCRPKG_URL}'" >> "${OCWD}/ENVPATH"
if [ -n "${GHCRPKG+x}" ] && [ -n "${GHCRPKG##*[[:space:]]}" ]; then
DOWNLOAD_URL="$(echo "${GHCRPKG}/${PROG}" | sed 's|^ghcr.io|https://api.ghcr.pkgforge.dev|' | sed ':a; s/\/\//\//g; ta')?tag=${SBUILD_PKGVER}-${HOST_TRIPLET,,}&download=${PROG}"
BUILD_LOG="$(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/download='"${PROG}"'.log/')"
elif [ -n "${GHCRPKG_URL+x}" ] && [ -n "${GHCRPKG_URL##*[[:space:]]}" ]; then
DOWNLOAD_URL="$(echo "${GHCRPKG_URL}" | sed 's|^ghcr.io|https://api.ghcr.pkgforge.dev|' | sed ':a; s/\/\//\//g; ta')?tag=${SBUILD_PKGVER}-${HOST_TRIPLET,,}&download=${PROG}"
BUILD_LOG="$(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/download='"${PROG}"'.log/')"
fi
export BUILD_LOG DOWNLOAD_URL
#json
echo -e "\n[+] Generating Json for ${SBUILD_PKG} (PROG=${PROG}) ==> ${SBUILD_OUTDIR}/${PROG}.json"
echo -e "[+] ==> $(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/download='"${PROG}"'.json/')"
if [ -n "${SBUILD_SCRIPT+x}" ] && [ -n "${SBUILD_SCRIPT##*[[:space:]]}" ]; then
Expand Down Expand Up @@ -492,9 +500,6 @@ if [[ "${SBUILD_SUCCESSFUL}" == "YES" ]]; then
fi
export BUILD_GHACTIONS BUILD_ID
#Generate Snapshots
unset GHCRPKG_URL SNAPSHOT_JSON SNAPSHOT_TAGS TAG_URL
generate_ghcrpkgurl
echo "export GHCRPKG_URL='${GHCRPKG_URL}'" >> "${OCWD}/ENVPATH"
if [ -n "${GHCRPKG_URL+x}" ] && [ -n "${GHCRPKG_URL##*[[:space:]]}" ]; then
#Generate Manifest
unset PKG_MANIFEST ; PKG_MANIFEST="$(echo "${DOWNLOAD_URL}" | sed 's/download=[^&]*/manifest/')" ; export PKG_MANIFEST
Expand Down

0 comments on commit 3c113ef

Please sign in to comment.