forked from AsahiLinux/asahi-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·112 lines (77 loc) · 2.28 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# SPDX-License-Identifier: MIT
set -e
cd "$(dirname "$0")"
PYTHON_VER=3.9.6
PYTHON_PKG=python-$PYTHON_VER-macos11.pkg
PYTHON_URI="https://www.python.org/ftp/python/$PYTHON_VER/$PYTHON_PKG"
M1N1="$PWD/m1n1"
ARTWORK="$PWD/artwork"
AFW="$PWD/asahi_firmware"
SRC="$PWD/src"
VENDOR="$PWD/vendor"
DL="$PWD/dl"
PACKAGE="$PWD/package"
RELEASES="$PWD/releases"
RELEASES_DEV="$PWD/releases-dev"
rm -rf "$PACKAGE"
mkdir -p "$DL" "$PACKAGE" "$RELEASES" "$RELEASES_DEV"
mkdir -p "$PACKAGE/bin"
echo "Determining version..."
VER=$(git describe --always --dirty --tags)
echo "Version: $VER"
if [ -z "$VER" ]; then
if [ -e version.tag ]; then
VER="$(cat version.tag)"
else
echo "Could not determine version!"
exit 1
fi
fi
echo "Downloading installer components..."
cd "$DL"
wget -Nc "$PYTHON_URI"
echo "Building m1n1..."
make -C "$M1N1" RELEASE=1 CHAINLOADING=1 -j4
echo "Copying files..."
cp -r "$SRC"/* "$PACKAGE/"
rm "$PACKAGE/asahi_firmware"
cp -r "$AFW" "$PACKAGE/"
cp "$ARTWORK/logos/icns/AsahiLinux_logomark.icns" "$PACKAGE/logo.icns"
mkdir -p "$PACKAGE/boot"
cp "$M1N1/build/m1n1.bin" "$PACKAGE/boot"
echo "Extracting Python framework..."
mkdir -p "$PACKAGE/Frameworks/Python.framework"
7z x -so "$DL/$PYTHON_PKG" Python_Framework.pkg/Payload | zcat | \
cpio -i -D "$PACKAGE/Frameworks/Python.framework"
cd "$PACKAGE/Frameworks/Python.framework/Versions/Current"
echo "Copying vendored libffi into Python framework..."
cp -P "$VENDOR"/libffi/* lib/
echo "Slimming down Python..."
rm -rf include share
cd lib
rm -rf -- tdb* tk* Tk* libtk* *tcl*
cd python3.*
rm -rf test ensurepip idlelib
cd lib-dynload
rm -f _test* _tkinter*
echo "Copying certificates..."
certs="$(python3 -c 'import certifi; print(certifi.where())')"
cp "$certs" "$PACKAGE/Frameworks/Python.framework/Versions/Current/etc/openssl/cert.pem"
echo "Packaging installer..."
cd "$PACKAGE"
echo "$VER" > version.tag
if [ "$1" == "prod" ]; then
PKGFILE="$RELEASES/installer-$VER.tar.gz"
LATEST="$RELEASES/latest"
elif [ "$1" == "dev" ]; then
PKGFILE="$RELEASES_DEV/installer-$VER.tar.gz"
LATEST="$RELEASES_DEV/latest"
else
PKGFILE="../installer.tar.gz"
LATEST="../latest"
fi
tar czf "$PKGFILE" .
echo "$VER" > "$LATEST"
echo
echo "Built package: $(basename "$PKGFILE")"