Skip to content

Commit

Permalink
Updating patches, preparing for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Jul 19, 2019
1 parent 74518ea commit 0dc1a18
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 16 deletions.
33 changes: 26 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"io/ioutil"
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
"time"

"github.com/Dids/clobber/patches"
Expand Down Expand Up @@ -55,6 +57,9 @@ var Spinner = spinner.New(spinner.CharSets[14], 100*time.Millisecond)
// Hiss hiss, said the snake
var Hiss bool

// Controls whether to patch buildpkg.sh or not
var patchBuildPkg = true

// Create a new logger
var log = logrus.New()

Expand Down Expand Up @@ -106,6 +111,14 @@ var rootCmd = &cobra.Command{
Long: `Clobber is a command-line application for building Clover.
Built by @Dids with tons of love, sweat and tears.`,
Run: func(cmd *cobra.Command, args []string) {
// Setup graceful shutdown support
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGINT)
go func() {
<-c
log.Fatal("CTRL-C detected, aborting..")
}()

// FIXME: Integrate this with the builder?!
if Hiss {
game := snake.NewGame()
Expand Down Expand Up @@ -299,38 +312,42 @@ var rootCmd = &cobra.Command{
Spinner.Prefix = formatSpinnerText("Updating extra EFI drivers", false)

// Download and copy HFSPlus.efi
if err := util.DownloadFile("https://github.com/Micky1979/Build_Clover/raw/work/Files/HFSPlus_x64.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/UEFI/FileSystem/HFSPlus.efi"); err != nil {
if err := util.DownloadFile("https://github.com/Micky1979/Build_Clover/raw/work/Files/HFSPlus_x64.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/UEFI/HFSPlus.efi"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
if err := util.DownloadFile("https://github.com/Micky1979/Build_Clover/raw/work/Files/HFSPlus_x64.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/BIOS/FileSystem/HFSPlus.efi"); err != nil {
if err := util.DownloadFile("https://github.com/Micky1979/Build_Clover/raw/work/Files/HFSPlus_x64.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/BIOS/HFSPlus.efi"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}

// Download Acidanthera drivers
os.RemoveAll(os.TempDir() + "AppleSupportPkg.zip")
if err := util.DownloadFile(getGitHubReleaseLink("https://api.github.com/repos/acidanthera/AppleSupportPkg/releases/latest", "browser_download_url.*RELEASE.zip"), os.TempDir()+"AppleSupportPkg.zip"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
defer os.RemoveAll(os.TempDir() + "AppleSupportPkg.zip")
os.RemoveAll(os.TempDir() + "AptioFixPkg.zip")
if err := util.DownloadFile(getGitHubReleaseLink("https://api.github.com/repos/acidanthera/AptioFixPkg/releases/latest", "browser_download_url.*RELEASE.zip"), os.TempDir()+"AptioFixPkg.zip"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
defer os.RemoveAll(os.TempDir() + "AptioFixPkg.zip")

// Extract Acidanthera drivers
os.RemoveAll(os.TempDir() + "AppleSupportPkg")
if err := archiver.Unarchive(os.TempDir()+"AppleSupportPkg.zip", os.TempDir()+"AppleSupportPkg"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
defer os.RemoveAll(os.TempDir() + "AppleSupportPkg")
os.RemoveAll(os.TempDir() + "AptioFixPkg")
if err := archiver.Unarchive(os.TempDir()+"AptioFixPkg.zip", os.TempDir()+"AptioFixPkg"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
defer os.RemoveAll(os.TempDir() + "AptioFixPkg")

// Copy ApfsDriverLoader.efi
if err := util.CopyFile(os.TempDir()+"AppleSupportPkg/Drivers/ApfsDriverLoader.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/UEFI/FileSystem/ApfsDriverLoader.efi"); err != nil {
if err := util.CopyFile(os.TempDir()+"AppleSupportPkg/Drivers/ApfsDriverLoader.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/UEFI/ApfsDriverLoader.efi"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
if err := util.CopyFile(os.TempDir()+"AppleSupportPkg/Drivers/ApfsDriverLoader.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/BIOS/FileSystem/ApfsDriverLoader.efi"); err != nil {
if err := util.CopyFile(os.TempDir()+"AppleSupportPkg/Drivers/ApfsDriverLoader.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/BIOS/ApfsDriverLoader.efi"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}

Expand Down Expand Up @@ -367,7 +384,7 @@ var rootCmd = &cobra.Command{
// }

// Copy AptioMemoryFix.efi
if err := util.CopyFile(os.TempDir()+"AptioFixPkg/Drivers/AptioMemoryFix.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/UEFI/MemoryFix/AptioMemoryFix.efi"); err != nil {
if err := util.CopyFile(os.TempDir()+"AptioFixPkg/Drivers/AptioMemoryFix.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/UEFI/AptioMemoryFix.efi"); err != nil {
log.Fatal("Error: Failed to update extra EFI drivers: ", err)
}
// if err := util.CopyFile(os.TempDir()+"AptioFixPkg/Drivers/AptioMemoryFix.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/EFI/CLOVER/drivers/off/BIOS/MemoryFix/AptioMemoryFix.efi"); err != nil {
Expand Down Expand Up @@ -424,8 +441,10 @@ var rootCmd = &cobra.Command{
}

// Patch the Clover installer package
if patchErr := patches.Patch(packedPatches, "buildpkg6", util.GetCloverPath()+"/CloverPackage/package/buildpkg.sh"); patchErr != nil {
log.Fatal("Error: Failed to patch Clover installer (patch buildpkg.sh): ", patchErr)
if patchBuildPkg {
if patchErr := patches.Patch(packedPatches, "buildpkg6", util.GetCloverPath()+"/CloverPackage/package/buildpkg.sh"); patchErr != nil {
log.Fatal("Error: Failed to patch Clover installer (patch buildpkg.sh): ", patchErr)
}
}
// Load the installer image asset
backgroundPatch, backgroundPatchErr := packedAssets.Find("background.tiff")
Expand Down
70 changes: 61 additions & 9 deletions patches/buildpkg6.patch
Original file line number Diff line number Diff line change
@@ -1,32 +1,84 @@
--- buildpkg.sh
+++ buildpkg.sh
@@ -843,7 +843,7 @@
addChoice --group="Recommended64" \
--- /Users/dids/.clobber/src/edk2/Clover/CloverPackage/package/buildpkg.sh 2019-07-19 11:41:21.000000000 +0300
+++ /Users/dids/.clobber/src/edk2/Clover/CloverPackage/package/buildpkg_patched.sh 2019-07-19 11:42:11.000000000 +0300
@@ -13,6 +13,15 @@
set -u # Abort with unset variables
#set -x

+isDefaultPackage () {
+ local packageRefId="${1}"
+ if [[ $packageRefId =~ ^(.*)(apfsdriverloader|aptiomemoryfix|hfsplus)(.*)$ ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
usage () {
printf "\n\e[1m%s\e[0m" "Usage: $0 --srcroot <path> --symroot <name> --builddir <path> [flag1 flag2...]"
echo
@@ -526,7 +535,7 @@
--subst="INSTALLER_CHOICE=$packageRefId" MarkChoice
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EFIROOTDIR"
if [[ ${NOEXTRAS} != *"CloverEFI"* ]]; then
- addChoice --start-visible="true" --start-selected="choicePreviouslySelected('$packageRefId')" \
+ addChoice --start-visible="true" --start-selected="cloverPackageFirstRun() || choicePreviouslySelected('$packageRefId')" \
--pkg-refs="$packageRefId" "${choiceId}"
else
addChoice --start-visible="false" --start-selected="true" \
@@ -840,12 +849,22 @@
# (i.e. Clover package never run on that target partition).
# Otherwise each single choice start selected only for legacy Clover and only if you previously selected it
buildpackage "$packageRefId" "${driverChoice}" "${PKG_BUILD_DIR}/${driverChoice}" "${driverDestDir}"
- addChoice --group="Recommended64" \
+ if isDefaultPackage "$packageRefId"; then
+ addChoice --group="Recommended64" \
+ --start-visible="true" \
+ --enabled="!choices['UEFI.only'].selected" \
+ --start-selected="!choices['UEFI.only'].selected" \
+ --visible="!choices['UEFI.only'].selected" \
+ --pkg-refs="$packageRefId" "${driverChoice}"
+ else
+ addChoice --group="Recommended64" \
--start-visible="true" \
--enabled="!choices['UEFI.only'].selected" \
- --start-selected="!choices['UEFI.only'].selected &amp;&amp; (cloverPackageFirstRun() || choicePreviouslySelected('$packageRefId'))" \
+ --start-selected="!choices['UEFI.only'].selected &amp;&amp; (choicePreviouslySelected('$packageRefId'))" \
--visible="!choices['UEFI.only'].selected" \
--pkg-refs="$packageRefId" "${driverChoice}"
+ fi
+
rm -R -f "${PKG_BUILD_DIR}/${driverChoice}"
@@ -1009,7 +1009,7 @@
done
fi
@@ -1007,10 +1026,17 @@
fi

buildpackage "$packageRefId" "${driverChoice}" "${PKG_BUILD_DIR}/${driverChoice}" "${driverDestDir}"
addChoice --group="Recommended64UEFI" \
- addChoice --group="Recommended64UEFI" \
+ if isDefaultPackage "$packageRefId"; then
+ addChoice --group="Recommended64UEFI" \
--start-visible="true" \
- --start-selected="cloverPackageFirstRun() || choicePreviouslySelected('$packageRefId')" \
+ --start-selected="choicePreviouslySelected('$packageRefId')" \
+ --start-selected="true" \
--pkg-refs="$packageRefId" "${driverChoice}"
+ else
+ addChoice --group="Recommended64UEFI" \
+ --start-visible="true" \
+ --start-selected="choicePreviouslySelected('$packageRefId')" \
+ --pkg-refs="$packageRefId" "${driverChoice}"
+ fi
rm -R -f "${PKG_BUILD_DIR}/${driverChoice}"
done
@@ -1359,7 +1359,6 @@
fi
@@ -1359,7 +1385,6 @@
for (( i = 0 ; i < ${#specialThemes[@]} ; i++ )); do
local themeName=${specialThemes[$i]##*/}
# Don't add christmas and newyear themes if month < 11
- [[ $currentMonth -lt 11 ]] && [[ "$themeName" == christmas || "$themeName" == newyear ]] && continue
mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/"
rsync -r --exclude=.svn --exclude="*~" "$artwork/${specialThemes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}"
packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}")
@@ -1369,7 +1368,7 @@
@@ -1369,7 +1394,7 @@
InstallTheme

buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "${themeDestDir}"
Expand Down

0 comments on commit 0dc1a18

Please sign in to comment.