add an example to build a custom .deb
This commit is contained in:
parent
d45037dee9
commit
526605ff87
5
Makefile
5
Makefile
|
@ -36,9 +36,10 @@ reset:
|
|||
# clear your terminal
|
||||
reset
|
||||
|
||||
gocui: build
|
||||
# use the ncurses gui (only kinda works still)
|
||||
ncurses: build
|
||||
reset
|
||||
./go-deb --gui gocui >/tmp/witgui.log.stderr 2>&1
|
||||
./go-deb --gui gocui
|
||||
|
||||
nocui: reset build
|
||||
./go-deb --gui nocui
|
||||
|
|
|
@ -42,7 +42,12 @@ func (c *controlBox) buildPackage() (bool, error) {
|
|||
fulldebname := filepath.Join(homeDir, "incoming", debname)
|
||||
if shell.Exists(fulldebname) {
|
||||
log.Info("debian package already built: " + fulldebname)
|
||||
return true, errors.New("debian package already built: " + fulldebname)
|
||||
if argv.Auto {
|
||||
return true, errors.New("debian package already built: " + fulldebname)
|
||||
} else {
|
||||
return false, errors.New("debian package already built: " + fulldebname)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var fullfilename string
|
||||
|
@ -132,13 +137,17 @@ func (c *controlBox) buildPackage() (bool, error) {
|
|||
log.Warn("mkdir failed")
|
||||
return false, errors.New("mkdir files/usr/bin")
|
||||
}
|
||||
if r := shell.Run([]string{"cp", fullfilename, "files/usr/bin"}); r.Error != nil {
|
||||
log.Warn("cp failed")
|
||||
return false, r.Error
|
||||
}
|
||||
if r := shell.Run([]string{"strip", "files/usr/bin/" + filename}); r.Error != nil {
|
||||
log.Warn("strip failed")
|
||||
return false, r.Error
|
||||
if os.Getenv("GO_DEB_CUSTOM") == "true" {
|
||||
// skip cp & strip on custom 'control' files
|
||||
} else {
|
||||
if r := shell.Run([]string{"cp", fullfilename, "files/usr/bin"}); r.Error != nil {
|
||||
log.Warn("cp failed")
|
||||
return false, r.Error
|
||||
}
|
||||
if r := shell.Run([]string{"strip", "files/usr/bin/" + filename}); r.Error != nil {
|
||||
log.Warn("strip failed")
|
||||
return false, r.Error
|
||||
}
|
||||
}
|
||||
|
||||
// put the README in there (if missing, generate it?)
|
||||
|
@ -168,19 +177,10 @@ func (c *controlBox) buildPackage() (bool, error) {
|
|||
shell.Run([]string{"cp", "postinst", "files/DEBIAN/"})
|
||||
}
|
||||
|
||||
if c.status == nil {
|
||||
log.Warn("c.status == nil")
|
||||
panic(-1)
|
||||
}
|
||||
// experiment for the toolkit package
|
||||
// if the git repo has a "./build" script run it before packaging
|
||||
// this way the user can put custom files in the .deb package
|
||||
if c.status.Exists("build") {
|
||||
if argv.Release {
|
||||
os.Unsetenv("GO111MODULE")
|
||||
} else {
|
||||
os.Setenv("GO111MODULE", "off")
|
||||
}
|
||||
if shell.Exists("build") {
|
||||
shell.Run([]string{"./build"})
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.PHONY: build
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
go-deb --repo .
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash -x
|
||||
|
||||
# this is the new protobuf generator
|
||||
#
|
||||
# go-clone google.golang.org/protobuf
|
||||
# cd ~/go/src/google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
# go install
|
||||
|
||||
mkdir -p files/usr/bin
|
||||
cp ~/go/bin/protoc-gen-go files/usr/bin
|
|
@ -0,0 +1,12 @@
|
|||
Source: google.golang.org.protobuf
|
||||
Build-Depends: golang
|
||||
Package: protoc-gen-go-new
|
||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||
Packager: Jeff Carr <jcarr@wit.com>
|
||||
Architecture: amd64
|
||||
Depends:
|
||||
URL: https://go.wit.com/
|
||||
Recommends:
|
||||
Version: 0.1
|
||||
Description: protoc-gen-go from google.golang.org/protobuf
|
||||
You need this one until the debian sid packages are updated
|
30
main.go
30
main.go
|
@ -35,7 +35,7 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
myGui = gui.New()
|
||||
if !argv.Auto {
|
||||
if !argv.Auto {
|
||||
myGui.InitEmbed(resources)
|
||||
}
|
||||
myGui.Default()
|
||||
|
@ -44,8 +44,14 @@ func main() {
|
|||
|
||||
// todo: add the go.work file logic here
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
filepath := filepath.Join(homeDir, "go/src", argv.Repo)
|
||||
os.Chdir(filepath)
|
||||
var debpath string
|
||||
if argv.Repo == "." {
|
||||
os.Setenv("GO_DEB_CUSTOM", "true")
|
||||
debpath, _ = os.Getwd()
|
||||
} else {
|
||||
debpath = filepath.Join(homeDir, "go/src", argv.Repo)
|
||||
}
|
||||
os.Chdir(debpath)
|
||||
|
||||
// scan the repo
|
||||
cBox.addRepo(argv.Repo)
|
||||
|
@ -60,19 +66,23 @@ func main() {
|
|||
// verify the values for the package
|
||||
|
||||
if cBox.status == nil {
|
||||
log.Info("argv.Repo =", argv.Repo)
|
||||
log.Info("repo not found. Try:")
|
||||
log.Info("")
|
||||
log.Info(" go-clone", argv.Repo)
|
||||
log.Info("")
|
||||
os.Exit(-1)
|
||||
if argv.Repo == "." {
|
||||
// this means try the local directory for a custom 'control' file
|
||||
} else {
|
||||
log.Info("argv.Repo =", argv.Repo)
|
||||
log.Info("repo not found. Try:")
|
||||
log.Info("")
|
||||
log.Info(" go-clone", argv.Repo)
|
||||
log.Info("")
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
// set the working directory to argv.Repo
|
||||
log.Info("cd", cBox.status.Path())
|
||||
os.Chdir(cBox.status.Path())
|
||||
|
||||
if argv.Auto {
|
||||
if argv.Auto {
|
||||
shell.TestTerminalColor()
|
||||
// basicWindow.Show() // broken gui package. convert to protobuf
|
||||
if ok, err := cBox.buildPackage(); ok {
|
||||
|
|
|
@ -65,6 +65,8 @@ func (c *controlBox) readControlFile() error {
|
|||
c.Depends.SetText(value)
|
||||
case "Recommends":
|
||||
c.Recommends.SetText(value)
|
||||
case "Version":
|
||||
c.Version.SetText(value)
|
||||
case "Package":
|
||||
c.Package.SetText(value)
|
||||
// if c.Package.String() != value {
|
||||
|
|
|
@ -36,6 +36,7 @@ func makebasicWindow() *gadgets.BasicWindow {
|
|||
basicWindow.Disable()
|
||||
if ok, err := cBox.buildPackage(); ok {
|
||||
log.Info("build worked")
|
||||
os.Exit(0)
|
||||
} else {
|
||||
log.Warn("build failed", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue