Skip to content

Commit

Permalink
build: small improvements
Browse files Browse the repository at this point in the history
- add python framework into variable
- move command sections together
- remove cd command from build process

Signed-off-by: Andrej Valek <andy@skyrain.eu>
  • Loading branch information
andy9a9 committed Mar 1, 2022
1 parent e3d26f7 commit 8de1986
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,57 @@ ARTWORK="$PWD/artwork"
SRC="$PWD/src"
DL="$PWD/dl"
PACKAGE="$PWD/package"
PYTHON_FWORK="$PACKAGE/Frameworks/Python.framework"
PYTHON_FWORK_VERSION="$PYTHON_FWORK/Versions/Current"

rm -rf "$PACKAGE"

mkdir -p "$DL" "$PACKAGE"
mkdir -p "$PACKAGE/bin"
mkdir -p "$DL" "$PACKAGE/bin" "$PACKAGE/boot"

echo "Updating submodules..."

git submodule update --init --recursive

echo "Downloading installer components..."

cd "$DL"

wget -Nc "$PYTHON_URI"
wget -P "$DL" -Nc "$PYTHON_URI"

echo "Building m1n1..."

make -C "$M1N1" RELEASE=1 -j4

echo "Building u-boot..."

make -C "$UBOOT" CROSS_COMPILE=aarch64-linux-gnu- -j4 apple_m1_defconfig all

echo "Copying files..."

cp -r "$SRC"/* "$PACKAGE/"
cp "$ARTWORK/logos/icns/AsahiLinux_logomark.icns" "$PACKAGE/logo.icns"
mkdir -p "$PACKAGE/boot"
cp "$M1N1/build/m1n1.bin" "$PACKAGE/boot"
cat "$M1N1/build/m1n1.bin" \
"$UBOOT/arch/arm/dts/"t[86]*.dtb \
"$UBOOT/u-boot-nodtb.bin" \
> "$PACKAGE/boot/m1n1-uboot.bin"

echo "Extracting Python framework..."

mkdir -p "$PACKAGE/Frameworks/Python.framework"

echo "Extracting Python framework..."
mkdir -p "$PYTHON_FWORK"
7z x -so "$DL/$PYTHON_PKG" Python_Framework.pkg/Payload | zcat | \
cpio -i -D "$PACKAGE/Frameworks/Python.framework"
cpio -i -D "$PYTHON_FWORK"

echo "Slimming down Python..."

cd "$PACKAGE/Frameworks/Python.framework/Versions/Current"
echo "Slimming down Python..."
(
cd "$PYTHON_FWORK_VERSION"
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*
)

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"
cp "$certs" "$PYTHON_FWORK_VERSION/etc/openssl/cert.pem"

echo "Packaging installer..."

cd "$PACKAGE"

tar czf ../installer.tar.gz .

0 comments on commit 8de1986

Please sign in to comment.