Skip to content

Commit

Permalink
Merge pull request #45 from cannam/main
Browse files Browse the repository at this point in the history
All the packaging updates!
  • Loading branch information
yucongj authored Mar 1, 2024
2 parents bede907 + 9a28979 commit fb3dc9a
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 169 deletions.
28 changes: 16 additions & 12 deletions deploy/clean-build-and-package
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ echo

if [ -d /Applications ]; then

archs="x86_64"
# archs="x86_64 arm64"
archs="x86_64 arm64"

qtdir_x86_64="/Users/cannam/Qt/5.15.2/clang_64"
qtdir_arm64="/Users/cannam/Qt/5.15.2-arm64"
qtdir_x86_64="/Users/cannam/Qt/6.6.1/macos"
qtdir_arm64="/Users/cannam/Qt/6.6.1/macos"

echo "Proceed to rebuild, package, and sign version $version of $full_name using:"
for arch in $archs; do
Expand All @@ -32,12 +31,12 @@ if [ -d /Applications ]; then
echo "*** ERROR: Qt dir $qtdir does not exist"
exit 1
fi
if [ ! -f "$qtdir/bin/qmake" ]; then
qmake=$qtdir/bin/qmake
if [ ! -f "$qmake" ]; then
echo "*** ERROR: qmake not found in $qmake (for Qt dir $qtdir)"
exit 1
fi
qmake_arch=$(lipo -archs "$qtdir/bin/qmake")
if [ t"$qmake_arch" != t"$arch" ]; then
if ! lipo -archs "$qmake" | grep -q "$arch"; then
echo "*** ERROR: wrong arch $qmake_arch for qmake $qmake (expected $arch)"
exit 1
fi
Expand All @@ -49,25 +48,30 @@ if [ -d /Applications ]; then

./repoint install

builddirs=""

for arch in $archs; do

case "$arch" in
x86_64) qtdir="$qtdir_x86_64";;
arm64) qtdir="$qtdir_arm64";;
esac

rm -rf build-$arch
PATH="$qtdir/bin:$PATH" arch -$arch meson build-$arch --cross-file=deploy/cross/macos-$arch.txt --buildtype release -Db_lto=true
ninja -C build-$arch
builddir="build-$arch"

rm -rf "$builddir"
PATH="$qtdir/bin:$PATH" arch -$arch meson setup "$builddir" --cross-file=deploy/cross/macos-$arch.txt --buildtype release -Db_lto=true
ninja -C "$builddir"

builddirs="$builddirs $builddir"

done

rm -rf "$full_app"
rm -rf "$full_versioned"
rm -f "$full_dmg"

deploy/macos/deploy-and-package.sh build-x86_64
# deploy/macos/deploy-and-package.sh build-x86_64 build-arm64
deploy/macos/deploy-and-package.sh $builddirs

mv "$full_dmg" packages/

Expand Down
2 changes: 1 addition & 1 deletion deploy/cross/macos-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ needs_exe_wrapper = false
c = '/usr/bin/cc'
cpp = '/usr/bin/c++'
strip = 'strip'
pkgconfig = 'pkg-config'
pkg-config = 'pkg-config'
qmake = 'qmake'

[built-in options]
Expand Down
2 changes: 1 addition & 1 deletion deploy/cross/macos-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ needs_exe_wrapper = false
c = '/usr/bin/cc'
cpp = '/usr/bin/c++'
strip = 'strip'
pkgconfig = 'pkg-config'
pkg-config = 'pkg-config'
qmake = 'qmake'

[built-in options]
Expand Down
5 changes: 0 additions & 5 deletions deploy/macos/copy-scores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ if [ -d "$datadir" ]; then
fi
done
echo
echo "Removing trivial scores (C major scales and TheBlues)..."
rm -r "$sdir/C major"*
rm -r "$rdir/C major"*
rm -r "$rdir/TheBlues"*
echo
echo "Done"
else
echo
Expand Down
11 changes: 9 additions & 2 deletions deploy/macos/deploy-and-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ echo "Version: $version"

source="$full_name.app"
volume="$full_versioned"
volname="$full_name - $version"
target="$volume"/"$full_name".app
dmg="$volume".dmg

