Skip to content

Commit

Permalink
fix usql
Browse files Browse the repository at this point in the history
  • Loading branch information
Azathothas committed Mar 8, 2025
1 parent 489077e commit 7fecf85
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 4 deletions.
96 changes: 96 additions & 0 deletions binaries/usql/static.glibc.source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/SBUILD ver @v1.0.0
#SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/binaries/usql/static.glibc.source.yaml
_disabled: false

pkg: "usql"
pkg_id: "github.com.xo.usql.source.glibc"
pkg_type: "static"
category:
- "ConsoleOnly"
- "Utility"
description:
_default: "Universal command-line interface for SQL databases"
usql: "Universal command-line interface for SQL databases"
usql.upx: "Upxed (--best) version of the main usql binary"
distro_pkg:
alpine:
- "usql"
archlinux:
aur:
- "usql"
- "usql-bin"
nixpkgs:
- "usql"
homepage:
- "https://github.com/xo/usql"
license:
- id: "MIT"
url: "https://github.com/xo/usql/raw/2be774d5fd7c660d8f7477f647cec585a3b111bb/LICENSE"
maintainer:
- "Azathothas (https://github.com/Azathothas)"
note:
- "[DO NOT RUN] (Meant for pkgforge CI Only)"
- "Built From Source (Latest Git HEAD). Check/Report @ https://github.com/xo/usql"
- "This contains most drivers"
- "Statically Linked on Debian (GLIBC)"
provides:
- "usql"
- "usql.upx"
repology:
- "usql-cli"
src_url:
- "https://github.com/xo/usql"
tag:
- "database"
- "sql"
x_exec:
host:
- "aarch64-Linux"
- "x86_64-Linux"
shell: "bash"
pkgver: |
pushd "$(mktemp -d)" >/dev/null 2>&1 && \
git clone --depth="1" --filter="blob:none" --no-checkout --single-branch --quiet "https://github.com/xo/usql" "./TEMPREPO" >/dev/null 2>&1 && \
git --git-dir="./TEMPREPO/.git" --no-pager log -1 --pretty=format:'HEAD-%h-%cd' --date=format:'%y%m%dT%H%M%S' && \
[ -d "$(realpath .)/TEMPREPO" ] && rm -rf "$(realpath .)" >/dev/null 2>&1 && popd >/dev/null 2>&1
run: |
#Build
mkdir -pv "${SBUILD_TMPDIR}/tmp" && docker run --privileged --net="host" --name "debian-builder-unstable" --pull="always" \
-e "PKG=${PKG}" -e "PKG_ID=${PKG_ID}" -e "PKG_TYPE=${PKG_TYPE}" -e "PKG_VER=${PKG_VER}" \
-e "PKGVER=${PKGVER}" -e "SBUILD_PKG=${SBUILD_PKG}" -e "SBUILD_PKGVER=${SBUILD_PKGVER}" \
--volume "${SBUILD_TMPDIR}/tmp:/tmp:rw" \
"ghcr.io/pkgforge/devscripts/debian-builder-unstable:$(uname -m)" \
bash -l -c '
#Setup ENV
set -x ; mkdir -p "/build-bins" && pushd "$(mktemp -d)" >/dev/null 2>&1
CGO_ENABLED="1"
CGO_CFLAGS="-D_LARGEFILE64_SOURCE -O2 -flto=auto -fPIE -fpie -static -w -pipe"
GOARCH="$(uname -m | sed "s/x86_64/amd64/;s/aarch64/arm64/")"
GOOS="linux"
export CGO_ENABLED CGO_CFLAGS GOARCH GOOS
#Deps
BASE_PKGS=(libiodbc2-dev libsqlite3-dev postgresql-server-dev-all)
apt clean -y -qq
apt update -y -qq
for pkg in "${BASE_PKGS[@]}"; do DEBIAN_FRONTEND="noninteractive" sudo apt install "${pkg}" -y -qq --ignore-missing 2>/dev/null; done
#Build
git clone --filter "blob:none" --quiet "https://github.com/xo/usql" "./TEMPREPO" && cd "./TEMPREPO"
echo -e "\n[+] Target: \"${GOARCH}/${GOOS}\""
echo -e "[+] Flags: CGO_ENABLED=\"${CGO_ENABLED}\" CGO_CFLAGS=\"${CGO_CFLAGS}\"\n"
go mod tidy -v ; go generate 2>/dev/null
go build -x -v -trimpath -buildmode="pie" -ldflags="-s -w -buildid= -linkmode=external -extldflags '\''-s -w -static-pie -Wl,--build-id=none'\''" -tags "most" -o "/build-bins/usql"
#Copy
( askalono --format "json" crawl --follow "$(realpath .)" | jq -r ".. | objects | .path? // empty" | head -n 1 | xargs -I "{}" cp -fv "{}" "/build-bins/LICENSE" ) 2>/dev/null
#Strip
find "/build-bins/" -type f -exec objcopy --remove-section=".comment" --remove-section=".note.*" "{}" \;
find "/build-bins/" -type f ! -name "*.no_strip" -exec strip --strip-debug --strip-dwo --strip-unneeded "{}" \; 2>/dev/null
#Upx
upx --best "/build-bins/usql" -f --force-overwrite -o"/build-bins/usql.upx" -qq
#Info
file "/build-bins/"* && du -sh "/build-bins/"*
popd >/dev/null 2>&1
'
#Copy & Meta
docker cp "debian-builder-unstable:/build-bins/." "${SBUILD_TMPDIR}/"
[ -s "${SBUILD_TMPDIR}/LICENSE" ] && cp -fv "${SBUILD_TMPDIR}/LICENSE" "${SBUILD_OUTDIR}/LICENSE"
find "${SBUILD_TMPDIR}" -maxdepth 1 -type f -exec file -i "{}" \; | grep -Ei "application/.*executable|text/x-perl|text/.*script" | cut -d":" -f1 | xargs realpath | xargs -I "{}" rsync -achvL "{}" "${SBUILD_OUTDIR}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/SBUILD ver @v1.0.0
#SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/binaries/usql/static.official.source.yaml
#SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/binaries/usql/static.musl.source.yaml
_disabled: false

