Merge pull request #1225 from ichizok/feature/libsodium

Support "sodium" feature in release package
This commit is contained in:
ichizok
2022-02-20 20:37:34 +09:00
committed by GitHub
4 changed files with 128 additions and 65 deletions
@@ -0,0 +1,84 @@
name: Universal package
description: Create universal Homebrew package which contains x86_64 and arm64
inputs:
formula:
description: Formura name
required: true
contents:
description: Path for contents in package's keg
required: true
runs:
using: 'composite'
steps:
- name: Set up formula
shell: bash
run: |
echo '::group::Set up formula'
set -o pipefail
formula=${{ inputs.formula }}
# Patch the official Homebrew formula to explicitly build for min deployment target
brew cat ${formula} | \
sed '/^[[:blank:]]*def install$/a\'$'\n ENV["MACOSX_DEPLOYMENT_TARGET"] = "'${MACOSX_DEPLOYMENT_TARGET}$'"\n' >${formula}.rb
# Uninstall the already installed formula because we want to build our own
brew uninstall --ignore-dependencies ${formula} || true
echo '::endgroup::'
- name: Cache keg
id: cache-keg
uses: actions/cache@v2
with:
path: /usr/local/Cellar/${{ inputs.formula }}
key: ${{ inputs.formula }}-homebrew-cache-patched-unified-${{ hashFiles(format('{0}.rb', inputs.formula)) }}
- name: Install formula
shell: bash
env:
HOMEBREW_NO_AUTO_UPDATE: '1'
run: |
echo '::group::Install formula'
formula=${{ inputs.formula }}
# This will be a no-op if formula was cached
brew install --formula -s ./${formula}.rb
# If formula was cached, this step is necessary to relink it to /usr/local/
brew unlink ${formula} && brew link ${formula}
echo '::endgroup::'
- name: Create universal binaries with arm64 bottle
if: steps.cache-keg.outputs.cache-hit != 'true'
shell: bash
run: |
echo '::group::Create universal binaries with arm64 bottle'
set -o verbose
formula=${{ inputs.formula }}
contents=($(IFS=,; for x in ${{ inputs.contents }}; do echo ${x}; done))
# Manually download and extract a bottle for arm64
source /dev/stdin <<<"$(brew info --json ${formula} | \
jq -r '.[0] | "bottle_url=\(.bottle.stable.files.arm64_big_sur.url)", "formula_ver=\(.versions.stable)", "formula_rev=\(.revision)"')"
if [[ ${formula_rev} -ne 0 ]]; then
formula_ver=${formula_ver}_${formula_rev}
fi
workdir=${formula}_download
mkdir ${workdir}
cd ${workdir}
wget --no-verbose --header 'Authorization: Bearer QQ==' -O ${formula}.tar.gz ${bottle_url}
tar xf ${formula}.tar.gz
for content in "${contents[@]}"; do
# Just for diagnostics, print out the old archs. This should be a thin binary (x86_64)
lipo -info /usr/local/${content}
# Create a universal binary by patching the custom built x86_64 one with the downloaded arm64 one.
# Modify the actual binaries in /usr/local/Cellar instead of the symlinks to allow caching to work.
lipo -create -output /usr/local/Cellar/${formula}/${formula_ver}/${content} \
/usr/local/Cellar/${formula}/${formula_ver}/${content} ./${formula}/${formula_ver}/${content}
# Print out the new archs and verify they are universal with 2 archs.
lipo -info /usr/local/${content} | grep 'x86_64 arm64'
done
echo '::endgroup::'
+15 -65
View File
@@ -5,12 +5,12 @@ on:
pull_request:
env:
MACOSX_DEPLOYMENT_TARGET: "10.9"
MACOSX_DEPLOYMENT_TARGET: '10.9'
CC: clang
VERSIONER_PERL_VERSION: "5.18"
VERSIONER_PYTHON_VERSION: "2.7"
VERSIONER_PERL_VERSION: '5.18'
VERSIONER_PYTHON_VERSION: '2.7'
vi_cv_path_python: /usr/bin/python
vi_cv_path_python3: /usr/local/bin/python3
vi_cv_path_plain_lua: /usr/local/bin/lua
@@ -39,10 +39,10 @@ jobs:
matrix:
include:
- os: macos-10.15
xcode: "11.7"
xcode: '11.7'
- os: macos-10.15
- os: macos-11
xcode: "13.0"
xcode: '13.0'
publish: true
runs-on: ${{ matrix.os }}
@@ -65,69 +65,19 @@ jobs:
- name: Set up gettext
if: matrix.publish
run: |
# Patch the official Homebrew gettext formula to explicitly build for min deployment target
cp /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gettext.rb gettext.rb
cat << EOF > gettext_diff.patch
--- gettext_orig.rb
+++ gettext.rb
@@ -24,2 +24,3 @@
def install
+ ENV["MACOSX_DEPLOYMENT_TARGET"] = "${MACOSX_DEPLOYMENT_TARGET}"
args = [
EOF
patch gettext.rb gettext_diff.patch
# Uninstall the already installed gettext because we want to build our own
brew uninstall --ignore-dependencies gettext
- name: Cache gettext
id: cache-gettext
if: matrix.publish
uses: actions/cache@v2
uses: ./.github/actions/universal-package
with:
path: /usr/local/Cellar/gettext
key: gettext-homebrew-cache-patched-unified-${{ hashFiles('gettext.rb') }}
formula: gettext
contents: lib/libintl.a,lib/libintl.dylib
- name: Install gettext
# Set up, install, and cache libsodium library for encryption.
- name: Set up libsodium
if: matrix.publish
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: |
# This will be a no-op if gettext was cached
brew install --formula -s ./gettext.rb
# If gettext was cached, this step is necessary to relink it to /usr/local/
brew link gettext
- name: Create universal gettext with arm64 bottle
if: matrix.publish && steps.cache-gettext.outputs.cache-hit != 'true'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: |
set -o verbose
# Manually download and extract gettext bottle for arm64
source /dev/stdin <<<"$(brew info --json gettext | jq -r '"gettext_url=\(.[0].bottle.stable.files.arm64_big_sur.url)", "gettext_ver=\(.[0].versions.stable)"')"
mkdir gettext_download
cd gettext_download
wget --no-verbose --header 'Authorization: Bearer QQ==' -O gettext.tar.gz ${gettext_url}
tar xf gettext.tar.gz
# Just for diagnostics, print out the old archs. This should be a thin binary (x86_64)
lipo -info /usr/local/lib/libintl.a
lipo -info /usr/local/lib/libintl.dylib
# Create a universal binary by patching the custom built x86_64 one with the downloaded arm64 one.
# Modify the actual binaries in /usr/local/Cellar instead of the symlinks to allow caching to work.
lipo -create -output /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.a /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.a ./gettext/${gettext_ver}/lib/libintl.a
lipo -create -output /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.dylib /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.dylib ./gettext/${gettext_ver}/lib/libintl.dylib
# Print out the new archs and verify they are universal with 2 archs.
lipo -info /usr/local/lib/libintl.a | grep 'x86_64 arm64'
lipo -info /usr/local/lib/libintl.dylib | grep 'x86_64 arm64'
uses: ./.github/actions/universal-package
with:
formula: libsodium
contents: lib/libsodium.a,lib/libsodium.dylib
# Set up remaining packages and tools
+16
View File
@@ -13402,6 +13402,22 @@ $as_echo "no; try installing libsodium-dev" >&6; }; CFLAGS="$ac_save_CFLAGS"; LI
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
# MacVim: Hack to statically link against libsodium instead of dynamic link, as we can't distribute app bundles with
# external linkage dependencies. Clang doesn't support any way to specify static linkage as it prefers dynamic
# linkage if a dylib exists in the same folder, and as such we have to manually specify the library path instead
# of using -l<lib> syntax. This also means it won't work with AC_TRY_LINK as specifying full lib path only works
# if you have separate compile/link stages but AC_TRY_LINK just compiles/link in one command.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libsodium.a" >&5
printf %s "checking for libsodium.a... " >&6; }
if test -f ${local_dir}/lib/libsodium.a; then
LIBS="$ac_save_LIBS ${local_dir}/lib/libsodium.a"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Using ${local_dir}/lib/libsodium.a instead of -lsodium" >&5
printf "%s\n" "Using ${local_dir}/lib/libsodium.a instead of -lsodium" >&6; };
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: libsodium.a not found - keeping using -lsodium" >&5
printf "%s\n" "libsodium.a not found - keeping using -lsodium" >&6; };
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_blksize" >&5
+13
View File
@@ -4053,6 +4053,19 @@ if test "$enable_libsodium" = "yes"; then
printf("%d", sodium_init()); ],
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
# MacVim: Hack to statically link against libsodium instead of dynamic link, as we can't distribute app bundles with
# external linkage dependencies. Clang doesn't support any way to specify static linkage as it prefers dynamic
# linkage if a dylib exists in the same folder, and as such we have to manually specify the library path instead
# of using -l<lib> syntax. This also means it won't work with AC_TRY_LINK as specifying full lib path only works
# if you have separate compile/link stages but AC_TRY_LINK just compiles/link in one command.
AC_MSG_CHECKING([for libsodium.a])
if test -f ${local_dir}/lib/libsodium.a; then
LIBS="$ac_save_LIBS ${local_dir}/lib/libsodium.a"
AC_MSG_RESULT([Using ${local_dir}/lib/libsodium.a instead of -lsodium]);
else
AC_MSG_RESULT([libsodium.a not found - keeping using -lsodium]);
fi
fi
dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible