cmd/mkinitfs: add --version option
This commit is contained in:
3
Makefile
3
Makefile
@@ -1,6 +1,7 @@
|
|||||||
.POSIX:
|
.POSIX:
|
||||||
.SUFFIXES: .1 .1.scd
|
.SUFFIXES: .1 .1.scd
|
||||||
|
|
||||||
|
VERSION?=`git describe --tags --dirty 2>/dev/null || echo 0.0.0`
|
||||||
VPATH=doc
|
VPATH=doc
|
||||||
PREFIX?=/usr/local
|
PREFIX?=/usr/local
|
||||||
BINDIR?=$(PREFIX)/sbin
|
BINDIR?=$(PREFIX)/sbin
|
||||||
@@ -8,7 +9,7 @@ MANDIR?=$(PREFIX)/share/man
|
|||||||
SHAREDIR?=$(PREFIX)/share
|
SHAREDIR?=$(PREFIX)/share
|
||||||
GO?=go
|
GO?=go
|
||||||
GOFLAGS?=
|
GOFLAGS?=
|
||||||
LDFLAGS+=-s -w
|
LDFLAGS+=-s -w -X main.Version=$(VERSION)
|
||||||
RM?=rm -f
|
RM?=rm -f
|
||||||
GOTEST=go test -count=1 -race
|
GOTEST=go test -count=1 -race
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -26,7 +27,21 @@ import (
|
|||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/pkgs/deviceinfo"
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/pkgs/deviceinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// set at build time
|
||||||
|
var Version string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
outDir := flag.String("d", "/boot", "Directory to output initfs(-extra) and other boot files")
|
||||||
|
var showVersion bool
|
||||||
|
flag.BoolVar(&showVersion, "version", false, "Print version and quit.")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if showVersion {
|
||||||
|
fmt.Printf("%s - %s\n", filepath.Base(os.Args[0]), Version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
deviceinfoFile := "/etc/deviceinfo"
|
deviceinfoFile := "/etc/deviceinfo"
|
||||||
if !misc.Exists(deviceinfoFile) {
|
if !misc.Exists(deviceinfoFile) {
|
||||||
log.Print("NOTE: deviceinfo (from device package) not installed yet, " +
|
log.Print("NOTE: deviceinfo (from device package) not installed yet, " +
|
||||||
@@ -40,9 +55,6 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
outDir := flag.String("d", "/boot", "Directory to output initfs(-extra) and other boot files")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
defer misc.TimeFunc(time.Now(), "mkinitfs")
|
defer misc.TimeFunc(time.Now(), "mkinitfs")
|
||||||
|
|
||||||
kernVer, err := misc.GetKernelVersion()
|
kernVer, err := misc.GetKernelVersion()
|
||||||
|
Reference in New Issue
Block a user