From 0bef1fb937abdd7012286521578dd51c832ebe9d Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Thu, 2 May 2024 17:46:29 +0200 Subject: [PATCH] Initial pkgpatch check-in --- cmd/pkgpatch/generate.go | 108 +++++++ cmd/pkgpatch/main.go | 28 ++ cmd/pkgpatch/open.go | 268 ++++++++++++++++++ go.mod | 14 +- go.sum | 18 +- worker_server/srpm_import/srpm_import.go | 6 +- worker_server/srpm_import/srpm_import_test.go | 6 +- 7 files changed, 423 insertions(+), 25 deletions(-) create mode 100644 cmd/pkgpatch/generate.go create mode 100644 cmd/pkgpatch/main.go create mode 100644 cmd/pkgpatch/open.go diff --git a/cmd/pkgpatch/generate.go b/cmd/pkgpatch/generate.go new file mode 100644 index 0000000..21ce188 --- /dev/null +++ b/cmd/pkgpatch/generate.go @@ -0,0 +1,108 @@ +package main + +import ( + "fmt" + "os" + + "github.com/go-git/go-billy/v5" + "github.com/go-git/go-billy/v5/osfs" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing/cache" + "github.com/go-git/go-git/v5/storage/filesystem" + "github.com/urfave/cli/v2" +) + +func openRepo(rootFS billy.Filesystem, path string) (*git.Repository, error) { + dot, err := rootFS.Chroot(path + "/.git") + if err != nil { + return nil, err + } + storer := filesystem.NewStorage(dot, cache.NewObjectLRUDefault()) + repo, err := git.Open(storer, rootFS) + if err != nil { + return nil, err + } + + return repo, nil +} + +func getRootPatch(rootFS billy.Filesystem) (string, error) { + // Open the git repository + repo, err := openRepo(rootFS, ".") + if err != nil { + return "", err + } + + // Check if there are any changes + wt, err := repo.Worktree() + if err != nil { + return "", err + } + + status, err := wt.Status() + if err != nil { + return "", err + } + + return status.String(), nil +} + +func getTarballPatch(rootFS billy.Filesystem) (string, error) { + // Open the git repository + repo, err := openRepo(rootFS, "tarball") + if err != nil { + return "", err + } + + // Check if there are any changes + wt, err := repo.Worktree() + if err != nil { + return "", err + } + + status, err := wt.Status() + if err != nil { + return "", err + } + + return status.String(), nil +} + +func generate(ctx *cli.Context) error { + if ctx.NArg() != 1 { + return cli.Exit("usage: pkgpatch generate MESSAGE", 1) + } + msg := ctx.Args().First() + fmt.Println(msg) + + // Verify that this is ran from a .pkgpatchroot directory + currentDir, err := os.Getwd() + if err != nil { + return err + } + + if _, err := os.Stat(".pkgpatchroot"); os.IsNotExist(err) { + return fmt.Errorf("not a .pkgpatchroot directory") + } + + // Open the root filesystem + rootFS := osfs.New(currentDir) + + // Get the root patch + rootPatch, err := getRootPatch(rootFS) + if err != nil { + return err + } + fmt.Println(rootPatch) + + // Get the tarball patch + if _, err := rootFS.Stat("tarball"); err == nil { + tarballPatch, err := getTarballPatch(rootFS) + if err != nil { + return err + } + fmt.Println(tarballPatch) + } + + return nil +} diff --git a/cmd/pkgpatch/main.go b/cmd/pkgpatch/main.go new file mode 100644 index 0000000..421a4af --- /dev/null +++ b/cmd/pkgpatch/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "log/slog" + "os" + + "github.com/openela/mothership/base" + "github.com/urfave/cli/v2" +) + +func main() { + app := &cli.App{ + Name: "pkgpatch", + Commands: []*cli.Command{ + { + Name: "open", + Usage: "open an entry for patching", + Action: open, + }, + // todo(mustafa): finish the "generate" command + }, + Flags: base.WithFlags(), + } + + if err := app.Run(os.Args); err != nil { + slog.Error("Could not run pkgpatch", "err", err) + } +} diff --git a/cmd/pkgpatch/open.go b/cmd/pkgpatch/open.go new file mode 100644 index 0000000..b16c017 --- /dev/null +++ b/cmd/pkgpatch/open.go @@ -0,0 +1,268 @@ +package main + +import ( + "encoding/json" + "io" + "log/slog" + "net/http" + "os" + "os/exec" + "path/filepath" + "strings" + "time" + + "github.com/fatih/color" + "github.com/go-git/go-billy/v5/osfs" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing/cache" + "github.com/go-git/go-git/v5/storage/filesystem" + "github.com/openela/mothership/worker_server/srpm_import" + "github.com/urfave/cli/v2" +) + +const baseSrpmURL = "https://ax8edlmsvvfp.compat.objectstorage.us-phoenix-1.oraclecloud.com/mship-srpm1" + +type entryChecksum struct { + Sha256Sum string `json:"sha256Sum"` +} + +func downloadResource(url, dest string) error { + slog.Info("Downloading resource", "url", url, "dest", dest) + // Fetch the resource from the URL + // Write the response body to a file in the dest directory + client := &http.Client{} + + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return err + } + + res, err := client.Do(req) + if err != nil { + return err + } + + defer res.Body.Close() + + file, err := os.Create(dest) + if err != nil { + return err + } + + defer file.Close() + + if _, err := io.Copy(file, res.Body); err != nil { + return err + } + + return nil +} + +func open(ctx *cli.Context) error { + if ctx.NArg() == 0 { + return cli.Exit("usage: pkgpatch open ENTRY_ID", 1) + } + + entryID := ctx.Args().First() + + // Fetch from https://imports.openela.org/api/v1/entries/ENTRY_ID + // Parse the response body as JSON + client := &http.Client{ + Timeout: time.Second * 10, + } + + slog.Info("Fetching entry", "entryID", entryID) + + req, err := http.NewRequest(http.MethodGet, "https://imports.openela.org/api/v1/entries/"+entryID, nil) + if err != nil { + return err + } + + res, err := client.Do(req) + if err != nil { + return err + } + + defer res.Body.Close() + + var checksum entryChecksum + if err := json.NewDecoder(res.Body).Decode(&checksum); err != nil { + return err + } + + slog.Info("Entry fetched", "entryID", entryID, "checksum", checksum.Sha256Sum) + + // Create a temporary directory and download the resource + tmpDir, err := os.MkdirTemp("", "mothership-worker-server-import-rpm-*") + if err != nil { + return err + } + + dest := tmpDir + "/resource.rpm" + downloadURL := baseSrpmURL + "/" + checksum.Sha256Sum + if err := downloadResource(downloadURL, dest); err != nil { + return err + } + + // Do an SRPM expand + slog.Info("Expanding SRPM", "dest", tmpDir) + state, err := srpm_import.FromFile(dest, true) + if err != nil { + return err + } + + // Create expand directory + expandDir := tmpDir + "/expand" + if err := os.Mkdir(expandDir, 0755); err != nil { + return err + } + + expandFS := osfs.New(expandDir) + err = state.ExpandLayout(expandFS) + if err != nil { + return err + } + + // Expand the largest tarball, that will be a separate .git repo + // but first we need to find the largest tarball + var largestTarball string + var largestSize int64 + ls, err := expandFS.ReadDir("SOURCES") + if err != nil { + return err + } + for _, file := range ls { + if strings.Contains(file.Name(), ".tar") && file.Size() > largestSize { + largestSize = file.Size() + largestTarball = file.Name() + } + } + + if largestSize > 0 { + slog.Info("Tarball found", "tarball", largestTarball, "size", largestSize) + + // Create a base tarball directory + tarballDir := expandDir + "/tarball" + if err := os.Mkdir(tarballDir, 0755); err != nil { + return err + } + + slog.Info("Expanding tarball and creating a git repository (this might take a while)") + + // Expand the largest tarball + cmd := exec.Command("tar", "-x", "--strip-components=1", "-C", tarballDir, "-f", filepath.Join(expandDir, "SOURCES", largestTarball)) + cmd.Stderr = os.Stderr + err = cmd.Run() + if err != nil { + return err + } + + // Delete the tarball + err = expandFS.Remove("SOURCES/" + largestTarball) + if err != nil { + return err + } + + // Init a new git repository in that directory + err = expandFS.MkdirAll("tarball/.git", 0755) + if err != nil { + return err + } + + dot, err := expandFS.Chroot("tarball/.git") + if err != nil { + return err + } + storer := filesystem.NewStorage(dot, cache.NewObjectLRUDefault()) + tarballFS, err := expandFS.Chroot("tarball") + if err != nil { + return err + } + repo, err := git.Init(storer, tarballFS) + if err != nil { + return err + } + + // Add all files to the git repository + w, err := repo.Worktree() + if err != nil { + return err + } + + _, err = w.Add(".") + if err != nil { + return err + } + + _, err = w.Commit("Initial commit", &git.CommitOptions{}) + if err != nil { + return err + } + } + + // Init a new git repository in that directory + err = expandFS.MkdirAll(".git", 0755) + if err != nil { + return err + } + dot, err := expandFS.Chroot(".git") + if err != nil { + return err + } + storer := filesystem.NewStorage(dot, cache.NewObjectLRUDefault()) + repo, err := git.Init(storer, expandFS) + if err != nil { + return err + } + + // Create a gitignore file for the tarball directory + gitignore := []byte("tarball/\n") + f, err := expandFS.OpenFile(".gitignore", os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return err + } + defer f.Close() + if _, err := f.Write(gitignore); err != nil { + return err + } + + // Create a .pkgpatchroot file + f, err = expandFS.OpenFile(".pkgpatchroot", os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return err + } + defer f.Close() + + // Add all files to the git repository + w, err := repo.Worktree() + if err != nil { + return err + } + + _, err = w.Add(".") + if err != nil { + return err + } + + _, err = w.Commit("Initial commit", &git.CommitOptions{}) + if err != nil { + return err + } + + expandDirBold := color.New(color.Bold).Sprint(expandDir) + generateBold := color.New(color.Bold).Sprint("pkgpatch generate MESSAGE") + color.Green(` +Success! +A new workspace has been created for entry %s + +Open %s in your favorite editor. +When you're done run %s to generate the patches. + +NOTICE: Currently, the "generate" command is not implemented. +You need to generate the patches manually in both repositories. +If you make a change in "expand", then commit the changes and run "git format-patch HEAD^1" +same applies to the "tarball" repository. +`, entryID, expandDirBold, generateBold) + + return nil +} diff --git a/go.mod b/go.mod index 9293f2b..37e83e3 100644 --- a/go.mod +++ b/go.mod @@ -4,18 +4,16 @@ go 1.21.1 require ( github.com/aws/aws-sdk-go v1.49.6 - github.com/coreos/go-oidc/v3 v3.6.0 github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.11.0 github.com/golang-jwt/jwt/v5 v5.0.0 github.com/golang-migrate/migrate/v4 v4.17.0 - github.com/gorilla/csrf v1.7.1 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 + github.com/iancoleman/strcase v0.3.0 github.com/jarcoal/httpmock v1.3.1 - github.com/julienschmidt/httprouter v1.3.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.17.0 github.com/rocky-linux/srpmproc v0.5.1 @@ -29,7 +27,6 @@ require ( go.temporal.io/api v1.24.0 go.temporal.io/sdk v1.24.0 golang.org/x/crypto v0.19.0 - golang.org/x/oauth2 v0.14.0 google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 google.golang.org/grpc v1.59.0 @@ -64,9 +61,9 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect + github.com/fatih/color v1.16.0 // indirect github.com/gertd/go-pluralize v0.2.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-jose/go-jose/v3 v3.0.3 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/gogo/googleapis v1.4.1 // indirect @@ -74,13 +71,11 @@ require ( github.com/gogo/status v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.4.0 // indirect - github.com/gorilla/securecookie v1.1.1 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/iancoleman/strcase v0.3.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect @@ -90,6 +85,8 @@ require ( github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect @@ -129,7 +126,6 @@ require ( golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect - google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 29f9456..6459dba 100644 --- a/go.sum +++ b/go.sum @@ -842,8 +842,6 @@ github.com/containerd/containerd v1.7.11 h1:lfGKw3eU35sjV0aG2eYZTiwFEY1pCzxdzicH github.com/containerd/containerd v1.7.11/go.mod h1:5UluHxHTX2rdvYuZ5OJTC5m/KJNs0Zs9wVoJm9zf5ZE= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/coreos/go-oidc/v3 v3.6.0 h1:AKVxfYw1Gmkn/w96z0DbT/B/xFnzTd3MkZvWLjF4n/o= -github.com/coreos/go-oidc/v3 v3.6.0/go.mod h1:ZpHUsHBucTUj6WOkrP4E20UPynbLZzhTQ1XKCXkxyPc= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= @@ -892,6 +890,8 @@ github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6Ni github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fergusstrange/embedded-postgres v1.23.0 h1:ZYRD89nammxQDWDi6taJE2CYjDuAoVc1TpEqRIYQryc= github.com/fergusstrange/embedded-postgres v1.23.0/go.mod h1:wL562t1V+iuFwq0UcgMi2e9rp8CROY9wxWZEfP8Y874= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -917,8 +917,6 @@ github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lK github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= -github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= @@ -985,6 +983,8 @@ github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -1057,10 +1057,6 @@ github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2e github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE= -github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= @@ -1099,8 +1095,6 @@ github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Cc github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= @@ -1138,9 +1132,13 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= diff --git a/worker_server/srpm_import/srpm_import.go b/worker_server/srpm_import/srpm_import.go index 0c8ba6a..449907e 100644 --- a/worker_server/srpm_import/srpm_import.go +++ b/worker_server/srpm_import/srpm_import.go @@ -302,10 +302,10 @@ func (s *State) writeMetadataFile(targetFS billy.Filesystem) error { return nil } -// expandLayout expands the layout of the SRPM into the target filesystem. +// ExpandLayout expands the layout of the SRPM into the target filesystem. // Moves all sources into SOURCES/ directory. // Spec file is moved to SPECS/ directory. -func (s *State) expandLayout(targetFS billy.Filesystem) error { +func (s *State) ExpandLayout(targetFS billy.Filesystem) error { // Create SOURCES/ directory. err := targetFS.MkdirAll("SOURCES", 0755) if err != nil { @@ -618,7 +618,7 @@ func (s *State) populateTargetRepo(repo *git.Repository, targetFS billy.Filesyst } // Expand the layout of the SRPM. - err = s.expandLayout(targetFS) + err = s.ExpandLayout(targetFS) if err != nil { return errors.Wrap(err, "failed to expand layout") } diff --git a/worker_server/srpm_import/srpm_import_test.go b/worker_server/srpm_import/srpm_import_test.go index 6e1e687..431e4a8 100644 --- a/worker_server/srpm_import/srpm_import_test.go +++ b/worker_server/srpm_import/srpm_import_test.go @@ -188,7 +188,7 @@ func TestExpandLayout(t *testing.T) { }() fs := memfs.New() - require.Nil(t, s.expandLayout(fs)) + require.Nil(t, s.ExpandLayout(fs)) fi, err := fs.ReadDir(".") require.Nil(t, err) @@ -227,7 +227,7 @@ func TestExpandLayout_CopyMode(t *testing.T) { require.Nil(t, shellFile.Close()) fs := memfs.New() - require.Nil(t, s.expandLayout(fs)) + require.Nil(t, s.ExpandLayout(fs)) fi, err := fs.ReadDir(".") require.Nil(t, err) @@ -263,7 +263,7 @@ func TestWriteMetadataExpandLayout(t *testing.T) { fs := memfs.New() require.Nil(t, s.determineLookasideBlobs()) require.Nil(t, s.writeMetadataFile(fs)) - require.Nil(t, s.expandLayout(fs)) + require.Nil(t, s.ExpandLayout(fs)) fi, err := fs.ReadDir(".") require.Nil(t, err)