Skip to content

Commit

Permalink
Better fix for Xcode path change isssues
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Sep 24, 2019
1 parent 6520736 commit 332359c
Show file tree
Hide file tree
Showing 48 changed files with 390 additions and 291 deletions.
100 changes: 76 additions & 24 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -198,7 +199,9 @@ var rootCmd = &cobra.Command{
Spinner.Prefix = formatSpinnerText("Verifying EDK is up to date", false)
// Disable cleaning up of extra files if the NoClean flag is set
if !NoClean {
runCommand("cd " + util.GetEdkPath() + " && git clean -fdx --exclude=\"Clover/\"")
if err := runCommand("cd " + util.GetEdkPath() + " && git clean -fdx --exclude=\"Clover/\""); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
}
git.Checkout(util.GetSourcePath(), git.CheckoutOptions{Branch: "EDK"})
Spinner.Prefix = formatSpinnerText("Verifying EDK is up to date", true)
Expand All @@ -215,7 +218,9 @@ var rootCmd = &cobra.Command{
}
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())
if err := runCommand("svn co " + "https://svn.code.sf.net/p/cloverefiboot/code" + " " + util.GetCloverPath()); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Downloading Clover", true)
}

Expand All @@ -225,11 +230,19 @@ var rootCmd = &cobra.Command{
Spinner.Prefix = formatSpinnerText("Verifying Clover is up to date", false)
// Disable cleaning up of extra files if the NoClean flag is set
if !NoClean {
runCommand("svn cleanup " + util.GetCloverPath())
runCommand("svn cleanup --remove-unversioned " + util.GetCloverPath())
runCommand("svn revert -R" + " " + util.GetCloverPath())
if err := runCommand("svn cleanup " + util.GetCloverPath()); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
if err := runCommand("svn cleanup --remove-unversioned " + util.GetCloverPath()); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
if err := runCommand("svn revert -R" + " " + util.GetCloverPath()); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
}
if err := runCommand("svn up -r" + Revision + " " + util.GetCloverPath()); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
runCommand("svn up -r" + Revision + " " + util.GetCloverPath())
Spinner.Prefix = formatSpinnerText("Verifying Clover is up to date", true)
}

