|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
# This script helps to build release artifacts.
|
|
|
# arg1: profile, e.g. emqx | emqx-edge | emqx-pkg | emqx-edge-pkg
|
|
|
-# arg2: artifact, e.g. rel | relup | zip | pkg
|
|
|
+# arg2: artifact, e.g. rel | relup | tgz | pkg
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
@@ -79,28 +79,18 @@ make_rel() {
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-## unzip previous version .zip files to _build/$PROFILE/rel/emqx/releases before making relup
|
|
|
+## extract previous version .tar.gz files to _build/$PROFILE/rel/emqx before making relup
|
|
|
make_relup() {
|
|
|
- local lib_dir="_build/$PROFILE/rel/emqx/lib"
|
|
|
- local releases_dir="_build/$PROFILE/rel/emqx/releases"
|
|
|
- mkdir -p "$lib_dir" "$releases_dir"
|
|
|
+ local rel_dir="_build/$PROFILE/rel/emqx"
|
|
|
+ mkdir -p "${rel_dir}/lib"
|
|
|
+ mkdir -p "${rel_dir}/releases"
|
|
|
local releases=()
|
|
|
- if [ -d "$releases_dir" ]; then
|
|
|
- while read -r zip; do
|
|
|
- local base_vsn
|
|
|
- base_vsn="$(echo "$zip" | grep -oE "[0-9]+\.[0-9]+(\.[0-9]+|(-(alpha|beta)\.[0-9]))(-[0-9a-e]{8})?")"
|
|
|
- if [ ! -d "$releases_dir/$base_vsn" ]; then
|
|
|
- local tmp_dir
|
|
|
- tmp_dir="$(mktemp -d -t emqx.XXXXXXX)"
|
|
|
- unzip -q "$zip" "emqx/releases/*" -d "$tmp_dir"
|
|
|
- unzip -q "$zip" "emqx/lib/*" -d "$tmp_dir"
|
|
|
- cp -r -n "$tmp_dir/emqx/releases"/* "$releases_dir"
|
|
|
- cp -r -n "$tmp_dir/emqx/lib"/* "$lib_dir"
|
|
|
- rm -rf "$tmp_dir"
|
|
|
- fi
|
|
|
- releases+=( "$base_vsn" )
|
|
|
- done < <("$FIND" _upgrade_base -maxdepth 1 -name "*$PROFILE-otp${OTP_VSN}-$SYSTEM*-$ARCH.zip" -type f)
|
|
|
- fi
|
|
|
+ while read -r tgzfile ; do
|
|
|
+ local base_vsn
|
|
|
+ base_vsn="$(echo "$tgzfile" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)\.[0-9])?(-[0-9a-f]{8})?" | head -1)"
|
|
|
+ tar -C "$rel_dir" -zxf ---keep-old-files "$tgzfile" emqx/releases emqx/lib
|
|
|
+ releases+=( "$base_vsn" )
|
|
|
+ done < <("$FIND" _upgrade_base -maxdepth 1 -name "$PROFILE*${SYSTEM}-${ARCH}.tar.gz" -type f)
|
|
|
if [ ${#releases[@]} -eq 0 ]; then
|
|
|
log "No upgrade base found, relup ignored"
|
|
|
return 0
|
|
|
@@ -126,9 +116,9 @@ cp_dyn_libs() {
|
|
|
| sort -u)
|
|
|
}
|
|
|
|
|
|
-## make_zip turns .tar.gz into a .zip with a slightly different name.
|
|
|
+## Re-pack the relx assembled .tar.gz to EMQ X's package naming scheme
|
|
|
## It assumes the .tar.gz has been built -- relies on Makefile dependency
|
|
|
-make_zip() {
|
|
|
+make_tgz() {
|
|
|
# build the tarball again to ensure relup is included
|
|
|
make_rel
|
|
|
|
|
|
@@ -142,14 +132,14 @@ make_zip() {
|
|
|
if [ ! -f "$tarball" ]; then
|
|
|
log "ERROR: $tarball is not found"
|
|
|
fi
|
|
|
- local zipball
|
|
|
- zipball="${pkgpath}/${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.zip"
|
|
|
+ local target
|
|
|
+ target="${pkgpath}/${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
|
|
tar zxf "${tarball}" -C "${tard}/emqx"
|
|
|
- ## try to be portable for zip packages.
|
|
|
+ ## try to be portable for tar.gz packages.
|
|
|
## for DEB and RPM packages the dependencies are resoved by yum and apt
|
|
|
cp_dyn_libs "${tard}/emqx"
|
|
|
- (cd "${tard}" && zip -qr - emqx) > "${zipball}"
|
|
|
- log "Zip package successfully created: ${zipball}"
|
|
|
+ (cd "${tard}" && tar -cz emqx) > "${target}"
|
|
|
+ log "Tarball successfully repacked: ${target}"
|
|
|
}
|
|
|
|
|
|
## This function builds the default docker image based on alpine:3.14 (by default)
|
|
|
@@ -166,7 +156,7 @@ make_docker() {
|
|
|
}
|
|
|
|
|
|
## This function accepts any base docker image,
|
|
|
-## a emqx zip-image, and a image tag (for the image to be built),
|
|
|
+## a emqx tgz-image, and a image tag (for the image to be built),
|
|
|
## to build a docker image which runs EMQ X
|
|
|
##
|
|
|
## Export below variables to quickly build an image
|
|
|
@@ -174,7 +164,7 @@ make_docker() {
|
|
|
## Name Default Example
|
|
|
## ---------------------------------------------------------------------
|
|
|
## EMQX_BASE_IMAGE current os centos:7
|
|
|
-## EMQX_ZIP_PACKAGE _packages/<current-zip-target> /tmp/emqx-4.4.0-otp23.3.4.9-3-centos7-amd64.zip
|
|
|
+## EMQX_TGZ_packages/<current-tgz-target> /tmp/emqx-4.4.0-otp23.3.4.9-3-centos7-amd64.tar.gz
|
|
|
## EMQX_IMAGE_TAG emqx/emqx:<current-vns-rel> emqx/emqx:testing-tag
|
|
|
##
|
|
|
make_docker_testing() {
|
|
|
@@ -193,17 +183,17 @@ make_docker_testing() {
|
|
|
esac
|
|
|
fi
|
|
|
EMQX_IMAGE_TAG="${EMQX_IMAGE_TAG:-emqx/$PROFILE:${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}}"
|
|
|
- local defaultzip
|
|
|
- defaultzip="_packages/${PROFILE}/${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.zip"
|
|
|
- local zip="${EMQX_ZIP_PACKAGE:-$defaultzip}"
|
|
|
- if [ ! -f "$zip" ]; then
|
|
|
- log "ERROR: $zip not built?"
|
|
|
+ local default_tgz
|
|
|
+ default_tgz="_packages/${PROFILE}/${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
|
|
+ local tgz="${EMQX_TGZ_PACKAGE:-$default_tgz}"
|
|
|
+ if [ ! -f "$tgz" ]; then
|
|
|
+ log "ERROR: $tgz not built?"
|
|
|
exit 1
|
|
|
fi
|
|
|
set -x
|
|
|
docker build \
|
|
|
--build-arg BUILD_FROM="${EMQX_BASE_IMAGE}" \
|
|
|
- --build-arg EMQX_ZIP_PACKAGE="${zip}" \
|
|
|
+ --build-arg EMQX_TGZ_PACKAGE="${tgz}" \
|
|
|
--tag "$EMQX_IMAGE_TAG" \
|
|
|
-f "${DOCKERFILE_TESTING}" .
|
|
|
}
|
|
|
@@ -220,8 +210,8 @@ case "$ARTIFACT" in
|
|
|
relup)
|
|
|
make_relup
|
|
|
;;
|
|
|
- zip)
|
|
|
- make_zip
|
|
|
+ tgz)
|
|
|
+ make_tgz
|
|
|
;;
|
|
|
pkg)
|
|
|
if [ -z "${PKGERDIR:-}" ]; then
|