glacier-ng 4.0.0
This commit is contained in:
commit
0cf4829fa5
159 files changed
+33717
No files matched your search
@@ -0,0 +1,131 @@
|
||||
# build-driver.sh: runs INSIDE gsandbox as /.glacier/in/driver
|
||||
# (BUILD_DESIGN.txt section 6). POSIX sh: the build root may only have
|
||||
# busybox. Everything it reads is under /.glacier/in, written by
|
||||
# gpkg/syspkg:
|
||||
#
|
||||
# env NAME, VER, BUILD, SOURCES, PATCHES, CONFIGURE_ARGS,
|
||||
# TRAITS, JOBS, CFLAGS, CXXFLAGS, LDFLAGS (shell
|
||||
# assignments, every value quoted)
|
||||
# bundle.grcp the recipe bundle (already checked by the library)
|
||||
# sources/FILE each source, hash already checked
|
||||
# manifest.gpm.cfg the package's manifest
|
||||
#
|
||||
# It writes /.glacier/out/NAME-VER.gpkg and nothing else counts. The
|
||||
# package is checked again outside, so nothing here is trusted.
|
||||
|
||||
set -eu
|
||||
. /.glacier/in/env
|
||||
|
||||
say() { printf '==> %s\n' "$*"; }
|
||||
die() { printf '==> ERROR: %s\n' "$*"; exit 1; }
|
||||
|
||||
# trait NAME: whether trait NAME is on (for build hooks).
|
||||
trait() {
|
||||
for t in $TRAITS; do
|
||||
[ "$t" = "$1" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
B=/build
|
||||
R=$B/recipe/$NAME-$VER
|
||||
DESTDIR=$B/dest
|
||||
mkdir -p $B/recipe $B/src $DESTDIR $B/pkg
|
||||
export DESTDIR CFLAGS CXXFLAGS LDFLAGS
|
||||
export MAKEFLAGS="-j$JOBS"
|
||||
|
||||
say "Unpacking $NAME $VER"
|
||||
tar -xzf /.glacier/in/bundle.grcp -C $B/recipe
|
||||
cd $B/src
|
||||
for f in $SOURCES; do
|
||||
case $f in
|
||||
*.tar|*.tar.gz|*.tgz|*.tar.xz|*.txz|*.tar.bz2|*.tbz2|*.tar.zst|*.tzst)
|
||||
tar -xf "/.glacier/in/sources/$f" ;;
|
||||
*)
|
||||
cp "/.glacier/in/sources/$f" . ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# The source tree: the one directory the sources unpacked into, else
|
||||
# the unpack directory itself.
|
||||
S=$B/src
|
||||
n=0
|
||||
for d in $B/src/* $B/src/.[!.]*; do
|
||||
[ -d "$d" ] && { n=$((n + 1)); one=$d; }
|
||||
done
|
||||
[ "$n" = 1 ] && S=$one
|
||||
cd "$S"
|
||||
|
||||
for p in $PATCHES; do
|
||||
say "Applying $p"
|
||||
patch -p1 < "$R/patches/$p"
|
||||
done
|
||||
|
||||
# configure_args CMD...: run CMD with CONFIGURE_ARGS appended. Those
|
||||
# are quoted words: the recipe's CONFIGURE, the trait arguments, then
|
||||
# the per-package CONFIGURE.
|
||||
configure_args() { eval "set -- \"\$@\" $CONFIGURE_ARGS"; "$@"; }
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
if [ -f CMakeLists.txt ]; then BUILD=cmake
|
||||
elif [ -f meson.build ]; then BUILD=meson
|
||||
# configure BEFORE a bare Makefile (CLAUDE.md bug 8)
|
||||
elif [ -f configure ] || [ -f configure.ac ]; then BUILD=autotools
|
||||
elif [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then BUILD=make
|
||||
else die "Cannot tell how to build $NAME: set BUILD in the recipe"
|
||||
fi
|
||||
say "Build system: $BUILD"
|
||||
fi
|
||||
|
||||
case $BUILD in
|
||||
autotools)
|
||||
prepare() { [ -x configure ] || autoreconf -fi; }
|
||||
configure() { configure_args ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var; }
|
||||
compile() { make; }
|
||||
package() { make install DESTDIR="$DESTDIR"; }
|
||||
;;
|
||||
cmake)
|
||||
prepare() { :; }
|
||||
configure() { configure_args cmake -B _build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release; }
|
||||
compile() { cmake --build _build -j "$JOBS"; }
|
||||
package() { DESTDIR="$DESTDIR" cmake --install _build; }
|
||||
;;
|
||||
meson)
|
||||
prepare() { :; }
|
||||
configure() { configure_args meson setup _build --prefix=/usr --buildtype=release; }
|
||||
compile() { meson compile -C _build -j "$JOBS"; }
|
||||
package() { DESTDIR="$DESTDIR" meson install -C _build; }
|
||||
;;
|
||||
make)
|
||||
prepare() { :; }
|
||||
configure() { :; }
|
||||
compile() { configure_args make PREFIX=/usr; }
|
||||
package() { make install PREFIX=/usr DESTDIR="$DESTDIR"; }
|
||||
;;
|
||||
hooks)
|
||||
prepare() { :; }
|
||||
configure() { :; }
|
||||
compile() { :; }
|
||||
package() { :; }
|
||||
;;
|
||||
*)
|
||||
die "Unknown build system $BUILD"
|
||||
;;
|
||||
esac
|
||||
|
||||
# The recipe's own hooks replace any of the four.
|
||||
[ -f "$R/build" ] && . "$R/build"
|
||||
|
||||
say "Preparing"; prepare
|
||||
say "Configuring"; configure
|
||||
say "Compiling"; compile
|
||||
say "Installing into DESTDIR"; package
|
||||
|
||||
[ -n "$(ls -A "$DESTDIR")" ] || die "$NAME installed nothing"
|
||||
|
||||
say "Packing $NAME-$VER.gpkg"
|
||||
mkdir -p "$B/pkg/$NAME-$VER"
|
||||
mv "$DESTDIR" "$B/pkg/$NAME-$VER/files"
|
||||
cp /.glacier/in/manifest.gpm.cfg "$B/pkg/$NAME-$VER/manifest.gpm.cfg"
|
||||
tar -czf "/.glacier/out/$NAME-$VER.gpkg" -C "$B/pkg" "$NAME-$VER"
|
||||
say "Done"
|
||||
Reference in new issue
Block a user