|
1 | 1 | #!/bin/bash |
2 | 2 | # |
3 | | -# Reset default charset for GNUsed problems... |
4 | | -#set -x |
| 3 | +# Clover package build script |
| 4 | +# created by vector sigma, refined version |
| 5 | +# |
| 6 | + |
| 7 | +# --- Reset locale to avoid GNU sed issues --- |
5 | 8 | export LC_ALL=C |
6 | 9 |
|
7 | | -usage () { |
8 | | -printf "\n\e[1m%s\e[0m\n" "Usage: $0 [flag1 flag2...]" |
9 | | -printf "\n%s" "The (optional) exclude flags are being passed to the buildpkg.sh script, when specified." |
10 | | -printf "\n%s\n" "Possible flag values:" |
11 | | -printf "\n\e[1m%s\e[0m\t%s" "--nothemes" "Excludes the Themes subpackage." |
12 | | -# printf "\n\e[1m%s\e[0m\t%s" "--noprefpane" "Excludes the Clover Prefpane / Clover Updater subpackage." |
13 | | -printf "\n\e[1m%s\e[0m\t\t%s" "--norc" "Excludes the RC scripts subpackage." |
14 | | -printf "\n\e[1m%s\e[0m\t%s" "--nolegacy" "Excludes the CloverEFI subpackages." |
15 | | -echo |
| 10 | +# --- Ensure the script is called from make (optional warning) --- |
| 11 | +caller=$(ps -p $PPID -o comm=) |
| 12 | +if [[ "$caller" != "make" ]]; then |
| 13 | + echo "Warning: don't call the '$0' script directly !" >&2 |
| 14 | + echo "Use the 'make pkg' command instead" >&2 |
| 15 | + # exit 1 # uncomment if you want to enforce this |
| 16 | +fi |
| 17 | + |
| 18 | +# --- Define important paths --- |
| 19 | +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 20 | +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 21 | +SYMROOT="$SCRIPT_DIR/sym" |
| 22 | +PKG_BUILD_DIR="$SYMROOT/package" |
| 23 | + |
| 24 | +# --- Add local toolchain and gettext to PATH --- |
| 25 | +export PATH="$REPO_ROOT/toolchain/bin:$REPO_ROOT/toolchain/bin/gettext/bin:$PATH" |
| 26 | + |
| 27 | +# --- Usage help function --- |
| 28 | +usage() { |
| 29 | + echo |
| 30 | + echo -e "\e[1mUsage:\e[0m $0 [flag1 flag2...]" |
| 31 | + echo |
| 32 | + echo "Optional exclude flags passed to buildpkg.sh:" |
| 33 | + echo -e "\e[1m--nothemes\e[0m\tExcludes the Themes subpackage." |
| 34 | + echo -e "\e[1m--norc\e[0m\t\tExcludes the RC scripts subpackage." |
| 35 | + echo -e "\e[1m--nolegacy\e[0m\tExcludes the CloverEFI subpackages." |
| 36 | + echo |
16 | 37 | } |
17 | 38 |
|
| 39 | +# --- Parse arguments --- |
| 40 | +NOEXTRAS="" |
18 | 41 | while [[ $# -gt 0 ]]; do |
19 | | - case "${1}" in |
20 | | - --nothemes ) NOEXTRAS+=" --nothemes";; |
21 | | - # --noprefpane ) NOEXTRAS+=" --noprefpane";; |
22 | | - --norc ) NOEXTRAS+=" --norc";; |
23 | | - --nolegacy ) NOEXTRAS+=" --nolegacy";; |
24 | | - * ) printf "\e[1m%s\e[0m\n" "Invalid option: ${1} !"; usage; exit 1;; |
25 | | - esac |
26 | | - shift |
| 42 | + case "${1}" in |
| 43 | + --nothemes) NOEXTRAS+=" --nothemes";; |
| 44 | + --norc) NOEXTRAS+=" --norc";; |
| 45 | + --nolegacy) NOEXTRAS+=" --nolegacy";; |
| 46 | + *) echo -e "\e[1mInvalid option:\e[0m ${1}"; usage; exit 1;; |
| 47 | + esac |
| 48 | + shift |
27 | 49 | done |
28 | 50 |
|
29 | | -# Workspace = edk2/Clover/CloverPackage |
30 | | - |
31 | | -# Go to the script directory to create the package |
32 | | -cd "$(dirname $0)" |
33 | | - |
34 | | -revision=$(git describe --tags $(git rev-list --tags --max-count=1)) |
35 | | - |
36 | | -SRCROOT="${PWD}" |
37 | | -SYMROOT="${SRCROOT}"/sym |
38 | | -PKG_BUILD_DIR="${SYMROOT}"/package |
39 | | - |
40 | | -echo "${revision}" > revision |
41 | | - |
42 | | -# Workspace = edk2/Clover/CloverPackage |
| 51 | +# --- Move to script directory --- |
| 52 | +cd "$SCRIPT_DIR" || { echo "Failed to enter script directory"; exit 1; } |
43 | 53 |
|
| 54 | +# --- Determine latest git revision --- |
| 55 | +revision=$(git describe --tags "$(git rev-list --tags --max-count=1)") |
| 56 | +echo "$revision" > revision |
44 | 57 |
|
45 | | -# Workspace = Clover/CloverPackage |
46 | | -# Prepare i386 for building package installer. |
47 | | - |
48 | | -# if [[ -d "$PKG_BUILD_DIR" && $(stat -f '%u' "$PKG_BUILD_DIR") -eq 0 ]]; then |
49 | | -# sudo rm -rf sym |
50 | | -# fi |
51 | | -# rm -rf sym |
52 | | -# |
53 | | -# # Create a new sym directory |
54 | | -# mkdir sym |
55 | | - |
56 | | -# Make the translation |
57 | | -echo "" |
58 | | -echo "========= Translating Resources ========" |
| 58 | +# --- Translate resources --- |
| 59 | +echo |
| 60 | +echo "========= Translating Resources =========" |
59 | 61 | ./package/translate.sh || exit $? |
60 | 62 |
|
61 | | -# Check that XCode is install properly |
| 63 | +# --- Check Xcode installation and build utils --- |
62 | 64 | xcode_path=$(/usr/bin/xcode-select --print-path 2>/dev/null) |
63 | 65 | if [[ -n "$xcode_path" ]]; then |
64 | | - # # Make CloverUpdater |
65 | | - # "${SRCROOT}"/CloverUpdater/translate_xib.sh # workaround for a bug in Xcode 10 Beta |
66 | | - # make -C "${SRCROOT}"/CloverUpdater || exit $? |
67 | | - # # Make CloverPrefpane |
68 | | - # "${SRCROOT}"/CloverPrefpane/translate_xib.sh # workaround for a bug in Xcode 10 Beta |
69 | | - # "${SRCROOT}"/CloverPrefpane/translate_source.sh # workaround for a bug in Xcode 10 Beta |
70 | | - # make -C "${SRCROOT}"/CloverPrefpane || exit $? |
71 | | - # Make utils |
72 | | - make -C "${SRCROOT}"/utils || exit $? |
73 | | -# temporary use ready-to-use binaries |
74 | | -# mkdir -p "${SYMROOT}"/utils |
75 | | -# cp -v "${SRCROOT}"/utils/binaries/* "${SYMROOT}"/utils/ |
| 66 | + echo "Xcode detected at: $xcode_path" |
| 67 | + echo "Building utils..." |
| 68 | + make -C "${SCRIPT_DIR}/utils" || exit $? |
| 69 | +else |
| 70 | + echo "Warning: Xcode not found — skipping utils build." |
76 | 71 | fi |
77 | 72 |
|
78 | | -# Start to build installer. |
79 | | - |
80 | | -package/buildpkg.sh --srcroot "$SRCROOT" --symroot "sym" --builddir "$PKG_BUILD_DIR" ${NOEXTRAS:1} || exit $? |
81 | | - |
82 | | -#(cd sym ; zip Clover_r${revision}.zip \ |
83 | | -# Clover_r${revision}.pkg \ |
84 | | -# Clover_r${revision}.pkg.md5 ) |
85 | | - |
86 | | -# Workspace = edk2/Clover/CloverPackage/ |
87 | | -# Remove temp files. |
| 73 | +# --- Build installer package --- |
| 74 | +echo |
| 75 | +echo "========= Building Installer =========" |
| 76 | +package/buildpkg.sh \ |
| 77 | + --srcroot "$SCRIPT_DIR" \ |
| 78 | + --symroot "sym" \ |
| 79 | + --builddir "$PKG_BUILD_DIR" \ |
| 80 | + ${NOEXTRAS:1} || exit $? |
88 | 81 |
|
89 | | -rm -f version # take this to clean old sources |
90 | | -rm -f revision |
| 82 | +# --- Cleanup temporary files --- |
| 83 | +rm -f version revision |
91 | 84 |
|
92 | | -# Workspace = edk2/Clover/CloverPackage |
93 | | -# Open the final folder. |
| 85 | +# --- Show result and open folder --- |
| 86 | +echo |
| 87 | +echo "========= Build Complete =========" |
94 | 88 | ls -la sym |
95 | 89 | open sym |
96 | | -# Finish building installer. |
97 | 90 |
|
98 | 91 | exit 0 |
0 commit comments