Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil ptr written bug fix #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Libary usage

Once the API firms up, the preferred way to use debgo will be as a library. It should become most useful as part of a build system.

Please see [godoc](http://godoc.org/pkg/github.com/laher/debgo-v0.2/) for API docs.
Please see [godoc](http://godoc.org/pkg/debgo/) for API docs.

#### The deb package

Expand All @@ -44,7 +44,7 @@ You can use debgo from the commandline, but there is no configuration - just fla

debgo comes with a few basic commands for building Debian packages. For the most part, each takes the same arguments.

`go get github.com/laher/debgo-v0.2/cmd/...`
`go get debgo/cmd/...`

* debgo-deb produces .deb files for each architecture
* debgo-source produces 3 'source package' files.
Expand Down
5 changes: 3 additions & 2 deletions cmd/cmdutils.go → cmdutils/cmdutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package cmdutils
import (
"flag"
"fmt"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"os"

"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func InitFlags(name string, pkg *deb.Package, build *debgen.BuildParams) *flag.FlagSet {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main

import (
"github.com/laher/debgo-v0.2/cmd"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"
"path/filepath"
"os"
"path/filepath"
"text/template"

"github.com/mwpcheung/debgo/cmdutils"
"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func main() {
Expand Down
7 changes: 4 additions & 3 deletions cmd/debgen-deb/main.go → cmdutils/debgen-deb/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package main

import (
"github.com/laher/debgo-v0.2/cmd"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"
"os"
"path/filepath"

"github.com/mwpcheung/debgo/cmdutils"
"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func main() {
Expand Down
Binary file added cmdutils/debgen-dev/debgen-dev
Binary file not shown.
7 changes: 4 additions & 3 deletions cmd/debgen-dev/main.go → cmdutils/debgen-dev/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/laher/debgo-v0.2/cmd"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"

"github.com/mwpcheung/debgo/cmdutils"
"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func main() {
Expand Down
9 changes: 5 additions & 4 deletions cmd/debgen-source/main.go → cmdutils/debgen-source/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/laher/debgo-v0.2/cmd"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"

"github.com/mwpcheung/debgo/cmdutils"
"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func main() {
Expand Down Expand Up @@ -36,7 +37,7 @@ func main() {
}
spkg := deb.NewSourcePackage(pkg)
sourcesDestinationDir := pkg.Name + "_" + pkg.Version
spgen := debgen.NewSourcePackageGenerator(spkg, build)
spgen := debgen.NewSourcePackageGenerator(spkg, build)
spgen.OrigFiles, err = debgen.GlobForSources(sourcesRelativeTo, sourceDir, glob, sourcesDestinationDir, []string{build.TmpDir, build.DestDir})
if err != nil {
log.Fatalf("Error resolving sources: %v", err)
Expand Down
5 changes: 3 additions & 2 deletions cmd/debgo-deb/main.go → cmdutils/debgo-deb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"flag"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"
"os"

"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func main() {
Expand Down
16 changes: 8 additions & 8 deletions deb/deb_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
package deb

import (
"fmt"
"archive/tar"
"github.com/laher/argo/ar"
"github.com/laher/debgo-v0.2/targz"
"fmt"
"io"
"io/ioutil"
"log"
"strings"

"github.com/laher/argo/ar"
"github.com/mwpcheung/debgo/targz"
)

type DebReader struct {
Reader io.Reader
ArReader *ar.Reader
Reader io.Reader
ArReader *ar.Reader
HasDebianVersion bool
}

func NewDebReader(rdr io.Reader) (*DebReader, error) {
drdr := &DebReader{Reader:rdr, HasDebianVersion: false}
drdr := &DebReader{Reader: rdr, HasDebianVersion: false}
arr, err := ar.NewReader(rdr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -63,7 +64,6 @@ func (drdr *DebReader) NextTar() (string, *tar.Reader, error) {
}
}


func DebGetContents(rdr io.Reader, topLevelFilename string) ([]string, error) {
ret := []string{}
fileNotFound := true
Expand Down Expand Up @@ -206,7 +206,7 @@ func DebParseMetadata(rdr io.Reader) (*Package, error) {
}
} else {
//SKIP
log.Printf("File %s", thdr.Name)
// log.Printf("File %s", thdr.Name)
}
}

Expand Down
6 changes: 4 additions & 2 deletions deb/deb_reader_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package deb_test

import (
"github.com/laher/argo/ar"
"github.com/laher/debgo-v0.2/deb"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"

"github.com/laher/argo/ar"

"github.com/mwpcheung/debgo/deb"
)

func XTest_parse(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions deb/deb_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package deb

import (
"fmt"
"github.com/laher/argo/ar"
"io"
"os"
"path/filepath"

"github.com/laher/argo/ar"
)

// DebWriter is an architecture-specific deb
Expand All @@ -30,7 +31,7 @@ type DebWriter struct {
Architecture Architecture
Filename string
DebianBinaryVersion string
ControlArchive string
ControlArchive string
DataArchive string
MappedFiles map[string]string
}
Expand Down
5 changes: 3 additions & 2 deletions deb/deb_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package deb_test

import (
"archive/tar"
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/targz"
"log"
"os"
"path/filepath"
"testing"
"time"

"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/targz"
)

func Example_buildBinaryDeb() {
Expand Down
3 changes: 2 additions & 1 deletion deb/dev_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package deb_test

import (
"github.com/laher/debgo-v0.2/deb"
"log"
"testing"

"github.com/mwpcheung/debgo/deb"
)

func Example_buildDevPackage() {
Expand Down
6 changes: 2 additions & 4 deletions deb/dsc_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package deb
import (
"bufio"
"io"
"log"
"strings"
)

Expand All @@ -29,7 +28,7 @@ type DscReader struct {
}

//NewDscReader is a factory for reading Dsc files.
func NewDscReader(rdr io.Reader) (*DscReader) {
func NewDscReader(rdr io.Reader) *DscReader {
return &DscReader{rdr}
}

Expand All @@ -47,7 +46,7 @@ func (dscr *DscReader) Parse() (*Package, error) {
}
if strings.Contains(line, ":") {
res := strings.SplitN(line, ":", 2)
log.Printf("Control File entry: '%s': %s", res[0], res[1])
// log.Printf("Control File entry: '%s': %s", res[0], res[1])
pkg.SetField(res[0], res[1])
} else {

Expand All @@ -56,4 +55,3 @@ func (dscr *DscReader) Parse() (*Package, error) {
return pkg, nil

}

3 changes: 3 additions & 0 deletions deb/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func (pkg *Package) SetField(key, value string) {
case "Other":
pkg.Other = value
default:
if pkg.AdditionalControlData == nil {
pkg.AdditionalControlData = make(map[string]string)
}
pkg.AdditionalControlData[key] = value
}
}
Expand Down
3 changes: 2 additions & 1 deletion deb/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package deb_test

import (
"github.com/laher/debgo-v0.2/deb"
"testing"

"github.com/mwpcheung/debgo/deb"
)

func TestCopy(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions deb/source_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package deb_test

import (
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/targz"
"io/ioutil"
"log"
"path/filepath"
"testing"

"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/targz"
)

func Example_buildSourceDeb() {
Expand Down
3 changes: 2 additions & 1 deletion deb/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package deb_test

import (
"github.com/laher/debgo-v0.2/deb"
"log"
"testing"

"github.com/mwpcheung/debgo/deb"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions debgen/binary_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package debgen_test

import (
"github.com/laher/debgo-v0.2/deb"
"github.com/laher/debgo-v0.2/debgen"
"log"
"os"
"path/filepath"

"github.com/mwpcheung/debgo/deb"
"github.com/mwpcheung/debgo/debgen"
)

func Example_genBinaryPackage() {
Expand Down
4 changes: 2 additions & 2 deletions debgen/build_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package debgen

import (
"errors"
"github.com/laher/debgo-v0.2/deb"
"os"

"github.com/mwpcheung/debgo/deb"
)

// BuildParams provides information about a particular build
Expand Down Expand Up @@ -50,7 +51,6 @@ func NewBuildParams() *BuildParams {
return bp
}


//Initialise build directories (make Temp and Dest directories)
func (bp *BuildParams) Init() error {
//make tmpDir
Expand Down
22 changes: 10 additions & 12 deletions debgen/constants.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package debgen

import (
"github.com/laher/debgo-v0.2/deb"
)
import "github.com/mwpcheung/debgo/deb"

const (
GlobGoSources = "*.go"
TemplateDebianSourceFormat = deb.FormatDefault // Debian source formaat
TemplateDebianSourceFormat = deb.FormatDefault // Debian source formaat
TemplateDebianSourceOptions = `tar-ignore = .hg
tar-ignore = .git
tar-ignore = .bzr` //specifies files to ignore while building.
tar-ignore = .bzr` //specifies files to ignore while building.

// The debian rules file describes how to build a 'source deb' into a binary deb. The default template here invokes debhelper scripts to automate this process for simple cases.
TemplateDebianRulesDefault = `#!/usr/bin/make -f
Expand Down Expand Up @@ -114,13 +112,13 @@ Files:{{range .Checksums.ChecksumsMd5}}
{{.Checksum}} {{.Size}} {{.File}}{{end}}
{{.Package.Other}}`

TemplateChangelogHeader = `{{.Package.Name}} ({{.Package.Version}}) {{.Package.Status}}; urgency=low`
TemplateChangelogInitialEntry = ` * Initial import`
TemplateChangelogFooter = ` -- {{.Package.Maintainer}} {{.EntryDate}}`
TemplateChangelogInitial = TemplateChangelogHeader + "\n\n" + TemplateChangelogInitialEntry + "\n\n" + TemplateChangelogFooter
TemplateChangelogAdditionalEntry = "\n\n" + TemplateChangelogHeader + "\n\n{{.ChangelogEntry}}\n\n" + TemplateChangelogFooter
TemplateDebianCopyright = `Copyright 2014 {{.Package.Name}}`
TemplateDebianReadme = `{{.Package.Name}}
TemplateChangelogHeader = `{{.Package.Name}} ({{.Package.Version}}) {{.Package.Status}}; urgency=low`
TemplateChangelogInitialEntry = ` * Initial import`
TemplateChangelogFooter = ` -- {{.Package.Maintainer}} {{.EntryDate}}`
TemplateChangelogInitial = TemplateChangelogHeader + "\n\n" + TemplateChangelogInitialEntry + "\n\n" + TemplateChangelogFooter
TemplateChangelogAdditionalEntry = "\n\n" + TemplateChangelogHeader + "\n\n{{.ChangelogEntry}}\n\n" + TemplateChangelogFooter
TemplateDebianCopyright = `Copyright 2014 {{.Package.Name}}`
TemplateDebianReadme = `{{.Package.Name}}
==========

`
Expand Down
Loading