Fix package name

This commit is contained in:
Tyler 2017-09-11 22:35:41 -04:00
parent 2d2c2403b3
commit 3c922d7445
5 changed files with 90 additions and 79 deletions

View File

@ -30,7 +30,7 @@ build-i386:
- GOOS=linux GOARCH=386 go build -o build/i386/deb-simple
artifacts:
paths:
- build
- build/i386
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull
@ -45,7 +45,7 @@ build-amd64:
- go build -o build/amd64/deb-simple
artifacts:
paths:
- build
- build/amd64
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull
@ -60,7 +60,7 @@ build-armv7:
- GOOS=linux GOARCH=arm GOARM=7 go build -o build/armv7/deb-simple
artifacts:
paths:
- build
- build/armv7
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull

View File

@ -1,5 +1,5 @@
fpm -s dir -t deb -p build/$ARCH/deb-simple_$VERSION.deb \
-n astra -v $VERSION \
-n deb-simple -v $VERSION \
--config-files /etc/deb-simple.conf \
--deb-priority optional --force \
--deb-compression bzip2 \
@ -8,4 +8,6 @@ fpm -s dir -t deb -p build/$ARCH/deb-simple_$VERSION.deb \
--before-install packaging/scripts/preinst.deb \
-a $ARCH build/$ARCH/deb-simple=/usr/bin/deb-simple \
packaging/deb-simple.service=/lib/systemd/system/deb-simple.service \
sample_conf.ini=/etc/deb-simple.conf
sample_conf.ini=/etc/deb-simple.conf
curl -X POST "$UPLOAD_URL" -F "file=@build/$ARCH/deb-simple_$VERSION.deb"

View File

@ -3,12 +3,7 @@ package simple
import (
"os"
"fmt"
"github.com/blakesmith/ar"
"bytes"
"io"
"compress/gzip"
"archive/tar"
"log"
"path/filepath"
"io/ioutil"
"strings"
@ -21,74 +16,6 @@ import (
"meow.tf/deb-simple/deb/release"
)
func inspectPackage(filename string) (string, error) {
f, err := os.Open(filename)
if err != nil {
return "", fmt.Errorf("error opening package file %s: %s", filename, err)
}
arReader := ar.NewReader(f)
defer f.Close()
var controlBuf bytes.Buffer
for {
header, err := arReader.Next()
if err == io.EOF {
break
}
if err != nil {
return "", fmt.Errorf("error in inspectPackage loop: %s", err)
}
if strings.Trim(header.Name, "/") == "control.tar.gz" {
io.Copy(&controlBuf, arReader)
return inspectPackageControl(controlBuf)
}
}
return "", nil
}
func inspectPackageControl(filename bytes.Buffer) (string, error) {
gzf, err := gzip.NewReader(bytes.NewReader(filename.Bytes()))
if err != nil {
return "", fmt.Errorf("error creating gzip reader: %s", err)
}
tarReader := tar.NewReader(gzf)
var controlBuf bytes.Buffer
for {
header, err := tarReader.Next()
if err == io.EOF {
break
}
if err != nil {
return "", fmt.Errorf("failed to inspect package: %s", err)
}
name := header.Name
switch header.Typeflag {
case tar.TypeDir:
continue
case tar.TypeReg:
if name == "./control" {
io.Copy(&controlBuf, tarReader)
return controlBuf.String(), nil
}
default:
log.Printf(
"Unable to figure out type : %c in file %s\n",
header.Typeflag, name,
)
}
}
return "", nil
}
func createRelease(config Conf, distro string) error {
outfile, err := os.Create(filepath.Join(config.DistPath(distro), "Release"))

View File

@ -0,0 +1,81 @@
package archive
import (
"os"
"fmt"
"github.com/blakesmith/ar"
"bytes"
"io"
"strings"
"compress/gzip"
"archive/tar"
"log"
)
func InspectPackage(filename string) (string, error) {
f, err := os.Open(filename)
if err != nil {
return "", fmt.Errorf("error opening package file %s: %s", filename, err)
}
arReader := ar.NewReader(f)
defer f.Close()
var controlBuf bytes.Buffer
for {
header, err := arReader.Next()
if err == io.EOF {
break
}
if err != nil {
return "", fmt.Errorf("error in inspectPackage loop: %s", err)
}
if strings.Trim(header.Name, "/") == "control.tar.gz" {
io.Copy(&controlBuf, arReader)
return InspectPackageControl(controlBuf)
}
}
return "", nil
}
func InspectPackageControl(filename bytes.Buffer) (string, error) {
gzf, err := gzip.NewReader(bytes.NewReader(filename.Bytes()))
if err != nil {
return "", fmt.Errorf("error creating gzip reader: %s", err)
}
tarReader := tar.NewReader(gzf)
var controlBuf bytes.Buffer
for {
header, err := tarReader.Next()
if err == io.EOF {
break
}
if err != nil {
return "", fmt.Errorf("failed to inspect package: %s", err)
}
name := header.Name
switch header.Typeflag {
case tar.TypeDir:
continue
case tar.TypeReg:
if name == "./control" {
io.Copy(&controlBuf, tarReader)
return controlBuf.String(), nil
}
default:
log.Printf(
"Unable to figure out type : %c in file %s\n",
header.Typeflag, name,
)
}
}
return "", nil
}

View File

@ -17,6 +17,7 @@ import (
"crypto/sha256"
"github.com/blang/semver"
"encoding/json"
"meow.tf/deb-simple/deb/archive"
)
var (
@ -163,7 +164,7 @@ func newPackageFile(path, name string) (*PackageFile, error) {
var err error
p.ControlData, err = inspectPackage(debPath)
p.ControlData, err = archive.InspectPackage(debPath)
if err != nil {
return nil, err