mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 11:00:25 +00:00
commit
3223897232
12
Makefile
12
Makefile
@ -2,9 +2,11 @@
|
|||||||
default: bin/moby moby-initrd.img
|
default: bin/moby moby-initrd.img
|
||||||
all: default
|
all: default
|
||||||
|
|
||||||
GO_COMPILE=mobylinux/go-compile:3afebc59c5cde31024493c3f91e6102d584a30b9@sha256:e0786141ea7df8ba5735b63f2a24b4ade9eae5a02b0e04c4fca33b425ec69b0a
|
VERSION="0.0" # dummy for now
|
||||||
|
GIT_COMMIT=$(shell git rev-list -1 HEAD)
|
||||||
|
|
||||||
|
GO_COMPILE=mobylinux/go-compile:a2ff853b00d687f845d0f67189fa645a567c006e@sha256:09fff8a5c022fc9ead35b2779209c043196b09193c6e61d98603d402c0971f03
|
||||||
|
|
||||||
MOBY_DEPS=$(wildcard src/cmd/moby/*.go)
|
|
||||||
GOOS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
|
GOOS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
GOARCH=amd64
|
GOARCH=amd64
|
||||||
ifneq ($(GOOS),linux)
|
ifneq ($(GOOS),linux)
|
||||||
@ -14,11 +16,13 @@ ifeq ($(GOOS),darwin)
|
|||||||
default: bin/infrakit-instance-hyperkit
|
default: bin/infrakit-instance-hyperkit
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
MOBY_DEPS=$(wildcard src/cmd/moby/*.go) Makefile vendor.conf
|
||||||
|
MOBY_DEPS+=$(wildcard src/initrd/*.go) $(wildcard src/pad4/*.go)
|
||||||
bin/moby: $(MOBY_DEPS) | bin
|
bin/moby: $(MOBY_DEPS) | bin
|
||||||
tar cf - vendor src/initrd src/pad4 -C src/cmd/moby . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/docker/moby -o $@ | tar xf -
|
tar cf - vendor src/initrd src/pad4 -C src/cmd/moby . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/docker/moby --ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" -o $@ | tar xf -
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
MOBY_DEPS=$(wildcard src/cmd/infrakit-instance-hyperkit/*.go)
|
INFRAKIT_DEPS=$(wildcard src/cmd/infrakit-instance-hyperkit/*.go) Makefile vendor.conf
|
||||||
bin/infrakit-instance-hyperkit: $(INFRAKIT_DEPS) | bin
|
bin/infrakit-instance-hyperkit: $(INFRAKIT_DEPS) | bin
|
||||||
tar cf - vendor -C src/cmd/infrakit-instance-hyperkit . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/docker/moby -o $@ | tar xf -
|
tar cf - vendor -C src/cmd/infrakit-instance-hyperkit . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/docker/moby -o $@ | tar xf -
|
||||||
touch $@
|
touch $@
|
||||||
|
@ -35,7 +35,7 @@ func build(args []string) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
conf := remArgs[0]
|
conf := remArgs[0]
|
||||||
if filepath.Ext(conf) == "" {
|
if !(filepath.Ext(conf) == ".yml" || filepath.Ext(conf) == ".yaml") {
|
||||||
conf = conf + ".yml"
|
conf = conf + ".yml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,19 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultLogFormatter = &log.TextFormatter{}
|
defaultLogFormatter = &log.TextFormatter{}
|
||||||
|
|
||||||
|
// Version is the human-readable version
|
||||||
|
Version = "unknown"
|
||||||
|
|
||||||
|
// GitCommit hash, set at compile time
|
||||||
|
GitCommit = "unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// infoFormatter overrides the default format for Info() log events to
|
// infoFormatter overrides the default format for Info() log events to
|
||||||
@ -24,15 +31,22 @@ func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) {
|
|||||||
return defaultLogFormatter.Format(entry)
|
return defaultLogFormatter.Format(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func version() {
|
||||||
|
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), Version)
|
||||||
|
fmt.Printf("commit: %s\n", GitCommit)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Printf("USAGE: %s [options] COMMAND\n\n", os.Args[0])
|
fmt.Printf("USAGE: %s [options] COMMAND\n\n", filepath.Base(os.Args[0]))
|
||||||
fmt.Printf("Commands:\n")
|
fmt.Printf("Commands:\n")
|
||||||
fmt.Printf(" build Build a Moby image from a YAML file\n")
|
fmt.Printf(" build Build a Moby image from a YAML file\n")
|
||||||
fmt.Printf(" run Run a Moby image on a local hypervisor\n")
|
fmt.Printf(" run Run a Moby image on a local hypervisor\n")
|
||||||
|
fmt.Printf(" version Print version information\n")
|
||||||
fmt.Printf(" help Print this message\n")
|
fmt.Printf(" help Print this message\n")
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
fmt.Printf("Run '%s COMMAND --help' for more information on the command\n", os.Args[0])
|
fmt.Printf("Run '%s COMMAND --help' for more information on the command\n", filepath.Base(os.Args[0]))
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
fmt.Printf("Options:\n")
|
fmt.Printf("Options:\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
@ -69,6 +83,8 @@ func main() {
|
|||||||
build(args[1:])
|
build(args[1:])
|
||||||
case "run":
|
case "run":
|
||||||
run(args[1:])
|
run(args[1:])
|
||||||
|
case "version":
|
||||||
|
version()
|
||||||
case "help":
|
case "help":
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
default:
|
default:
|
||||||
|
@ -26,6 +26,10 @@ do
|
|||||||
package="$2"
|
package="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--ldflags)
|
||||||
|
ldflags="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option $1"
|
echo "Unknown option $1"
|
||||||
exit 1
|
exit 1
|
||||||
@ -61,9 +65,14 @@ test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*
|
|||||||
|
|
||||||
if [ "$GOOS" = "darwin" ]
|
if [ "$GOOS" = "darwin" ]
|
||||||
then
|
then
|
||||||
go build -o $out "$package"
|
if [ -z "$ldflags" ]
|
||||||
|
then
|
||||||
|
go build -o $out "$package"
|
||||||
|
else
|
||||||
|
go build -o $out -ldflags "${ldflags}" "$package"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
go build -o $out -buildmode pie --ldflags '-s -w -extldflags "-static"' "$package"
|
go build -o $out -buildmode pie -ldflags "-s -w ${ldflags} -extldflags \"-static\"" "$package"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tar cf - $out
|
tar cf - $out
|
||||||
|
Loading…
Reference in New Issue
Block a user