Compare commits
No commits in common. "master" and "v0.0.1" have entirely different histories.
63
Makefile
63
Makefile
|
@ -1,32 +1,11 @@
|
||||||
.PHONY: debian
|
.PHONY: debian
|
||||||
|
|
||||||
VERSION = $(shell git describe --tags)
|
run: build
|
||||||
DATE = $(shell date +%Y.%m.%d)
|
./go-deb --open-gui
|
||||||
|
|
||||||
run: clean goimports vet install
|
build:
|
||||||
go-deb --gui andlabs gui
|
-cp ~/go/src/go.wit.com/toolkits/*.so resources/
|
||||||
|
GO111MODULE="off" go build -v
|
||||||
junk:
|
|
||||||
#go-deb --release go.wit.com/apps/go-mod-clean --dir /tmp/
|
|
||||||
#go-deb go.wit.com/apps/autotypist
|
|
||||||
#ls -lth /tmp/*deb
|
|
||||||
|
|
||||||
vet:
|
|
||||||
@GO111MODULE=off go vet
|
|
||||||
@echo this go library package builds okay
|
|
||||||
|
|
||||||
auto-build: build
|
|
||||||
./go-deb --repo go.wit.com/apps/autotypist
|
|
||||||
|
|
||||||
build: goimports vet
|
|
||||||
-rm resources/*.so
|
|
||||||
touch resources/blank.so
|
|
||||||
GO111MODULE="off" go build -v \
|
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.DATE=${DATE} -X gui.GUIVERSION=${VERSION}"
|
|
||||||
|
|
||||||
install: goimports
|
|
||||||
GO111MODULE="off" go install -v \
|
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.DATE=${DATE} -X gui.GUIVERSION=${VERSION}"
|
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
@ -40,34 +19,18 @@ reset:
|
||||||
# clear your terminal
|
# clear your terminal
|
||||||
reset
|
reset
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
gocui: build
|
||||||
ncurses: build
|
|
||||||
reset
|
reset
|
||||||
./go-deb --gui gocui
|
./go-deb --gui gocui >/tmp/witgui.log.stderr 2>&1
|
||||||
|
|
||||||
nocui: reset build
|
nocui: reset build
|
||||||
./go-deb --gui nocui
|
./go-deb --gui nocui
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f go.*
|
-rm go-deb
|
||||||
rm -f go-deb
|
-rm -rf files/
|
||||||
rm -f resources/*.so
|
-rm -f resources/*.so
|
||||||
touch resources/blank.so
|
-rm *.deb
|
||||||
|
|
||||||
build-go-gui-toolkits: build
|
mirrors:
|
||||||
./go-deb --release --repo go.wit.com/apps/go-gui-toolkits
|
-wit mirrors
|
||||||
|
|
||||||
build-test-failure: build
|
|
||||||
./go-deb --release --repo go.wit.com/apps/junk
|
|
||||||
|
|
||||||
build-test-keep-files: build
|
|
||||||
./go-deb --keep-files --repo go.wit.com/apps/go-deb
|
|
||||||
|
|
||||||
build-release:
|
|
||||||
go-deb --release --repo go.wit.com/apps/go-deb
|
|
||||||
|
|
||||||
debian: build
|
|
||||||
./go-deb --keep-files --repo go.wit.com/apps/go-deb
|
|
||||||
|
|
||||||
test2:
|
|
||||||
go-deb go.wit.com/apps/utils/go-gui-toolkits --dir /tmp
|
|
||||||
|
|
38
README.md
38
README.md
|
@ -1,38 +0,0 @@
|
||||||
# go-deb - package things to make it easier on everyone else
|
|
||||||
|
|
||||||
Makes a debian package from a go git repository, but also arbitrary things.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
* go-deb --auto --repo go.wit.com/apps/go-clone # just make the .deb file already
|
|
||||||
* go-deb ---repo go.wit.com/apps/go-clone # will try to open a gtk gui
|
|
||||||
* go-deb --repo . # can be used for packaging anything. looks for a 'control' and 'build' file
|
|
||||||
|
|
||||||
# examples/
|
|
||||||
|
|
||||||
See the examples/ directory for custom 'control' and 'build' files for packaging arbitrary projects.
|
|
||||||
|
|
||||||
# Notes
|
|
||||||
|
|
||||||
Make a 'control' file for the debian package.
|
|
||||||
You can also make a custom 'build' script to run to place additional files in the debian package.
|
|
||||||
|
|
||||||
|
|
||||||
.deb files are actually a smart and very simple file format based off of tar. This was
|
|
||||||
a smart design decision in the early days when, if things went wrong, your system
|
|
||||||
could break when updating things like glibc. This would mean that you couldn't even
|
|
||||||
figure out what is what. Having a very primitive file format is a bonus. That also
|
|
||||||
means, it is simple to make them! This can be non-intuitive however. This tool
|
|
||||||
tries to simpilfy that process.
|
|
||||||
|
|
||||||
Basically a .deb file is based off of 'tar' and 'ar' (I can only assume 'ar' is a
|
|
||||||
precurser to tar, but I don't know for sure and will ask maddog!)
|
|
||||||
|
|
||||||
Inside the .deb file are some control files and debian specific files and then
|
|
||||||
a tarball of all the files to extract.
|
|
||||||
|
|
||||||
# Todo
|
|
||||||
|
|
||||||
* make .rpm, gentoo, arch, etc file formats also
|
|
||||||
* make whatever the macos needs
|
|
||||||
* windows support I guess. golang needs plugin support on windows first.
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
this parses the command line arguements
|
||||||
|
|
||||||
|
this enables command line options from other packages like 'gui' and 'log'
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/dev/alexflint/arg"
|
||||||
|
"go.wit.com/lib/debugger"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var args struct {
|
||||||
|
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
|
||||||
|
OpenGui bool `arg:"--open-gui" help:"open the go-deb gui"`
|
||||||
|
Repo string `arg:"--repo" help:"go get path to the repo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
arg.MustParse(&args)
|
||||||
|
|
||||||
|
if debugger.ArgDebug() {
|
||||||
|
log.Info("cmd line --debugger == true")
|
||||||
|
} else {
|
||||||
|
log.Info("cmd line --debugger == false")
|
||||||
|
}
|
||||||
|
}
|
62
argv.go
62
argv.go
|
@ -1,62 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
this parses the command line arguements
|
|
||||||
|
|
||||||
this enables command line options from other packages like 'gui' and 'log'
|
|
||||||
*/
|
|
||||||
|
|
||||||
type args struct {
|
|
||||||
Commit *EmptyCmd `arg:"subcommand:commit" help:"'git commit' but errors out if on wrong branch"`
|
|
||||||
Show *EmptyCmd `arg:"subcommand:show" help:"show what would be done"`
|
|
||||||
Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"`
|
|
||||||
Dump *EmptyCmd `arg:"subcommand:dump" help:"dump out the future control file"`
|
|
||||||
Ldflags []string `arg:"--ldflags" help:"flags to pass to go build"`
|
|
||||||
OutDir string `arg:"--dir" help:"write .deb file into this directory"`
|
|
||||||
Release bool `arg:"--release" help:"build a release from the last git tag"`
|
|
||||||
KeepFiles bool `arg:"--keep-files" help:"keep the build files/"`
|
|
||||||
Force bool `arg:"--force" default:"false" help:"force overwrite an existing .deb file"`
|
|
||||||
Verbose bool `arg:"--verbose" help:"show more things"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (args) Version() string {
|
|
||||||
return "go-clone " + VERSION + " Built on " + DATE
|
|
||||||
}
|
|
||||||
|
|
||||||
type EmptyCmd struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a args) Description() string {
|
|
||||||
return `
|
|
||||||
Example usage:
|
|
||||||
guireleaser go.wit.com/apps/go-clone --increment --release --dry-run --reason "blerg"
|
|
||||||
|
|
||||||
This will pull down the go sources and
|
|
||||||
the repositories in the go.sum file using git clone`
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
handles shell autocomplete
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (a args) DoAutoComplete(argv []string) {
|
|
||||||
switch argv[0] {
|
|
||||||
case "arch":
|
|
||||||
fmt.Println("riscv64")
|
|
||||||
case "build":
|
|
||||||
fmt.Println("user devel release")
|
|
||||||
case "--gui":
|
|
||||||
fmt.Println("nocui andlabs")
|
|
||||||
default:
|
|
||||||
if argv[0] == ARGNAME {
|
|
||||||
// list the subcommands here
|
|
||||||
fmt.Println("arch build gui show --gui")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
244
build.go
244
build.go
|
@ -1,244 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func buildPackage(repo *gitpb.Repo) (bool, error) {
|
|
||||||
// TODO: if dirty, set GO111MODULE
|
|
||||||
// also, if last tag != version
|
|
||||||
/*
|
|
||||||
go install -ldflags " \
|
|
||||||
-X main.GITCOMMIT=${GITCOMMIT} \
|
|
||||||
-X main.GOVERSION='${GOVERSION}' \
|
|
||||||
-X main.BUILDTIME='${BUILDTIME}' \
|
|
||||||
-X main.VERSION=${VERSION}"
|
|
||||||
*/
|
|
||||||
// ldflags := "main.GOTAG=" + repo.LastTag()
|
|
||||||
|
|
||||||
filename := repo.Control["Package"] // c.Package.String()
|
|
||||||
if filename == "" {
|
|
||||||
return false, errors.New("filename is blank")
|
|
||||||
}
|
|
||||||
|
|
||||||
arch := repo.Control["Architecture"] // c.Architecture.String()
|
|
||||||
if arch == "" {
|
|
||||||
arch = "amd64" // todo: detect what you are building on
|
|
||||||
}
|
|
||||||
version := repo.Control["Version"]
|
|
||||||
log.Info("version is:", version)
|
|
||||||
debname := filename + "_" + version + "_" + arch + ".deb"
|
|
||||||
var fulldebname string
|
|
||||||
if argv.OutDir == "" {
|
|
||||||
fulldebname = debname
|
|
||||||
} else {
|
|
||||||
fulldebname = filepath.Join(argv.OutDir, debname)
|
|
||||||
}
|
|
||||||
if shell.Exists(fulldebname) {
|
|
||||||
log.Info("debian package already built: " + fulldebname)
|
|
||||||
return true, errors.New("debian package already built: " + fulldebname)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var fullfilename string
|
|
||||||
_, fullfilename = filepath.Split(filename)
|
|
||||||
|
|
||||||
if fullfilename == "" {
|
|
||||||
log.Info("fullfilename =", fullfilename)
|
|
||||||
badExit(log.Errorf("binary name was blank"))
|
|
||||||
}
|
|
||||||
if fullfilename == "." {
|
|
||||||
log.Info("fullfilename =", fullfilename)
|
|
||||||
badExit(log.Errorf("binary name was ."))
|
|
||||||
}
|
|
||||||
if shell.Exists(fullfilename) {
|
|
||||||
repo.RunVerbose([]string{"rm", "-f", fullfilename})
|
|
||||||
}
|
|
||||||
|
|
||||||
if shell.Exists(fullfilename) {
|
|
||||||
// something wrong
|
|
||||||
return false, errors.New("binary existed before build")
|
|
||||||
}
|
|
||||||
|
|
||||||
if argv.Release {
|
|
||||||
os.Unsetenv("GO111MODULE")
|
|
||||||
cmd := []string{"go"}
|
|
||||||
cmd = append(cmd, "install")
|
|
||||||
if argv.Verbose {
|
|
||||||
cmd = append(cmd, "-v")
|
|
||||||
cmd = append(cmd, "-x")
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
cmd = append(cmd, "some path"+"@v"+version)
|
|
||||||
if err := shell.PathExecVerbose("", cmd); err != nil {
|
|
||||||
badExit(err)
|
|
||||||
return false, fmt.Errorf("go build err %v", err)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
cmd = []string{"go"}
|
|
||||||
cmd = append(cmd, "build")
|
|
||||||
if argv.Verbose {
|
|
||||||
cmd = append(cmd, "-v")
|
|
||||||
cmd = append(cmd, "-x")
|
|
||||||
}
|
|
||||||
cmd = append(cmd, "this should be the path")
|
|
||||||
if err := shell.PathExecVerbose("", cmd); err != nil {
|
|
||||||
badExit(err)
|
|
||||||
return false, fmt.Errorf("go build err %v", err)
|
|
||||||
}
|
|
||||||
log.Warn("build worked")
|
|
||||||
} else {
|
|
||||||
// set the GO111 build var to true. pass the versions to the compiler manually
|
|
||||||
os.Setenv("GO111MODULE", "off")
|
|
||||||
cmd := []string{"go", "build"}
|
|
||||||
// set standard ldflag options
|
|
||||||
now := time.Now()
|
|
||||||
datestamp := now.UTC().Format("2006/01/02_1504_UTC")
|
|
||||||
log.Info("datestamp =", datestamp)
|
|
||||||
// add some standard golang flags
|
|
||||||
ldflags := "-X main.VERSION=" + version + " "
|
|
||||||
ldflags += "-X main.BUILDTIME=" + datestamp + " "
|
|
||||||
ldflags += "-X main.GUIVERSION=" + version + "" // todo: git this from the filesystem
|
|
||||||
cmd = append(cmd, "-ldflags", ldflags)
|
|
||||||
|
|
||||||
// add any flags from the command line
|
|
||||||
// this might not actually work
|
|
||||||
// todo: test this
|
|
||||||
for _, flag := range argv.Ldflags {
|
|
||||||
cmd = append(cmd, "-ldflags", "-X "+flag)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.RunVerbose(cmd)
|
|
||||||
if err != nil {
|
|
||||||
return false, fmt.Errorf("go build err %v", err)
|
|
||||||
}
|
|
||||||
log.Warn("go build worked")
|
|
||||||
}
|
|
||||||
|
|
||||||
filebase := filepath.Base(repo.Control["pathL"]) // c.pathL.String())
|
|
||||||
if fullfilename != filebase {
|
|
||||||
// this exception is for when you want to override a package name
|
|
||||||
// sometimes that's the best option. This way you can keep your
|
|
||||||
// name, but the .deb package name can be different so you can
|
|
||||||
// still apt-get it. For an example, look at the gozookeeper package
|
|
||||||
fullfilename = filebase
|
|
||||||
}
|
|
||||||
|
|
||||||
if !shell.Exists(fullfilename) {
|
|
||||||
log.Warn("build failed. filename does not exist", fullfilename)
|
|
||||||
return false, errors.New("missing " + fullfilename)
|
|
||||||
}
|
|
||||||
|
|
||||||
if shell.Exists("files") {
|
|
||||||
repo.RunVerbose([]string{"rm", "-rf", "files"})
|
|
||||||
// log.Info("running sync")
|
|
||||||
repo.RunVerbose([]string{"sync"})
|
|
||||||
if shell.Exists("files") {
|
|
||||||
log.Warn("rm failed for some reason")
|
|
||||||
return false, errors.New("rm files/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repo.RunVerbose([]string{"sync"}) // for some reason the next check fails sometimes?
|
|
||||||
if shell.Exists("files") {
|
|
||||||
// probably the 'shell' package id being stupid and not waiting for the process to actually exit
|
|
||||||
log.Warn("rm failed. files/ still exists. is golang doing these in parallel?")
|
|
||||||
return false, errors.New("rm files/")
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll("files/DEBIAN", os.ModePerm); err != nil {
|
|
||||||
return false, errors.New("mkdir files/DEBIAN")
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll("files/usr/bin", os.ModePerm); err != nil {
|
|
||||||
log.Warn("mkdir failed")
|
|
||||||
return false, errors.New("mkdir files/usr/bin")
|
|
||||||
}
|
|
||||||
if os.Getenv("GO_DEB_CUSTOM") == "true" {
|
|
||||||
// skip cp & strip on custom 'control' files
|
|
||||||
// probably deprecate this
|
|
||||||
log.Info("REPO GO_DEB_CUSTOM=true means binary is not copied")
|
|
||||||
} else {
|
|
||||||
_, fname := filepath.Split(repo.GetFullPath())
|
|
||||||
cmd := []string{"cp", fname, "files/usr/bin"}
|
|
||||||
log.Info("REPO FILENAME cp", cmd)
|
|
||||||
if err := repo.RunVerbose(cmd); err != nil {
|
|
||||||
log.Warn("cp failed")
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
cmd = []string{"strip", "files/usr/bin/" + fname}
|
|
||||||
if err := repo.RunVerbose(cmd); err != nil {
|
|
||||||
log.Warn("strip failed")
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// put the README in there (if missing, generate it?)
|
|
||||||
var readme string = ""
|
|
||||||
if shell.Exists("README.md") {
|
|
||||||
readme = "README.md"
|
|
||||||
}
|
|
||||||
|
|
||||||
if shell.Exists("README") {
|
|
||||||
readme = "README"
|
|
||||||
}
|
|
||||||
|
|
||||||
if readme != "" {
|
|
||||||
path := filepath.Join("files/usr/lib/" + filename)
|
|
||||||
if err := os.MkdirAll(path, os.ModePerm); err != nil {
|
|
||||||
return false, errors.New("no files/usr/lib")
|
|
||||||
}
|
|
||||||
if err := repo.RunVerbose([]string{"cp", readme, path}); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !writeDebianControlFile(repo) {
|
|
||||||
return false, errors.New("write control file")
|
|
||||||
}
|
|
||||||
if shell.Exists("postinst") {
|
|
||||||
repo.RunVerbose([]string{"cp", "postinst", "files/DEBIAN/"})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 shell.Exists("build") {
|
|
||||||
log.Info(repo.FullPath, "FOUND ./build HERE")
|
|
||||||
repo.RunVerbose([]string{"./build"})
|
|
||||||
} else {
|
|
||||||
log.Info(repo.FullPath, "NOT FOUND ./build HERE")
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := []string{"dpkg-deb", "--root-owner-group", "--build", "files", fulldebname}
|
|
||||||
result := repo.RunVerbose(cmd)
|
|
||||||
if shell.Exists(fulldebname) {
|
|
||||||
} else {
|
|
||||||
log.Warn("CMD FAILED", cmd, result)
|
|
||||||
log.Warn("build failed: full name was not created:", fulldebname)
|
|
||||||
return false, errors.New("dpkg-deb --build failed")
|
|
||||||
}
|
|
||||||
repo.RunVerbose([]string{"dpkg-deb", "-I", fulldebname})
|
|
||||||
repo.RunVerbose([]string{"dpkg-deb", "-c", fulldebname})
|
|
||||||
|
|
||||||
// cleanup files
|
|
||||||
if shell.Exists("files") {
|
|
||||||
if argv.KeepFiles {
|
|
||||||
log.Info("keeping the build files/")
|
|
||||||
} else {
|
|
||||||
repo.RunVerbose([]string{"rm", "-rf", "files"})
|
|
||||||
// log.Info("running sync")
|
|
||||||
repo.RunVerbose([]string{"sync"})
|
|
||||||
if shell.Exists("files") {
|
|
||||||
log.Warn("rm -rf files/ failed. Run() returned false")
|
|
||||||
return false, errors.New("rm files/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
15
control
15
control
|
@ -2,15 +2,8 @@ Source: go-deb
|
||||||
Build-Depends: golang
|
Build-Depends: golang
|
||||||
Package: go-deb
|
Package: go-deb
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Depends: go-gui-toolkits
|
Depends:
|
||||||
URL: https://go.wit.com/
|
Recommends: libgtk-3-0, ddclient, ddupdate
|
||||||
Recommends:
|
Description: a control panel for DNS and IPv6 settings
|
||||||
Conflicts: testingoldstuff
|
Goals: show the settings, validate & update DNS
|
||||||
Description: create distribution packages for golang repositories
|
|
||||||
Hopefully, this can make compatible and correct source
|
|
||||||
packages for things like debuild or the incoming queue since
|
|
||||||
golang applications are more strict then the traditional C
|
|
||||||
libraries and binaries that require lots of scripting.
|
|
||||||
A person can dream anyway.
|
|
||||||
|
|
145
control.read.go
145
control.read.go
|
@ -1,145 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"unicode"
|
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func trimNonNumericPrefix(s string) string {
|
|
||||||
// Find the index of the first character that IS a digit.
|
|
||||||
firstDigitIndex := strings.IndexFunc(s, unicode.IsDigit)
|
|
||||||
|
|
||||||
// If no digit is found, IndexFunc returns -1.
|
|
||||||
// In this case, the result should be an empty string.
|
|
||||||
if firstDigitIndex == -1 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the substring starting from the first digit.
|
|
||||||
return s[firstDigitIndex:]
|
|
||||||
}
|
|
||||||
|
|
||||||
// readGitConfig reads and parses the control file
|
|
||||||
func readControlFile(repo *gitpb.Repo) error {
|
|
||||||
pairs := make(map[string]string)
|
|
||||||
var key string
|
|
||||||
|
|
||||||
file, err := os.Open("control")
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("readControlFile() could not find the file")
|
|
||||||
// return errors.New("'control': file not found")
|
|
||||||
// if this happens, make up a fake control file
|
|
||||||
pairs["Architecture"] = "amd64" // TODO: figure this out
|
|
||||||
pairs["Recommends"] = ""
|
|
||||||
pairs["Source"] = "notsure"
|
|
||||||
if me.repo == nil {
|
|
||||||
pairs["Description"] = "put something here"
|
|
||||||
} else {
|
|
||||||
pairs["Description"] = me.repo.GetGoPath()
|
|
||||||
}
|
|
||||||
if repo.Control == nil {
|
|
||||||
repo.Control = make(map[string]string)
|
|
||||||
}
|
|
||||||
for key, value := range pairs {
|
|
||||||
repo.Control[key] = value
|
|
||||||
}
|
|
||||||
if os.Getenv("GIT_AUTHOR_NAME") != "" {
|
|
||||||
author := log.Sprintf("%s <%s>", os.Getenv("GIT_AUTHOR_NAME"), os.Getenv("GIT_AUTHOR_EMAIL"))
|
|
||||||
repo.Control["Packager"] = author
|
|
||||||
}
|
|
||||||
_, fname := filepath.Split(repo.GetFullPath())
|
|
||||||
repo.Control["Package"] = fname
|
|
||||||
repo.Control["Version"] = trimNonNumericPrefix(repo.GetCurrentVersion())
|
|
||||||
repo.Control["URL"] = repo.URL
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
pairs["Version"] = trimNonNumericPrefix(repo.GetCurrentVersion())
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(file)
|
|
||||||
for scanner.Scan() {
|
|
||||||
line := scanner.Text()
|
|
||||||
|
|
||||||
// Skip empty lines and comments
|
|
||||||
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// if line starts with a space, it's part of the last key
|
|
||||||
if strings.HasPrefix(line, " ") {
|
|
||||||
pairs[key] = pairs[key] + "\n" + strings.TrimSpace(line)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
partsNew := strings.SplitN(line, ":", 2)
|
|
||||||
if len(partsNew) < 2 {
|
|
||||||
log.Warn("error on line:", line)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
key = strings.TrimSpace(partsNew[0])
|
|
||||||
value := strings.TrimSpace(partsNew[1])
|
|
||||||
pairs[key] = value
|
|
||||||
}
|
|
||||||
if repo.Control == nil {
|
|
||||||
repo.Control = make(map[string]string)
|
|
||||||
}
|
|
||||||
for key, value := range pairs {
|
|
||||||
repo.Control[key] = value
|
|
||||||
/*
|
|
||||||
switch key {
|
|
||||||
case "Source":
|
|
||||||
c.Source.SetText(value)
|
|
||||||
case "Build-Depends":
|
|
||||||
c.BuildDepends.SetText(value)
|
|
||||||
case "Description":
|
|
||||||
c.Description.SetText(value)
|
|
||||||
case "Maintainer":
|
|
||||||
c.Maintainer.SetText(value)
|
|
||||||
case "Packager":
|
|
||||||
c.Packager.SetText(value)
|
|
||||||
case "GoPath":
|
|
||||||
c.GoPath.SetText(value)
|
|
||||||
case "URL":
|
|
||||||
c.URL.SetText(value)
|
|
||||||
case "Depends":
|
|
||||||
c.Depends.SetText(value)
|
|
||||||
case "Recommends":
|
|
||||||
c.Recommends.SetText(value)
|
|
||||||
case "Conflicts":
|
|
||||||
c.Conflicts.SetText(value)
|
|
||||||
case "Version":
|
|
||||||
c.Version.SetText(value)
|
|
||||||
case "Package":
|
|
||||||
c.Package.SetText(value)
|
|
||||||
// if c.Package.String() != value {
|
|
||||||
// log.Warn("not sure what to do with Package", c.Package.String(), value)
|
|
||||||
// }
|
|
||||||
case "Architecture":
|
|
||||||
// todo: add logic to find OS arch
|
|
||||||
if c.Architecture.String() != value {
|
|
||||||
log.Warn("attempting to set arch to", value)
|
|
||||||
c.Architecture.SetText(value)
|
|
||||||
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
log.Warn("the 'control' file has a value I don't know about")
|
|
||||||
log.Warn("error unknown key", key, "value:", value)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
pairs["Architecture"] = "amd64" // TODO: figure this out
|
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
106
control.write.go
106
control.write.go
|
@ -1,106 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/go-cmd/cmd"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func writeDebianControlFile(repo *gitpb.Repo) bool {
|
|
||||||
filename := "files/DEBIAN/control"
|
|
||||||
cf, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("open control file failed", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
fmt.Fprintln(cf, "Package:", repo.Control["Package"]) // c.Package.String())
|
|
||||||
fmt.Fprintln(cf, "Source:", repo.Control["Source"]) // c.Source.String())
|
|
||||||
fmt.Fprintln(cf, "Version:", repo.Control["Version"])
|
|
||||||
if repo.Control["Architecture"] == "" {
|
|
||||||
repo.Control["Architecture"] = "amd64"
|
|
||||||
}
|
|
||||||
fmt.Fprintln(cf, "Architecture:", repo.Control["Architecture"]) // c.Architecture.String())
|
|
||||||
|
|
||||||
writeControlVar(cf, repo, "Depends")
|
|
||||||
writeControlVar(cf, repo, "Build-Depends")
|
|
||||||
writeControlVar(cf, repo, "Maintainer")
|
|
||||||
writeControlVar(cf, repo, "Packager")
|
|
||||||
writeControlVar(cf, repo, "GoPath")
|
|
||||||
writeControlVar(cf, repo, "URL")
|
|
||||||
writeControlVar(cf, repo, "Conflicts")
|
|
||||||
|
|
||||||
stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
|
||||||
// update to now now despite what the GUI is showing
|
|
||||||
fmt.Fprintln(cf, "Package-Build-Date:", stamp)
|
|
||||||
fmt.Fprintln(cf, "Git-Tag-Date:", "todo: get from repo")
|
|
||||||
|
|
||||||
desc, _ := repo.Control["Description"] // c.Description.String()
|
|
||||||
parts := strings.Split(desc, "\n")
|
|
||||||
fmt.Fprintln(cf, "Description:", strings.Join(parts, "\n "))
|
|
||||||
|
|
||||||
log.Info("file written as:", filename)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeControlVar(f *os.File, repo *gitpb.Repo, varname string) {
|
|
||||||
val, _ := repo.Control[varname]
|
|
||||||
if val == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Fprintln(f, varname+":", val)
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to guess or figure out the config file values
|
|
||||||
// if there is not a control file
|
|
||||||
func computeControlValues(repo *gitpb.Repo) bool {
|
|
||||||
if repo.Control["Package"] == "" {
|
|
||||||
// get the package name from the repo name
|
|
||||||
path := repo.Control["pathL"] // c.pathL.String()
|
|
||||||
parts := strings.Split(path, "/")
|
|
||||||
name := parts[len(parts)-1]
|
|
||||||
repo.Control["Package"] = name
|
|
||||||
}
|
|
||||||
if repo.Control["Source"] == "" {
|
|
||||||
repo.Control["Source"] = repo.Control["Package"]
|
|
||||||
}
|
|
||||||
if repo.Control["Build-Depends"] == "" {
|
|
||||||
repo.Control["Build-Depends"] = repo.Control["golang"]
|
|
||||||
}
|
|
||||||
if repo.Control["Recommends"] == "" {
|
|
||||||
repo.Control["Recommends"] = repo.Control["go-gui-toolkits"]
|
|
||||||
}
|
|
||||||
if repo.Control["Maintainer"] == "" {
|
|
||||||
repo.Control["Maintainer"] = "todo: get from ENV"
|
|
||||||
}
|
|
||||||
if repo.Control["Description"] == "" {
|
|
||||||
repo.Control["Description"] = "todo: put URL here"
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
|
||||||
|
|
||||||
func getDateStamp(tag string) string {
|
|
||||||
var r cmd.Status
|
|
||||||
r = me.repo.Run([]string{"git", "log", "-1", "--format=%at", tag})
|
|
||||||
|
|
||||||
out := strings.Join(r.Stdout, "\n")
|
|
||||||
out = strings.TrimSpace(out)
|
|
||||||
|
|
||||||
// Convert the string to an integer
|
|
||||||
gitTagTimestampInt, err := strconv.ParseInt(out, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error converting timestamp:", err)
|
|
||||||
return "git tag " + tag + " unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the Unix timestamp into a time.Time object
|
|
||||||
gitTagDate := time.Unix(gitTagTimestampInt, 0)
|
|
||||||
return gitTagDate.UTC().Format("2006-01-02_15:04:05_UTC") // close to RFC3339
|
|
||||||
}
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
// This gets the values for the debian/control file
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
)
|
||||||
|
|
||||||
|
type controlFile struct {
|
||||||
|
group *gui.Node // the group
|
||||||
|
grid *gui.Node // the grid
|
||||||
|
|
||||||
|
Package *gadgets.OneLiner
|
||||||
|
Source *gadgets.OneLiner
|
||||||
|
Maintainer *gadgets.OneLiner
|
||||||
|
Architecture *gadgets.BasicDropdown
|
||||||
|
InstallPath *gadgets.BasicCombobox
|
||||||
|
Depends *gadgets.OneLiner
|
||||||
|
BuildDepends *gadgets.OneLiner
|
||||||
|
Recommends *gadgets.OneLiner
|
||||||
|
Description *gadgets.OneLiner
|
||||||
|
}
|
||||||
|
|
||||||
|
// This initializes the control box
|
||||||
|
func newControl(parent *gui.Node) *controlFile {
|
||||||
|
var c *controlFile
|
||||||
|
c = new(controlFile)
|
||||||
|
c.group = parent.NewGroup("choices")
|
||||||
|
c.grid = c.group.NewGrid("gridiron", 8, 1)
|
||||||
|
|
||||||
|
c.Package = gadgets.NewOneLiner(c.grid, "Package")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Source = gadgets.NewOneLiner(c.grid, "Source")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture")
|
||||||
|
c.Architecture.AddText("riscv")
|
||||||
|
c.Architecture.AddText("amd64")
|
||||||
|
c.Architecture.AddText("arm")
|
||||||
|
c.Architecture.AddText("noarch")
|
||||||
|
c.Architecture.AddText("src")
|
||||||
|
c.Architecture.SetText("amd64")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.InstallPath = gadgets.NewBasicCombobox(c.grid, "Install Path")
|
||||||
|
c.InstallPath.AddText("/usr/bin")
|
||||||
|
c.InstallPath.AddText("/usr/local/bin")
|
||||||
|
c.InstallPath.AddText("/bin")
|
||||||
|
c.InstallPath.AddText("/opt/<pkg>/bin")
|
||||||
|
c.InstallPath.SetText("/usr/bin")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Maintainer = gadgets.NewOneLiner(c.grid, "Maintainer")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Depends = gadgets.NewOneLiner(c.grid, "Depends")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.BuildDepends = gadgets.NewOneLiner(c.grid, "Build-Depends")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Recommends = gadgets.NewOneLiner(c.grid, "Recommends")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Description = gadgets.NewOneLiner(c.grid, "Description")
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func scanConfigFile() {
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
all:
|
|
||||||
make clean
|
|
||||||
make extract
|
|
||||||
make create
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf stuff/ blah/ jcarr-new.deb
|
|
||||||
|
|
||||||
extract:
|
|
||||||
mkdir stuff/ blah/
|
|
||||||
cd stuff && ar x ../jcarr.deb
|
|
||||||
cd stuff && tar xvf control.tar.xz
|
|
||||||
dpkg-deb --raw-extract jcarr.deb blah/
|
|
||||||
cp control blah/DEBIAN/
|
|
||||||
cp stuff/debian-binary blah/
|
|
||||||
mkdir blah/files
|
|
||||||
mv blah/etc blah/files/
|
|
||||||
mv blah/usr blah/files/
|
|
||||||
|
|
||||||
create:
|
|
||||||
cd blah/DEBIAN && tar --ignore-failed-read -cvJf ../control.tar.xz {post,pre}{inst,rm} md5sums control
|
|
||||||
cd blah/files && tar -cvJf ../data.tar.xz .
|
|
||||||
cd blah && ar rcs ../jcarr-new.deb debian-binary control.tar.xz data.tar.xz
|
|
||||||
|
|
||||||
info:
|
|
||||||
dpkg-deb --info jcarr-new.deb
|
|
||||||
|
|
||||||
install:
|
|
||||||
dpkg --install jcarr-new.deb
|
|
|
@ -1,11 +0,0 @@
|
||||||
Package: jcarr
|
|
||||||
Source: jcarr
|
|
||||||
Version: 0.1
|
|
||||||
Architecture: amd64
|
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
|
||||||
Installed-Size: 5883
|
|
||||||
Homepage: https://www.wit.com/
|
|
||||||
Description: jeff's test package
|
|
||||||
this is a test golang package to make .deb and .rpm packages
|
|
||||||
.
|
|
||||||
It doesn't do anything yet
|
|
Binary file not shown.
|
@ -0,0 +1,49 @@
|
||||||
|
# GITVERSION=$(shell git rev-parse FETCH_HEAD)
|
||||||
|
VERSION=$(shell git describe --tags $(git rev-list --tags --max-count=1) | sed 's/^v//')
|
||||||
|
|
||||||
|
BASENAME=control-panel-dns
|
||||||
|
|
||||||
|
all: help deb
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo
|
||||||
|
@echo "make deb # attempt to build the .deb package using dpkg"
|
||||||
|
@echo
|
||||||
|
|
||||||
|
deb: clean extract DEBIAN build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ../files
|
||||||
|
rm -f ../*.deb
|
||||||
|
rm -f ../*.tar.xz data.tar.xz
|
||||||
|
rm -rf DEBIAN
|
||||||
|
|
||||||
|
extract:
|
||||||
|
mkdir -p ../files/usr/bin
|
||||||
|
mkdir -p ../files/usr/lib/control-panel-dns/
|
||||||
|
cp ../README.md ../files/usr/lib/control-panel-dns/
|
||||||
|
cp ~/go/bin/control-panel-dns ../files/usr/bin/
|
||||||
|
|
||||||
|
# makes the DEBIAN/ directory
|
||||||
|
DEBIAN:
|
||||||
|
mkdir -p DEBIAN
|
||||||
|
|
||||||
|
# make the md5sum file
|
||||||
|
cd ../files/ && find -type f -exec md5sum '{}' \; |sort -k2 >../md5sums
|
||||||
|
mv ../md5sums DEBIAN/
|
||||||
|
|
||||||
|
# make the control there
|
||||||
|
mkdir -p DEBIAN
|
||||||
|
cp control DEBIAN/
|
||||||
|
echo Version: ${VERSION} >>DEBIAN/control
|
||||||
|
|
||||||
|
cp postinst DEBIAN
|
||||||
|
|
||||||
|
build:
|
||||||
|
mv DEBIAN ../files/
|
||||||
|
cd .. && dpkg-deb --build files ${BASENAME}_${VERSION}_amd64.deb
|
||||||
|
@echo
|
||||||
|
@echo '#######################'
|
||||||
|
cd .. && dpkg-deb --info ${BASENAME}_${VERSION}_amd64.deb
|
||||||
|
@echo '#######################'
|
||||||
|
@echo
|
|
@ -0,0 +1 @@
|
||||||
|
10
|
|
@ -0,0 +1 @@
|
||||||
|
#!/bin/sh
|
132
doGui.go
132
doGui.go
|
@ -1,132 +0,0 @@
|
||||||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the GPL 3.0
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
// An app to submit patches for the 30 GO GUI repos
|
|
||||||
|
|
||||||
func doGui() {
|
|
||||||
log.Warn("init basicWindow state")
|
|
||||||
win := gadgets.NewGenericWindow("Create .deb files for GO applications", "things")
|
|
||||||
win.Custom = func() {
|
|
||||||
log.Info("got to close")
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
var cbox *controlBox
|
|
||||||
|
|
||||||
vbox := win.Middle.Box().Horizontal()
|
|
||||||
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
|
||||||
|
|
||||||
group1.NewButton("go build", func() {
|
|
||||||
shell.Run([]string{"go", "build", "-v", "-x"})
|
|
||||||
})
|
|
||||||
|
|
||||||
group1.NewButton("read control file", func() {
|
|
||||||
readControlFile(me.repo)
|
|
||||||
})
|
|
||||||
|
|
||||||
group1.NewButton("write control file", func() {
|
|
||||||
writeDebianControlFile(me.repo)
|
|
||||||
})
|
|
||||||
|
|
||||||
group1.NewButton("dump repo.Control", func() {
|
|
||||||
// log.Info("CONTROL:", me.repo.Control)
|
|
||||||
for v := range me.repo.Control {
|
|
||||||
log.Infof("CONTROL: %s: %s\n", v, me.repo.Control[v])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
group1.NewButton("Make .deb", func() {
|
|
||||||
win.Disable()
|
|
||||||
if ok, err := buildPackage(me.repo); ok {
|
|
||||||
log.Info("build worked")
|
|
||||||
os.Exit(0)
|
|
||||||
} else {
|
|
||||||
log.Warn("build failed with err:", err)
|
|
||||||
}
|
|
||||||
win.Enable()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid := win.Middle.RawGrid()
|
|
||||||
cbox = newControl(grid)
|
|
||||||
|
|
||||||
updateControl(cbox)
|
|
||||||
}
|
|
||||||
|
|
||||||
// This initializes the control box
|
|
||||||
func newControl(grid *gui.Node) *controlBox {
|
|
||||||
c := new(controlBox)
|
|
||||||
c.grid = grid
|
|
||||||
|
|
||||||
c.Package = gadgets.NewOneLiner(c.grid, "Package")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Source = gadgets.NewOneLiner(c.grid, "Source")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Version = gadgets.NewOneLiner(c.grid, "Version")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture")
|
|
||||||
c.Architecture.AddText("all")
|
|
||||||
c.Architecture.AddText("riscv64")
|
|
||||||
c.Architecture.AddText("amd64")
|
|
||||||
c.Architecture.AddText("arm64")
|
|
||||||
c.Architecture.AddText("ppc64")
|
|
||||||
c.Architecture.AddText("i386")
|
|
||||||
c.Architecture.AddText("sparc64")
|
|
||||||
c.Architecture.AddText("alpha")
|
|
||||||
c.Architecture.SetText("riscv64")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.InstallPath = gadgets.NewBasicCombobox(c.grid, "Install Path")
|
|
||||||
c.InstallPath.AddText("/usr/bin")
|
|
||||||
c.InstallPath.AddText("/usr/local/bin")
|
|
||||||
c.InstallPath.AddText("/bin")
|
|
||||||
c.InstallPath.AddText("/opt/<pkg>/bin")
|
|
||||||
c.InstallPath.SetText("/usr/bin")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Maintainer = gadgets.NewOneLiner(c.grid, "Maintainer")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Packager = gadgets.NewBasicEntry(c.grid, "Packager")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.GoPath = gadgets.NewBasicEntry(c.grid, "GoPath")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Namespace = gadgets.NewBasicEntry(c.grid, "Namespace")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.URL = gadgets.NewBasicEntry(c.grid, "URL")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Depends = gadgets.NewOneLiner(c.grid, "Depends")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.BuildDepends = gadgets.NewOneLiner(c.grid, "Build-Depends")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Recommends = gadgets.NewOneLiner(c.grid, "Recommends")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Conflicts = gadgets.NewBasicEntry(c.grid, "Conflicts")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
c.Description = gadgets.NewOneLiner(c.grid, "Description")
|
|
||||||
c.Description.SetText("na")
|
|
||||||
c.grid.NextRow()
|
|
||||||
|
|
||||||
return c
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# cmd github.com/posener/complete/gocomplete
|
|
||||||
|
|
||||||
# this is the awesome gocomplete from github.com/posener/complete
|
|
||||||
|
|
||||||
mkdir -p files/usr/bin
|
|
||||||
cp ~/go/src/github.com/posener/complete/gocomplete/gocomplete files/usr/bin/
|
|
|
@ -1,12 +0,0 @@
|
||||||
Source:
|
|
||||||
Package: gocomplete
|
|
||||||
Build-Depends:
|
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends:
|
|
||||||
GoPath: github.com/posener/complete
|
|
||||||
Recommends: golang
|
|
||||||
Version: 0.0.2
|
|
||||||
Description: gocomplete from posener
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# do nothing. this package is just an 'alias'
|
|
||||||
# since I never remember where goimport is
|
|
||||||
# (it's in golang-golang-x-tools)
|
|
|
@ -1,13 +0,0 @@
|
||||||
Source:
|
|
||||||
Package: goimports
|
|
||||||
Build-Depends:
|
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends: golang-golang-x-tools
|
|
||||||
GoPath: golang.org/x/tools
|
|
||||||
Recommends: golang
|
|
||||||
Version: 0.0.1
|
|
||||||
Description: apt install's golang.org/x/tools
|
|
||||||
This doesn't do anything. it's just a shortcut.
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# gomobile binary from go
|
|
||||||
|
|
||||||
mkdir -p files/usr/bin
|
|
||||||
cd ~/go/bin/golang.org/x/mobile/cmd/gomobile/
|
|
||||||
go build
|
|
||||||
cp ~/go/src/golang.org/x/mobile/cmd/gomobile/gomobile files/usr/bin
|
|
|
@ -1,11 +0,0 @@
|
||||||
Source:
|
|
||||||
Package: gomobile
|
|
||||||
Build-Depends:
|
|
||||||
Maintainer: golang <?@golang.org>
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends:
|
|
||||||
URL: golang.org/x/mobile
|
|
||||||
Version: 0.0.1
|
|
||||||
Description: gomobile
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# these are the keys and files you need
|
|
||||||
#
|
|
||||||
# to be able to apt install packages from mirrors.wit.com
|
|
||||||
|
|
||||||
mkdir -p files/etc/apt/trusted.gpg.d/
|
|
||||||
cp wit-sid.asc files/etc/apt/trusted.gpg.d/
|
|
||||||
|
|
||||||
mkdir -p files/etc/apt/sources.list.d/
|
|
||||||
cp wit.list files/etc/apt/sources.list.d/
|
|
|
@ -1,12 +0,0 @@
|
||||||
Source:
|
|
||||||
Package: mirrors.wit.com
|
|
||||||
Build-Depends:
|
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: all
|
|
||||||
Depends:
|
|
||||||
URL: https://mirrors.wit.com/
|
|
||||||
Recommends:
|
|
||||||
Version: 0.0.7
|
|
||||||
Description: apt keys and source file
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
|
@ -1,41 +0,0 @@
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
|
|
||||||
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
|
|
||||||
yGA=
|
|
||||||
=tw/F
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
|
|
@ -1,4 +0,0 @@
|
||||||
deb http://mirrors.wit.com/wit/ sid main
|
|
||||||
# deb-src http://mirrors.wit.com/wit/ sid main
|
|
||||||
|
|
||||||
# cp apt-wit.list /etc/apt/sources.list.d/
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# pkgsite binary from go
|
|
||||||
# go-clone golang.org/x/pkgsite
|
|
||||||
# cd ~/go/src/golang.org/x/pkgsite/cmd/pkgsite
|
|
||||||
# go build
|
|
||||||
|
|
||||||
mkdir -p files/usr/bin
|
|
||||||
cp ~/go/src/golang.org/x/pkgsite/cmd/pkgsite/pkgsite files/usr/bin/
|
|
|
@ -1,10 +0,0 @@
|
||||||
Package: pkgsite
|
|
||||||
Maintainer: https://golang.org/x/pkgsite
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends:
|
|
||||||
Source: go-clone golang.org/x/pkgsite
|
|
||||||
URL: https://golang.org/x/pkgsite
|
|
||||||
Version: 0.0.1
|
|
||||||
Description: pkgsite
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
|
@ -1,15 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
go-deb --repo .
|
|
||||||
|
|
||||||
# keep the files/ directory after the package is made
|
|
||||||
keep-files:
|
|
||||||
go-deb --keep-files --repo .
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
go-deb --gui gocui --repo .
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/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 build
|
|
||||||
|
|
||||||
mkdir -p files/usr/bin
|
|
||||||
cp ~/go/src/google.golang.org/protobuf/cmd/protoc-gen-go/protoc-gen-go files/usr/bin/
|
|
|
@ -1,12 +0,0 @@
|
||||||
Source: go-clone google.golang.org/protobuf
|
|
||||||
Build-Depends: golang
|
|
||||||
Package: protoc-gen-go-wit
|
|
||||||
Maintainer: https://google.golang.org/protobuf/
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends: protobuf-compiler
|
|
||||||
Conflicts: protoc-gen-go, protoc-gen-go-1-3, protoc-gen-go-1-5
|
|
||||||
Recommends:
|
|
||||||
Version: 1.35.1-devel
|
|
||||||
Description: protoc-gen-go from google.golang.org/protobuf
|
|
||||||
I didn't change anything, it's a straight build from the sources.
|
|
|
@ -1,13 +0,0 @@
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
# this is how the mirrors.wit.com debian package is created
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
cp build control ~/go/src/golang.org/x/tools/
|
|
||||||
go-deb --auto --repo golang.org/x/tools
|
|
||||||
|
|
||||||
# use the ncurses gui (only kinda works still)
|
|
||||||
ncurses:
|
|
||||||
# go-deb --gui gocui --repo .
|
|
|
@ -1,37 +0,0 @@
|
||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
# bin /usr/bin
|
|
||||||
# cmd golang.org/x/tools/cmd/benchcmp
|
|
||||||
# cmd golang.org/x/tools/cmd/godoc
|
|
||||||
# cmd golang.org/x/tools/cmd/goimports
|
|
||||||
#
|
|
||||||
# bin /usr/lib/golang.org/x/tools/
|
|
||||||
# cmd golang.org/x/tools/cmd/auth golang-authtest
|
|
||||||
# cmd golang.org/x/tools/cmd/bisect golang-bisect
|
|
||||||
# cmd golang.org/x/tools/cmd/bundle golang-bundle
|
|
||||||
# cmd golang.org/x/tools/cmd/callgraph
|
|
||||||
# cmd golang.org/x/tools/cmd/compilebench
|
|
||||||
# cmd golang.org/x/tools/cmd/deadcode
|
|
||||||
# cmd golang.org/x/tools/cmd/digraph
|
|
||||||
# cmd golang.org/x/tools/cmd/eg
|
|
||||||
# cmd golang.org/x/tools/cmd/file2fuzz
|
|
||||||
# cmd golang.org/x/tools/cmd/fiximports
|
|
||||||
# cmd golang.org/x/tools/cmd/go-contrib-init
|
|
||||||
# cmd golang.org/x/tools/cmd/godex
|
|
||||||
# cmd golang.org/x/tools/cmd/gomvpkg
|
|
||||||
# cmd golang.org/x/tools/cmd/gonew
|
|
||||||
# cmd golang.org/x/tools/cmd/gotype
|
|
||||||
# cmd golang.org/x/tools/cmd/goyacc
|
|
||||||
# cmd golang.org/x/tools/cmd/html2article
|
|
||||||
# cmd golang.org/x/tools/cmd/present
|
|
||||||
# cmd golang.org/x/tools/cmd/present2md
|
|
||||||
# cmd golang.org/x/tools/cmd/signature-fuzzer
|
|
||||||
# cmd golang.org/x/tools/cmd/splitdwarf
|
|
||||||
# cmd golang.org/x/tools/cmd/ssadump
|
|
||||||
# cmd golang.org/x/tools/cmd/stress
|
|
||||||
# cmd golang.org/x/tools/cmd/stringer
|
|
||||||
# cmd golang.org/x/tools/cmd/toolstash
|
|
||||||
|
|
||||||
# doc man1 benchcmp.1.gz
|
|
||||||
|
|
||||||
# normal bash stuff below still will run
|
|
|
@ -1,14 +0,0 @@
|
||||||
Source:
|
|
||||||
Package: golang.org-x-tools
|
|
||||||
Build-Depends:
|
|
||||||
Maintainer: https://golang.org/issue/
|
|
||||||
Packager: Jeff Carr <jcarr@wit.com>
|
|
||||||
Architecture: amd64
|
|
||||||
Depends:
|
|
||||||
GoPath: golang.org/x/tools
|
|
||||||
Recommends: golang
|
|
||||||
BuildIgnore:
|
|
||||||
Description: GO lang x/tools
|
|
||||||
Just an example of how it could be packaged using go-deb
|
|
||||||
incase that is of any use or not.
|
|
||||||
This was packaged with go-deb from go.wit.com
|
|
20
exit.go
20
exit.go
|
@ -1,20 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func okExit(thing string) {
|
|
||||||
if thing != "" {
|
|
||||||
log.Info(thing, "ok")
|
|
||||||
}
|
|
||||||
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func badExit(err error) {
|
|
||||||
log.Info("go-deb failed: ", err)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
130
main.go
130
main.go
|
@ -1,99 +1,67 @@
|
||||||
|
// make debian packages for go applications
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"go.wit.com/gui"
|
||||||
"os"
|
"go.wit.com/lib/debugger"
|
||||||
"path/filepath"
|
"go.wit.com/lib/gadgets"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/lib/gui/prep"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sent from -ldflags
|
// This is the beginning of the binary tree of GUI widgets
|
||||||
var VERSION string
|
var myGui *gui.Node
|
||||||
var DATE string
|
|
||||||
|
|
||||||
//go:embed resources/*
|
// this is the primary window. If you close it, the program will exit
|
||||||
var resources embed.FS
|
// var mainWindow *gui.Node
|
||||||
|
|
||||||
var ARGNAME string = "go-deb"
|
// this is a basic window. the user can open and close it
|
||||||
var argv args
|
var basicWindow *gadgets.BasicWindow
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(mainType)
|
if debugger.ArgDebug() {
|
||||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
log.SetAll(true)
|
||||||
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
log.ShowFlags()
|
||||||
me.pp = arg.MustParse(&argv)
|
}
|
||||||
|
if args.TmpLog {
|
||||||
|
// send all log() output to a file in /tmp
|
||||||
|
log.SetTmp()
|
||||||
|
}
|
||||||
|
myGui = gui.New()
|
||||||
|
myGui.Default()
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
// helloworld()
|
||||||
if err != nil {
|
basicWindow = makebasicWindow()
|
||||||
badExit(err)
|
|
||||||
|
if args.OpenGui {
|
||||||
|
basicWindow.Show()
|
||||||
|
// go will sit here until the window exits
|
||||||
|
gui.Watchdog()
|
||||||
}
|
}
|
||||||
|
|
||||||
me.repo, err = gitpb.NewRepo(wd)
|
// run the debugger if triggered from the commandline
|
||||||
if err != nil {
|
if debugger.ArgDebug() {
|
||||||
badExit(err)
|
go func() {
|
||||||
|
log.Sleep(2)
|
||||||
|
debugger.DebugWindow()
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// build()
|
|
||||||
if argv.Show != nil {
|
|
||||||
log.Info("todo: show", me.repo.GetGoPath())
|
|
||||||
okExit("")
|
|
||||||
}
|
|
||||||
log.Info("Namespace:", me.repo.GetNamespace(), "Fullpath:", me.repo.GetFullPath())
|
|
||||||
|
|
||||||
// figure out where we are working from
|
|
||||||
// os.Chdir to that directory
|
|
||||||
var debpath string
|
|
||||||
if me.repo == nil {
|
|
||||||
os.Setenv("GO_DEB_CUSTOM", "true")
|
|
||||||
debpath, _ = os.Getwd()
|
|
||||||
} else {
|
|
||||||
debpath = me.repo.GetFullPath()
|
|
||||||
}
|
|
||||||
_, basename := filepath.Split(debpath)
|
|
||||||
me.goPath = basename
|
|
||||||
os.Chdir(debpath)
|
|
||||||
|
|
||||||
// look for a 'config' file in the repo
|
|
||||||
if readControlFile(me.repo) == nil {
|
|
||||||
log.Warn("scan worked")
|
|
||||||
} else {
|
|
||||||
log.Warn("scan failed")
|
|
||||||
}
|
|
||||||
computeControlValues(me.repo)
|
|
||||||
|
|
||||||
if argv.Dump != nil {
|
|
||||||
for v := range me.repo.Control {
|
|
||||||
log.Infof("CONTROL: %s: %s\n", v, me.repo.Control[v])
|
|
||||||
}
|
|
||||||
okExit("")
|
|
||||||
}
|
|
||||||
|
|
||||||
if argv.Gui != nil {
|
|
||||||
// only load teh toolkit if you get this far
|
|
||||||
me.myGui.Start() // loads the GUI toolkit
|
|
||||||
doGui()
|
|
||||||
debug()
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Info("go-deb: attempting to build package")
|
|
||||||
if ok, err := buildPackage(me.repo); ok {
|
|
||||||
log.Info("build worked")
|
|
||||||
} else {
|
|
||||||
log.Warn("build failed:", err)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func debug() {
|
/*
|
||||||
time.Sleep(2 * time.Second)
|
// This initializes the first window and some widgets
|
||||||
for {
|
func helloworld() {
|
||||||
log.Info("idle loop() todo: could check for things here")
|
mainWindow = myGui.NewWindow("Debian Package Creater for GO Language Applicatiosn").SetProgName("BASEWIN")
|
||||||
time.Sleep(90 * time.Second)
|
|
||||||
|
box := mainWindow.NewBox("hbox", true)
|
||||||
|
// section1 = newChoices(box)
|
||||||
|
|
||||||
|
group := box.NewGroup("control file")
|
||||||
|
group.NewButton("show basic window", func() {
|
||||||
|
if basicWindow.Hidden() {
|
||||||
|
basicWindow.Show()
|
||||||
|
} else {
|
||||||
|
basicWindow.Hide()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// readGitConfig reads and parses the control file
|
||||||
|
func (c *controlFile) readControlFile() error {
|
||||||
|
file, err := os.Open("control")
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("readControlFile() could not find the file")
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
pairs := make(map[string]string)
|
||||||
|
var key string
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
line := scanner.Text()
|
||||||
|
|
||||||
|
// Skip empty lines and comments
|
||||||
|
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// if line starts with a space, it's part of the last key
|
||||||
|
if strings.HasPrefix(line, " ") {
|
||||||
|
pairs[key] = pairs[key] + "\n" + strings.TrimSpace(line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
partsNew := strings.SplitN(line, ":", 2)
|
||||||
|
if len(partsNew) < 2 {
|
||||||
|
log.Warn("error on line:", line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
key = strings.TrimSpace(partsNew[0])
|
||||||
|
value := strings.TrimSpace(partsNew[1])
|
||||||
|
pairs[key] = value
|
||||||
|
}
|
||||||
|
for key, value := range pairs {
|
||||||
|
switch key {
|
||||||
|
case "Source":
|
||||||
|
// log.Info("FOUND Source!", value)
|
||||||
|
c.Source.SetText(value)
|
||||||
|
case "Build-Depends":
|
||||||
|
c.BuildDepends.SetText(value)
|
||||||
|
case "Description":
|
||||||
|
c.Description.SetText(value)
|
||||||
|
case "Maintainer":
|
||||||
|
c.Maintainer.SetText(value)
|
||||||
|
case "Depends":
|
||||||
|
c.Depends.SetText(value)
|
||||||
|
case "Recommends":
|
||||||
|
c.Recommends.SetText(value)
|
||||||
|
case "Package":
|
||||||
|
c.Package.SetText(value)
|
||||||
|
// if c.Package.String() != value {
|
||||||
|
// log.Warn("not sure what to do with Package", c.Package.String(), value)
|
||||||
|
// }
|
||||||
|
case "Architecture":
|
||||||
|
if c.Architecture.String() != value {
|
||||||
|
log.Warn("not sure what to do with Architecture", c.Architecture.String(), value)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Warn("error unknown key", key, "value:", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
// This window, when it's hidden, still exists to the application
|
||||||
|
// so it can be treated as if it really exists
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var apple *gui.Node
|
||||||
|
|
||||||
|
// This initializes the first window, a group and a button
|
||||||
|
func makebasicWindow() *gadgets.BasicWindow {
|
||||||
|
log.Warn("init basicWindow state")
|
||||||
|
basicWindow = gadgets.NewBasicWindow(myGui, "Create .deb files for GO applications")
|
||||||
|
basicWindow.Make()
|
||||||
|
basicWindow.Custom = func() {
|
||||||
|
log.Info("got to close")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
box1 := basicWindow.Box()
|
||||||
|
control := newControl(box1)
|
||||||
|
|
||||||
|
vbox := box1.Box().Horizontal()
|
||||||
|
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
||||||
|
|
||||||
|
group1.NewButton("go build", func() {
|
||||||
|
shell.Run([]string{"go", "build", "-v", "-x"})
|
||||||
|
})
|
||||||
|
|
||||||
|
group1.NewButton("read control file", func() {
|
||||||
|
control.readControlFile()
|
||||||
|
})
|
||||||
|
|
||||||
|
group1.NewButton("Make .deb", func() {
|
||||||
|
})
|
||||||
|
|
||||||
|
group1.NewButton("open repo", func() {
|
||||||
|
})
|
||||||
|
/*
|
||||||
|
group1.NewButton("show apple", func() {
|
||||||
|
apple.Show()
|
||||||
|
})
|
||||||
|
apple = group1.NewButton("apple", func() {
|
||||||
|
log.Info("is not a pear")
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
return basicWindow
|
||||||
|
}
|
52
structs.go
52
structs.go
|
@ -1,52 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/prep"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
)
|
|
||||||
|
|
||||||
var me *mainType
|
|
||||||
|
|
||||||
// this app's variables
|
|
||||||
type mainType struct {
|
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
|
||||||
goSrc string // path to ~/go/src or go.work file
|
|
||||||
goPath string // the goPath to use for the package
|
|
||||||
hasWork bool // true if using go.work file
|
|
||||||
repo *gitpb.Repo // this is the repo we are in
|
|
||||||
myGui *prep.GuiPrep // the gui toolkit handle
|
|
||||||
}
|
|
||||||
|
|
||||||
type controlBox struct {
|
|
||||||
group *gui.Node // the group
|
|
||||||
grid *gui.Node // the grid
|
|
||||||
|
|
||||||
Package *gadgets.OneLiner
|
|
||||||
Source *gadgets.OneLiner
|
|
||||||
Version *gadgets.OneLiner
|
|
||||||
Maintainer *gadgets.OneLiner
|
|
||||||
Packager *gadgets.BasicEntry
|
|
||||||
GoPath *gadgets.BasicEntry
|
|
||||||
Namespace *gadgets.BasicEntry
|
|
||||||
URL *gadgets.BasicEntry
|
|
||||||
Architecture *gadgets.BasicDropdown
|
|
||||||
InstallPath *gadgets.BasicCombobox
|
|
||||||
Depends *gadgets.OneLiner
|
|
||||||
BuildDepends *gadgets.OneLiner
|
|
||||||
Recommends *gadgets.OneLiner
|
|
||||||
Conflicts *gadgets.BasicEntry
|
|
||||||
Test gui.Widget
|
|
||||||
Description *gadgets.OneLiner
|
|
||||||
|
|
||||||
// repostatus things
|
|
||||||
pathL *gadgets.OneLiner
|
|
||||||
lastTag *gadgets.OneLiner
|
|
||||||
dirtyL *gadgets.OneLiner
|
|
||||||
currentL *gadgets.OneLiner
|
|
||||||
buildDate *gadgets.OneLiner
|
|
||||||
tagDate *gadgets.BasicEntry
|
|
||||||
// status *repostatus.RepoStatus
|
|
||||||
}
|
|
16
update.go
16
update.go
|
@ -1,16 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
func updateControl(c *controlBox) {
|
|
||||||
c.Namespace.SetText(me.repo.Namespace)
|
|
||||||
c.URL.SetText(me.repo.URL)
|
|
||||||
c.Package.SetText(me.repo.Control["Package"])
|
|
||||||
c.Source.SetText(me.repo.Control["Source"])
|
|
||||||
c.Maintainer.SetText(me.repo.Control["Maintainer"])
|
|
||||||
c.Packager.SetText(me.repo.Control["Packager"])
|
|
||||||
c.Version.SetText(me.repo.Control["Version"])
|
|
||||||
c.Description.SetText(me.repo.Control["Description"])
|
|
||||||
c.Depends.SetText(me.repo.Control["Depends"])
|
|
||||||
c.Recommends.SetText(me.repo.Control["Recommends"])
|
|
||||||
|
|
||||||
c.Architecture.SetText("amd64")
|
|
||||||
}
|
|
Loading…
Reference in New Issue