2022-02-22 00:10:22 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Build portable binary release tarballs for Linux/x64 and Linux/arm64.
|
|
|
|
#
|
|
|
|
# Author: Holger Weiss <holger@zedat.fu-berlin.de>.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2022 ProcessOne, SARL.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
export PATH='/usr/local/bin:/usr/bin:/bin'
|
|
|
|
|
|
|
|
myself=${0##*/}
|
|
|
|
|
|
|
|
info()
|
|
|
|
{
|
|
|
|
echo "$myself: $*"
|
|
|
|
}
|
|
|
|
|
|
|
|
error()
|
|
|
|
{
|
|
|
|
echo >&2 "$myself: $*"
|
|
|
|
}
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo >&2 "Usage: $myself"
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
mix_version()
|
|
|
|
{
|
|
|
|
# Mix insists on SemVer format.
|
|
|
|
local vsn="$(printf '%s' "$1" | sed 's/\.0/./')"
|
|
|
|
|
|
|
|
case $vsn in
|
|
|
|
*.*.*) printf '%s' "$vsn" ;;
|
|
|
|
*.*) printf '%s.0' "$vsn" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! [ -e 'mix.exs' ] || ! [ -e "tools/$myself" ]
|
|
|
|
then
|
|
|
|
error "Please call this script from the repository's root directory."
|
|
|
|
exit 2
|
|
|
|
elif [ $# -ne 0 ]
|
|
|
|
then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
rel_name='ejabberd'
|
2022-04-22 20:30:23 +02:00
|
|
|
rel_vsn=$(git describe --tags | sed -e 's/-g.*//' -e 's/-/./' | tr -d '[:space:]')
|
2022-02-22 00:10:22 +01:00
|
|
|
mix_vsn=$(mix_version "$rel_vsn")
|
2023-09-26 23:55:01 +02:00
|
|
|
crosstool_vsn='1.26.0'
|
2022-02-22 00:10:22 +01:00
|
|
|
termcap_vsn='1.3.1'
|
2024-03-11 13:27:11 +01:00
|
|
|
expat_vsn='2.6.2'
|
2024-02-14 21:25:51 +01:00
|
|
|
zlib_vsn='1.3.1'
|
2022-02-22 00:10:22 +01:00
|
|
|
yaml_vsn='0.2.5'
|
2024-06-04 22:40:55 +02:00
|
|
|
ssl_vsn='3.3.1'
|
2024-05-25 21:07:19 +02:00
|
|
|
otp_vsn='26.2.5'
|
|
|
|
elixir_vsn='1.16.3'
|
2024-04-10 16:59:08 +02:00
|
|
|
pam_vsn='1.6.1'
|
2024-02-14 21:25:51 +01:00
|
|
|
png_vsn='1.6.42'
|
|
|
|
jpeg_vsn='9f'
|
2023-09-27 00:28:46 +02:00
|
|
|
webp_vsn='1.3.2'
|
2022-02-22 00:10:22 +01:00
|
|
|
gd_vsn='2.3.3'
|
2023-09-27 00:28:46 +02:00
|
|
|
odbc_vsn='2.3.12'
|
2024-02-14 21:25:51 +01:00
|
|
|
sqlite_vsn='3450100'
|
2022-02-22 00:10:22 +01:00
|
|
|
root_dir="${BUILD_DIR:-$HOME/build}"
|
|
|
|
bootstrap_dir="$root_dir/bootstrap"
|
|
|
|
ct_prefix_dir="$root_dir/x-tools"
|
|
|
|
build_dir="$root_dir/$rel_name"
|
|
|
|
crosstool_dir="crosstool-ng-$crosstool_vsn"
|
|
|
|
termcap_dir="termcap-$termcap_vsn"
|
|
|
|
expat_dir="expat-$expat_vsn"
|
|
|
|
zlib_dir="zlib-$zlib_vsn"
|
|
|
|
yaml_dir="yaml-$yaml_vsn"
|
|
|
|
ssl_dir="openssl-$ssl_vsn"
|
|
|
|
otp_dir="otp_src_$otp_vsn"
|
|
|
|
elixir_dir="elixir-$elixir_vsn"
|
|
|
|
pam_dir="Linux-PAM-$pam_vsn"
|
|
|
|
png_dir="libpng-$png_vsn"
|
|
|
|
jpeg_dir="jpeg-$jpeg_vsn"
|
|
|
|
webp_dir="libwebp-$webp_vsn"
|
|
|
|
gd_dir="libgd-$gd_vsn"
|
|
|
|
odbc_dir="unixODBC-$odbc_vsn"
|
|
|
|
sqlite_dir="sqlite-autoconf-$sqlite_vsn"
|
|
|
|
crosstool_tar="$crosstool_dir.tar.xz"
|
|
|
|
termcap_tar="$termcap_dir.tar.gz"
|
|
|
|
expat_tar="$expat_dir.tar.gz"
|
|
|
|
zlib_tar="$zlib_dir.tar.gz"
|
|
|
|
yaml_tar="$yaml_dir.tar.gz"
|
|
|
|
ssl_tar="$ssl_dir.tar.gz"
|
|
|
|
otp_tar="$otp_dir.tar.gz"
|
|
|
|
elixir_tar="v$elixir_vsn.tar.gz"
|
|
|
|
pam_tar="$pam_dir.tar.xz"
|
|
|
|
png_tar="$png_dir.tar.gz"
|
|
|
|
jpeg_tar="jpegsrc.v$jpeg_vsn.tar.gz"
|
|
|
|
webp_tar="$webp_dir.tar.gz"
|
|
|
|
gd_tar="$gd_dir.tar.gz"
|
|
|
|
sqlite_tar="$sqlite_dir.tar.gz"
|
|
|
|
odbc_tar="$odbc_dir.tar.gz"
|
|
|
|
rel_tar="$rel_name-$mix_vsn.tar.gz"
|
|
|
|
ct_jobs=$(nproc)
|
|
|
|
src_dir="$root_dir/src"
|
2022-11-18 21:55:17 +01:00
|
|
|
platform=$(gcc -dumpmachine)
|
2022-02-22 00:10:22 +01:00
|
|
|
targets='x86_64-linux-gnu aarch64-linux-gnu'
|
|
|
|
build_start=$(date '+%F %T')
|
2022-03-08 10:23:54 +01:00
|
|
|
have_current_deps='false'
|
|
|
|
dep_vsns_file="$build_dir/.dep_vsns"
|
|
|
|
dep_vsns=''
|
|
|
|
deps='crosstool
|
|
|
|
termcap
|
|
|
|
expat
|
|
|
|
zlib
|
|
|
|
yaml
|
|
|
|
ssl
|
|
|
|
otp
|
|
|
|
elixir
|
|
|
|
pam
|
|
|
|
png
|
|
|
|
jpeg
|
|
|
|
webp
|
|
|
|
gd
|
|
|
|
odbc
|
|
|
|
sqlite'
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
umask 022
|
|
|
|
|
|
|
|
#' Try to find a browser for checking dependency versions.
|
|
|
|
have_browser()
|
|
|
|
{
|
|
|
|
for browser in 'lynx' 'links' 'elinks'
|
|
|
|
do
|
|
|
|
$browser -dump 'https://ejabberd.im/' >'/dev/null' && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Check whether the given dependency version is up-to-date.
|
|
|
|
check_vsn()
|
|
|
|
{
|
|
|
|
local name="$1"
|
|
|
|
local our_vsn="$2"
|
|
|
|
local src_url="$3"
|
|
|
|
local reg_exp="$4"
|
|
|
|
local cur_vsn=$($browser -dump "$src_url" |
|
|
|
|
sed -n "s/.*$reg_exp.*/\\1/p" |
|
|
|
|
head -1)
|
|
|
|
|
|
|
|
if [ "$our_vsn" = "$cur_vsn" ]
|
|
|
|
then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
error "Current $name version is: $cur_vsn"
|
|
|
|
error "But our $name version is: $our_vsn"
|
|
|
|
error "Update $0 or set CHECK_DEPS=false"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Check whether our dependency versions are up-to-date.
|
2022-03-08 10:23:54 +01:00
|
|
|
check_configured_dep_vsns()
|
2022-02-22 00:10:22 +01:00
|
|
|
{
|
|
|
|
check_vsn 'OpenSSL' "$ssl_vsn" \
|
|
|
|
'https://www.openssl.org/source/' \
|
2024-02-07 19:06:20 +01:00
|
|
|
'openssl-\(3\.[1-9]\.[0-9.]*\)\.tar\.gz'
|
2022-02-22 00:10:22 +01:00
|
|
|
check_vsn 'LibYAML' "$yaml_vsn" \
|
|
|
|
'https://pyyaml.org/wiki/LibYAML' \
|
|
|
|
'yaml-\([0-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'zlib' "$zlib_vsn" \
|
|
|
|
'https://zlib.net/' \
|
|
|
|
'zlib-\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'Expat' "$expat_vsn" \
|
|
|
|
'https://github.com/libexpat/libexpat/releases' \
|
2023-07-23 15:51:27 +02:00
|
|
|
'\([1-9]\.[0-9]*\.[0-9]*\)'
|
2022-02-22 00:10:22 +01:00
|
|
|
check_vsn 'Termcap' "$termcap_vsn" \
|
|
|
|
'https://ftp.gnu.org/gnu/termcap/' \
|
|
|
|
'termcap-\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'SQLite' "$sqlite_vsn" \
|
|
|
|
'https://www.sqlite.org/download.html' \
|
|
|
|
'sqlite-autoconf-\([1-9][0-9]*\)\.tar\.gz'
|
|
|
|
check_vsn 'ODBC' "$odbc_vsn" \
|
|
|
|
'http://www.unixodbc.org/download.html' \
|
|
|
|
'unixODBC-\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'Linux-PAM' "$pam_vsn" \
|
|
|
|
'https://github.com/linux-pam/linux-pam/releases' \
|
2022-09-23 13:45:09 +02:00
|
|
|
'[0-9]\]Linux-PAM \([1-9][0-9.]*\)'
|
2022-02-22 00:10:22 +01:00
|
|
|
check_vsn 'libpng' "$png_vsn" \
|
|
|
|
'http://www.libpng.org/pub/png/libpng.html' \
|
|
|
|
'libpng-\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'JPEG' "$jpeg_vsn" \
|
|
|
|
'https://www.ijg.org' \
|
|
|
|
'jpegsrc.v\([1-9][0-9a-z]*\)\.tar\.gz'
|
|
|
|
check_vsn 'WebP' "$webp_vsn" \
|
|
|
|
'https://developers.google.com/speed/webp/download' \
|
|
|
|
'libwebp-\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
check_vsn 'LibGD' "$gd_vsn" \
|
|
|
|
'https://github.com/libgd/libgd/releases' \
|
2022-09-23 13:45:09 +02:00
|
|
|
'gd-\([1-9][0-9.]*\)'
|
2022-02-22 00:10:22 +01:00
|
|
|
check_vsn 'Elixir' "$elixir_vsn" \
|
|
|
|
'https://elixir-lang.org/install.html' \
|
|
|
|
'v\([1-9][0-9.]*\)\.tar\.gz'
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
#' Check whether existing dependencies are up-to-date.
|
|
|
|
check_built_dep_vsns()
|
|
|
|
{
|
|
|
|
for dep in $deps
|
|
|
|
do
|
|
|
|
eval dep_vsns=\"\$dep_vsns\$${dep}_vsn\"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -e "$dep_vsns_file" ]
|
|
|
|
then
|
|
|
|
if [ "$dep_vsns" = "$(cat "$dep_vsns_file")" ]
|
|
|
|
then have_current_deps='true'
|
|
|
|
fi
|
|
|
|
rm "$dep_vsns_file"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Save built dependency versions.
|
|
|
|
save_built_dep_vsns()
|
|
|
|
{
|
|
|
|
echo "$dep_vsns" >"$dep_vsns_file"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
#' Create common part of Crosstool-NG configuration file.
|
|
|
|
create_common_config()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
cat >"$file" <<-'EOF'
|
2022-04-22 21:37:25 +02:00
|
|
|
CT_CONFIG_VERSION="4"
|
2022-02-22 00:10:22 +01:00
|
|
|
CT_DOWNLOAD_AGENT_CURL=y
|
|
|
|
CT_OMIT_TARGET_VENDOR=y
|
2022-04-22 21:37:25 +02:00
|
|
|
CT_CC_LANG_CXX=y
|
2022-02-22 00:10:22 +01:00
|
|
|
CT_ARCH_64=y
|
|
|
|
CT_KERNEL_LINUX=y
|
2023-07-23 14:49:07 +02:00
|
|
|
CT_LINUX_V_3_16=y
|
2022-11-18 21:55:17 +01:00
|
|
|
CT_LOG_PROGRESS_BAR=n
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Create Crosstool-NG configuration file for glibc.
|
|
|
|
create_gnu_config()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
create_common_config "$file"
|
|
|
|
|
|
|
|
cat >>"$file" <<-'EOF'
|
2023-03-13 17:57:55 +01:00
|
|
|
CT_GLIBC_V_2_19=y
|
2022-11-18 21:55:17 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Create Crosstool-NG configuration file for musl.
|
|
|
|
create_musl_config()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
create_common_config "$file"
|
|
|
|
|
|
|
|
cat >>"$file" <<-'EOF'
|
|
|
|
CT_EXPERIMENTAL=y
|
|
|
|
CT_LIBC_MUSL=y
|
2022-02-22 00:10:22 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Create Crosstool-NG configuration file for x64.
|
|
|
|
create_x64_config()
|
|
|
|
{
|
|
|
|
local file="$1"
|
2022-11-18 21:55:17 +01:00
|
|
|
local libc="$2"
|
2022-02-22 00:10:22 +01:00
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
create_${libc}_config "$file"
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
cat >>"$file" <<-'EOF'
|
|
|
|
CT_ARCH_X86=y
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Create Crosstool-NG configuration file for arm64.
|
|
|
|
create_arm64_config()
|
|
|
|
{
|
|
|
|
local file="$1"
|
2022-11-18 21:55:17 +01:00
|
|
|
local libc="$2"
|
2022-02-22 00:10:22 +01:00
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
create_${libc}_config "$file"
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
cat >>"$file" <<-'EOF'
|
|
|
|
CT_ARCH_ARM=y
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Return our name for the given platform.
|
|
|
|
arch_name()
|
|
|
|
{
|
|
|
|
local target="$1"
|
|
|
|
|
|
|
|
case $target in
|
|
|
|
x86_64*)
|
|
|
|
printf 'x64'
|
|
|
|
;;
|
|
|
|
aarch64*)
|
|
|
|
printf 'arm64'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "Unsupported target platform: $target"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
#' Add native Erlang/OTP "bin" directory to PATH (for bootstrapping and Mix).
|
|
|
|
add_otp_path()
|
|
|
|
{
|
|
|
|
local mode="$1"
|
|
|
|
local prefix="$2"
|
|
|
|
|
|
|
|
if [ "$mode" = 'native' ]
|
|
|
|
then native_otp_bin="$prefix/bin"
|
2023-07-23 15:35:09 +02:00
|
|
|
elif [ -n "${INSTALL_DIR_FOR_OTP+x}" ] && [ -n "${INSTALL_DIR_FOR_ELIXIR+x}" ]
|
2023-07-23 15:06:40 +02:00
|
|
|
then
|
|
|
|
# For github runners to build for non-native systems:
|
|
|
|
# https://github.com/erlef/setup-beam#environment-variables
|
2024-02-24 17:14:36 +01:00
|
|
|
native_otp_bin="$INSTALL_DIR_FOR_OTP/bin"
|
|
|
|
native_elixir_bin="$INSTALL_DIR_FOR_ELIXIR/bin"
|
2022-11-18 21:55:17 +01:00
|
|
|
export PATH="$native_elixir_bin:$PATH"
|
2022-03-08 10:23:54 +01:00
|
|
|
fi
|
|
|
|
export PATH="$native_otp_bin:$PATH"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
#' Create and populate /opt/ejabberd directory.
|
|
|
|
create_data_dir()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
local data_dir="$2"
|
|
|
|
|
|
|
|
mkdir "$data_dir" "$data_dir/database" "$data_dir/logs"
|
|
|
|
mv "$code_dir/conf" "$data_dir"
|
|
|
|
chmod 'o-rwx' "$data_dir/"*
|
2023-09-29 17:33:09 +02:00
|
|
|
curl -fsS -o "$data_dir/conf/cacert.pem" 'https://curl.se/ca/cacert.pem'
|
2022-02-22 00:10:22 +01:00
|
|
|
sed -i '/^loglevel:/a\
|
|
|
|
\
|
|
|
|
ca_file: /opt/ejabberd/conf/cacert.pem\
|
|
|
|
\
|
|
|
|
certfiles:\
|
|
|
|
- /opt/ejabberd/conf/server.pem' "$data_dir/conf/$rel_name.yml"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Add systemd unit and init script.
|
|
|
|
add_systemd_unit()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
|
|
|
|
sed -e "s|@ctlscriptpath@|/opt/$rel_name-$rel_vsn/bin|g" \
|
|
|
|
-e "s|@installuser@|$rel_name|g" 'ejabberd.service.template' \
|
|
|
|
>"$code_dir/bin/ejabberd.service"
|
|
|
|
sed -e "s|@ctlscriptpath@|/opt/$rel_name-$rel_vsn/bin|g" \
|
|
|
|
-e "s|@installuser@|$rel_name|g" 'ejabberd.init.template' \
|
|
|
|
>"$code_dir/bin/ejabberd.init"
|
|
|
|
chmod '+x' "$code_dir/bin/ejabberd.init"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-05-28 15:00:25 +02:00
|
|
|
#' Add CAPTCHA script(s).
|
|
|
|
add_captcha_script()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
|
|
|
|
cp -p 'tools/captcha'*'.sh' "$code_dir/lib"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
#' Use our VT100 to avoid depending on Terminfo, adjust options/paths.
|
|
|
|
edit_ejabberdctl()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
-e "2iexport TERM='internal'" \
|
|
|
|
-e '/ERL_OPTIONS=/d' \
|
|
|
|
-e 's|_DIR:=".*}/|_DIR:="/opt/ejabberd/|' \
|
2022-05-18 17:08:05 +02:00
|
|
|
-e 's|/database|/database/$ERLANG_NODE|' \
|
2023-09-26 13:55:34 +02:00
|
|
|
-e 's|#vt100 ||' \
|
2022-02-22 00:10:22 +01:00
|
|
|
"$code_dir/bin/${rel_name}ctl"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Delete unused files and directories, just to save some space.
|
|
|
|
remove_unused_files()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
|
|
|
|
# Remove shared object file used only in test suite:
|
|
|
|
find "$code_dir/lib" -name 'otp_test_engine.so' -delete
|
|
|
|
|
|
|
|
# Remove shared object files of statically linked NIFs:
|
|
|
|
find "$code_dir/lib/crypto-"* "$code_dir/lib/asn1-"* \
|
|
|
|
'(' -name 'asn1rt_nif.so' -o \
|
|
|
|
-name 'crypto.so' -o \
|
|
|
|
-name 'lib' -o \
|
|
|
|
-name 'priv' ')' \
|
|
|
|
-delete
|
|
|
|
|
|
|
|
# Remove unused ERTS binaries (see systools_make:erts_binary_filter/0):
|
|
|
|
find "$code_dir/erts-"*'/bin' \
|
|
|
|
'(' -name 'ct_run' -o \
|
|
|
|
-name 'dialyzer' -o \
|
|
|
|
-name 'erlc' -o \
|
|
|
|
-name 'typer' -o \
|
|
|
|
-name 'yielding_c_fun' ')' \
|
|
|
|
-delete
|
|
|
|
|
|
|
|
# Remove unused Mix stuff:
|
|
|
|
find "$code_dir/bin" -name 'ejabberd' -delete
|
|
|
|
find "$code_dir/releases" -name 'COOKIE' -delete
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Strip ERTS binaries, shared objects, and BEAM files.
|
|
|
|
strip_files()
|
|
|
|
{
|
|
|
|
local code_dir="$1"
|
|
|
|
local strip_cmd="$2"
|
|
|
|
|
|
|
|
find "$code_dir/lib" \
|
|
|
|
-type f \
|
|
|
|
-name '*.so' \
|
|
|
|
-exec "$strip_cmd" -s '{}' '+'
|
|
|
|
find "$code_dir/erts-"*'/bin' "$code_dir/lib/"*'/priv/bin' \
|
|
|
|
-type f \
|
|
|
|
-perm '-u+x' \
|
|
|
|
-exec "$strip_cmd" -s '{}' '+' 2>'/dev/null' || :
|
|
|
|
erl -noinput -eval \
|
|
|
|
"{ok, _} = beam_lib:strip_release('$code_dir'), halt()"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Build toochain for a given target.
|
|
|
|
build_toolchain()
|
|
|
|
{
|
|
|
|
local target="$1"
|
|
|
|
local prefix="$2"
|
|
|
|
local arch=$(arch_name "$target")
|
2023-07-23 15:06:40 +02:00
|
|
|
local libc="${target##*-}"
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
if [ -d "$prefix" ]
|
|
|
|
then
|
|
|
|
info "Using existing toolchain in $prefix ..."
|
|
|
|
else
|
|
|
|
if ! [ -x "$bootstrap_dir/bin/ct-ng" ]
|
|
|
|
then
|
|
|
|
info "Extracting Crosstool-NG $crosstool_vsn ..."
|
|
|
|
cd "$src_dir"
|
|
|
|
tar -xJf "$crosstool_tar"
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
|
|
|
info "Building Crosstool-NG $crosstool_vsn ..."
|
|
|
|
cd "$src_dir/$crosstool_dir"
|
|
|
|
./configure --prefix="$bootstrap_dir"
|
2022-11-16 11:18:12 +01:00
|
|
|
make V=0
|
2022-02-22 00:10:22 +01:00
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
fi
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building toolchain for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$root_dir"
|
2022-11-18 21:55:17 +01:00
|
|
|
create_${arch}_config 'defconfig' "$libc"
|
2022-04-22 21:37:25 +02:00
|
|
|
ct-ng defconfig
|
2022-02-22 00:10:22 +01:00
|
|
|
ct-ng build CT_PREFIX="$ct_prefix_dir" CT_JOBS="$ct_jobs"
|
|
|
|
rm -rf '.config' '.build' 'build.log'
|
|
|
|
cd "$OLDPWD"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
#' Build target dependencies.
|
|
|
|
build_deps()
|
2022-02-22 00:10:22 +01:00
|
|
|
{
|
|
|
|
local mode="$1"
|
|
|
|
local target="$2"
|
|
|
|
local prefix="$3"
|
|
|
|
local arch="$(arch_name "$target")"
|
2023-07-23 15:06:40 +02:00
|
|
|
local libc="${target##*-}"
|
2022-02-22 00:10:22 +01:00
|
|
|
local target_src_dir="$prefix/src"
|
|
|
|
local saved_path="$PATH"
|
|
|
|
|
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then configure="./configure --host=$target --build=$platform"
|
|
|
|
else configure='./configure'
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir "$prefix"
|
|
|
|
|
|
|
|
info 'Extracting dependencies ...'
|
|
|
|
mkdir "$target_src_dir"
|
|
|
|
cd "$target_src_dir"
|
|
|
|
tar -xzf "$src_dir/$termcap_tar"
|
|
|
|
tar -xzf "$src_dir/$sqlite_tar"
|
|
|
|
tar -xzf "$src_dir/$odbc_tar"
|
|
|
|
tar -xzf "$src_dir/$expat_tar"
|
|
|
|
tar -xzf "$src_dir/$zlib_tar"
|
|
|
|
tar -xzf "$src_dir/$yaml_tar"
|
|
|
|
tar -xzf "$src_dir/$ssl_tar"
|
|
|
|
tar -xzf "$src_dir/$otp_tar"
|
|
|
|
tar -xzf "$src_dir/$elixir_tar"
|
|
|
|
tar -xzf "$src_dir/$png_tar"
|
|
|
|
tar -xzf "$src_dir/$jpeg_tar"
|
|
|
|
tar -xzf "$src_dir/$webp_tar"
|
|
|
|
tar -xzf "$src_dir/$gd_tar"
|
|
|
|
tar -xJf "$src_dir/$pam_tar"
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building Termcap $termcap_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$termcap_dir"
|
|
|
|
$configure --prefix="$prefix"
|
|
|
|
cat >'config.h' <<-'EOF'
|
|
|
|
#ifndef CONFIG_H
|
|
|
|
#define CONFIG_H
|
|
|
|
#define INTERNAL_TERMINAL "internal:\\\n" \
|
|
|
|
"\t:am:bs:ms:xn:xo:\\\n" \
|
|
|
|
"\t:co#80:it#8:li#24:vt#3:\\\n" \
|
|
|
|
"\t:@8=\\EOM:DO=\\E[%dB:K1=\\EOq:K2=\\EOr:K3=\\EOs:K4=\\EOp:K5=\\EOn:\\\n" \
|
|
|
|
"\t:LE=\\E[%dD:RA=\\E[?7l:RI=\\E[%dC:SA=\\E[?7h:UP=\\E[%dA:\\\n" \
|
|
|
|
"\t:ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\\\n" \
|
|
|
|
"\t:ae=^O:as=^N:bl=^G:cb=\\E[1K:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:\\\n" \
|
|
|
|
"\t:cm=\\E[%i%d;%dH:cr=^M:cs=\\E[%i%d;%dr:ct=\\E[3g:do=^J:\\\n" \
|
|
|
|
"\t:eA=\\E(B\\E)0:ho=\\E[H:k0=\\EOy:k1=\\EOP:k2=\\EOQ:k3=\\EOR:\\\n" \
|
|
|
|
"\t:k4=\\EOS:k5=\\EOt:k6=\\EOu:k7=\\EOv:k8=\\EOl:k9=\\EOw:k;=\\EOx:\\\n" \
|
|
|
|
"\t:kb=^H:kd=\\EOB:ke=\\E[?1l\\E>:kl=\\EOD:kr=\\EOC:ks=\\E[?1h\\E=:\\\n" \
|
|
|
|
"\t:ku=\\EOA:le=^H:mb=\\E[5m:md=\\E[1m:me=\\E[m\\017:mr=\\E[7m:\\\n" \
|
|
|
|
"\t:nd=\\E[C:rc=\\E8:rs=\\E>\\E[?3l\\E[?4l\\E[?5l\\E[?7h\\E[?8h:\\\n" \
|
|
|
|
"\t:..sa=\\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\\016%e\\017%;:\\\n" \
|
|
|
|
"\t:sc=\\E7:se=\\E[m:sf=^J:so=\\E[7m:sr=\\EM:st=\\EH:ta=^I:ue=\\E[m:\\\n" \
|
|
|
|
"\t:up=\\E[A:us=\\E[4m:"
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
make CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H=1"
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building zlib $zlib_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$zlib_dir"
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC" ./configure --prefix="$prefix" --static
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building OpenSSL $ssl_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$ssl_dir"
|
2024-02-07 19:06:20 +01:00
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC" \
|
|
|
|
./Configure no-shared no-module no-ui-console \
|
2022-02-22 00:10:22 +01:00
|
|
|
--prefix="$prefix" \
|
|
|
|
--openssldir="$prefix" \
|
2024-02-07 19:06:20 +01:00
|
|
|
--libdir='lib' \
|
2022-11-18 21:55:17 +01:00
|
|
|
"linux-${target%-linux-*}"
|
2022-02-22 00:10:22 +01:00
|
|
|
make build_libs
|
|
|
|
make install_dev
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building Expat $expat_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$expat_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
--without-docbook \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building LibYAML $yaml_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$yaml_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building SQLite $sqlite_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$sqlite_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building ODBC $odbc_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$odbc_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
|
|
|
info "Building Linux-PAM $pam_vsn for $arch ..."
|
|
|
|
cd "$target_src_dir/$pam_dir"
|
|
|
|
$configure --prefix="$prefix" --includedir="$prefix/include/security" \
|
2023-07-23 16:08:25 +02:00
|
|
|
--enable-static --disable-shared --disable-doc --disable-examples \
|
|
|
|
--enable-db=no \
|
2022-02-22 00:10:22 +01:00
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building libpng $png_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$png_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building JPEG $jpeg_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$jpeg_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building WebP $webp_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$webp_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building LibGD $gd_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$gd_dir"
|
|
|
|
$configure --prefix="$prefix" --enable-static --disable-shared \
|
|
|
|
--with-zlib="$prefix" \
|
|
|
|
--with-webp="$prefix" \
|
|
|
|
--with-jpeg="$prefix" \
|
|
|
|
--with-png="$prefix" \
|
|
|
|
--without-avif \
|
|
|
|
--without-fontconfig \
|
|
|
|
--without-freetype \
|
|
|
|
--without-heif \
|
|
|
|
--without-libiconv-prefix \
|
|
|
|
--without-liq \
|
|
|
|
--without-raqm \
|
|
|
|
--without-tiff \
|
|
|
|
--without-x \
|
|
|
|
--without-xpm \
|
|
|
|
CFLAGS="$CFLAGS -O3 -fPIC"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building Erlang/OTP $otp_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then
|
2022-03-08 10:23:54 +01:00
|
|
|
add_otp_path "$mode" "$prefix"
|
2022-02-22 00:10:22 +01:00
|
|
|
export erl_xcomp_sysroot="$prefix"
|
|
|
|
fi
|
|
|
|
cd "$target_src_dir/$otp_dir"
|
2024-05-13 10:36:24 +02:00
|
|
|
# Revert https://github.com/erlang/otp/commit/53ef5df40c733ce3d8215c5c98805f99f378f656
|
|
|
|
# because it breaks MSSQL, see https://github.com/processone/ejabberd/issues/4178
|
|
|
|
sed -i 's|if(size == 0 && (sql_type == SQL_LONGVARCHAR|if((sql_type == SQL_LONGVARCHAR|g' lib/odbc/c_src/odbcserver.c
|
2022-02-22 00:10:22 +01:00
|
|
|
# The additional CFLAGS/LIBS below are required by --enable-static-nifs.
|
|
|
|
# The "-ldl" flag specifically is only needed for ODBC, though.
|
|
|
|
$configure \
|
|
|
|
--prefix="$prefix" \
|
|
|
|
--with-ssl="$prefix" \
|
|
|
|
--with-odbc="$prefix" \
|
|
|
|
--without-javac \
|
|
|
|
--disable-dynamic-ssl-lib \
|
|
|
|
--enable-static-nifs \
|
|
|
|
CFLAGS="$CFLAGS -Wl,-L$prefix/lib" \
|
|
|
|
LIBS='-lcrypto -ldl'
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
if [ "$mode" = 'native' ]
|
2022-03-08 10:23:54 +01:00
|
|
|
then add_otp_path "$mode" "$prefix"
|
|
|
|
else unset erl_xcomp_sysroot
|
2022-02-22 00:10:22 +01:00
|
|
|
fi
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building Elixir $elixir_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
cd "$target_src_dir/$elixir_dir"
|
|
|
|
make install PREFIX="$prefix"
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
export PATH="$saved_path"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
#' Build the actual release.
|
|
|
|
build_rel()
|
|
|
|
{
|
|
|
|
local mode="$1"
|
|
|
|
local target="$2"
|
|
|
|
local prefix="$3"
|
|
|
|
local arch="$(arch_name "$target")"
|
2023-07-23 15:06:40 +02:00
|
|
|
local libc="${target##*-}"
|
2022-03-08 10:23:54 +01:00
|
|
|
local rel_dir="$PWD/_build/prod"
|
|
|
|
local target_data_dir="$prefix/$rel_name"
|
|
|
|
local target_dst_dir="$prefix/$rel_name-$rel_vsn"
|
2022-11-18 21:55:17 +01:00
|
|
|
local target_dst_tar="$rel_name-$rel_vsn-linux-$libc-$arch.tar.gz"
|
2022-03-08 10:23:54 +01:00
|
|
|
local saved_path="$PATH"
|
|
|
|
|
2023-10-03 17:56:27 +02:00
|
|
|
export PATH="$ct_prefix_dir/$target/bin:$PATH"
|
2022-03-08 10:23:54 +01:00
|
|
|
export CC="$target-gcc"
|
|
|
|
export CXX="$target-g++"
|
|
|
|
export CPP="$target-cpp"
|
|
|
|
export LD="$target-ld"
|
|
|
|
export AS="$target-as"
|
|
|
|
export AR="$target-ar"
|
|
|
|
export NM="$target-nm"
|
|
|
|
export RANLIB="$target-ranlib"
|
|
|
|
export OBJCOPY="$target-objcopy"
|
|
|
|
export STRIP="$target-strip"
|
|
|
|
export CPPFLAGS="-I$prefix/include"
|
|
|
|
export CFLAGS="-g0 -O2 -pipe -fomit-frame-pointer -static-libgcc $CPPFLAGS"
|
|
|
|
export CXXFLAGS="$CFLAGS -static-libstdc++"
|
|
|
|
export LDFLAGS="-L$prefix/lib -static-libgcc -static-libstdc++"
|
2023-03-13 17:57:55 +01:00
|
|
|
export ERL_COMPILER_OPTIONS='[no_debug_info]' # Building 25.x fails with 'deterministic'.
|
2022-03-08 10:23:54 +01:00
|
|
|
|
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then configure="./configure --host=$target --build=$platform"
|
|
|
|
else configure='./configure'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $have_current_deps = false ]
|
2023-07-23 15:06:40 +02:00
|
|
|
then build_deps "$mode" "$target" "$prefix"
|
2022-03-08 10:23:54 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
add_otp_path "$mode" "$prefix"
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
if [ "$mode" = 'native' ] # In order to only do this once.
|
|
|
|
then
|
|
|
|
info "Fetching Mix dependencies"
|
|
|
|
mix local.hex --force
|
|
|
|
mix local.rebar --force
|
|
|
|
fi
|
|
|
|
|
|
|
|
info "Removing old $rel_name builds"
|
|
|
|
rm -rf '_build' 'deps'
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Building $rel_name $rel_vsn for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
./autogen.sh
|
2022-05-25 20:37:37 +02:00
|
|
|
eimp_cflags='-fcommon'
|
2022-02-22 00:10:22 +01:00
|
|
|
eimp_libs='-lwebp -ljpeg -lpng -lz -lm'
|
|
|
|
export CC="$CC -Wl,-ldl" # Required by (statically linking) epam.
|
|
|
|
export LIBS="$eimp_libs -lcrypto -lpthread -ldl"
|
2022-05-25 20:37:37 +02:00
|
|
|
export CFLAGS="$CFLAGS $eimp_cflags"
|
2022-02-22 00:10:22 +01:00
|
|
|
export LDFLAGS="$LDFLAGS $eimp_libs"
|
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then
|
|
|
|
# Hand over --host/--build to configure scripts of dependencies.
|
|
|
|
export host_alias="$target"
|
|
|
|
export build_alias="$platform"
|
|
|
|
fi
|
|
|
|
# The cache variable makes cross compilation work.
|
|
|
|
ac_cv_erlang_root_dir="$prefix/lib/erlang" $configure \
|
|
|
|
--with-rebar='mix' \
|
|
|
|
--with-sqlite3="$prefix" \
|
|
|
|
--enable-user="$rel_name" \
|
|
|
|
--enable-all \
|
|
|
|
--disable-erlang-version-check
|
|
|
|
make deps
|
2022-05-28 10:21:43 +02:00
|
|
|
sed -i 's/ *-lstdc++//g' 'deps/'*'/rebar.config'* # Link statically.
|
2022-02-22 00:10:22 +01:00
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then
|
|
|
|
ln -s "$prefix/lib/erlang" 'lib/erlang'
|
|
|
|
erts_dir=$(ls -1d 'lib/erlang/erts-'*)
|
|
|
|
ei_inc="$prefix/lib/erlang/lib/erl_interface-"*'/include'
|
|
|
|
ei_lib="$prefix/lib/erlang/lib/erl_interface-"*'/lib'
|
|
|
|
export LDLIBS='-lpthread'
|
|
|
|
export ERL_EI_INCLUDE_DIR=$(ls -1d $ei_inc)
|
|
|
|
export ERL_EI_LIBDIR=$(ls -1d $ei_lib)
|
|
|
|
sed -i "/include_executables/a\\
|
|
|
|
include_erts: \"$erts_dir\"," 'mix.exs'
|
|
|
|
fi
|
|
|
|
make rel
|
|
|
|
if [ "$mode" = 'cross' ]
|
|
|
|
then
|
|
|
|
sed -i '/include_erts/d' 'mix.exs'
|
|
|
|
rm 'lib/erlang'
|
|
|
|
unset LDLIBS ERL_EI_INCLUDE_DIR ERL_EI_LIBDIR
|
|
|
|
unset host_alias build_alias
|
|
|
|
fi
|
|
|
|
|
2022-11-18 21:55:17 +01:00
|
|
|
info "Putting together $rel_name $rel_vsn archive for $arch-$libc ..."
|
2022-02-22 00:10:22 +01:00
|
|
|
mkdir "$target_dst_dir"
|
|
|
|
tar -C "$target_dst_dir" -xzf "$rel_dir/$rel_tar"
|
2022-03-08 10:23:54 +01:00
|
|
|
create_data_dir "$target_dst_dir" "$target_data_dir"
|
2022-02-22 00:10:22 +01:00
|
|
|
add_systemd_unit "$target_dst_dir"
|
2022-05-28 15:00:25 +02:00
|
|
|
add_captcha_script "$target_dst_dir"
|
2022-02-22 00:10:22 +01:00
|
|
|
edit_ejabberdctl "$target_dst_dir"
|
|
|
|
remove_unused_files "$target_dst_dir"
|
|
|
|
strip_files "$target_dst_dir" "$STRIP"
|
|
|
|
tar -C "$prefix" --owner="$rel_name" --group="$rel_name" -cf - \
|
|
|
|
"$rel_name" "$rel_name-$rel_vsn" | gzip -9 >"$target_dst_tar"
|
2022-03-08 10:23:54 +01:00
|
|
|
rm -rf "$target_dst_dir" "$target_data_dir"
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
info "Created $target_dst_tar successfully."
|
|
|
|
|
|
|
|
unset CC CXX CPP LD AS AR NM RANLIB OBJCOPY STRIP
|
|
|
|
unset CFLAGS CXXFLAGS LDFLAGS LIBS ERL_COMPILER_OPTIONS
|
|
|
|
export PATH="$saved_path"
|
|
|
|
}
|
|
|
|
#.
|
|
|
|
|
|
|
|
if [ "${CHECK_DEPS:-true}" = 'true' ]
|
|
|
|
then
|
|
|
|
if have_browser
|
|
|
|
then
|
2022-03-08 10:23:54 +01:00
|
|
|
check_configured_dep_vsns
|
2022-02-22 00:10:22 +01:00
|
|
|
else
|
|
|
|
error 'Cannot check dependency versions.'
|
|
|
|
error 'Install a browser or set CHECK_DEPS=false'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
info "Won't check dependency versions."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! mkdir -p "$root_dir"
|
|
|
|
then
|
|
|
|
error 'Set BUILD_DIR to a usable build directory path.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
check_built_dep_vsns
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
info 'Removing old bootstrap tools ...'
|
|
|
|
rm -rf "$bootstrap_dir"
|
|
|
|
mkdir "$bootstrap_dir"
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
if [ $have_current_deps = true ]
|
|
|
|
then
|
|
|
|
info 'Dependencies are up-to-date ...'
|
|
|
|
else
|
|
|
|
# Keep existing toolchains but rebuild everything else.
|
|
|
|
info 'Removing old builds ...'
|
|
|
|
rm -rf "$build_dir"
|
|
|
|
mkdir "$build_dir"
|
|
|
|
|
|
|
|
info 'Removing old source ...'
|
|
|
|
rm -rf "$src_dir"
|
|
|
|
mkdir "$src_dir"
|
|
|
|
|
|
|
|
info 'Downloading dependencies ...'
|
|
|
|
cd "$src_dir"
|
2023-09-29 17:33:09 +02:00
|
|
|
curl -fsSLO "https://github.com/crosstool-ng/crosstool-ng/releases/download/$crosstool_dir/$crosstool_tar"
|
|
|
|
curl -fsSLO "https://ftp.gnu.org/gnu/termcap/$termcap_tar"
|
|
|
|
curl -fsSLO "https://github.com/libexpat/libexpat/releases/download/R_$(printf '%s' "$expat_vsn" | sed 's/\./_/g')/$expat_tar"
|
|
|
|
curl -fsSLO "https://zlib.net/fossils/$zlib_tar"
|
|
|
|
curl -fsSLO "https://pyyaml.org/download/libyaml/$yaml_tar"
|
|
|
|
curl -fsSLO "https://www.openssl.org/source/$ssl_tar"
|
|
|
|
curl -fsSLO "https://github.com/erlang/otp/releases/download/OTP-$otp_vsn/$otp_tar"
|
|
|
|
curl -fsSLO "https://github.com/elixir-lang/elixir/archive/v$elixir_vsn.tar.gz"
|
|
|
|
curl -fsSLO "https://github.com/linux-pam/linux-pam/releases/download/v$pam_vsn/$pam_tar"
|
|
|
|
curl -fsSLO "https://download.sourceforge.net/libpng/$png_tar"
|
|
|
|
curl -fsSLO "https://www.ijg.org/files/$jpeg_tar"
|
|
|
|
curl -fsSLO "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/$webp_tar"
|
|
|
|
curl -fsSLO "https://github.com/libgd/libgd/releases/download/gd-$gd_vsn/$gd_tar"
|
|
|
|
curl -fsSLO "http://www.unixodbc.org/$odbc_tar"
|
|
|
|
curl -fsSLO "https://www.sqlite.org/$(date '+%Y')/$sqlite_tar" \
|
|
|
|
|| curl -fsSLO "https://www.sqlite.org/$(date -d '1 year ago' '+%Y')/$sqlite_tar" \
|
|
|
|
|| curl -fsSLO "https://www.sqlite.org/$(date -d '2 years ago' '+%Y')/$sqlite_tar"
|
2022-03-08 10:23:54 +01:00
|
|
|
cd "$OLDPWD"
|
|
|
|
fi
|
2022-02-22 00:10:22 +01:00
|
|
|
|
|
|
|
mkdir "$bootstrap_dir/bin"
|
|
|
|
export PATH="$bootstrap_dir/bin:$PATH" # For ct-ng.
|
|
|
|
export LC_ALL='C.UTF-8' # Elixir insists on a UTF-8 environment.
|
|
|
|
|
|
|
|
for target in $targets
|
|
|
|
do
|
2023-07-23 15:06:40 +02:00
|
|
|
prefix="$build_dir/$target"
|
2022-02-22 00:10:22 +01:00
|
|
|
toolchain_dir="$ct_prefix_dir/$target"
|
|
|
|
|
2023-07-23 15:06:40 +02:00
|
|
|
if [ "$platform" = "$target" ]
|
2022-02-22 00:10:22 +01:00
|
|
|
then mode='native'
|
|
|
|
else mode='cross'
|
|
|
|
fi
|
2023-07-23 15:06:40 +02:00
|
|
|
build_toolchain "$target" "$toolchain_dir"
|
|
|
|
build_rel "$mode" "$target" "$prefix"
|
2022-02-22 00:10:22 +01:00
|
|
|
done
|
|
|
|
|
2022-03-08 10:23:54 +01:00
|
|
|
save_built_dep_vsns
|
|
|
|
|
2022-02-22 00:10:22 +01:00
|
|
|
info "Build started: $build_start"
|
|
|
|
info "Build ended: $(date '+%F %T')"
|
|
|
|
|
|
|
|
# vim:set foldmarker=#',#. foldmethod=marker:
|