forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 2
/
makebb.go
47 lines (38 loc) · 1013 Bytes
/
makebb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2015-2018 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// makebb compiles many Go commands into one bb-style binary.
package main
import (
"flag"
"log"
"path/filepath"
"github.com/u-root/u-root/pkg/golang"
"github.com/u-root/u-root/pkg/uroot"
"github.com/u-root/u-root/pkg/uroot/builder"
)
var outputPath = flag.String("o", "bb", "Path to busybox binary")
func main() {
flag.Parse()
env := golang.Default()
if env.CgoEnabled {
log.Printf("Disabling CGO for u-root...")
env.CgoEnabled = false
}
log.Printf("Build environment: %s", env)
pkgs := flag.Args()
if len(pkgs) == 0 {
pkgs = []string{"github.com/u-root/u-root/cmds/*"}
}
pkgs, err := uroot.ResolvePackagePaths(env, pkgs)
if err != nil {
log.Fatal(err)
}
o, err := filepath.Abs(*outputPath)
if err != nil {
log.Fatal(err)
}
if err := builder.BuildBusybox(env, pkgs, o); err != nil {
log.Fatal(err)
}
}