Expand Down Expand Up @@ -92,7 +93,13 @@ for builddir in $builddirs; do
echo "App exists in target $target, merging..."
find "$source" -name "$full_name" -o -name \*.dylib -o -name Qt\* |
while read f; do
lipo "$f" "$volume/$f" -create -output "$volume/$f"
this=$(lipo -archs "$f")
that=$(lipo -archs "$volume/$f")
if [ "$this" = "$that" ]; then
echo "File $f already has desired arch(s) in target"
else
lipo "$f" "$volume/$f" -create -output "$volume/$f"
fi
done
for helper in vamp-plugin-load-checker piper-vamp-simple-server; do
path="Contents/MacOS/$helper"
Expand Down Expand Up @@ -123,7 +130,7 @@ deploy/macos/sign.sh "$volume" || exit 1

rm -f "$dmg"

hdiutil create -srcfolder "$volume" "$dmg" -volname "$volume" -fs HFS+ &&
hdiutil create -srcfolder "$volume" "$dmg" -volname "$volname" -fs HFS+ &&
rm -r "$volume"

echo "Done"
Expand Down
67 changes: 7 additions & 60 deletions deploy/macos/notarize.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/bin/bash

## The following assumes we have generated an app password at
## appleid.apple.com and then stored it to keychain id "altool" using
## e.g.
## security add-generic-password -a "[email protected]" \
## -w "generated-app-password" -s "altool"

## NB to verify:
# spctl -a -v "/Applications/Application.app"

user="[email protected]"
team_id="73F996B92S"

set -eu

Expand All @@ -21,60 +16,12 @@ dmg="$full_dmg"
echo
echo "Uploading for notarization..."

uuidfile=.notarization-uuid
statfile=.notarization-status
rm -f "$uuidfile" "$statfile"

# At some point we need to switch to...
#xcrun notarytool submit \
# "$dmg" \
# --apple-id "$user" \
# --keychain-profile altool \
# --wait --progress

xcrun altool --notarize-app \
-f "$dmg" \
--primary-bundle-id "$bundleid" \
-u "$user" \
-p @keychain:altool 2>&1 | tee "$uuidfile"

uuid=$(cat "$uuidfile" | grep RequestUUID | awk '{ print $3; }')

if [ -z "$uuid" ]; then
echo
echo "Failed (no UUID returned, check output)"
exit 1
fi

echo "Done, UUID is $uuid"

echo
echo "Waiting and checking for completion..."

while true ; do
sleep 30

xcrun altool --notarization-info \
"$uuid" \
-u "$user" \
-p @keychain:altool 2>&1 | tee "$statfile"
if grep -q 'Package Approved' "$statfile"; then
echo
echo "Approved! Status output is:"
cat "$statfile"
break
elif grep -q 'in progress' "$statfile" ; then
echo
echo "Still in progress... Status output is:"
cat "$statfile"
echo "Waiting..."
else
echo
echo "Failure or unknown status in output:"
cat "$statfile"
exit 2
fi
done
xcrun notarytool submit \
"$dmg" \
--apple-id "$user" \
--team-id "$team_id" \
--keychain-profile notarytool-cannam \
--wait --progress

echo
echo "Stapling to package..."
Expand Down
46 changes: 28 additions & 18 deletions deploy/win64/build-64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo on

set STARTPWD=%CD%