pkg: "usql"
pkg_id: "github.com.xo.usql"
pkg_id: "github.com.xo.usql.source.musl"
pkg_type: "static"
category:
- "ConsoleOnly"
Expand All @@ -28,6 +28,7 @@ maintainer:
note:
- "[DO NOT RUN] (Meant for pkgforge CI Only)"
- "Built From Source (Latest Git HEAD). Check/Report @ https://github.com/xo/usql"
- "This contains all drivers"
provides:
- "usql"
repology:
Expand Down Expand Up @@ -58,16 +59,19 @@ x_exec:
#Setup ENV
set -x ; mkdir -p "/build-bins" && pushd "$(mktemp -d)" >/dev/null 2>&1
CGO_ENABLED="1"
CGO_CFLAGS="-O2 -flto=auto -fPIE -fpie -static -w -pipe"
CGO_CFLAGS="-D_LARGEFILE64_SOURCE -O2 -flto=auto -fPIE -fpie -static -w -pipe"
GOARCH="$(uname -m | sed "s/x86_64/amd64/;s/aarch64/arm64/")"
GOOS="linux"
export CGO_ENABLED CGO_CFLAGS GOARCH GOOS
#Deps
apk update && apk upgrade --no-interactive
apk add unixodbc-static --latest --upgrade --no-interactive
#Build
git clone --filter "blob:none" --quiet "https://github.com/xo/usql" "./TEMPREPO" && cd "./TEMPREPO"
echo -e "\n[+] Target: \"${GOARCH}/${GOOS}\""
echo -e "[+] Flags: CGO_ENABLED=\"${CGO_ENABLED}\" CGO_CFLAGS=\"${CGO_CFLAGS}\"\n"
go mod tidy -v ; go generate
go build -x -v -trimpath -buildmode="pie" -ldflags="-s -w -buildid= -linkmode=external -extldflags '\''-s -w -static-pie -Wl,--build-id=none'\''" -o "/build-bins/usql"
go build -x -v -trimpath -buildmode="pie" -ldflags="-s -w -buildid= -linkmode=external -extldflags '\''-s -w -static-pie -Wl,--build-id=none'\''" -tags "most " -o "/build-bins/usql"
#Copy
( askalono --format "json" crawl --follow "$(realpath .)" | jq -r ".. | objects | .path? // empty" | head -n 1 | xargs -I "{}" cp -fv "{}" "/build-bins/LICENSE" ) 2>/dev/null
#Strip
Expand Down

0 comments on commit 7fecf85

Please sign in to comment.