Cleanup, fix issue with package being removed after being updated with the same ver
the build failed Details

This commit is contained in:
Tyler 2018-10-14 04:35:50 -04:00
parent face5e5029
commit b0e3d80022
7 changed files with 44 additions and 131 deletions

View File

@ -1,88 +0,0 @@
image: git.meow.tf:4567/tyler/golang-glide:1.8
before_script:
- export VERSION=`grep "VERSION" src/meow.tf/deb-simple/server.go | head -n 1 | awk '{print $5}' | sed -e 's/^"//' -e 's/"$//' | tr -d '\n'`
- chmod +x packaging/build-package.sh packaging/package-upload.sh
- export GOPATH=`pwd`
stages:
- init
- build
- package
glide-install:
stage: init
script:
- cd $CI_PROJECT_DIR/src/meow.tf/deb-simple
- glide install
- cd $CI_PROJECT_DIR
- mkdir -p build/i386 build/amd64 build/armv7
- tar -zcf cache.tgz src/meow.tf/deb-simple/vendor
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: push
paths:
- cache.tgz
build-i386:
stage: build
script:
- echo "Extracting vendor files..."
- tar -xf cache.tgz
- echo "Building i386 binary..."
- mkdir -p build/i386
- GOOS=linux GOARCH=386 go build -o build/i386/deb-simple
artifacts:
paths:
- build/i386
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull
paths:
- cache.tgz
build-amd64:
stage: build
script:
- echo "Extracting vendor files..."
- tar -xf cache.tgz
- echo "Building amd64 binary..."
- mkdir -p build/amd64
- go build -o build/amd64/deb-simple
artifacts:
paths:
- build/amd64
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull
paths:
- cache.tgz
build-armv7:
stage: build
script:
- echo "Extracting vendor files..."
- tar -xf cache.tgz
- echo "Building armv7 binary..."
- mkdir -p build/armv7
- GOOS=linux GOARCH=arm GOARM=7 go build -o build/armv7/deb-simple
artifacts:
paths:
- build/armv7
cache:
key: "pipeline-$CI_PIPELINE_ID"
policy: pull
paths:
- cache.tgz
package:
stage: package
image: tystuyfzand/fpm
script:
- ARCH=i386 packaging/build-package.sh
- ARCH=amd64 packaging/build-package.sh
- ARCH=armv7 packaging/build-package.sh
- packaging/package-upload.sh
artifacts:
paths:
- build

14
apt.go
View File

@ -1,19 +1,19 @@
package main package main
import ( import (
"os"
"fmt"
"io"
"io/ioutil"
"strings"
"crypto/md5" "crypto/md5"
"crypto/sha1" "crypto/sha1"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"golang.org/x/crypto/openpgp" "fmt"
"time"
"gitea.meow.tf/tyler/deb-simple/deb/release" "gitea.meow.tf/tyler/deb-simple/deb/release"
"golang.org/x/crypto/openpgp"
"io"
"io/ioutil"
"os"
"path" "path"
"strings"
"time"
) )

View File

@ -1,8 +1,8 @@
package main package main
import ( import (
"strings"
"path" "path"
"strings"
) )
type Conf struct { type Conf struct {

View File

@ -1,15 +1,15 @@
package archive package archive
import ( import (
"os" "archive/tar"
"bytes"
"compress/gzip"
"fmt" "fmt"
"github.com/blakesmith/ar" "github.com/blakesmith/ar"
"bytes"
"io" "io"
"strings"
"compress/gzip"
"archive/tar"
"log" "log"
"os"
"strings"
) )
func InspectPackage(filename string) (string, error) { func InspectPackage(filename string) (string, error) {
@ -21,7 +21,6 @@ func InspectPackage(filename string) (string, error) {
arReader := ar.NewReader(f) arReader := ar.NewReader(f)
defer f.Close() defer f.Close()
var controlBuf bytes.Buffer
for { for {
header, err := arReader.Next() header, err := arReader.Next()
@ -35,15 +34,14 @@ func InspectPackage(filename string) (string, error) {
} }
if strings.Trim(header.Name, "/") == "control.tar.gz" { if strings.Trim(header.Name, "/") == "control.tar.gz" {
io.Copy(&controlBuf, arReader) return InspectPackageControl(arReader)
return InspectPackageControl(controlBuf)
} }
} }
return "", nil return "", nil
} }
func InspectPackageControl(filename bytes.Buffer) (string, error) { func InspectPackageControl(reader io.Reader) (string, error) {
gzf, err := gzip.NewReader(bytes.NewReader(filename.Bytes())) gzf, err := gzip.NewReader(reader)
if err != nil { if err != nil {
return "", fmt.Errorf("error creating gzip reader: %s", err) return "", fmt.Errorf("error creating gzip reader: %s", err)
} }

19
http.go
View File

@ -1,15 +1,15 @@
package main package main
import ( import (
"net/http"
"io"
"os"
"log"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/blang/semver" "github.com/blang/semver"
"strings" "io"
"log"
"net/http"
"os"
"path" "path"
"strings"
) )
func rescanHandler(w http.ResponseWriter, r *http.Request) { func rescanHandler(w http.ResponseWriter, r *http.Request) {
@ -199,9 +199,12 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
oldPath := path.Join(conf.Repo.Root, p.Path) oldPath := path.Join(conf.Repo.Root, p.Path)
if err := os.Remove(oldPath); err != nil && !os.IsNotExist(err) { // If oldPath == newPath then we already overwrote it
httpErrorf(w, "Unable to remove old package: %s", err) if oldPath != newPath {
continue if err := os.Remove(oldPath); err != nil && !os.IsNotExist(err) {
httpErrorf(w, "Unable to remove old package: %s", err)
continue
}
} }
} }

View File

@ -1,23 +1,23 @@
package main package main
import ( import (
"regexp"
"fmt"
"strings"
"os"
"bytes"
"bufio" "bufio"
"bytes"
"compress/gzip" "compress/gzip"
"encoding/hex"
"io"
"io/ioutil"
"crypto/md5" "crypto/md5"
"crypto/sha1" "crypto/sha1"
"crypto/sha256" "crypto/sha256"
"github.com/blang/semver" "encoding/hex"
"encoding/json" "encoding/json"
"fmt"
"gitea.meow.tf/tyler/deb-simple/deb/archive" "gitea.meow.tf/tyler/deb-simple/deb/archive"
"github.com/blang/semver"
"io"
"io/ioutil"
"os"
"path" "path"
"regexp"
"strings"
) )
var ( var (
@ -64,7 +64,7 @@ type Distro struct {
} }
var ( var (
distros map[string]*Distro = make(map[string]*Distro) distros = make(map[string]*Distro)
) )
func loadCache(dist string) error { func loadCache(dist string) error {

View File

@ -1,22 +1,22 @@
package main package main
import ( import (
"errors"
"flag" "flag"
"fmt" "fmt"
"github.com/go-ini/ini"
"golang.org/x/crypto/openpgp"
"io"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
"sync"
"strings"
"golang.org/x/crypto/openpgp"
"runtime" "runtime"
"errors" "strings"
"github.com/go-ini/ini" "sync"
"io"
) )
var VERSION string = "1.3.7" var VERSION = "1.3.8"
func packageName(name string) string { func packageName(name string) string {
if index := strings.Index(name, "_"); index != -1 { if index := strings.Index(name, "_"); index != -1 {