From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- packaging/macos/jhb/etc/jhb.conf.sh | 53 ++ packaging/macos/jhb/etc/jhb.conf/10.sh | 1 + packaging/macos/jhb/etc/jhb.conf/20.sh | 1 + packaging/macos/jhb/etc/jhb.conf/30.sh | 1 + packaging/macos/jhb/etc/jhb.conf/README.md | 12 + packaging/macos/jhb/etc/jhb.conf/bash_d.sh | 30 + packaging/macos/jhb/etc/jhb.conf/ccache.sh | 49 ++ packaging/macos/jhb/etc/jhb.conf/ci.sh | 42 ++ packaging/macos/jhb/etc/jhb.conf/directories.sh | 83 +++ packaging/macos/jhb/etc/jhb.conf/dmgbuild.sh | 96 ++++ packaging/macos/jhb/etc/jhb.conf/home.sh | 24 + packaging/macos/jhb/etc/jhb.conf/jhbuild.sh | 229 ++++++++ packaging/macos/jhb/etc/jhb.conf/path.sh | 23 + packaging/macos/jhb/etc/jhb.conf/pip.sh | 26 + packaging/macos/jhb/etc/jhb.conf/release.sh | 35 ++ packaging/macos/jhb/etc/jhb.conf/sdkroot.sh | 41 ++ packaging/macos/jhb/etc/jhb.conf/sys.sh | 121 ++++ packaging/macos/jhb/etc/jhb.conf/temp.sh | 27 + packaging/macos/jhb/etc/jhb.conf/version.sh | 24 + packaging/macos/jhb/etc/jhb.conf/xdg.sh | 25 + packaging/macos/jhb/etc/jhbuildrc | 613 +++++++++++++++++++++ .../macos/jhb/etc/modulesets/jhb/bootstrap.modules | 158 ++++++ packaging/macos/jhb/etc/modulesets/jhb/jhb.modules | 60 ++ .../macos/jhb/etc/modulesets/jhb/moduleset.dtd | 240 ++++++++ .../macos/jhb/etc/modulesets/jhb/moduleset.xsl | 196 +++++++ .../jhb/patches/libtool-apple-sort.patch | 38 ++ .../etc/modulesets/jhb/patches/vasnprintf.patch | 11 + 27 files changed, 2259 insertions(+) create mode 100644 packaging/macos/jhb/etc/jhb.conf.sh create mode 120000 packaging/macos/jhb/etc/jhb.conf/10.sh create mode 120000 packaging/macos/jhb/etc/jhb.conf/20.sh create mode 120000 packaging/macos/jhb/etc/jhb.conf/30.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/README.md create mode 100644 packaging/macos/jhb/etc/jhb.conf/bash_d.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/ccache.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/ci.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/directories.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/dmgbuild.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/home.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/jhbuild.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/path.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/pip.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/release.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/sdkroot.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/sys.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/temp.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/version.sh create mode 100644 packaging/macos/jhb/etc/jhb.conf/xdg.sh create mode 100644 packaging/macos/jhb/etc/jhbuildrc create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/bootstrap.modules create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/jhb.modules create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/moduleset.dtd create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/moduleset.xsl create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/patches/libtool-apple-sort.patch create mode 100644 packaging/macos/jhb/etc/modulesets/jhb/patches/vasnprintf.patch (limited to 'packaging/macos/jhb/etc') diff --git a/packaging/macos/jhb/etc/jhb.conf.sh b/packaging/macos/jhb/etc/jhb.conf.sh new file mode 100644 index 0000000..398e9d3 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf.sh @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2022 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# This is a convenience wrapper to source all individual configuration files. +# It also takes care of placing a custom configuration file in the appropriate +# location. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### dependencies ############################################################### + +SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1; pwd) + +CUSTOM_CONFIG=$SELF_DIR/jhb-custom.conf.sh +# copy a custom configuration file to the appropriate place +if [[ $1 == *.conf.sh ]] && [ -f "$1" ]; then + cp "$1" "$CUSTOM_CONFIG" +fi + +# source a custom configuration file if present +if [ -f "$CUSTOM_CONFIG" ]; then + # shellcheck disable=SC1090 # file is optional + source "$CUSTOM_CONFIG" +fi +unset CUSTOM_CONFIG + +# source items from jhb.conf directory +for CONFIG_ITEM in $(\ + "$SELF_DIR"/../usr/bin/run-parts list "$SELF_DIR"/jhb.conf/'*.sh' \ + ); do + # shellcheck disable=SC1090 # can't point to a single source here + source "$CONFIG_ITEM" +done +unset CONFIG_ITEM + +unset SELF_DIR + +### variables ################################################################## + +# Nothing here. + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/10.sh b/packaging/macos/jhb/etc/jhb.conf/10.sh new file mode 120000 index 0000000..b7ae2b7 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/10.sh @@ -0,0 +1 @@ +version.sh \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/20.sh b/packaging/macos/jhb/etc/jhb.conf/20.sh new file mode 120000 index 0000000..96f9d20 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/20.sh @@ -0,0 +1 @@ +ci.sh \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/30.sh b/packaging/macos/jhb/etc/jhb.conf/30.sh new file mode 120000 index 0000000..c1d5631 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/30.sh @@ -0,0 +1 @@ +directories.sh \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/README.md b/packaging/macos/jhb/etc/jhb.conf/README.md new file mode 100644 index 0000000..c79b3ad --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/README.md @@ -0,0 +1,12 @@ +# JHB configuration + +Files in here are being sourced by `../../usr/bin/run-parts` + +- in their lexical order _and_ +- only once in case a symlink exists. + +This way we don't have to prefix the filenames themselves to influnce the order of inclusion (a "poor man's dependency management"). + +The filename is also the prefix for any variable or function name within. + +A file is not allowed to depend on any function or variable outside this directory, with the exception of functions included from `bash_d.sh`. diff --git a/packaging/macos/jhb/etc/jhb.conf/bash_d.sh b/packaging/macos/jhb/etc/jhb.conf/bash_d.sh new file mode 100644 index 0000000..5ab11b2 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/bash_d.sh @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2022 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Enable bash_d usage by providing bash_d_include function. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### dependencies ############################################################### + +# shellcheck source=../../usr/src/bash_d/bash_d.sh +source "$(dirname "${BASH_SOURCE[0]}")"/../../usr/src/bash_d/bash_d.sh + +bash_d_include echo + +### variables ################################################################## + +# Nothing here. + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/ccache.sh b/packaging/macos/jhb/etc/jhb.conf/ccache.sh new file mode 100644 index 0000000..82a2208 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/ccache.sh @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2022 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Settings and functions to setup ccache. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### variables ################################################################## + +export CCACHE_DIR=${CCACHE_DIR:-$WRK_DIR/ccache} + +# https://ccache.dev +# https://github.com/ccache/ccache +# https://gitlab.com/dehesselle/ccache_macos +CCACHE_VER=4.6.3r1 +CCACHE_URL=https://gitlab.com/api/v4/projects/29039216/packages/generic/\ +ccache_macos/$CCACHE_VER/ccache_$(uname -m).tar.xz + +### functions ################################################################## + +function ccache_configure +{ + mkdir -p "$CCACHE_DIR" + + cat < "$CCACHE_DIR/ccache.conf" +base_dir = $WRK_DIR +hash_dir = false +max_size = 3.0G +temporary_dir = $CCACHE_DIR/tmp +EOF +} + +function ccache_install +{ + curl -L "$CCACHE_URL" | tar -C "$USR_DIR"/bin --exclude="ccache.sha256" -xJ + + for compiler in clang clang++ gcc g++; do + ln -sf ccache "$USR_DIR"/bin/$compiler + done +} + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/ci.sh b/packaging/macos/jhb/etc/jhb.conf/ci.sh new file mode 100644 index 0000000..727cb2a --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/ci.sh @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# check if running in CI (GitHub or GitLab) + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +if [ -z "$CI" ]; then # both GitHub and GitLab set this + CI=false + CI_GITHUB=false + CI_GITLAB=false +else + CI=true + + if [ -z "$CI_PROJECT_NAME" ]; then # this is a GitLab-only variable + CI_GITHUB=true + CI_GITLAB=false + else + CI_GITHUB=false + CI_GITLAB=true + + # Since GitLab uses colors in their CI there's no need to disable ours. + # shellcheck disable=SC2034 # this is a bash_d setting + ANSI_TERM_ONLY=false # use ANSI control characters even if not in terminal + fi +fi + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/directories.sh b/packaging/macos/jhb/etc/jhb.conf/directories.sh new file mode 100644 index 0000000..4119456 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/directories.sh @@ -0,0 +1,83 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# FSH-inspired directory layout + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +#--------------------------------------------------------- main directory layout + +# WRK_DIR (/Users/Shared/work) +# ┃ +# ┣━━ REP_DIR (repo) +# ┃ +# ┗━━ VER_DIR (jhb-$VERSION) +# ┃ +# ┣━━ BIN_DIR (bin) +# ┣━━ ETC_DIR (etc) +# ┣━━ INC_DIR (include) +# ┣━━ LIB_DIR (lib) +# ┣━━ OPT_DIR (opt) +# ┃ +# ┣━━ TMP_DIR (tmp) +# ┃ +# ┣━━ USR_DIR (usr) +# ┃ ┗━━ SRC_DIR (src) +# ┃ +# ┗━━ VAR_DIR (var) +# ┣━━ BLD_DIR (build) +# ┗━━ PKG_DIR (cache/pkg) +# +# You can either override a variable directly or use a corresponding +# "*_TEMPLATE" variable if you want to reference other variables, e.g. +# +# VER_DIR_TEMPLATE="\$WRK_DIR/myFoo-\$VERSION" + +WRK_DIR=$(eval echo "${WRK_DIR:-${WRK_DIR_TEMPLATE:-/Users/Shared/work}}") + +REP_DIR=$(eval echo "${REP_DIR:-${REP_DIR_TEMPLATE:-$WRK_DIR/repo}}") + +VER_DIR=$(eval echo "${VER_DIR:-${VER_DIR_TEMPLATE:-$WRK_DIR/jhb-$VERSION}}") + +BIN_DIR=$(eval echo "${BIN_DIR:-${BIN_DIR_TEMPLATE:-$VER_DIR/bin}}") +ETC_DIR=$(eval echo "${ETC_DIR:-${ETC_DIR_TEMPLATE:-$VER_DIR/etc}}") +INC_DIR=$(eval echo "${INC_DIR:-${INC_DIR_TEMPLATE:-$VER_DIR/include}}") +LIB_DIR=$(eval echo "${LIB_DIR:-${LIB_DIR_TEMPLATE:-$VER_DIR/lib}}") +OPT_DIR=$(eval echo "${OPT_DIR:-${OPT_DIR_TEMPLATE:-$VER_DIR/opt}}") + +USR_DIR=$(eval echo "${USR_DIR:-${USR_DIR_TEMPLATE:-$VER_DIR/usr}}") +SRC_DIR=$(eval echo "${SRC_DIR:-${SRC_DIR_TEMPLATE:-$USR_DIR/src}}") + +TMP_DIR=$(eval echo "${TMP_DIR:-${TMP_DIR_TEMPLATE:-$VER_DIR/tmp}}") + +VAR_DIR=$(eval echo "${VAR_DIR:-${VAR_DIR_TEMPLATE:-$VER_DIR/var}}") +BLD_DIR=$(eval echo "${BLD_DIR:-${BLD_DIR_TEMPLATE:-$VAR_DIR/build}}") +PKG_DIR=$(eval echo "${PKG_DIR:-${PKG_DIR_TEMPLATE:-$VAR_DIR/cache/pkg}}") + +#------------------------------------------------------------ artifact directory + +if [ -z "$ARTIFACT_DIR" ]; then + if $CI_GITHUB; then + ARTIFACT_DIR=$GITHUB_WORKSPACE + elif $CI_GITLAB; then + ARTIFACT_DIR=$CI_PROJECT_DIR + else + ARTIFACT_DIR=$VER_DIR + fi +fi + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/dmgbuild.sh b/packaging/macos/jhb/etc/jhb.conf/dmgbuild.sh new file mode 100644 index 0000000..d957703 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/dmgbuild.sh @@ -0,0 +1,96 @@ +# SPDX-FileCopyrightText: 2022 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# dmgbuild is a Python package that simplifies the process of creating a +# disk image (dmg) for distribution. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### dependencies ############################################################### + +# Nothing here. + +### variables ################################################################## + +# https://dmgbuild.readthedocs.io/en/latest/ +# https://github.com/al45tair/dmgbuild +# including optional dependencies: +# - biplist: binary plist parser/generator +# - pyobjc-*: framework wrappers +DMGBUILD_PIP="\ + biplist==1.0.3\ + dmgbuild==1.5.2\ + ds-store==1.3.0\ + mac-alias==2.2.0\ + pyobjc-core==8.5.1\ + pyobjc-framework-Cocoa==8.5.1\ + pyobjc-framework-Quartz==8.5.1\ +" + +### functions ################################################################## + +function dmgbuild_install +{ + # shellcheck disable=SC2086 # we need word splitting here + jhb run $JHBUILD_PYTHON_PIP install --prefix=$USR_DIR wheel $DMGBUILD_PIP + + # dmgbuild has issues with detaching, workaround is to increase max retries + gsed -i '$ s/HiDPI)/HiDPI, detach_retries=15)/g' "$USR_DIR"/bin/dmgbuild +} + +function dmgbuild_run +{ + local config=$1 + local plist=$2 + local dmg=$3 # optional; default is ___.dmg + + local app_dir + app_dir=$(echo "$ARTIFACT_DIR"/*.app) + + if [ -z "$dmg" ]; then + local version + version=$(/usr/libexec/PlistBuddy \ + -c "Print :CFBundleShortVersionString" "$plist") + local build + build=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$plist") + + dmg=$(basename -s .app "$app_dir")_${version}+${build}_$(uname -m).dmg + fi + + # Copy templated version of the file (it contains placeholders) to source + # directory. They copy will be modified to contain the actual values. + cp "$config" "$SRC_DIR" + config=$SRC_DIR/$(basename "$config") + + # set application + gsed -i "s|PLACEHOLDERAPPLICATION|$app_dir|" "$config" + + # set disk image icon (if it exists) + local icon + icon=$SRC_DIR/$(basename -s .py "$config").icns + if [ -f "$icon" ]; then + gsed -i "s|PLACEHOLDERICON|$icon|" "$config" + fi + + # set background image (if it exists) + local background + background=$SRC_DIR/$(basename -s .py "$config").png + if [ -f "$background" ]; then + gsed -i "s|PLACEHOLDERBACKGROUND|$background|" "$config" + fi + + # Create disk image in temporary location and move to target location + # afterwards. This way we can run multiple times without requiring cleanup. + dmgbuild -s "$config" "$(basename -s .app "$app_dir")" \ + "$TMP_DIR"/"$(basename "$dmg")" + mv "$TMP_DIR"/"$(basename "$dmg")" "$dmg" +} + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/home.sh b/packaging/macos/jhb/etc/jhb.conf/home.sh new file mode 100644 index 0000000..31bf892 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/home.sh @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Redirect user's home directory. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +export HOME=$VER_DIR/home + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/jhbuild.sh b/packaging/macos/jhb/etc/jhb.conf/jhbuild.sh new file mode 100644 index 0000000..31df78c --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/jhbuild.sh @@ -0,0 +1,229 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# This file contains functions to download, install and configure JHBuild. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### dependencies ############################################################### + +# Nothing here. + +### variables ################################################################## + +export JHBUILDRC=$ETC_DIR/jhbuildrc +export JHBUILDRC_CUSTOM=$JHBUILDRC-custom + +JHBUILD_REQUIREMENTS="\ + certifi==2022.9.24\ + meson==0.59.2\ + ninja==1.10.2.3\ +" + +# JHBuild build system >3.38.0 (current master as of 08.03.2022) +# The last stable release (3.38.0) is missing a critical fix (commit +# a896cbf404461cab979fa3cd1c83ddf158efe83b) so we have to stay on master branch +# for the time being. +# https://gitlab.gnome.org/GNOME/jhbuild +# https://wiki.gnome.org/Projects/Jhbuild/Introduction +JHBUILD_VER=d1c5316 +JHBUILD_URL=https://gitlab.gnome.org/GNOME/jhbuild/-/archive/$JHBUILD_VER/\ +jhbuild-$JHBUILD_VER.tar.bz2 + +# A dedicated Python runtime (only) for JHBuild. It is installed and kept +# separately from the rest of the system. It won't interfere with a Python +# that might get installed as part of building modules with JHBuild. +JHBUILD_PYTHON_VER_MAJOR=3 +JHBUILD_PYTHON_VER_MINOR=8 +JHBUILD_PYTHON_VER=$JHBUILD_PYTHON_VER_MAJOR.$JHBUILD_PYTHON_VER_MINOR +JHBUILD_PYTHON_URL="https://gitlab.com/api/v4/projects/26780227/packages/\ +generic/python_macos/15/python_${JHBUILD_PYTHON_VER/./}_$(uname -m).tar.xz" +JHBUILD_PYTHON_DIR=$OPT_DIR/Python.framework/Versions/$JHBUILD_PYTHON_VER +JHBUILD_PYTHON_BIN_DIR=$JHBUILD_PYTHON_DIR/bin + +export JHBUILD_PYTHON_BIN=$JHBUILD_PYTHON_BIN_DIR/python$JHBUILD_PYTHON_VER +export JHBUILD_PYTHON_PIP=$JHBUILD_PYTHON_BIN_DIR/pip$JHBUILD_PYTHON_VER + +### functions ################################################################## + +function jhbuild_install_python +{ + # Download and extract Python.framework to OPT_DIR. + curl -L "$JHBUILD_PYTHON_URL" | tar -C "$OPT_DIR" -x + + # Create a pkg-config configuration to match our installation location. + # Note: sed changes the prefix and exec_prefix lines! + find "$JHBUILD_PYTHON_DIR"/lib/pkgconfig/*.pc \ + -type f \ + -exec sed -i "" "s|prefix=.*|prefix=$JHBUILD_PYTHON_DIR|" {} \; + + jhbuild_set_python_interpreter + + # add to PYTHONPATH + echo "../../../../../../../usr/lib/python$JHBUILD_PYTHON_VER/site-packages"\ + > "$OPT_DIR"/Python.framework/Versions/$JHBUILD_PYTHON_VER/lib/\ +python$JHBUILD_PYTHON_VER/site-packages/jhb.pth +} + +function jhbuild_set_python_interpreter +{ + # Symlink binaries to USR_DIR/bin. + if command -v gln 1>/dev/null; then + local gnu=g # necessary for union mount + fi + ${gnu}ln -sf "$JHBUILD_PYTHON_BIN" "$USR_DIR"/bin + ${gnu}ln -sf "$JHBUILD_PYTHON_PIP" "$USR_DIR"/bin + + # Set interpreter to the one in USR_DIR/bin. + while IFS= read -r -d '' file; do + local file_type + file_type=$(file "$file") + if [[ $file_type = *"Python script"* ]]; then + sed -i "" "1 s|.*|#!$USR_DIR/bin/python$JHBUILD_PYTHON_VER|" "$file" + fi + done < <(find "$USR_DIR"/bin/ -maxdepth 1 -type f -print0) +} + +function jhbuild_install +{ + # We use our own custom Python. + jhbuild_install_python + + # Install dependencies. + # shellcheck disable=SC2086 # we need word splitting for requirements + $JHBUILD_PYTHON_PIP install --prefix=$USR_DIR $JHBUILD_REQUIREMENTS + + function pem_remove_expired + { + local pem_bundle=$1 + + # BSD's csplit does not support '{*}' (it's a GNU extension) + csplit -n 3 -k -f "$TMP_DIR"/pem- "$pem_bundle" \ + '/END CERTIFICATE/+1' '{999}' >/dev/null 2>&1 || true + + for pem in "$TMP_DIR"/pem-*; do + if [ "$(stat -f%z "$pem")" -eq 0 ]; then + rm "$pem" # the csplit command above created one superfluous empty file + elif ! openssl x509 -checkend 0 -noout -in "$pem"; then + echo_d "removing $pem: $(openssl x509 -enddate -noout -in "$pem")" + rm "$pem" + fi + done + + cat "$TMP_DIR"/pem-??? > "$pem_bundle" + } + + local cacert="$USR_DIR"/lib/python$JHBUILD_PYTHON_VER/site-packages/certifi/\ +cacert.pem + + pem_remove_expired "$cacert" + + # Download JHBuild. Setting CURL_CA_BUNDLE is required on older macOS, e.g. + # High Sierra. + local archive + archive=$PKG_DIR/$(basename $JHBUILD_URL) + CURL_CA_BUNDLE=$cacert curl -o "$archive" -L "$JHBUILD_URL" + tar -C "$SRC_DIR" -xf "$archive" + + ( # Install JHBuild. + cd "$SRC_DIR"/jhbuild-$JHBUILD_VER || exit 1 + ./autogen.sh \ + --prefix="$USR_DIR" \ + --with-python="$JHBUILD_PYTHON_BIN" + make + make install + ) +} + +function jhbuild_configure +{ + local moduleset=$1 + + moduleset=${moduleset:-jhb.modules} + local suffix + suffix=$(basename -s .modules "$moduleset") + + # install custom moduleset + if [ "$suffix" != "jhb" ]; then + local moduleset_dir + moduleset_dir=$(dirname "$(greadlink -f "$moduleset")") + rsync -a --delete "$moduleset_dir"/ "$ETC_DIR/modulesets/$suffix/" + fi + + local target + target=$(/usr/libexec/PlistBuddy -c "Print \ + :DefaultProperties:MACOSX_DEPLOYMENT_TARGET" "$SDKROOT"/SDKSettings.plist) + + # create custom jhbuildrc configuration + { + echo "# -*- mode: python -*-" + + # moduleset + echo "modulesets_dir = '$ETC_DIR/modulesets/$suffix'" + echo "moduleset = '$(basename "$moduleset")'" + echo "use_local_modulesets = True" + + # basic directory layout + echo "buildroot = '$BLD_DIR'" + echo "checkoutroot = '$SRC_DIR'" + echo "prefix = '$VER_DIR'" + echo "tarballdir = '$PKG_DIR'" + echo "top_builddir = '$VAR_DIR/jhbuild'" + + # setup macOS SDK + echo "setup_sdk(target=\"$target\")" + + # set release build + echo "setup_release()" + + # Use compiler binaries from our own USR_DIR/bin if present, the intention + # being that these are symlinks pointing to ccache if that has been + # installed (see ccache.sh for details). + if [ -x "$USR_DIR/bin/gcc" ]; then + echo "os.environ[\"CC\"] = \"$USR_DIR/bin/gcc\"" + echo "os.environ[\"OBJC\"] = \"$USR_DIR/bin/gcc\"" + fi + if [ -x "$USR_DIR/bin/g++" ]; then + echo "os.environ[\"CXX\"] = \"$USR_DIR/bin/g++\"" + fi + + # certificates for https + echo "os.environ[\"SSL_CERT_FILE\"] = \ + \"$USR_DIR/lib/python$JHBUILD_PYTHON_VER/site-packages/certifi/cacert.pem\"" + echo "os.environ[\"REQUESTS_CA_BUNDLE\"] = \ + \"$USR_DIR/lib/python$JHBUILD_PYTHON_VER/site-packages/certifi/cacert.pem\"" + + # user home directory + echo "os.environ[\"HOME\"] = \"$HOME\"" + + # less noise on the terminal if not CI + if ! $CI; then + echo "quiet_mode = True" + echo "progress_bar = True" + fi + + # add moduleset-specific settings if exist + local moduleset_rc=$ETC_DIR/modulesets/$suffix/jhbuildrc + if [ -f "$moduleset_rc" ]; then + cat "$moduleset_rc" + fi + + } > "$JHBUILDRC-$suffix" + + if command -v gln 1>/dev/null; then + local gnu=g # necessary for union mount + fi + ${gnu}ln -sf "$(basename "$JHBUILDRC-$suffix")" "$JHBUILDRC_CUSTOM" + + # Update the paths to Python. + jhbuild_set_python_interpreter +} + +### main ####################################################################### + +# Nothing here. \ No newline at end of file diff --git a/packaging/macos/jhb/etc/jhb.conf/path.sh b/packaging/macos/jhb/etc/jhb.conf/path.sh new file mode 100644 index 0000000..07e7adc --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/path.sh @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Set PATH. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced + +### variables ################################################################## + +export PATH=$BIN_DIR:$USR_DIR/bin:/usr/bin:/bin:/usr/sbin:/sbin + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/pip.sh b/packaging/macos/jhb/etc/jhb.conf/pip.sh new file mode 100644 index 0000000..5804468 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/pip.sh @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Redirect pip cache directories. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +export PIP_CACHE_DIR=$VAR_DIR/cache/pip # instead ~/Library/Caches/pip +export PIPENV_CACHE_DIR=$VAR_DIR/cache/pipenv # instead ~/Library/Caches/pipenv +export PYTHONPYCACHEPREFIX=$VAR_DIR/cache/pycache + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/release.sh b/packaging/macos/jhb/etc/jhb.conf/release.sh new file mode 100644 index 0000000..6fe8708 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/release.sh @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: 2022 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Release artifact. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +RELEASE_ARCHIVE=${RELEASE_ARCHIVE:-$(basename "$VER_DIR")_$(uname -m).tar.xz} + +# GitHub and GitLab +# shellcheck disable=2206 # we need expansion for the array to work +RELEASE_URLS=(${RELEASE_URLS[@]:- + "https://github.com/dehesselle/jhb/releases/download/\ +v$VERSION/$RELEASE_ARCHIVE" + "https://gitlab.com/api/v4/projects/35965804/packages/generic/jhb/\ +$VERSION/$RELEASE_ARCHIVE" +}) + +RELEASE_OVERLAY=overlay + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/sdkroot.sh b/packaging/macos/jhb/etc/jhb.conf/sdkroot.sh new file mode 100644 index 0000000..deda692 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/sdkroot.sh @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# If SDKROOT is set, use that. If it is not set, use whatever SDK is available. +# This might still end up being invalid if neither Xcode nor CLT have been +# installed, and that's what sdkroot_exists is for. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +if [ -z "$SDKROOT" ]; then + if xcodebuild --help 2>/dev/null; then + SDKROOT=$(xcodebuild -version -sdk macosx Path) + else + SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk + fi +fi +export SDKROOT + +### functions ################################################################## + +function sdkroot_exists +{ + if [ -d "$SDKROOT" ]; then + return 0 # SDK found + else + echo_e "SDK not found: $SDKROOT" + return 1 + fi +} + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/sys.sh b/packaging/macos/jhb/etc/jhb.conf/sys.sh new file mode 100644 index 0000000..1871b21 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/sys.sh @@ -0,0 +1,121 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# System and version checks. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### dependencies ############################################################### + +# Nothing here. + +### variables ################################################################## + +SYS_ARCH=$(uname -m | tr '[:lower:]' '[:upper:]') + +if [ "$SYS_USRLOCAL_IGNORE" != "true" ]; then + SYS_USRLOCAL_IGNORE=false +fi + +SYS_MACOS_VER=$(sw_vers -productVersion) + +# descending order on purpose: most recent platform first +# shellcheck disable=2206 # we need expansion for the array to work +SYS_MACOS_VER_RECOMMENDED=(${SYS_MACOS_VER_RECOMMENDED:- + 12.6.1 + 12.6 + 11.7 +}) + +SYS_SDK_VER="$(/usr/libexec/PlistBuddy -c \ + "Print :DefaultProperties:MACOSX_DEPLOYMENT_TARGET" \ + "$SDKROOT"/SDKSettings.plist)" + +SYS_SDK_VER_RECOMMENDED_X86_64=${SYS_SDK_VER_RECOMMENDED_X86_64:-10.13} +SYS_SDK_VER_RECOMMENDED_ARM64=${SYS_SDK_VER_RECOMMENDED_ARM64:-11.3} +SYS_SDK_VER_RECOMMENDED=$(eval echo \$SYS_SDK_VER_RECOMMENDED_"$SYS_ARCH") + +### functions ################################################################## + +function sys_create_log +{ + # Create jhb.log file. + + mkdir -p "$VAR_DIR"/log + + for var in SYS_MACOS_VER SYS_SDK_VER VERSION VER_DIR WRK_DIR; do + echo "$var = $(eval echo \$$var)" >> "$VAR_DIR"/log/jhb.log + done +} + +function sys_macos_is_recommended +{ + for version in "${SYS_MACOS_VER_RECOMMENDED[@]}"; do + if [ "$version" = "$SYS_MACOS_VER" ]; then + return 0 + fi + done + + echo_w "using macOS $SYS_MACOS_VER (recommended: \ +${SYS_MACOS_VER_RECOMMENDED[0]})" + return 1 +} + +function sys_sdk_is_recommended +{ + if [ "$SYS_SDK_VER_RECOMMENDED" = "$SYS_SDK_VER" ]; then + return 0 + fi + + echo_w "using SDK $SYS_SDK_VER (recommended: $SYS_SDK_VER_RECOMMENDED)" + return 1 +} + +function sys_usrlocal_is_clean +{ + local count=0 + + # Based on GitHub CI experience, it appears to be enough to make sure + # the following folders do not contain files. + for dir in include lib share; do + count=$(( count + \ + $(find /usr/local/$dir -type f 2>/dev/null | wc -l | awk '{ print $1 }')\ + )) + done + + if [ "$count" -ne 0 ]; then + if $SYS_USRLOCAL_IGNORE; then + echo_w "Found files in '/usr/local/[include|lib|share]'." + else + echo_e "Found files in '/usr/local/[include|lib|share]'!" + echo_e "This is known to cause trouble, but you can downgrade this error" + echo_e "to a warning at your own risk:" + echo_e " " + echo_e " export SYS_USRLOCAL_IGNORE=true" + return 1 + fi + fi + + return 0 +} + +function sys_wrkdir_is_usable +{ + if mkdir -p "$WRK_DIR" 2>/dev/null && + [ -w "$WRK_DIR" ] ; then + return 0 # WRK_DIR has been created or was already there and is writable + else + echo_e "WRK_DIR not usable: $WRK_DIR" + return 1 + fi +} + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/temp.sh b/packaging/macos/jhb/etc/jhb.conf/temp.sh new file mode 100644 index 0000000..5de20a7 --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/temp.sh @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Redirect temporary locations. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +# shellcheck disable=SC2153 # this is no misspelling +export TMP=$TMP_DIR +export TEMP=$TMP_DIR +export TMPDIR=$TMP_DIR # TMPDIR is the common macOS default + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/version.sh b/packaging/macos/jhb/etc/jhb.conf/version.sh new file mode 100644 index 0000000..edd851b --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/version.sh @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# The main version number. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +VERSION=${VERSION:-0.22} + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhb.conf/xdg.sh b/packaging/macos/jhb/etc/jhb.conf/xdg.sh new file mode 100644 index 0000000..28a786e --- /dev/null +++ b/packaging/macos/jhb/etc/jhb.conf/xdg.sh @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2021 René de Hesselle +# +# SPDX-License-Identifier: GPL-2.0-or-later + +### description ################################################################ + +# Redirect some XDG directories. + +### shellcheck ################################################################# + +# shellcheck shell=bash # no shebang as this file is intended to be sourced +# shellcheck disable=SC2034 # we only use exports if we really need them + +### variables ################################################################## + +export XDG_CACHE_HOME=$VAR_DIR/cache # instead ~/.cache +export XDG_CONFIG_HOME=$ETC_DIR # instead ~/.config + +### functions ################################################################## + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/packaging/macos/jhb/etc/jhbuildrc b/packaging/macos/jhb/etc/jhbuildrc new file mode 100644 index 0000000..2e3fb6f --- /dev/null +++ b/packaging/macos/jhb/etc/jhbuildrc @@ -0,0 +1,613 @@ +# -*- mode: python -*- +# +# Copyright (C) 2006, 2007, 2008 Imendio AB +# Copyright 2009, 2010, 2011 John Ralls, Fremont, CA +# +# Default setup for building GTK+ on Mac OS X. Note that you should +# normally never need to edit this file. Any custom settings should be +# done in ~/.jhbuildrc-custom. +# +# Specific builds can be set up by creating files named +# ~/.jhbuildrc-. When setting the environment variable JHB to +# such a name, the corresponding rc file will be read (e.g.: +# JHB=mybuild jhbuild shell). +# +# Use .jhbuildrc-custom to override the moduleset, modules to build, +# the source checkout location, installation prefix, or svn usernames +# etc. +# +# Please email richard@imendio.com if you have suggestions for +# improving this setup, or have any patches that you would like to get +# included. + +import sys +import errno +import re + +#some variables we'll need defined later +_default_arch = "" +_osx_version = 0.0 +_target = '10.11' + +def _popen(cmd_arg): + from subprocess import Popen, PIPE + devnull = open('/dev/null') + cmd = Popen(cmd_arg, stdout=PIPE, stderr=devnull, shell=True) + retval = cmd.stdout.read().strip() + err = cmd.wait() + cmd.stdout.close() + devnull.close() + if err: + raise RuntimeError("Failed to close %s stream" % cmd_arg) + return retval.decode('utf-8') + +# Register an extra command to get the checkout dir for a module. +# +import jhbuild +class _cmd_get_srcdir(jhbuild.commands.Command): + doc = 'Display information about one or more modules' + + from jhbuild.errors import FatalError + + name = 'gtk-osx-get-srcdir' + usage_args = 'module' + + def run(self, config, options, args, help=None): + module_set = jhbuild.moduleset.load(config) + + if args: + modname = args[0] + try: + module = module_set.get_module(modname, ignore_case = True) + except KeyError: + raise RuntimeError(_('unknown module %s') % modname) + print(module.get_srcdir(None)) + else: + raise FatalError('no module specified') + +jhbuild.commands.register_command(_cmd_get_srcdir) + +class _cmd_bootstrap_gtk_osx(jhbuild.commands.base.cmd_build): + doc = 'Build buildsystem tools not provided by MacOS.' + + name = 'bootstrap-gtk-osx' + + def run(self, config, options, args, help=None): + global use_local_modulesets + moduleset="bootstrap" + modulesets_dir = os.path.dirname(config.moduleset) + if (use_local_modulesets and + os.path.exists(os.path.join(modulesets_dir, + moduleset + '.modules'))): + config.modulesets_dir = modulesets_dir + config.moduleset = moduleset + elif (use_local_modulesets and config.modulesets_dir and + os.path.exists(os.path.join(config.modulesets_dir, + moduleset + '.modules'))): + config.moduleset = moduleset + else: + config.moduleset = 'https://raw.githubusercontent.com/dehesselle/jhb/master/etc/modulesets/jhb/bootstrap.modules' + + args = ['meta-bootstrap'] + + for item in options.skip: + config.skip += item.split(',') + options.skip = [] + + rc = jhbuild.commands.base.cmd_build.run(self, config, options, args) + return rc + +jhbuild.commands.register_command(_cmd_bootstrap_gtk_osx) + +class _getenv(jhbuild.commands.Command): + doc = "Retrieve an environment variable set within jhbuild" + + name = "gtk-osx-getenv" + usage_args = 'envvar' + + def run(self, config, options, args): + # module_set = jhbuild.moduleset.load(config) + + if not args: + raise FatalError("No environment variable") + + var = args[0] + if var not in os.environ: + raise FatalError("variable " + var + " not defined in jhbuild environment") + print(os.environ[var]) + +jhbuild.commands.register_command(_getenv) + +# Determine the native system: +def osx_ver(): + global _default_arch, _osx_version, _target + vstring = _popen("uname -r") + mstring = _popen("machine") + exp = re.compile(r'(\d+\.\d+)\.\d+') + vernum = exp.match(vstring) + _osx_version = float(vernum.group(1)) - 4.0 + if _osx_version < 16: + _target = '10.%d' % int(_osx_version) + else: + _target = '%d' % (_osx_version - 5) + + _default_arch = _popen("uname -m") + +# Determine the XCode Version: +def xcode_ver(): + global conditions + devdir = _popen("xcode-select -p") + if devdir != "/Library/Developer/CommandLineTools": + ver = _popen("xcodebuild -version") + exp = re.compile(r'Xcode (\d+\.\d+)') + vernum = exp.match(ver) + if vernum: + _xcode_ver = float(vernum.group(1)) + if _xcode_ver < 5.0: + raise EnvironmentError("Xcode Version %f is not supported; if you want to build with Xcode versions earlier than 5.0 checkout tag Last-Lion." % _xcode_ver) + if _xcode_ver < 10.0: + conditions.add('pre-Mavericks') + return _xcode_ver + else: + raise EnvironmentError("No suitable Xcode found. Xcode 5.0 or later is required.") + else: #Command-Line Tools instead of Xcode + ver_str = _popen("pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version*") + print("Found Command Line Tools '%s'" % ver_str) + exp = re.compile(r'version: (\d+\.\d+)') + vernum = exp.match(ver_str) + if vernum: + print("Command Line Tools version %f" % float(vernum.group(1))) + return float(vernum.group(1)) + else: + return 8.0 + +# Some utitily functions used here and in custom files: +# +def environ_append(key, value, separator=' '): + old_value = os.environ.get(key) + if old_value is not None: + value = old_value + separator + value + os.environ[key] = value + +def environ_prepend(key, value, separator=' '): + old_value = os.environ.get(key) + if old_value is not None: + value = value + separator + old_value + os.environ[key] = value + +def environ_remove(key, value, separator=':'): + old_value = os.environ.get(key) + if old_value is not None: + old_value_split = old_value.split(separator) + value_split = [x for x in old_value_split if x != value] + value = separator.join(value_split) + os.environ[key] = value + +def parse_custom_argument(key): + for i, arg in enumerate(sys.argv[:-1]): + if arg == key: + return sys.argv[i+1] + return None + +def append_autogenargs(module, args): + old_value = module_autogenargs.get(module, autogenargs) + module_autogenargs[module] = old_value + " " + args + +def remove_autogenargs(module, args): + arg_string = module_autogenargs.get(module, autogenargs) + module_autogenargs[module] = arg_string.replace(args, "") + +# Call either setup_debug or setup_release in your .jhbuildrc-custom +# or other customization file to get the compilation flags. +def setup_debug(): + global autogenargs +# The enable-debug option generally turns on ASSERTS, which can slow +# down code and in the case of WebKit, breaks it on OSX because of +# threading problems. It's better to set it for individual packages +# with append_autogenargs(). + +# autogenargs = autogenargs + " --enable-debug=yes" + +# Gtk+ crashes in gdk_window_quartz_raise() -- in a call to [NSWindow +# orderFront:] if gcc is passed -O0 for 64-bit compilation. The old +# stabs+ debug format also doesn't work. See Snow Leopard in the Wiki +# for more information about debugging. + environ_prepend('CFLAGS', "-O0 -g") + environ_prepend('CXXFLAGS', "-O0 -g") + environ_prepend('OBJCFLAGS', "-O0 -g") + +def setup_release(): + environ_prepend('CFLAGS', "-O2") + environ_prepend('CXXFLAGS', "-O2") + environ_prepend('OBJCFLAGS', "-O2") + +# Set up the environment for building against particular SDK. +# + +#We call osx_ver() here so that we can set up _default_arch for setup_sdk +osx_ver() + +# +# This is the workhorse of the setup. Call this function from +# .jhbuildrc-custom to configure compile and link flags. Optionally +# specify a minimum MacOS version (10.11, 10.12, 10.13, etc.) and a list +# of architectures. +# +# The sdk_version does nothing, as since Xcode 5 it is preferred to +# build with the SDK that goes with the selected Xcode or command-line +# tools, which we retrieve via xcrun. sdk_version remains in the +# setup_sdk signature to prevent breaking existing jhbuildrc-customs. +# +# For most users accepting the defaults is the right course. + +def setup_sdk(target=_target, sdk_version=None, architectures=[_default_arch]): + + global use_local_modulesets, conditions + os.environ["MACOSX_DEPLOYMENT_TARGET"] = target + sdkdir = None + xcodepath = None + xcodeversion = xcode_ver() + + sdkdir = _popen("xcrun --show-sdk-path") + + if sdkdir: + environ_prepend("LDFLAGS", "-L" + sdkdir + "/usr/lib") + environ_prepend("CFLAGS", "-I" + sdkdir + "/usr/include") + environ_prepend("CXXFLAGS", "-I" + sdkdir + "/usr/include") + environ_prepend("OBJCFLAGS", "-I" + sdkdir + "/usr/include") + environ_prepend("CPPFLAGS", "-I" + sdkdir + "/usr/include") + environ_prepend("CMAKE_PREFIX_PATH", os.path.join(sdkdir, 'usr'), ':') + environ_prepend("LIBRARY_PATH", sdkdir + "/usr/lib", ':') + + # It's often necessary to look for things in the SDK when + # developing, and it takes a lot of typing, so define a + # convenience environment variable: + environ_append('SDKDIR', sdkdir) + os.environ["SDKROOT"] = sdkdir + + # Apple Documentation says that "-syslibroot" is the arg to pass to the + # linker, but we are using the compiler to control the linker, and + # everything seems to be working correctly. + environ_append("CFLAGS", "-isysroot " + sdkdir) + environ_append("CPPFLAGS", "-isysroot " + sdkdir) + environ_append("CXXFLAGS", "-isysroot " + sdkdir) + environ_append("OBJCFLAGS", "-isysroot " + sdkdir) + environ_append("LDFLAGS", "-isysroot " + sdkdir) + + # To pick up cups-config from the right place. + os.environ["CUPS_CONFIG"] = os.path.join(sdkdir, "usr/bin/cups-config") + + if architectures == ["i386"]: + # The '#' on openssl is to stop jhbuild from appending any more autogen + # arguments such as --disable-Werror; they cause openssl to error out + append_autogenargs("openssl", "darwin-i386-cc #") + elif architectures == ["x86_64"]: + conditions.add('64-bit') + append_autogenargs("glib", "ac_cv_c_bigendian=no") + append_autogenargs("openssl", "darwin64-x86_64-cc #") + elif architectures == ["arm64"]: + conditions.add('64-bit') + conditions.add('arm64') + append_autogenargs("glib", "ac_cv_c_bigendian=no") + append_autogenargs("openssl", "darwin64-arm64-cc #") # Not a legal value + elif len(set(architectures) - {"i386", "x86_64", 'arm64'}) > 0: + raise EnvironmentError("Only architectures i386, x86_64, and arm64 are supported.") + if len(set(architectures)) > 1: + print("WARNING: Universal builds are neither prohibited nor supported. It might work, but if it doesn't you're on your own.") + # For unknown reasons, iconv is not picked up correctly without this + # + gcc = _popen("xcrun -f gcc") + gpp = _popen("xcrun -f g++") + ld = _popen("xcrun -f ld") + os.environ["CC"] = gcc + os.environ["OBJC"] = gcc + os.environ["CXX"] = gpp + os.environ['LD'] = ld + + # Set the -arch flags for everything we're building. + # + for arch in architectures: + environ_prepend("CFLAGS", "-arch " + arch) + environ_prepend("CXXFLAGS", "-arch " + arch) + environ_prepend("CPPFLAGS", "-arch " + arch) + environ_prepend("OBJCFLAGS", "-arch " + arch) + environ_prepend("LDFLAGS", "-arch " + arch) + # For intel, set glib's build parameter so that it builds the + # correct atomic asm functions + # + if architectures == ["i386"]: + append_autogenargs("glib", "--build=i486-apple-darwin") + append_autogenargs("gmp", "ABI=32") + append_autogenargs("liboil", "--host=i486-apple-darwin") + append_autogenargs("gnutls", "--host=i486-apple-darwin") + elif architectures == ["x86_64"]: + append_autogenargs("glib", "--build=x86_64-apple-darwin") + append_autogenargs("gmp", "--host=x86_64-apple-darwin ABI=64") + append_autogenargs("liboil", "--host=x86_64-apple-darwin") + append_autogenargs("gnutls", "--host=x86_64-apple-darwin") + elif architectures == ["arm64"]: + append_autogenargs("glib", "--build=aarch64-apple-darwin") + append_autogenargs("gmp", "--host=aarch64-apple-darwin ABI=64") + append_autogenargs("liboil", "--host=aarch64-apple-darwin") + append_autogenargs("libffi", "--host=aarch64-apple-darwin") + + # El Capitan needs bash to work around SIP. If you're using a + # common bootstrap directory (e.g. $HOME/.local) then override + # CONFIG_SHELL in .jhbuildrc-custom after calling setup_sdk(). + config_shell = os.path.join(prefix, 'bin', 'bash') + if _osx_version < 11.0: + skip.append('bash') + elif os.path.exists(config_shell): + os.environ['CONFIG_SHELL'] = config_shell + + if not sdkdir: + sdkdir = '/' + if os.path.exists(os.path.join(sdkdir, "usr", "include", "openssl")): + skip.append('openssl') # openssl removed in El Capitan + + # gettext-fw rebuilds gettext with an in-tree libiconv to get + # around the Apple-provided one not defining _libiconv_init for + # x86_64 + append_autogenargs("gettext-fw", "--with-libiconv-prefix=" + prefix) + + environ_append("CFLAGS", "-mmacosx-version-min=" + target) + environ_append("CXXFLAGS", "-mmacosx-version-min=" + target) + environ_append("OBJCFLAGS", "-mmacosx-version-min=" + target) + environ_append("LDFLAGS", "-mmacosx-version-min=" + target) + + #Overcome Python's obnoxious misconfiguration of portable builds + if len(architectures) == 1: + os.environ["BUILDCFLAGS"] = os.environ["CFLAGS"] + append_autogenargs("gnutls", "--disable-guile") + append_autogenargs("guile", 'CFLAGS="$CFLAGS -O1"') + #Some packages require special arguments or flags to compile with Clang: + module_extra_env["pkg-config"] = {'CFLAGS': os.environ['CFLAGS'] + ' -std=gnu89'} + append_autogenargs('libgcrypt', 'CFLAGS="$CFLAGS -fheinous-gnu-extensions"') + module_makeargs['liboil'] = 'CFLAGS="$CFLAGS -DHAVE_SYMBOL_UNDERSCORE -fheinous-gnu-extensions"' + + # openssl doesn't understand DESTDIR, but luckily it has its own mechanism. + module_extra_env['openssl'] = {'INSTALL_PREFIX': os.path.join(prefix, '_jhbuild', 'root-openssl')} + # GMP deliberately attempts to use CC_FOR_BUILD with no separate + # cflags so we need to force it: + module_extra_env['gmp'] = {'CC_FOR_BUILD':os.environ['CC'] + ' ' + os.environ['CFLAGS']} + # Kill a couple of noisy warnings for webkit1: + module_extra_env["webkit"] = {'CPPFLAGS':os.environ['CPPFLAGS'] + " -Wno-unused-local-typedef -Wno-missing-field-initializsers"} + module_extra_env["webkit1gtk3"] = {'CPPFLAGS':os.environ['CPPFLAGS'] + " -Wno-unused-local-typedef -Wno-missing-field-initializsers -Wno-undefined-bool-conversion"} + module_extra_env["webkit"] = {'CXXFLAGS':os.environ['CXXFLAGS'] + ' -Wno-inconsistent-missing-override'} + module_extra_env["webkit1gtk3"] = {'CXXFLAGS':os.environ['CXXFLAGS'] + ' -Wno-inconsistent-missing-override'} + + # Finally when building normally we need to force CFLAGS_FOR_BUILD + # to our current CFLAGS so that everything will link with other + # build products. Note that this will generally break + # cross-compilation, not that it works anyway. + os.environ['CFLAGS_FOR_BUILD'] = os.environ['CFLAGS'] + + # Make sure we don't link against XQuartz whose freetype-config is on PATH + # when XQuartz is installed by removing it from PATH + environ_remove('PATH', '/opt/X11/bin') + return sdkdir + + +###### End Function Definitions ####### + + +##### The following configuration can be overridden in custom files ###### + +# Moduleset to use. You can override this in .jhbuildrc-custom or on +# the command line. +# +moduleset = "" +use_local_modulesets = False +modulesets_dir = "" + +# A list of the modules to build. You can override this in +# .jhbuildrc-custom or on the command line. +# +modules = [ 'meta-gtk-osx-bootstrap', 'meta-gtk-osx-gtk3' ] + +# A list of modules to skip. +# +# Source and installation locations. +# +_root = os.path.expanduser("~/gtk") +checkoutroot = os.path.join(_root, "source") +prefix = os.path.join(_root, "inst") +_exec_prefix = None +tarballdir = None +# Extra arguments to pass to all autogen.sh scripts. +# +autogenargs='' + +# Extra meson args. --wrapmode=nofallback prevents meson projects from +# building dependencies on their own. We generally want failed +# dependencies to error out so that we know to add them to the +# appropriate modules. + +mesonargs='--wrap-mode=nofallback' + +# Use the included install-check program if available. It won't update +# timestamps if the header hasn't changed, which speeds up builds. +# +_path = os.path.expanduser('~/.local/bin/install-check') +if os.path.exists(_path): + os.environ['INSTALL'] = _path + +_gtk_osx_prompt_prefix = "JH" + +_gtk_osx_default_build = "" + +#print "Default Architecture %s\n" % _default_arch + +if _osx_version < 11.0: + print("Error: Mac OS X 10.11 or newer is required, exiting.") + raise SystemExit + +###### Import Customizations ###### + +# Import optional user RC for further customization. You can override +# the prefix or default build setup for example, or CFLAGS or +# module_autogenargs, etc. +# +_this_dir = os.path.dirname(__file__); +_home = os.path.expanduser('~') +_user_config_dir = os.environ.get('XDG_CONFIG_HOME', + os.path.join(_home, '.config')) + +_user_rc = '' +if ('JHBUILDRC_CUSTOM' in os.environ and + os.environ['JHBUILDRC_CUSTOM']): + _user_rc = os.environ['JHBUILDRC_CUSTOM'] +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_this_dir, 'jhbuildrc-custom'); +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_this_dir, '.jhbuildrc-custom') +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_user_config_dir, 'jhbuildrc-custom') +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_user_config_dir, '.jhbuildrc-custom') +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_home, 'jhbuildrc-custom') +if not os.path.exists(_user_rc): + _user_rc = os.path.join(_home, '.jhbuildrc-custom') + +if os.path.exists(_user_rc): + exec(compile(open(_user_rc, "rb").read(), _user_rc, 'exec')) + +# Allow including different variants depending on the environment +# variable JHB. This can be used to have different setups for SDK +# builds, for example. +# +_build = os.environ.get('JHB', _gtk_osx_default_build) +disable_Werror = False + +###### Everything Below Uses (and Overrides) customizations! ####### +# jhbuild turns on 'nice' by default ut that messes up some of the +# custom autogen-templates Gtk-OSX needs to use:" +nice_build = False + +# Harfbuzz needs to be built twice, once before cairo and again after +# gobject-introspection because cairo needs harfbuzz and +# gobject-introspection needs cairo. The only way to get jhbuild to +# run the configuration for harfbuzz the second time is to set +# alwaysautogen to true. + +alwaysautogen = True + +# Freetype2 if left to itself will create an install name without the +# path so none of the libraries that depend on it can link. Require +# the install name to be an absolute path. + +module_cmakeargs["freetype"] = '-DCMAKE_INSTALL_NAME_DIR="' + os.path.join(prefix, 'lib') + '"' +module_cmakeargs["freetype-no-harfbuzz"] = '-DCMAKE_INSTALL_NAME_DIR="' + os.path.join(prefix, 'lib') + '"' +module_cmakeargs["webkit2gtk3"] = '-DCMAKE_INSTALL_NAME_DIR="' + os.path.join(prefix, 'lib') + '"' +module_cmakeargs["zlib"] = '-DCMAKE_INSTALL_NAME_DIR="' + os.path.join(prefix, 'lib') + '"' + +# Check and warn if jhbuild is started from within jhbuild, since that +# will mess up environment variables, especially if different build +# setups are used. +# +_old_prefix = os.environ.get('JHBUILD_PREFIX', "") +_old_build = os.environ.get('JHBUILD_CONFIG', "") +_ran_recursively = _old_prefix != "" +if _ran_recursively: + if _old_build != _build: + print("Error: jhbuild is already running with a different build setup, exiting.") + raise SystemExit + + print("Warning: jhbuild is started from within a jhbuild session.") + +if _build != "": + try: + exec(compile(open(os.path.join(os.environ['HOME'], '.jhbuildrc-' + _build), "rb").read(), os.path.join(os.environ['HOME'], '.jhbuildrc-' + _build), 'exec')) + except EnvironmentError as e: + print("Couldn't find the file '.jhbuildrc-" + _build + "', exiting.") + raise SystemExit + +# The following parameters were set to None at the top of the file; +# they're set here to their default values after processing the +# customizations, but tested to make sure that if they've been +# customized, it will stick. + +# Default location for tarball download is into checkoutroot/pkgs. If +# you do multiple builds with different checkoutroots, you'll want to +# override this to somewhere common (~/.local/pkgs is one alternative) +if tarballdir == None: + tarballdir = os.path.join(checkoutroot, 'pkgs') +# _exec_prefix is used to set $M4 and $LIBTOOLIZE. We set it here to +# prefix if it wasn't over-ridden in .jhbuildrc-custom +if _exec_prefix == None: + _exec_prefix = prefix + + +os.environ['PREFIX'] = prefix # Deprecated, please move to JHBUILD_PREFIX. +os.environ['JHBUILD_PREFIX'] = prefix +os.environ['JHBUILD_SOURCE'] = checkoutroot + +# Some packages go off and find /usr/lib/gm4, which is broken Note the +# use of _exec_prefix here. By default it's prefix, but you can +# override it to somewhere else in jhbuildrc-custom if you like. +#os.environ["M4"] = _exec_prefix + "/bin/m4" +#os.environ['LIBTOOLIZE'] = _exec_prefix + '/bin/libtoolize' +#Some autogens detect that it's a Mac and use glibtoolize if it's +#available. Override this behavior. +if not ("LIBTOOLIZE" in os.environ and os.environ["LIBTOOLIZE"]): + environ_append('LIBTOOLIZE', os.path.join(prefix, "bin", "libtoolize")) + + +# The option "headerpad_max_install_names" is there to leave some room for +# changing the library locations with install_name_tool. Note that GNU +# libtool seems to drop the option if we don't use -W here. +# +environ_append('LDFLAGS', '-Wl,-headerpad_max_install_names') +#environ_append('LDFLAGS', '-Wl,-no_weak_imports') + +# Make sure we find our installed modules, and before other versions. +environ_prepend('LDFLAGS', '-L' + prefix + '/lib') +environ_prepend('CPPFLAGS', '-I' + prefix + '/include') + +# Make sure that ltdl can find our libraries +addpath("LTDL_LIBRARY_PATH", prefix + "/lib") + +# Add additional Perl paths so that our modules can be found. + +prependpath('PERL5LIB', prefix + '/lib/perl5/vendor_perl') +prependpath('PERL5LIB', prefix + '/lib/perl5/site_perl') + +# Point gtk-doc and other xsltproc users to our XML catalog. +# +_pfx_cat_file = os.path.join(prefix, 'share', 'xml', 'catalog') +if not os.path.exists(_pfx_cat_file): + os.makedirs(os.path.dirname(_pfx_cat_file)) + open(_pfx_cat_file, "w").close() +if 'XML_CATALOG_FILES' in os.environ: +# os.environ['XML_CATALOG_FILES'] += ':' + _pfx_cat_file + pass +else: + os.environ['XML_CATALOG_FILES'] = _pfx_cat_file + +#GConf needs to be built static, overriding the generic autogenargs, +#but including it in the module puts it in front of where autogenargs +#puts --disable-static, so we need the override here. +# +append_autogenargs("gconf", "--enable-static") + +if _build: + if "shell" in sys.argv: + print("Build setup: %s, prefix: %s" % (_build, prefix)) + os.environ["JHBUILD_CONFIG"] = _build +else: + if "shell" in sys.argv: + print("Prefix: %s" % (prefix)) + +if not _ran_recursively and _gtk_osx_prompt_prefix: + os.environ["JHBUILD_PROMPT"] = "[" + _gtk_osx_prompt_prefix + "] " + +os.environ["PYTHON"] = os.path.join(prefix, 'bin', 'python3') +module_extra_env['pkg-config'] = {'PYTHON':sys.executable} +module_extra_env["spidermonkey"] = {'AUTOCONF':'autoconf'} +# Unset this so we don't mess with the check for not starting +# recursively. +os.unsetenv("JHB") + +if "shell" in sys.argv: + print("Entered jhbuild shell, type 'exit' to return.") diff --git a/packaging/macos/jhb/etc/modulesets/jhb/bootstrap.modules b/packaging/macos/jhb/etc/modulesets/jhb/bootstrap.modules new file mode 100644 index 0000000..6cc2ed6 --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/bootstrap.modules @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/macos/jhb/etc/modulesets/jhb/jhb.modules b/packaging/macos/jhb/etc/modulesets/jhb/jhb.modules new file mode 100644 index 0000000..f2fc9e3 --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/jhb.modules @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/macos/jhb/etc/modulesets/jhb/moduleset.dtd b/packaging/macos/jhb/etc/modulesets/jhb/moduleset.dtd new file mode 100644 index 0000000..d9c392a --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/moduleset.dtd @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/macos/jhb/etc/modulesets/jhb/moduleset.xsl b/packaging/macos/jhb/etc/modulesets/jhb/moduleset.xsl new file mode 100644 index 0000000..c2e7f7a --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/moduleset.xsl @@ -0,0 +1,196 @@ + + + + + + + + + + Module Set + + + + + + + + + +

