Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BuildOnly bool
BuildOnly will only build, but not update anything
View Source
var InstallerOnly bool
InstallerOnly will only build the installer
View Source
var NoClean bool
NoClean skips cleaning of dirty files
View Source
var Quiet bool
Quiet enables silencing all output
View Source
var Revision string
Revision is the default Clover revision to use
View Source
var RootCmd = &cobra.Command{ Use: "clobber", Short: "Clobber is a command-line application for building Clover", 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) { executionStartTime := time.Now() logo := figure.NewFigure("CLOBBER", "puffy", true) logo.Print() fmt.Println(" v" + Version + " by @Dids") fmt.Println() if BuildOnly && UpdateOnly { log.Fatal("Error: Cannot use --build-only and --update-only simultaneously") } if BuildOnly && InstallerOnly { log.Fatal("Error: Cannot use --build-only and --installer-only simultaneously") } if UpdateOnly && InstallerOnly { log.Fatal("Error: Cannot use --update-only and --installer-only simultaneously") } if BuildOnly && UpdateOnly && InstallerOnly { log.Fatal("Error: Cannot use --build-only, --update-only and --installer-only simultaneously") } if !Verbose && !Quiet { Spinner.Start() } log.Debug("Target Clover revision:", Revision) if args != nil && len(args) > 0 { log.Debug("Building with arguments:", args) } Spinner.Prefix = formatSpinnerText("Verifying folder structure", false) time.Sleep(100 * time.Millisecond) mkdirErr := os.MkdirAll(util.GetSourcePath(), 0755) if mkdirErr != nil { log.Fatal("Error: MkdirAll failed with error: ", mkdirErr) } Spinner.Prefix = formatSpinnerText("Verifying folder structure", true) if _, err := os.Stat(util.GetUdkPath() + "/.git"); os.IsNotExist(err) { if BuildOnly { log.Fatal("Error: UDK2018 is missing and using --build-only, cannot continue") } if InstallerOnly { log.Fatal("Error: UDK2018 is missing and using --installer-only, cannot continue") } log.Debug("UDK2018 is missing, downloading..") Spinner.Prefix = formatSpinnerText("Downloading UDK2018", false) git.Clone("https://github.com/tianocore/edk2", util.GetUdkPath(), git.CloneRepoOptions{Branch: "UDK2018", Bare: false, Quiet: Verbose}) Spinner.Prefix = formatSpinnerText("Downloading UDK2018", true) } if !BuildOnly && !InstallerOnly { log.Debug("Verifying UDK2018 is up to date..") Spinner.Prefix = formatSpinnerText("Verifying UDK2018 is up to date", false) if !NoClean { runCommand("cd " + util.GetUdkPath() + " && git clean -fdx --exclude=\"Clover/\"") } git.Checkout(util.GetSourcePath(), git.CheckoutOptions{Branch: "UDK2018"}) Spinner.Prefix = formatSpinnerText("Verifying UDK2018 is up to date", true) } if _, err := os.Stat(util.GetCloverPath() + "/.svn"); os.IsNotExist(err) { if BuildOnly { log.Fatal("Error: Clover is missing and using --build-only, cannot continue") } if InstallerOnly { log.Fatal("Error: Clover is missing and using --installer-only, cannot continue") } log.Debug("Clover is missing, downloading..") Spinner.Prefix = formatSpinnerText("Downloading Clover", false) runCommand("svn co " + "https://svn.code.sf.net/p/cloverefiboot/code" + " " + util.GetCloverPath()) Spinner.Prefix = formatSpinnerText("Downloading Clover", true) } if !BuildOnly && !InstallerOnly { log.Debug("Verifying Clover is up to date..") Spinner.Prefix = formatSpinnerText("Verifying Clover is up to date", false) if !NoClean { runCommand("svn cleanup " + util.GetCloverPath()) runCommand("svn cleanup --remove-unversioned " + util.GetCloverPath()) runCommand("svn revert -R" + " " + util.GetCloverPath()) } runCommand("svn up -r" + Revision + " " + util.GetCloverPath()) Spinner.Prefix = formatSpinnerText("Verifying Clover is up to date", true) } if !UpdateOnly && !InstallerOnly { log.Debug("Overriding HOME..") os.Setenv("HOME", util.GetClobberPath()) log.Debug("Overriding TOOLCHAIN_DIR..") os.Setenv("TOOLCHAIN_DIR", util.GetSourcePath()+"/opt/local") log.Debug("Building base tools..") Spinner.Prefix = formatSpinnerText("Building base tools", false) runCommand("make -C" + " " + util.GetUdkPath() + "/BaseTools/Source/C") Spinner.Prefix = formatSpinnerText("Building base tools", true) log.Debug("Setting up UDK..") Spinner.Prefix = formatSpinnerText("Setting up UDK", false) runCommand("cd " + util.GetUdkPath() + " && " + "source edksetup.sh") Spinner.Prefix = formatSpinnerText("Setting up UDK", true) if _, err := os.Stat(util.GetSourcePath() + "/opt/local/bin/gettext"); os.IsNotExist(err) { log.Debug("Building gettext..") Spinner.Prefix = formatSpinnerText("Building gettext", false) runCommand(util.GetCloverPath() + "/buildgettext.sh") Spinner.Prefix = formatSpinnerText("Building gettext", true) } if _, err := os.Stat(util.GetSourcePath() + "/opt/local/bin/mtoc.NEW"); os.IsNotExist(err) { log.Debug("Building mtoc..") Spinner.Prefix = formatSpinnerText("Building mtoc", false) runCommand(util.GetCloverPath() + "/buildmtoc.sh") Spinner.Prefix = formatSpinnerText("Building mtoc", true) } if _, err := os.Stat(util.GetSourcePath() + "/opt/local/bin/nasm"); os.IsNotExist(err) { log.Debug("Building nasm..") Spinner.Prefix = formatSpinnerText("Building nasm", false) runCommand(util.GetCloverPath() + "/buildnasm.sh") Spinner.Prefix = formatSpinnerText("Building nasm", true) } log.Debug("Applying patches for UDK..") Spinner.Prefix = formatSpinnerText("Applying UDK patches", false) copyErr := copy.Copy(util.GetCloverPath()+"/Patches_for_UDK2018", util.GetUdkPath()) Spinner.Prefix = formatSpinnerText("Applying UDK patches", true) if copyErr != nil { log.Fatal("Error: Failed to copy UDK patches: ", copyErr) } log.Debug("Building Clover..") Spinner.Prefix = formatSpinnerText("Building Clover", false) runCommand(util.GetCloverPath() + "/ebuild.sh -cleanall") runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64 --ext-co -D NO_GRUB_DRIVERS_EMBEDDED") runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64-mcp --no-usb --ext-co -D NO_GRUB_DRIVERS_EMBEDDED") Spinner.Prefix = formatSpinnerText("Building Clover", true) } if !BuildOnly && !InstallerOnly { log.Debug("Updating extra EFI drivers..") Spinner.Prefix = formatSpinnerText("Updating extra EFI drivers", false) util.DownloadFile("https://github.com/Micky1979/Build_Clover/raw/work/Files/HFSPlus_x64.efi", util.GetCloverPath()+"/CloverPackage/CloverV2/drivers-Off/drivers64UEFI/HFSPlus.efi") Spinner.Prefix = formatSpinnerText("Updating extra EFI drivers", true) } if !UpdateOnly { log.Debug("Patching Clover installer..") Spinner.Prefix = formatSpinnerText("Patching Clover installer", false) log.Debug("Listing environment version information:\n" + util.GetVersionDump()) log.Debug("Updating package credits..") additionalCredits := "Custom package by Dids." creditsFilePath := util.GetCloverPath() + "/CloverPackage/CREDITS" fileBuffer, fileReadErr := ioutil.ReadFile(creditsFilePath) if fileReadErr != nil { log.Fatal("Error: Failed to update package credits: ", fileReadErr) } creditsString := string(fileBuffer) if !strings.Contains(creditsString, additionalCredits) { strReplaceErr := util.StringReplaceFile(creditsFilePath, "Chameleon team, crazybirdy, JrCs.", "Chameleon team, crazybirdy, JrCs. "+additionalCredits) if strReplaceErr != nil { log.Fatal("Error: Failed to update package credits: ", strReplaceErr) } } log.Debug("Updating package description..") additionalDescription := "<p><b>Dids's build details:</b></p>\n" additionalDescription += "<ul>\n" versionDump := util.GetVersionDump() for _, line := range strings.Split(strings.TrimSuffix(versionDump, "\n"), "\n") { additionalDescription += "<li>" + line + "</li>\n" } additionalDescription += "</ul>\n" descriptionFilePath := util.GetCloverPath() + "/CloverPackage/package/Resources/templates/Description.html" descriptionFileBuffer, descriptionFileReadErr := ioutil.ReadFile(descriptionFilePath) if descriptionFileReadErr != nil { log.Fatal("Error: Failed to update package description: ", descriptionFileReadErr) } descriptionString := string(descriptionFileBuffer) if !strings.Contains(descriptionString, additionalDescription) && !strings.Contains(descriptionString, "Dids's build details:") { strReplaceErr := util.StringReplaceFile(descriptionFilePath, "</body>\n</html>\n", additionalDescription+"</body>\n</html>\n") if strReplaceErr != nil { log.Fatal("Error: Failed to update package description: ", strReplaceErr) } } if err := patches.Patch(packedPatches, "buildpkg_old", util.GetCloverPath()+"/CloverPackage/package/buildpkg.sh"); err != nil { log.Fatal("Error: Failed to patch Clover installer: ", err) } backgroundPatch, backgroundPatchErr := packedAssets.Find("background.tiff") if backgroundPatchErr != nil { log.Fatal("Error: Failed to patch Clover installer: ", backgroundPatchErr) } if err := ioutil.WriteFile(util.GetCloverPath()+"/CloverPackage/package/Resources/background.tiff", backgroundPatch, 0644); err != nil { log.Fatal("Error: Failed to patch Clover installer: ", err) } Spinner.Prefix = formatSpinnerText("Patching Clover installer", true) log.Debug("Building Clover installer..") Spinner.Prefix = formatSpinnerText("Building Clover installer", false) runCommand(util.GetCloverPath() + "/CloverPackage/makepkg") Spinner.Prefix = formatSpinnerText("Building Clover installer", true) if !InstallerOnly { log.Debug("Building Clover ISO image..") Spinner.Prefix = formatSpinnerText("Building Clover ISO image", false) runCommand(util.GetCloverPath() + "/CloverPackage/makeiso") Spinner.Prefix = formatSpinnerText("Building Clover ISO image", true) } } executionElapsedTime := util.GenerateTimeString(time.Since(executionStartTime)) executionResult := fmt.Sprintf("\n🎉 Finished in %s 🎉\n", executionElapsedTime) if !Verbose && !Quiet { log.Debug(executionResult) Spinner.FinalMSG = executionResult Spinner.Stop() } else { log.Info(executionResult) } fmt.Println() }, }
RootCmd is the Cobra command object
View Source
var Spinner = spinner.New(spinner.CharSets[14], 100*time.Millisecond)
Spinner is the CLI spinner/activity indicator
View Source
var UpdateOnly bool
UpdateOnly will only update repositories, but not build anything
View Source
var Verbose bool
Verbose enables global verbose output
View Source
var Version = "0.0.0"
Version is set in main.go and is overridable when building
Functions ¶
Types ¶
type ClobberLogFormatter ¶
type ClobberLogFormatter struct { }
ClobberLogFormatter is a custom log formatter
Click to show internal directories.
Click to hide internal directories.