Initial commit.
gitea/icedream/nginx-mod-build-lua/master There was a failure building this commit Details

master
Icedream 2019-03-17 00:54:13 +01:00
commit bab5a9cf53
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
3 changed files with 158 additions and 0 deletions

55
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,55 @@
def MODULE_GIT_URL="https://github.com/openresty/lua-nginx-module.git"
pipeline {
agent none
parallel {
stage("Build on nginx:stable-alpine") {
agent {
docker {
image 'nginx:stable-alpine'
label 'linux && docker && amd64'
}
}
steps {
sh 'apk add --no-cache curl gnupg1'
sh './download-nginx.sh'
dir('module') {
git changelog: false, url: MODULE_GIT_URL
}
/* BUILD DEPENDENCIES */
sh 'apk add lua5.1-dev luajit-dev'
// FIXME - workaround wrong include path for luajit
sh 'echo "#include <luajit-2.1/luajit.h>" > /usr/include/luajit.h'
sh './build-alpine.sh'
archiveArtifacts "*.so,required_packages.txt"
}
}
stage("Build on nginx:mainline-alpine") {
agent {
docker {
image 'nginx:mainline-alpine'
label 'linux && docker && amd64'
}
}
steps {
sh 'apk add --no-cache curl gnupg1'
sh './download-nginx.sh'
dir('module') {
git changelog: false, url: MODULE_GIT_URL
}
/* BUILD DEPENDENCIES */
sh 'apk add lua5.1-dev luajit-dev'
// FIXME - workaround wrong include path for luajit
sh 'echo "#include <luajit-2.1/luajit.h>" > /usr/include/luajit.h'
sh './build-alpine.sh'
archiveArtifacts "*.so,required_packages.txt"
}
}
}
}

79
build-alpine.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh -e
resolve_package() {
for pkg in "$@"
do
apk info "$pkg" | head -n1 | awk '{print $1}'
done
}
strip_version_from_pkg_name() {
for pkg in "$@"
do
echo "$pkg" | sed 's,-[0-9a-zA-Z.]\+-r[0-9]\+$,,'
done
}
find_runtime_dependency_pkgs() {
for p in "$@"
do
ldd "$p" 2>/dev/null |\
grep '=> .\+\.so' |\
awk '{print $3}' |\
sort |\
uniq |\
while read -r so
do
apk info --who-owns $so
done |\
awk '{print $5}' |\
awk -F- '{print $1}'
done
}
find_devel_pkg() {
# shellcheck disable=SC2046
strip_version_from_pkg_name $(
apk list -d "$1" |\
grep dev |\
sort |\
uniq |\
awk '{print $1}'
)
}
# retrieve configure args of already packaged nginx
NGINX_CONFIGURE_ARGS="$(nginx -V 2>&1 | grep -o '^configure arguments: .*$' | sed 's,^configure arguments: ,,g')"
# remove preconfigured dynamic modules so only ours will be placed in the objs folder
NGINX_CONFIGURE_ARGS="$(printf '%s' "$NGINX_CONFIGURE_ARGS" | sed 's,--with-[^=]\+module=dynamic,,g')"
apk update
# Determine all dependencies used for the packaged nginx and install them
DEPENDENCIES="$(
find_runtime_dependency_pkgs /usr/lib/nginx/modules/*.so
# shellcheck disable=SC2046
strip_version_from_pkg_name $(resolve_package $(apk info -R nginx | tail -n+2))
)"
DEVPACKAGES="$(for dep in $DEPENDENCIES; do find_devel_pkg "$dep"; done | sort | uniq)"
apk add --virtual .build-deps \
gcc \
libc-dev \
make \
linux-headers \
$DEVPACKAGES
tar -zx -f nginx.tar.gz
rm nginx.tar.gz
cd nginx-*/
./configure $NGINX_CONFIGURE_ARGS --add-dynamic-module=../module --with-debug
make modules
. /etc/os_release
find_runtime_dependency_pkgs objs/*.so > ../required_packages.txt
for so in objs/*.so
do
name="$(basename "$so" .so)-$ID$VERSION_ID-nginx$NGINX_VERSION.so"
install -m644 "$so" "../$name"
done

24
download-nginx.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh -ex
NGINX_GPG_KEYS="B0F4253373F8F6F510D42178520A9993A1C052F8"
# NGINX_VERSION is provided by the Nginx Docker image as env var
NGINX_URL="https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz"
curl -fSL "$NGINX_URL" -o nginx.tar.gz
curl -fSL "$NGINX_URL.asc" -o nginx.tar.gz.asc
# GnuPG download integrity check
GNUPGHOME="$(mktemp -d)"
export GNUPGHOME
for server in \
ha.pool.sks-keyservers.net \
hkp://keyserver.ubuntu.com:80 \
hkp://p80.pool.sks-keyservers.net:80 \
pgp.mit.edu \
; do
echo "Fetching GPG key $NGINX_GPG_KEYS from $server"
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPG_KEYS" && found=yes && break
done
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1
gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz
rm -rf "$GNUPGHOME" nginx.tar.gz.asc