Expand All @@ -245,40 +258,62 @@ var rootCmd = &cobra.Command{
// Build base tools
log.Debug("Building base tools..")
Spinner.Prefix = formatSpinnerText("Building base tools", false)
// FIXME: Refactor this so that if "make" fails, it'll retry by running "make clean" first
runCommand("make clean -C" + " " + util.GetEdkPath() + "/BaseTools/Source/C")
runCommand("make -C" + " " + util.GetEdkPath() + "/BaseTools/Source/C")
if err := runCommand("make -C" + " " + util.GetEdkPath() + "/BaseTools/Source/C"); err != nil {
if err := runCommand("make clean -C" + " " + util.GetEdkPath() + "/BaseTools/Source/C"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
if err := runCommand("make -C" + " " + util.GetEdkPath() + "/BaseTools/Source/C"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
}
Spinner.Prefix = formatSpinnerText("Building base tools", true)

// Setup EDK
log.Debug("Setting up EDK..")
Spinner.Prefix = formatSpinnerText("Setting up EDK", false)
runCommand("cd " + util.GetEdkPath() + " && " + "source edksetup.sh")
if err := runCommand("cd " + util.GetEdkPath() + " && " + "source edksetup.sh"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Setting up EDK", true)

// Build gettext, mtoc and nasm (if necessary)
if _, err := os.Stat(util.GetSourcePath() + "/opt/local/bin/gettext"); os.IsNotExist(err) {
log.Debug("Linking gettext..")
Spinner.Prefix = formatSpinnerText("Linking gettext", false)
runCommand("brew link gettext --force")
if err := runCommand("brew link gettext --force"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
defer runCommand("brew unlink gettext")
runCommand("mkdir -p " + util.GetSourcePath() + "/opt/local/bin")
runCommand("ln -sf /usr/local/bin/gettext " + util.GetSourcePath() + "/opt/local/bin/gettext")
if err := runCommand("mkdir -p " + util.GetSourcePath() + "/opt/local/bin"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
if err := runCommand("ln -sf /usr/local/bin/gettext " + util.GetSourcePath() + "/opt/local/bin/gettext"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Linking 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")
if err := runCommand(util.GetCloverPath() + "/buildmtoc.sh"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Building mtoc", true)
}
if _, err := os.Stat(util.GetSourcePath() + "/opt/local/bin/nasm"); os.IsNotExist(err) {
log.Debug("Linking nasm..")
Spinner.Prefix = formatSpinnerText("Linking nasm", false)
runCommand("brew link nasm --force")

if err := runCommand("brew link nasm --force"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
defer runCommand("brew unlink nasm")
runCommand("mkdir -p " + util.GetSourcePath() + "/opt/local/bin")
runCommand("ln -sf /usr/local/bin/nasm " + util.GetSourcePath() + "/opt/local/bin/nasm")
if err := runCommand("mkdir -p " + util.GetSourcePath() + "/opt/local/bin"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
if err := runCommand("ln -sf /usr/local/bin/nasm " + util.GetSourcePath() + "/opt/local/bin/nasm"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Linking nasm", true)
}

Expand All @@ -302,9 +337,18 @@ var rootCmd = &cobra.Command{
// Build Clover (clean & build, with extras like ApfsDriverLoader checked out and compiled)
log.Debug("Building Clover..")
Spinner.Prefix = formatSpinnerText("Building Clover", false)
runCommand(util.GetCloverPath() + "/ebuild.sh -cleanall") // TODO: Should this technically be ignored when using --no-clean?
runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64 -D NO_GRUB_DRIVERS_EMBEDDED") // 64-bit (boot6, default)
runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64-mcp --no-usb -D NO_GRUB_DRIVERS_EMBEDDED") // 64-bit (boot7, MCP/BiosBlockIO)
// TODO: Should this technically be ignored when using --no-clean?
if err := runCommand(util.GetCloverPath() + "/ebuild.sh -cleanall"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
// 64-bit (boot6, default)
if err := runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64 -D NO_GRUB_DRIVERS_EMBEDDED"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
// 64-bit (boot7, MCP/BiosBlockIO)
if err := runCommand(util.GetCloverPath() + "/ebuild.sh -fr --x64-mcp --no-usb -D NO_GRUB_DRIVERS_EMBEDDED"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Building Clover", true)
}

Expand Down Expand Up @@ -487,15 +531,19 @@ var rootCmd = &cobra.Command{
// Build the Clover installer package
log.Debug("Building Clover installer..")
Spinner.Prefix = formatSpinnerText("Building Clover installer", false)
runCommand(util.GetCloverPath() + "/CloverPackage/makepkg")
if err := runCommand(util.GetCloverPath() + "/CloverPackage/makepkg"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Building Clover installer", true)

if !InstallerOnly {
// Build the Clover ISO image
log.Debug("Building Clover ISO image..")
Spinner.Prefix = formatSpinnerText("Building Clover ISO image", false)
runCommand(util.GetCloverPath() + "/CloverPackage/makeiso")
// FIXME: Error: don't call the '/Users/dids/.clobber/src/edk2/Clover/CloverPackage/makeiso' script directly !
if err := runCommand(util.GetCloverPath() + "/CloverPackage/makeiso"); err != nil {
log.Fatal("Error: Failure detected, aborting")
}
Spinner.Prefix = formatSpinnerText("Building Clover ISO image", true)
}
}
Expand Down Expand Up @@ -579,7 +627,7 @@ func customInit() {
}
}

func runCommand(command string) {
func runCommand(command string) error {
// If there are no args (or no spaces), we need to deal with those situations too
var (
cmd string
Expand All @@ -603,9 +651,13 @@ func runCommand(command string) {
err error
)
if cmdOut, err = exec.Command(cmd, args...).CombinedOutput(); err != nil {
log.Fatal("Error: Failed to run '" + cmd + " " + argsString + "':\n" + string(cmdOut))
// log.Fatal("Error: Failed to run '" + cmd + " " + argsString + "':\n" + string(cmdOut))
customErr := errors.New("Failed to run '" + cmd + " " + argsString + "':\n" + string(cmdOut))
log.Warn("Warning: " + customErr.Error())
return customErr
}
log.Debug("Command finished with output:\n" + string(cmdOut))
return nil
}

func getGitHubReleaseLink(url string, filter string) string {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20190924062700-2aa67d56cdd7 // indirect
google.golang.org/appengine v1.6.2 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM=
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924062700-2aa67d56cdd7 h1:9Vs0Vm0p/0tnWLBWn79aav6fpcxKjBZbd21Lhxzit4k=
golang.org/x/sys v0.0.0-20190924062700-2aa67d56cdd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
6 changes: 6 additions & 0 deletions vendor/golang.org/x/sys/unix/mkerrors.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall_darwin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall_dragonfly.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall_freebsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall_netbsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall_openbsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/golang.org/x/sys/unix/zerrors_darwin_386.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 332359c

Please sign in to comment.