diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 896ce79..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -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 diff --git a/apt.go b/apt.go index 2b8cb90..d88dd8c 100644 --- a/apt.go +++ b/apt.go @@ -1,19 +1,19 @@ package main import ( - "os" - "fmt" - "io" - "io/ioutil" - "strings" "crypto/md5" "crypto/sha1" "crypto/sha256" "encoding/hex" - "golang.org/x/crypto/openpgp" - "time" + "fmt" "gitea.meow.tf/tyler/deb-simple/deb/release" + "golang.org/x/crypto/openpgp" + "io" + "io/ioutil" + "os" "path" + "strings" + "time" ) diff --git a/config.go b/config.go index b8e9efd..7f4d5c7 100644 --- a/config.go +++ b/config.go @@ -1,8 +1,8 @@ package main import ( - "strings" "path" + "strings" ) type Conf struct { diff --git a/deb/archive/archive.go b/deb/archive/archive.go index 90f6205..4ce2990 100644 --- a/deb/archive/archive.go +++ b/deb/archive/archive.go @@ -1,15 +1,15 @@ package archive import ( - "os" + "archive/tar" + "bytes" + "compress/gzip" "fmt" "github.com/blakesmith/ar" - "bytes" "io" - "strings" - "compress/gzip" - "archive/tar" "log" + "os" + "strings" ) func InspectPackage(filename string) (string, error) { @@ -21,7 +21,6 @@ func InspectPackage(filename string) (string, error) { arReader := ar.NewReader(f) defer f.Close() - var controlBuf bytes.Buffer for { header, err := arReader.Next() @@ -35,15 +34,14 @@ func InspectPackage(filename string) (string, error) { } if strings.Trim(header.Name, "/") == "control.tar.gz" { - io.Copy(&controlBuf, arReader) - return InspectPackageControl(controlBuf) + return InspectPackageControl(arReader) } } return "", nil } -func InspectPackageControl(filename bytes.Buffer) (string, error) { - gzf, err := gzip.NewReader(bytes.NewReader(filename.Bytes())) +func InspectPackageControl(reader io.Reader) (string, error) { + gzf, err := gzip.NewReader(reader) if err != nil { return "", fmt.Errorf("error creating gzip reader: %s", err) } diff --git a/http.go b/http.go index 738f9a2..0a85b21 100644 --- a/http.go +++ b/http.go @@ -1,15 +1,15 @@ package main import ( - "net/http" - "io" - "os" - "log" "encoding/json" "fmt" "github.com/blang/semver" - "strings" + "io" + "log" + "net/http" + "os" "path" + "strings" ) 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) - if err := os.Remove(oldPath); err != nil && !os.IsNotExist(err) { - httpErrorf(w, "Unable to remove old package: %s", err) - continue + // If oldPath == newPath then we already overwrote it + if oldPath != newPath { + if err := os.Remove(oldPath); err != nil && !os.IsNotExist(err) { + httpErrorf(w, "Unable to remove old package: %s", err) + continue + } } } diff --git a/packages.go b/packages.go index cfd45fb..d1c8089 100644 --- a/packages.go +++ b/packages.go @@ -1,23 +1,23 @@ package main import ( - "regexp" - "fmt" - "strings" - "os" - "bytes" "bufio" + "bytes" "compress/gzip" - "encoding/hex" - "io" - "io/ioutil" "crypto/md5" "crypto/sha1" "crypto/sha256" - "github.com/blang/semver" + "encoding/hex" "encoding/json" + "fmt" "gitea.meow.tf/tyler/deb-simple/deb/archive" + "github.com/blang/semver" + "io" + "io/ioutil" + "os" "path" + "regexp" + "strings" ) var ( @@ -64,7 +64,7 @@ type Distro struct { } var ( - distros map[string]*Distro = make(map[string]*Distro) + distros = make(map[string]*Distro) ) func loadCache(dist string) error { diff --git a/server.go b/server.go index 9f0394f..895a1d4 100644 --- a/server.go +++ b/server.go @@ -1,22 +1,22 @@ package main import ( + "errors" "flag" "fmt" + "github.com/go-ini/ini" + "golang.org/x/crypto/openpgp" + "io" "io/ioutil" "log" "net/http" "os" - "sync" - "strings" - "golang.org/x/crypto/openpgp" "runtime" - "errors" - "github.com/go-ini/ini" - "io" + "strings" + "sync" ) -var VERSION string = "1.3.7" +var VERSION = "1.3.8" func packageName(name string) string { if index := strings.Index(name, "_"); index != -1 {