packages/

lua

Details
Source
FROM scratch AS base
ARG ARCH=x86_64
ENV VERSION=5.4.6
ENV SRC_HASH=7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88
ENV SRC_FILE=lua-${VERSION}.tar.gz
ENV SRC_SITE=https://www.lua.org/ftp/${SRC_FILE}

FROM base AS fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .

FROM fetch AS build
COPY --from=stagex/busybox . /
COPY --from=stagex/musl . /
COPY --from=stagex/gcc . /
COPY --from=stagex/binutils . /
COPY --from=stagex/libtool . /
COPY --from=stagex/perl . /
COPY --from=stagex/autoconf . /
COPY --from=stagex/automake . /
COPY --from=stagex/ncurses . /
COPY --from=stagex/readline . /
COPY --from=stagex/m4 . /
COPY --from=stagex/make . /
COPY --from=stagex/cmake . /
COPY --from=stagex/zlib . /
RUN tar -xvf $SRC_FILE
WORKDIR /lua-${VERSION}
COPY <<-EOF configure.ac
    top_buildir=.
    AC_INIT(src/luaconf.h)
    AC_PROG_LIBTOOL
    AC_OUTPUT()
EOF
RUN --network=none <<-EOF
	set -eu
    libtoolize --force --install
    aclocal
    autoconf
	./configure \
		--build=${ARCH}-unknown-linux-musl \
		--host=${ARCH}-unknown-linux-musl \
		--prefix=/usr
	make \
        -j "$(nproc)" \
        V="${VERSION}" \
        LDFLAGS="-lncurses" \
        CFLAGS="-DLUA_USE_LINUX -DLUA_COMPAT_5_2 -DLUA_USE_LINENOISE" \
		RPATH="/usr/lib" \
		LIB_LIBS="-lpthread -lm -ldl -llinenoise" \
		linux
EOF

FROM build AS install
RUN --network=none \
    make \
        V="${VERSION}" \
		INSTALL_TOP="/rootfs/usr" \
		INSTALL_INC="/rootfs/usr/include/lua" \
		INSTALL_LIB="/rootfs/usr/lib/lua" \
		install

FROM stagex/filesystem AS package
COPY --from=install /rootfs/. /