set QTDIR=C:\Qt\5.13.2\msvc2017_64
set QTDIR=C:\QtOpenSource\6.6.2\msvc2019_64
if not exist %QTDIR% (
@ echo Could not find 64-bit Qt in %QTDIR%
@ exit /b 2
Expand All @@ -28,28 +28,38 @@ cd %STARTPWD%
call .\repoint install
if %errorlevel% neq 0 exit /b %errorlevel%

if not exist build_win64\build.ninja (
meson setup build_win64 --buildtype release -Db_lto=true
set BUILDDIR=build_win64

if not exist %BUILDDIR%\build.ninja (
meson setup %BUILDDIR% --buildtype release -Db_lto=true
if %errorlevel% neq 0 exit /b %errorlevel%
)

ninja -C build_win64
ninja -C %BUILDDIR%
if %errorlevel% neq 0 exit /b %errorlevel%

copy %QTDIR%\bin\Qt5Core.dll .\build_win64
copy %QTDIR%\bin\Qt5Gui.dll .\build_win64
copy %QTDIR%\bin\Qt5Widgets.dll .\build_win64
copy %QTDIR%\bin\Qt5Network.dll .\build_win64
copy %QTDIR%\bin\Qt5Xml.dll .\build_win64
copy %QTDIR%\bin\Qt5Svg.dll .\build_win64
copy %QTDIR%\bin\Qt5Test.dll .\build_win64
copy %QTDIR%\bin\Qt5Pdf.dll .\build_win64
copy %QTDIR%\plugins\platforms\qminimal.dll .\build_win64
copy %QTDIR%\plugins\platforms\qwindows.dll .\build_win64
copy %QTDIR%\plugins\styles\qwindowsvistastyle.dll .\build_win64
copy sv-dependency-builds\win64-msvc\lib\libsndfile-1.dll .\build_win64

meson test -C build_win64
copy %QTDIR%\bin\Qt6Core.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Gui.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Widgets.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Network.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Xml.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Svg.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Pdf.dll .\%BUILDDIR%
copy %QTDIR%\bin\Qt6Test.dll .\%BUILDDIR%

mkdir .\%BUILDDIR%\plugins
mkdir .\%BUILDDIR%\plugins\platforms
mkdir .\%BUILDDIR%\plugins\styles

copy %QTDIR%\plugins\platforms\qdirect2d.dll .\%BUILDDIR%\plugins\platforms
copy %QTDIR%\plugins\platforms\qminimal.dll .\%BUILDDIR%\plugins\platforms
copy %QTDIR%\plugins\platforms\qoffscreen.dll .\%BUILDDIR%\plugins\platforms
copy %QTDIR%\plugins\platforms\qwindows.dll .\%BUILDDIR%\plugins\platforms
copy %QTDIR%\plugins\styles\qwindowsvistastyle.dll .\%BUILDDIR%\plugins\styles

copy sv-dependency-builds\win64-msvc\lib\libsndfile-1.dll .\%BUILDDIR%

meson test -C %BUILDDIR%
if %errorlevel% neq 0 exit /b %errorlevel%

set PATH=%ORIGINALPATH%
2 changes: 1 addition & 1 deletion deploy/win64/build-and-package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if not exist "C:\Program Files (x86)\SMLNJ\bin" (
@ exit /b 2
)

if not exist "C:\Program Files (x86)\WiX Toolset v3.11\bin" (
if not exist "C:\Program Files (x86)\WiX Toolset v3.14\bin" (
@ echo Could not find WiX Toolset
@ exit /b 2
)
Expand Down
4 changes: 3 additions & 1 deletion deploy/win64/generate-wxs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ $ErrorActionPreference = "Stop"

$redist_parent_dir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\"

$redists = (Get-ChildItem -Path $redist_parent_dir -Name -Include 14.* -Attributes Directory)
$redists = @(Get-ChildItem -Path $redist_parent_dir -Name -Include 14.* -Attributes Directory)

if (!$redists) {
echo "ERROR: No 14.x redistributable directories found under $redist_parent_dir"
exit 1
}

"Redists are: $redists"

$redist_ver = $redists[-1]

$wxs = "deploy\win64\$full_kebab.wxs"
Expand Down
10 changes: 5 additions & 5 deletions deploy/win64/package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if ($args[0] -eq "sign") {

. deploy\metadata.ps1

$kitdir = "C:\Program Files (x86)\Windows Kits\10\bin\x64"
$wixdir = "C:\Program Files (x86)\WiX Toolset v3.11\bin"
$kitdir = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64"
$wixdir = "C:\Program Files (x86)\WiX Toolset v3.14\bin"

if (! (Test-Path -Path $kitdir -PathType Container)) {
"ERROR: Windows Kit directory $kitdir not found"
Expand All @@ -35,13 +35,13 @@ $name = "Christopher Cannam"

if ($sign) {
"Signing executables"
&"$kitdir\signtool" sign /v /n "$name" /t http://time.certum.pl /fd sha1 /a build_win64\*.exe
&"$kitdir\signtool" sign /v /debug /n "$name" /t http://time.certum.pl /fd sha256 /a build_win64\*.exe
}

"Packaging"

if (Test-Path -Path "$full_kebab.msi") {
rm $full_kebab.msi
rm "$full_kebab.msi"
}

&"$wixdir\candle" -v deploy\win64\"$full_kebab.wxs"
Expand All @@ -51,7 +51,7 @@ rm "$full_kebab.wixpdb"

if ($sign) {
"Signing packages"
&"$kitdir\signtool" sign /v /n "$name" /t http://time.certum.pl /fd sha1 /a *.msi
&"$kitdir\signtool" sign /v /n "$name" /t http://time.certum.pl /fd sha256 /a *.msi
&"$kitdir\signtool" verify /pa "$full_kebab.msi"
}

Expand Down
Loading

0 comments on commit fb3dc9a

Please sign in to comment.