JHBuild Module Set

+
+ +
+
+ + + + + + + + + , + + + + + + + + + + + + + + +
+ module + tarball + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Module: + + + + + + + + + + revision: + + +
URL: + + + + + + + + + + + + ( bytes) + ( bytes) +
Patches: +
    + +
+
Checkout directory:
Autogen args:
Dependencies:
Suggests:
After:
+
+
+ + + + + +
+
+ + + + + + + +
Dependencies:
+
+
+ + +
  • +
    + +
    diff --git a/packaging/macos/jhb/etc/modulesets/jhb/patches/libtool-apple-sort.patch b/packaging/macos/jhb/etc/modulesets/jhb/patches/libtool-apple-sort.patch new file mode 100644 index 0000000..8c880ef --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/patches/libtool-apple-sort.patch @@ -0,0 +1,38 @@ +--- a/Makefile.am 2015-01-20 07:34:33.000000000 -0800 ++++ b/Makefile.am 2021-11-12 10:18:23.000000000 -0800 +@@ -416,8 +416,8 @@ + # files created in the build tree, so instead we regenerate the + # manual pages if the sources for the build-tree files we want to + # run have changed. +-$(libtool_1): $(ltmain_sh) +- $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool ++#$(libtool_1): $(ltmain_sh) ++# $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool + $(libtoolize_1): $(libtoolize_in) + $(AM_V_GEN)$(update_mans) libtoolize + +--- s/Makefile.in 2015-02-15 08:14:14.000000000 -0800 ++++ b/Makefile.in 2021-11-12 10:26:26.000000000 -0800 +@@ -2324,8 +2324,8 @@ + # files created in the build tree, so instead we regenerate the + # manual pages if the sources for the build-tree files we want to + # run have changed. +-$(libtool_1): $(ltmain_sh) +- $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool ++#$(libtool_1): $(ltmain_sh) ++# $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool + $(libtoolize_1): $(libtoolize_in) + $(AM_V_GEN)$(update_mans) libtoolize + +--- a/build-aux/ltmain.in 2015-02-06 04:57:56.000000000 -0800 ++++ b/build-aux/ltmain.in 2021-11-08 14:58:33.000000000 -0800 +@@ -3188,7 +3188,7 @@ + if test yes = "$lock_old_archive_extraction"; then + $opt_dry_run || rm -f "$lockfile" + fi +- if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then ++ if ($AR t "$f_ex_an_ar_oldlib" | sort -u | sort -c >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + diff --git a/packaging/macos/jhb/etc/modulesets/jhb/patches/vasnprintf.patch b/packaging/macos/jhb/etc/modulesets/jhb/patches/vasnprintf.patch new file mode 100644 index 0000000..995e1e3 --- /dev/null +++ b/packaging/macos/jhb/etc/modulesets/jhb/patches/vasnprintf.patch @@ -0,0 +1,11 @@ +--- a/lib/vasnprintf.c 2017-09-29 11:10:29.000000000 +0200 ++++ b/lib/vasnprintf.c 2017-09-29 11:15:06.000000000 +0200 +@@ -4858,7 +4858,7 @@ + #endif + *fbp = dp->conversion; + #if USE_SNPRINTF +-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) ++# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __APPLE__) + fbp[1] = '%'; + fbp[2] = 'n'; + fbp[3] = '\0'; -- cgit v1.2.3