Compare commits

...

70 Commits
v0.1.0 ... main

Author SHA1 Message Date
f2864a875a
Merge pull request #16 from dirkmueller/openela
Support the openELA "PATCHES" directory format as well
2023-11-16 18:04:50 +01:00
Dirk Müller
82271f5d9e
Support the openELA "PATCHES" directory format as well 2023-11-06 16:53:43 +01:00
963b5d25dd
Fix goreleaser archive name template 2023-10-06 08:13:19 +02:00
a5f9082c15
Be compatible with latest goreleaser 2023-10-06 08:05:29 +02:00
f2374845e3
Merge pull request #15 from nazunalika/main 2023-10-06 07:56:14 +02:00
Louis Abel
162e7cea34
continue as it's a loop 2023-09-19 17:16:08 -07:00
Louis Abel
edeb0239df
Add two features and one fix
This commit attempts to merge in custom changes on distrobuild. In
particular:

* Imports
  * Package: If there are no changes, do not import. This currently
    returns as an error, so may need adjusting.
  * Module: Import, regardless if there is changes or not. MBS cares
    more about the fact there's a commit associated with a module build.
    It will not build off the same commit ID.
  * Add --module-branch-names-only flag to make it so module yamls will
    have a branch name rather than commit ID. This makes it easier to
    work with MBS.
* Fixes
  * tagless imports should use the _topdir macro, otherwise a bug may
    surface where macros or other data cannot be determined, and a
    cryptic error may display.
2023-09-05 03:50:43 -07:00
40180a342b
Merge pull request #11 from skip77/manual-commits-fix
Manual commits fix
2023-03-12 03:06:01 +01:00
skip77
7f14563f93
Merge branch 'rocky-linux:main' into manual-commits-fix 2023-03-11 17:38:18 -05:00
6e2ed2eb23
Merge pull request #8 from skip77/main 2023-03-11 23:26:54 +01:00
Skip Grube
44725a727d
Repaired manual commits feature and added some bugfixes:
- Manual commits work properly again, and are passed to "tagless mode" for version discovery + tagging
- Fixed tagless mode issue with rpmspec warnings, only stdout is considered
- Fixed tagless mode issue where renamed folders were not properly overwritten, causing potential bad commits

-Skip G.
2023-03-05 22:04:20 -05:00
Skip Grube
4f975913b4
Removed old commented line
-Skip
2023-02-28 16:23:51 -05:00
Skip Grube
3371826851
Fixed up formatting issues from rpmspec commit
-Skip G.
2023-02-28 15:25:11 -05:00
skip77
f4f2a0a9e4
Merge branch 'rocky-linux:main' into main 2023-02-27 16:32:24 -05:00
skip77
5e8ed2e521
Fix Default cdn behavior (#9)
- CDN returned as-is for processing if no template indicators are found

-Skip G.
2023-02-27 15:26:21 -05:00
Skip Grube
2eb0768f33
Switched to using rpmspec for version determination in tagless mode:
- Greatly simplified getVersionFromSpec function due to rpmspec usage
- Function now returns error info in case rpmspec shell command goes wrong

-Skip Grube
2023-02-26 22:59:24 -05:00
2c6d6f0b0a
Merge pull request #7 from skip77/main 2023-02-24 02:16:54 +01:00
Skip Grube
0ea6123b6e
More cleanup from feedback
- Removed extra lines
- Externalized Lookaside struct{}

-Skip Grube
2023-02-23 13:57:21 -05:00
Skip Grube
2cc3bcc3a3
Updated cdn-related commits for style and cleanup
-Skip Grube
2023-02-23 12:31:31 -05:00
Skip Grube
3237794071
Updates to add flexibility to lookasides and tagless handling:
- Added template "macros" to allow for complex --cdn-url specifications ( {{.Name}}, {{.Branch}}, etc.)
- Added --cdn <distro> option with pre-set URL patterns to simplify use
- Kept default fallback behavior and search patterns of --cdn-url if templates are not used
- Removed "--altlookaside" option, as the above features make it redundant

- Automatic tagless:  If a proper git version/imports tag isn't found, a "tagless-mode" import will be attempted automatically at run-time
- taglessmode command line option kept in case user still wants to force a tagless import

-Skip Grube
2023-02-22 23:23:47 -05:00
06ffd1e507
Support ~ and % in Release 2022-11-15 15:14:59 +01:00
29778c7ea2
Proper NVR matching 2022-11-06 04:54:35 +01:00
2a2b10ba10
Formatting 2022-11-06 04:53:02 +01:00
e859f54e5e
Supported Go version is now 1.18 2022-11-03 04:39:57 +01:00
f3ac46447d
Stop converting v3 to v2 2022-11-03 04:36:25 +01:00
skip77
cff0cc0fbf
feature: "tagless import" feature mode (#4)
In order to build from lookahead sources, srpmproc must support the new gitlab address for centos 9 stream as well as manipulating the sources to expected format.

Resolves #2.


- Options for tagless import and new stream lookaside format added
- Git Mode now supports scanning for branch head in addition to the "normal" pulling of specific version tags
- Alternate ProcessRPM added for Tagless mode in process.go (still a WIP)
- Tagless mode converts a repo to the "traditional" format (SPECS/ + SOURCES/ + <pkg>.metadata )
- Tagless mode will build a dummy srpm to determine NVR information (rpmbuild + rpm shell commands) (will use this to tag imports in the target git)
- Limitation:  Tagless imports only pull the latest head from a branch
- CentOS-Stream import branches are converted from stream-<MODULE_VERSION>-<RHEL_VERSION> to the more familiar r9s-stream-<VERSION>
- stream-style YAML is detected and converted for modules, similar to the older modulemd.src.txt files
- This new pattern is for "tagless mode" only, previous tagged imports (from git.centos.org) should not be affected
2022-09-27 23:32:50 -04:00
9b44bc6e50
Merge pull request #5 from jarod-w/main 2022-09-12 21:13:13 +02:00
jarod.w
d7ed1c7a7f Fix the issue that nothing is ever written to tmpfs location when the
tmpfs is absolute path.

The test case of absolute path is below:
[root@rockylinux86 ~]# srpmproc --version 8 --upstream-prefix file:///root/rocky --storage-addr file:///tmp/srpmproc-cache --source-rpm sed --tmpfs-mode /root/rocky/rpms/sed
[root@rockylinux86 ~]# ls /root/rocky/rpms/sed/
r8  r8-beta  r8s

The test case of relative path is below:
[root@rockylinux86 ~]# pwd
/root
[root@rockylinux86 ~]# srpmproc --version 8 --upstream-prefix file:///root/rocky --storage-addr file:///tmp/srpmproc-cache --source-rpm sed --tmpfs-mode ./rocky/rpms/sed
[root@rockylinux86 ~]# ls /root/rocky/rpms/sed/
r8  r8-beta  r8s

Signed-off-by: jarod.w <wl.jarod@gmail.com>
2022-09-11 17:52:36 +08:00
Neil Hanlon
1c2091a489
Merge pull request #3 from NeilHanlon/main
Add s390x and ppc64le to builds
2022-06-03 13:57:11 -04:00
Neil Hanlon
aacedb189f
Add s390x and ppc64le to builds 2022-06-03 13:56:05 -04:00
Mustafa Gezen
6df2fe1e3f Fix NVR regex 2022-05-10 16:32:31 +02:00
Mustafa Gezen
e889daa21f Regex arguments should be escaped 2022-05-10 12:02:37 +02:00
Mustafa Gezen
3f4c4ad211 Fetch should conform to metadata format 2022-05-10 10:34:02 +02:00
Mustafa Gezen
6ab7f9f00a Metadata file not being found should throw an error 2022-05-10 09:35:48 +02:00
Mustafa Gezen
16ad80fdeb Support inconsistent metadata naming and case-insensitive tags 2022-05-09 19:57:43 +02:00
Mustafa Gezen
8199a79889 Add support for version/release based fetching 2022-05-05 04:25:07 +02:00
Mustafa Gezen
f7017a9eac Fix NVR regex for versions with a percentage, and fix dist regex for any EL 2022-05-02 10:39:42 +02:00
Mustafa Gezen
dd7fd31ebb retry fetching patch repo if the error is invalid auth method 2022-04-24 15:53:36 +02:00
Mustafa Gezen
bc9d81bd8e Strict branch mode should still include module streams 2022-04-23 22:56:39 +02:00
Mustafa Gezen
a84d5e5b62 fix non strict branch mode 2022-04-22 01:44:18 +02:00
Mustafa Gezen
45ad998d41 non-tmpfs mode should use memfs 2022-04-21 07:39:10 +02:00
Mustafa Gezen
a97ccb698b add support for modulemd v3 2022-04-21 07:25:44 +02:00
Mustafa Gezen
61eaa8b8f8 fix tmpfs mode, replace stream mode with branch suffix and strict mode 2022-04-21 06:30:33 +02:00
Mustafa Gezen
8f55eb397f enhancement: add support for downloading from blob storage instead of http endpoint 2022-04-03 04:29:49 +02:00
Mustafa Gezen
8f00773aac fix: disabling auto align should always return one space 2022-03-28 19:55:40 +02:00
Mustafa Gezen
2fafebaee8 Add support for disabling auto align 2022-03-28 19:49:55 +02:00
Mustafa Gezen
e0081b4ad9 Retry without authentication when upstream REQUIRES authentication and add support for basic auth in CLI 2022-03-25 18:54:23 +01:00
Mustafa Gezen
08aed871a3 Try the common authenticator for upstream then try without if failing 2022-03-25 18:40:09 +01:00
Mustafa Gezen
70c4c22665 Add authenticator to all Git calls (makes it possible to have private repos) 2022-03-25 17:39:50 +01:00
102ff0427a
enhancement: allow callers to use custom loggers 2022-01-05 15:42:49 +01:00
ad004a1671
fix: remove 8 check 2021-11-02 20:52:27 +01:00
16e049c658
fix: filesystem based blob storage should not fail when a blob is missing 2021-10-15 22:27:11 +02:00
ef5bd995b1
fix: fetch should respect root 2021-09-30 20:28:02 +02:00
6483386e19
fix(s3): nil dereference when key isn't found 2021-09-11 03:12:02 +02:00
7c15c41a9f
fix: s3 not found should not return an error 2021-09-11 03:08:24 +02:00
1e769f96dd
fix: make force-path-style available 2021-09-10 23:08:16 +02:00
373e96f0c9
fix: remove remaining fatal logs and turn them into errors 2021-09-10 22:31:59 +02:00
985748b05d
enhancement: add http basic auth option 2021-09-10 20:14:33 +02:00
42c043f8d6
enhancement: add more info for each processed package as well as print more info on cli 2021-09-08 17:00:56 +02:00
5d8fdcc702
fix: CopyFromFs should not exit on error 2021-09-07 13:30:50 +02:00
360c4d5849
enhancement: make cdn url configurable during import 2021-09-05 02:12:43 +02:00
fff8896c47
enhancement: make hashes available as a value and print out for cmd 2021-09-04 23:33:08 +02:00
825228e627
enhancement: make it possible to set custom s3 endpoints 2021-09-04 01:57:43 +02:00
f6c9dba678
enhancement: add option to modify fetch path 2021-09-03 23:52:04 +02:00
fb33e724c0
enhancement: expose fetch as an srpmproc library component 2021-09-03 23:46:38 +02:00
23bea74126
enhancement: make it a real library and drop srpm mode 2021-09-03 23:07:02 +02:00
7d84156a4b
enhancement: expose srpmproc library 2021-08-19 12:11:07 +02:00
f71605a7d5
Update README.md 2021-08-02 04:19:27 +02:00
36d19954ba
Fix stream branch detection 2021-06-11 18:36:14 +02:00
b7acbd6f01
Fix authenticator for tmpfs-mode 2021-06-11 18:36:00 +02:00
40 changed files with 3222 additions and 1587 deletions

View File

@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.18
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:

5
.gitignore vendored
View File

@ -14,7 +14,6 @@
# Dependency directories (remove the comment below to include it)
# vendor/
testdata
srpmproc
/srpmproc
.idea
dist/
dist/
/dist/

View File

@ -14,12 +14,16 @@ builds:
goarch:
- amd64
- arm64
- s390x
- ppc64le
archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
arm64: aarch64
- name_template: >-
{{- .ProjectName }}_
{{- .Version }}
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "arm64" }}aarch64
{{- else }}{{ .Arch }}{{ end }}{{ end -}}
checksum:
name_template: 'checksums.txt'
snapshot:

View File

@ -1,3 +1,79 @@
# srpmproc
SRPM processor
Upstream package importer with auto patching. Reference implementation for OpenPatch
## Usage
```
Usage:
srpmproc [flags]
srpmproc [command]
Available Commands:
fetch
help Help about any command
Flags:
--basic-password string Basic auth password
--basic-username string Basic auth username
--branch-prefix string Branch prefix (replaces import-branch-prefix) (default "r")
--branch-suffix string Branch suffix to use for imported branches
--cdn string CDN URL shortcuts for well-known distros, auto-assigns --cdn-url. Valid values: rocky8, rocky, fedora, centos, centos-stream. Setting this overrides --cdn-url
--cdn-url string CDN URL to download blobs from. Simple URL follows default rocky/centos patterns. Can be customized using macros (see docs) (default "https://git.centos.org/sources")
--git-committer-email string Email of committer (default "rockyautomation@rockylinux.org")
--git-committer-name string Name of committer (default "rockyautomation")
-h, --help help for srpmproc
--import-branch-prefix string Import branch prefix (default "c")
--manual-commits string Comma separated branch and commit list for packages with broken release tags (Format: BRANCH:HASH)
--module-fallback-stream string Override fallback stream. Some module packages are published as collections and mostly use the same stream name, some of them deviate from the main stream
--module-mode If enabled, imports a module instead of a package
--module-prefix string Where to retrieve modules if exists. Only used when source-rpm is a git repo (default "https://git.centos.org/modules")
--no-dup-mode If enabled, skips already imported tags
--no-storage-download If enabled, blobs are always downloaded from upstream
--no-storage-upload If enabled, blobs are not uploaded to blob storage
--package-release string Package release to fetch
--package-version string Package version to fetch
--rpm-prefix string Where to retrieve SRPM content. Only used when source-rpm is not a local file (default "https://git.centos.org/rpms")
--single-tag string If set, only this tag is imported
--source-rpm string Location of RPM to process
--ssh-key-location string Location of the SSH key to use to authenticate against upstream
--ssh-user string SSH User (default "git")
--storage-addr string Bucket to use as blob storage
--strict-branch-mode If enabled, only branches with the calculated name are imported and not prefix only
--taglessmode Tagless mode: If set, pull the latest commit from the branch and determine version numbers from spec file. This is auto-tried if tags aren't found.
--tmpfs-mode string If set, packages are imported to path and patched but not pushed
--upstream-prefix string Upstream git repository prefix
--version int Upstream version
Use "srpmproc [command] --help" for more information about a command.
```
<br />
## Examples:
1. Import the kernel package from git.centos.org/rpms/, to local folder /opt/gitroot/rpms/kernel.git/ . Download the lookaside source tarballs from the default CentOS file server location to local folder `/opt/fake_s3/` . We want to grab branch "c8" (import prefix plus RHEL version), and it will be committed as branch "r8" (branch prefix plus RHEL version). This assumes that `/opt/fake_s3` exists, and `/opt/gitroot/rpms/kernel.git` exists and is a git repository of some kind (even an empty one).
```
srpmproc --branch-prefix "r" --import-branch-prefix "c" --rpm-prefix "https://git.centos.org/rpms" --version 8 --storage-addr file:///opt/fake_s3 --upstream-prefix file:///opt/gitroot --cdn centos --strict-branch-mode --source-rpm kernel
```
<br />
## CDN and --cdn-url
The --cdn-url option allows for Go-style templates to craft complex URL patterns. These templates are: `{{.Name}}` (package name), `{{.Hash}}` (hash of lookaside file), `{{.Hashtype}}` (hash type of file, like "sha256" or "sha512"), `{{.Branch}}` (the branch we are importing), and `{{.Filename}}` (the lookaside file's name as it appears in SOURCES/). You can add these values as part of --cdn-url to craft your lookaside pattern.
For example, if I wanted my lookaside downloads to come from CentOS 9 Stream, I would use as part of my command:
```
--cdn-url "https://sources.stream.centos.org/sources/rpms/{{.Name}}/{{.Filename}}/{{.Hashtype}}/{{.Hash}}/{{.Filename}}"
```
**Default Behavior:** If these templates are not used, the default behavior of `--cdn-url` is to fall back on the traditional RHEL import pattern: `<CDN_URL>/<NAME>/<BRANCH>/<HASH>` . If that fails, a further fallback is attempted, the simple: `<CDN_URL>/<HASH>`. These cover the common Rocky Linux and RHEL/CentOS imports if the base lookaside URL is the only thing given. If no `--cdn-url` is specified, it defaults to "https://git.centos.org/sources" (for RHEL imports into Rocky Linux)
**CDN Shorthand:** For convenience, some lookaside patterns for popular distros are provided via the `--cdn` option. You can specify this without needing to use the longer `--cdn-url`. For example, when importing from CentOS 9 Stream, you could use `--cdn centos-stream`

View File

@ -21,16 +21,12 @@
package main
import (
"errors"
"fmt"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/spf13/cobra"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"github.com/go-git/go-billy/v5/osfs"
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"github.com/spf13/cobra"
)
var fetch = &cobra.Command{
@ -43,99 +39,18 @@ var cdnUrl string
func init() {
fetch.Flags().StringVar(&cdnUrl, "cdn-url", "", "Path to CDN")
_ = fetch.MarkFlagRequired("cdn-url")
root.AddCommand(fetch)
}
func runFetch(_ *cobra.Command, _ []string) {
wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
log.Fatalf("could not get working directory: %v", err)
}
metadataPath := ""
err = filepath.Walk(wd, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, ".metadata") {
if metadataPath != "" {
return errors.New("multiple metadata files")
}
metadataPath = path
}
return nil
})
err = srpmproc.Fetch(os.Stdout, cdnUrl, wd, osfs.New("/"), nil)
if err != nil {
log.Fatal(err)
}
metadataFile, err := os.Open(metadataPath)
if err != nil {
log.Fatalf("could not open metadata file: %v", err)
}
fileBytes, err := ioutil.ReadAll(metadataFile)
if err != nil {
log.Fatalf("could not read metadata file: %v", err)
}
client := &http.Client{
Transport: &http.Transport{
DisableCompression: false,
},
}
fileContent := strings.Split(string(fileBytes), "\n")
for _, line := range fileContent {
if strings.TrimSpace(line) == "" {
continue
}
lineInfo := strings.Split(line, " ")
hash := lineInfo[0]
path := lineInfo[1]
url := fmt.Sprintf("%s/%s", cdnUrl, hash)
log.Printf("downloading %s", url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err := client.Do(req)
if err != nil {
log.Fatalf("could not download dist-git file: %v", err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("could not read the whole dist-git file: %v", err)
}
err = resp.Body.Close()
if err != nil {
log.Fatalf("could not close body handle: %v", err)
}
hasher := data.CompareHash(body, hash)
if hasher == nil {
log.Fatal("checksum in metadata does not match dist-git file")
}
err = os.MkdirAll(filepath.Dir(path), 0755)
if err != nil {
log.Fatalf("could create all directories")
}
f, err := os.Create(path)
if err != nil {
log.Fatalf("could not open file pointer: %v", err)
}
_, err = f.Write(body)
if err != nil {
log.Fatalf("could not copy dist-git file to in-tree: %v", err)
}
_ = f.Close()
}
}
func init() {
root.AddCommand(fetch)
}

View File

@ -21,23 +21,12 @@
package main
import (
"fmt"
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob"
"github.com/rocky-linux/srpmproc/internal/blob/file"
"github.com/rocky-linux/srpmproc/internal/blob/gcs"
"github.com/rocky-linux/srpmproc/internal/blob/s3"
"github.com/rocky-linux/srpmproc/internal/data"
"encoding/json"
"log"
"os"
"os/user"
"path/filepath"
"strings"
"github.com/rocky-linux/srpmproc/internal"
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"github.com/spf13/cobra"
)
@ -61,9 +50,16 @@ var (
noStorageDownload bool
noStorageUpload bool
manualCommits string
upstreamPrefixHttps string
moduleFallbackStream string
allowStreamBranches bool
branchSuffix string
strictBranchMode bool
basicUsername string
basicPassword string
packageVersion string
packageRelease string
taglessMode bool
cdn string
moduleBranchNames bool
)
var root = &cobra.Command{
@ -72,106 +68,51 @@ var root = &cobra.Command{
}
func mn(_ *cobra.Command, _ []string) {
switch version {
case 8:
break
default:
log.Fatalf("unsupported upstream version %d", version)
}
var importer data.ImportMode
var blobStorage blob.Storage
if strings.HasPrefix(storageAddr, "gs://") {
blobStorage = gcs.New(strings.Replace(storageAddr, "gs://", "", 1))
} else if strings.HasPrefix(storageAddr, "s3://") {
blobStorage = s3.New(strings.Replace(storageAddr, "s3://", "", 1))
} else if strings.HasPrefix(storageAddr, "file://") {
blobStorage = file.New(strings.Replace(storageAddr, "file://", "", 1))
} else {
log.Fatalf("invalid blob storage")
}
sourceRpmLocation := ""
if strings.HasPrefix(sourceRpm, "file://") {
sourceRpmLocation = strings.TrimPrefix(sourceRpm, "file://")
importer = &internal.SrpmMode{}
} else {
if moduleMode {
sourceRpmLocation = fmt.Sprintf("%s/%s", modulePrefix, sourceRpm)
} else {
sourceRpmLocation = fmt.Sprintf("%s/%s", rpmPrefix, sourceRpm)
}
importer = &internal.GitMode{}
}
lastKeyLocation := sshKeyLocation
if lastKeyLocation == "" {
usr, err := user.Current()
if err != nil {
log.Fatalf("could not get user: %v", err)
}
lastKeyLocation = filepath.Join(usr.HomeDir, ".ssh/id_rsa")
}
var authenticator *ssh.PublicKeys
if tmpFsMode == "" {
var err error
// create ssh key authenticator
authenticator, err = ssh.NewPublicKeysFromFile(sshUser, lastKeyLocation, "")
if err != nil {
log.Fatalf("could not get git authenticator: %v", err)
}
}
fsCreator := func(branch string) billy.Filesystem {
return memfs.New()
}
if tmpFsMode != "" {
log.Printf("using tmpfs dir: %s", tmpFsMode)
fsCreator = func(branch string) billy.Filesystem {
tmpDir := filepath.Join(tmpFsMode, branch)
err := os.MkdirAll(tmpDir, 0755)
if err != nil {
log.Fatalf("could not create tmpfs dir: %v", err)
}
return osfs.New(tmpDir)
}
}
var manualCs []string
if strings.TrimSpace(manualCommits) != "" {
manualCs = strings.Split(manualCommits, ",")
}
internal.ProcessRPM(&data.ProcessData{
Importer: importer,
RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix,
SshKeyLocation: sshKeyLocation,
SshUser: sshUser,
pd, err := srpmproc.NewProcessData(&srpmproc.ProcessDataRequest{
Version: version,
BlobStorage: blobStorage,
GitCommitterName: gitCommitterName,
GitCommitterEmail: gitCommitterEmail,
ModulePrefix: modulePrefix,
ImportBranchPrefix: importBranchPrefix,
BranchPrefix: branchPrefix,
SingleTag: singleTag,
Authenticator: authenticator,
NoDupMode: noDupMode,
StorageAddr: storageAddr,
Package: sourceRpm,
ModuleMode: moduleMode,
TmpFsMode: tmpFsMode,
NoStorageDownload: noStorageDownload,
NoStorageUpload: noStorageUpload,
ManualCommits: manualCs,
UpstreamPrefixHttps: upstreamPrefixHttps,
ModulePrefix: modulePrefix,
RpmPrefix: rpmPrefix,
SshKeyLocation: sshKeyLocation,
SshUser: sshUser,
ManualCommits: manualCommits,
UpstreamPrefix: upstreamPrefix,
GitCommitterName: gitCommitterName,
GitCommitterEmail: gitCommitterEmail,
ImportBranchPrefix: importBranchPrefix,
BranchPrefix: branchPrefix,
NoDupMode: noDupMode,
BranchSuffix: branchSuffix,
StrictBranchMode: strictBranchMode,
ModuleFallbackStream: moduleFallbackStream,
AllowStreamBranches: allowStreamBranches,
FsCreator: fsCreator,
NoStorageUpload: noStorageUpload,
NoStorageDownload: noStorageDownload,
SingleTag: singleTag,
CdnUrl: cdnUrl,
HttpUsername: basicUsername,
HttpPassword: basicPassword,
PackageVersion: packageVersion,
PackageRelease: packageRelease,
TaglessMode: taglessMode,
Cdn: cdn,
ModuleBranchNames: moduleBranchNames,
})
if err != nil {
log.Fatal(err)
}
res, err := srpmproc.ProcessRPM(pd)
if err != nil {
log.Fatal(err)
}
err = json.NewEncoder(os.Stdout).Encode(res)
if err != nil {
log.Fatal(err)
}
}
func main() {
@ -192,6 +133,7 @@ func main() {
root.Flags().StringVar(&rpmPrefix, "rpm-prefix", "https://git.centos.org/rpms", "Where to retrieve SRPM content. Only used when source-rpm is not a local file")
root.Flags().StringVar(&importBranchPrefix, "import-branch-prefix", "c", "Import branch prefix")
root.Flags().StringVar(&branchPrefix, "branch-prefix", "r", "Branch prefix (replaces import-branch-prefix)")
root.Flags().StringVar(&cdnUrl, "cdn-url", "https://git.centos.org/sources", "CDN URL to download blobs from. Simple URL follows default rocky/centos patterns. Can be customized using macros (see docs)")
root.Flags().StringVar(&singleTag, "single-tag", "", "If set, only this tag is imported")
root.Flags().BoolVar(&noDupMode, "no-dup-mode", false, "If enabled, skips already imported tags")
root.Flags().BoolVar(&moduleMode, "module-mode", false, "If enabled, imports a module instead of a package")
@ -199,9 +141,16 @@ func main() {
root.Flags().BoolVar(&noStorageDownload, "no-storage-download", false, "If enabled, blobs are always downloaded from upstream")
root.Flags().BoolVar(&noStorageUpload, "no-storage-upload", false, "If enabled, blobs are not uploaded to blob storage")
root.Flags().StringVar(&manualCommits, "manual-commits", "", "Comma separated branch and commit list for packages with broken release tags (Format: BRANCH:HASH)")
root.Flags().StringVar(&upstreamPrefixHttps, "upstream-prefix-https", "", "Web version of upstream prefix. Required if module-mode")
root.Flags().StringVar(&moduleFallbackStream, "module-fallback-stream", "", "Override fallback stream. Some module packages are published as collections and mostly use the same stream name, some of them deviate from the main stream")
root.Flags().BoolVar(&allowStreamBranches, "allow-stream-branches", false, "Allow import from stream branches")
root.Flags().StringVar(&branchSuffix, "branch-suffix", "", "Branch suffix to use for imported branches")
root.Flags().BoolVar(&strictBranchMode, "strict-branch-mode", false, "If enabled, only branches with the calculated name are imported and not prefix only")
root.Flags().StringVar(&basicUsername, "basic-username", "", "Basic auth username")
root.Flags().StringVar(&basicPassword, "basic-password", "", "Basic auth password")
root.Flags().StringVar(&packageVersion, "package-version", "", "Package version to fetch")
root.Flags().StringVar(&packageRelease, "package-release", "", "Package release to fetch")
root.Flags().BoolVar(&taglessMode, "taglessmode", false, "Tagless mode: If set, pull the latest commit from the branch and determine version numbers from spec file. This is auto-tried if tags aren't found.")
root.Flags().StringVar(&cdn, "cdn", "", "CDN URL shortcuts for well-known distros, auto-assigns --cdn-url. Valid values: rocky8, rocky, fedora, centos, centos-stream. Setting this overrides --cdn-url")
root.Flags().BoolVar(&moduleBranchNames, "module-branch-names-only", false, "If enabled, module imports will use the branch name that is being imported, rather than use the commit hash.")
if err := root.Execute(); err != nil {
log.Fatal(err)

2
gen.go
View File

@ -18,5 +18,5 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//go:generate protoc -Iproto --go_opt=paths=source_relative --go_out=pb proto/cfg.proto
//go:generate protoc -Iproto --go_opt=paths=source_relative --go_out=pb proto/cfg.proto proto/response.proto
package srpmproc

53
go.mod
View File

@ -1,17 +1,60 @@
module github.com/rocky-linux/srpmproc
go 1.15
go 1.18
require (
cloud.google.com/go/storage v1.12.0
github.com/aws/aws-sdk-go v1.36.12
github.com/bluekeyes/go-gitdiff v0.5.0
github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e
github.com/cavaliercoder/go-rpm v0.0.0-20200122174316-8cb9fd9c31a8
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.2.0
github.com/golang/protobuf v1.4.2
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
require (
cloud.google.com/go v0.66.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200918232735-d647fc253266 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.32.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200921151605-7abf4a1a14d5 // indirect
google.golang.org/grpc v1.32.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)

59
go.sum
View File

@ -36,18 +36,20 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
cloud.google.com/go/storage v1.12.0 h1:4y3gHptW1EHVtcPAVE0eBBlFuGqEejTTG3KdIE0lUX4=
cloud.google.com/go/storage v1.12.0/go.mod h1:fFLk2dp2oAhDz8QFKwqrjdJvxSp/W2g7nillojlL5Ho=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.36.12 h1:YJpKFEMbqEoo+incs5qMe61n1JH3o4O1IMkMexLzJG8=
github.com/aws/aws-sdk-go v1.36.12/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
@ -57,10 +59,6 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/bluekeyes/go-gitdiff v0.5.0 h1:AXrIoy/VEA9Baz2lhwMlpdzDJ/sKof6C9yTt1oqw4hQ=
github.com/bluekeyes/go-gitdiff v0.5.0/go.mod h1:QpfYYO1E0fTVHVZAZKiRjtSGY9823iCdvGXBcEzHGbM=
github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e h1:hHg27A0RSSp2Om9lubZpiMgVbvn39bsUmW9U5h0twqc=
github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oDpT4efm8tSYHXV5tHSdRvBet/b/QzxZ+XyyPehvm3A=
github.com/cavaliercoder/go-rpm v0.0.0-20200122174316-8cb9fd9c31a8 h1:jP7ki8Tzx9ThnFPLDhBYAhEpI2+jOURnHQNURgsMvnY=
github.com/cavaliercoder/go-rpm v0.0.0-20200122174316-8cb9fd9c31a8/go.mod h1:AZIh1CCnMrcVm6afFf96PBvE2MRpWFco91z8ObJtgDY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@ -76,6 +74,7 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
@ -87,15 +86,16 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git v1.0.0 h1:YcN9iDGDoXuIw0vHls6rINwV416HYa0EB2X+RBsyYp4=
github.com/go-git/go-git v4.7.0+incompatible h1:+W9rgGY4DOKKdX2x6HxSR7HNeTxqiKrOvKnuittYVdA=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.2.0 h1:YPBLG/3UK1we1ohRkncLjaXWLW+HKp5QNM/jTli2JgI=
github.com/go-git/go-git/v5 v5.2.0/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
@ -144,8 +144,11 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
@ -159,6 +162,7 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@ -179,6 +183,7 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
@ -194,12 +199,14 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
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 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
@ -211,7 +218,9 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
@ -225,17 +234,22 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@ -244,7 +258,6 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0 h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
@ -253,38 +266,41 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sassoftware/go-rpmutils v0.1.1 h1:ZHMXpGoMHL/cpQJ1byyhEBW73TDtpNq4inYa9M4FxyY=
github.com/sassoftware/go-rpmutils v0.1.1/go.mod h1:euhXULoBpvAxqrBHEyJS4Tsu3hHxUmQWNymxoJbzgUY=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -307,10 +323,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -366,7 +379,6 @@ golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
@ -376,7 +388,6 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
@ -418,7 +429,6 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -428,10 +438,10 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f h1:Fqb3ao1hUmOR3GkUOg/Y+BadLwykBIzs5q8Ez2SbHyc=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -580,13 +590,14 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
@ -597,6 +608,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -1,316 +0,0 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"path/filepath"
"sort"
"strings"
"time"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
)
type remoteTarget struct {
remote string
when time.Time
}
type remoteTargetSlice []remoteTarget
func (p remoteTargetSlice) Len() int {
return len(p)
}
func (p remoteTargetSlice) Less(i, j int) bool {
return p[i].when.Before(p[j].when)
}
func (p remoteTargetSlice) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
type GitMode struct{}
func (g *GitMode) RetrieveSource(pd *data.ProcessData) *data.ModeData {
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
log.Fatalf("could not init git Repo: %v", err)
}
w, err := repo.Worktree()
if err != nil {
log.Fatalf("could not get Worktree: %v", err)
}
refspec := config.RefSpec("+refs/heads/*:refs/remotes/*")
remote, err := repo.CreateRemote(&config.RemoteConfig{
Name: "upstream",
URLs: []string{fmt.Sprintf("%s.git", pd.RpmLocation)},
Fetch: []config.RefSpec{refspec},
})
if err != nil {
log.Fatalf("could not create remote: %v", err)
}
err = remote.Fetch(&git.FetchOptions{
RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags,
Force: true,
})
if err != nil {
log.Fatalf("could not fetch upstream: %v", err)
}
var branches remoteTargetSlice
latestTags := map[string]*remoteTarget{}
tagAdd := func(tag *object.Tag) error {
if strings.HasPrefix(tag.Name, fmt.Sprintf("imports/%s%d", pd.ImportBranchPrefix, pd.Version)) {
refSpec := fmt.Sprintf("refs/tags/%s", tag.Name)
if tagImportRegex.MatchString(refSpec) {
match := tagImportRegex.FindStringSubmatch(refSpec)
exists := latestTags[match[2]]
if exists != nil && exists.when.After(tag.Tagger.When) {
return nil
}
latestTags[match[2]] = &remoteTarget{
remote: refSpec,
when: tag.Tagger.When,
}
}
}
return nil
}
tagIter, err := repo.TagObjects()
if err != nil {
log.Fatalf("could not get tag objects: %v", err)
}
_ = tagIter.ForEach(tagAdd)
list, err := remote.List(&git.ListOptions{})
if err != nil {
log.Fatalf("could not list upstream: %v", err)
}
for _, ref := range list {
if ref.Hash().IsZero() {
continue
}
commit, err := repo.CommitObject(ref.Hash())
if err != nil {
continue
}
_ = tagAdd(&object.Tag{
Name: strings.TrimPrefix(string(ref.Name()), "refs/tags/"),
Tagger: commit.Committer,
})
}
for _, branch := range latestTags {
log.Printf("tag: %s", strings.TrimPrefix(branch.remote, "refs/tags/"))
branches = append(branches, *branch)
}
sort.Sort(branches)
var sortedBranches []string
for _, branch := range branches {
sortedBranches = append(sortedBranches, branch.remote)
}
return &data.ModeData{
Repo: repo,
Worktree: w,
RpmFile: createPackageFile(filepath.Base(pd.RpmLocation)),
FileWrites: nil,
Branches: sortedBranches,
}
}
func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) {
remote, err := md.Repo.Remote("upstream")
if err != nil {
log.Fatalf("could not get upstream remote: %v", err)
}
var refspec config.RefSpec
var branchName string
if strings.HasPrefix(md.TagBranch, "refs/heads") {
refspec = config.RefSpec(fmt.Sprintf("+%s:%s", md.TagBranch, md.TagBranch))
branchName = strings.TrimPrefix(md.TagBranch, "refs/heads/")
} else {
match := tagImportRegex.FindStringSubmatch(md.TagBranch)
branchName = match[2]
refspec = config.RefSpec(fmt.Sprintf("+refs/heads/%s:%s", branchName, md.TagBranch))
}
log.Printf("checking out upstream refspec %s", refspec)
err = remote.Fetch(&git.FetchOptions{
RemoteName: "upstream",
RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags,
Force: true,
})
if err != nil && err != git.NoErrAlreadyUpToDate {
log.Fatalf("could not fetch upstream: %v", err)
}
err = md.Worktree.Checkout(&git.CheckoutOptions{
Branch: plumbing.ReferenceName(md.TagBranch),
Force: true,
})
if err != nil {
log.Fatalf("could not checkout source from git: %v", err)
}
_, err = md.Worktree.Add(".")
if err != nil {
log.Fatalf("could not add Worktree: %v", err)
}
metadataFile, err := md.Worktree.Filesystem.Open(fmt.Sprintf(".%s.metadata", md.RpmFile.Name()))
if err != nil {
log.Printf("warn: could not open metadata file, so skipping: %v", err)
return
}
fileBytes, err := ioutil.ReadAll(metadataFile)
if err != nil {
log.Fatalf("could not read metadata file: %v", err)
}
client := &http.Client{
Transport: &http.Transport{
DisableCompression: false,
},
}
fileContent := strings.Split(string(fileBytes), "\n")
for _, line := range fileContent {
if strings.TrimSpace(line) == "" {
continue
}
lineInfo := strings.SplitN(line, " ", 2)
hash := strings.TrimSpace(lineInfo[0])
path := strings.TrimSpace(lineInfo[1])
var body []byte
if md.BlobCache[hash] != nil {
body = md.BlobCache[hash]
log.Printf("retrieving %s from cache", hash)
} else {
fromBlobStorage := pd.BlobStorage.Read(hash)
if fromBlobStorage != nil && !pd.NoStorageDownload {
body = fromBlobStorage
log.Printf("downloading %s from blob storage", hash)
} else {
url := fmt.Sprintf("https://git.centos.org/sources/%s/%s/%s", md.RpmFile.Name(), branchName, hash)
log.Printf("downloading %s", url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err := client.Do(req)
if err != nil {
log.Fatalf("could not download dist-git file: %v", err)
}
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("could not read the whole dist-git file: %v", err)
}
err = resp.Body.Close()
if err != nil {
log.Fatalf("could not close body handle: %v", err)
}
}
md.BlobCache[hash] = body
}
f, err := md.Worktree.Filesystem.Create(path)
if err != nil {
log.Fatalf("could not open file pointer: %v", err)
}
hasher := data.CompareHash(body, hash)
if hasher == nil {
log.Fatal("checksum in metadata does not match dist-git file")
}
md.SourcesToIgnore = append(md.SourcesToIgnore, &data.IgnoredSource{
Name: path,
HashFunction: hasher,
})
_, err = f.Write(body)
if err != nil {
log.Fatalf("could not copy dist-git file to in-tree: %v", err)
}
_ = f.Close()
}
}
func (g *GitMode) PostProcess(md *data.ModeData) {
for _, source := range md.SourcesToIgnore {
_, err := md.Worktree.Filesystem.Stat(source.Name)
if err == nil {
err := md.Worktree.Filesystem.Remove(source.Name)
if err != nil {
log.Fatalf("could not remove dist-git file: %v", err)
}
}
}
_, err := md.Worktree.Add(".")
if err != nil {
log.Fatalf("could not add git sources: %v", err)
}
}
func (g *GitMode) ImportName(_ *data.ProcessData, md *data.ModeData) string {
if tagImportRegex.MatchString(md.TagBranch) {
match := tagImportRegex.FindStringSubmatch(md.TagBranch)
return match[3]
}
return strings.Replace(strings.TrimPrefix(md.TagBranch, "refs/heads/"), "%", "_", -1)
}

View File

@ -1,51 +0,0 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
import (
"github.com/cavaliercoder/go-rpm"
)
// TODO: ugly hack, should create an interface
// since GitMode does not parse an RPM file, we just mimick
// the headers of an actual file to reuse RpmFile.Name()
func createPackageFile(name string) *rpm.PackageFile {
return &rpm.PackageFile{
Lead: rpm.Lead{},
Headers: []rpm.Header{
{},
{
Version: 0,
IndexCount: 1,
Length: 1,
Indexes: []rpm.IndexEntry{
{
Tag: 1000,
Type: rpm.IndexDataTypeStringArray,
Offset: 0,
ItemCount: 1,
Value: []string{name},
},
},
},
},
}
}

View File

@ -1,21 +0,0 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal

View File

@ -1,400 +0,0 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
"time"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
)
var tagImportRegex *regexp.Regexp
func gitlabify(str string) string {
if str == "tree" {
return "treepkg"
}
return strings.Replace(str, "+", "plus", -1)
}
// ProcessRPM checks the RPM specs and discards any remote files
// This functions also sorts files into directories
// .spec files goes into -> SPECS
// metadata files goes to root
// source files goes into -> SOURCES
// all files that are remote goes into .gitignore
// all ignored files' hash goes into .{Name}.metadata
func ProcessRPM(pd *data.ProcessData) {
if pd.AllowStreamBranches {
tagImportRegex = regexp.MustCompile(fmt.Sprintf("refs/tags/(imports/(%s(?:.s|.)|%s(?:|s).-.+)/(.*))", pd.ImportBranchPrefix, pd.ImportBranchPrefix))
} else {
tagImportRegex = regexp.MustCompile(fmt.Sprintf("refs/tags/(imports/(%s.|%s.-.+)/(.*))", pd.ImportBranchPrefix, pd.ImportBranchPrefix))
}
md := pd.Importer.RetrieveSource(pd)
md.BlobCache = map[string][]byte{}
remotePrefix := "rpms"
if pd.ModuleMode {
remotePrefix = "modules"
}
latestHashForBranch := map[string]string{}
// already uploaded blobs are skipped
var alreadyUploadedBlobs []string
// if no-dup-mode is enabled then skip already imported versions
var tagIgnoreList []string
if pd.NoDupMode {
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
log.Fatalf("could not init git repo: %v", err)
}
remoteUrl := fmt.Sprintf("%s/%s/%s.git", pd.UpstreamPrefix, remotePrefix, gitlabify(md.RpmFile.Name()))
refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
remote, err := repo.CreateRemote(&config.RemoteConfig{
Name: "origin",
URLs: []string{remoteUrl},
Fetch: []config.RefSpec{refspec},
})
if err != nil {
log.Fatalf("could not create remote: %v", err)
}
list, err := remote.List(&git.ListOptions{
Auth: pd.Authenticator,
})
if err != nil {
log.Println("ignoring no-dup-mode")
} else {
for _, ref := range list {
if !strings.HasPrefix(string(ref.Name()), "refs/tags/imports") {
continue
}
tagIgnoreList = append(tagIgnoreList, string(ref.Name()))
}
}
}
sourceRepo := *md.Repo
sourceWorktree := *md.Worktree
commitPin := map[string]string{}
if pd.SingleTag != "" {
md.Branches = []string{fmt.Sprintf("refs/tags/%s", pd.SingleTag)}
} else if len(pd.ManualCommits) > 0 {
md.Branches = []string{}
for _, commit := range pd.ManualCommits {
branchCommit := strings.Split(commit, ":")
if len(branchCommit) != 2 {
log.Fatalln("invalid manual commit list")
}
head := fmt.Sprintf("refs/tags/imports/%s/%s-%s", branchCommit[0], md.RpmFile.Name(), branchCommit[1])
md.Branches = append(md.Branches, head)
commitPin[head] = branchCommit[1]
}
}
for _, branch := range md.Branches {
md.Repo = &sourceRepo
md.Worktree = &sourceWorktree
md.TagBranch = branch
for _, source := range md.SourcesToIgnore {
source.Expired = true
}
if strings.Contains(md.TagBranch, "-beta") {
continue
}
var matchString string
if !tagImportRegex.MatchString(md.TagBranch) {
if pd.ModuleMode {
prefix := fmt.Sprintf("refs/heads/%s%d", pd.ImportBranchPrefix, pd.Version)
if strings.HasPrefix(md.TagBranch, prefix) {
replace := strings.Replace(md.TagBranch, "refs/heads/", "", 1)
matchString = fmt.Sprintf("refs/tags/imports/%s/%s", replace, filepath.Base(pd.RpmLocation))
log.Printf("using match string: %s", matchString)
}
}
if !tagImportRegex.MatchString(matchString) {
continue
}
} else {
matchString = md.TagBranch
}
match := tagImportRegex.FindStringSubmatch(matchString)
md.PushBranch = pd.BranchPrefix + strings.TrimPrefix(match[2], pd.ImportBranchPrefix)
newTag := "imports/" + pd.BranchPrefix + strings.TrimPrefix(match[1], "imports/"+pd.ImportBranchPrefix)
newTag = strings.Replace(newTag, "%", "_", -1)
rpmFile := md.RpmFile
// create new Repo for final dist
repo, err := git.Init(memory.NewStorage(), pd.FsCreator(md.PushBranch))
if err != nil {
log.Fatalf("could not create new dist Repo: %v", err)
}
w, err := repo.Worktree()
if err != nil {
log.Fatalf("could not get dist Worktree: %v", err)
}
shouldContinue := true
for _, ignoredTag := range tagIgnoreList {
if ignoredTag == "refs/tags/"+newTag {
log.Printf("skipping %s", ignoredTag)
shouldContinue = false
}
}
if !shouldContinue {
continue
}
// create a new remote
remoteUrl := fmt.Sprintf("%s/%s/%s.git", pd.UpstreamPrefix, remotePrefix, gitlabify(rpmFile.Name()))
log.Printf("using remote: %s", remoteUrl)
refspec := config.RefSpec(fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", md.PushBranch, md.PushBranch))
log.Printf("using refspec: %s", refspec)
_, err = repo.CreateRemote(&config.RemoteConfig{
Name: "origin",
URLs: []string{remoteUrl},
Fetch: []config.RefSpec{refspec},
})
if err != nil {
log.Fatalf("could not create remote: %v", err)
}
err = repo.Fetch(&git.FetchOptions{
RemoteName: "origin",
RefSpecs: []config.RefSpec{refspec},
Auth: pd.Authenticator,
})
refName := plumbing.NewBranchReferenceName(md.PushBranch)
log.Printf("set reference to ref: %s", refName)
var hash plumbing.Hash
if commitPin[md.PushBranch] != "" {
hash = plumbing.NewHash(commitPin[md.PushBranch])
}
if err != nil {
h := plumbing.NewSymbolicReference(plumbing.HEAD, refName)
if err := repo.Storer.CheckAndSetReference(h, nil); err != nil {
log.Fatalf("could not set reference: %v", err)
}
} else {
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch),
Hash: hash,
Force: true,
})
if err != nil {
log.Fatalf("could not checkout: %v", err)
}
}
pd.Importer.WriteSource(pd, md)
data.CopyFromFs(md.Worktree.Filesystem, w.Filesystem, ".")
md.Repo = repo
md.Worktree = w
if pd.ModuleMode {
patchModuleYaml(pd, md)
} else {
executePatchesRpm(pd, md)
}
// get ignored files hash and add to .{Name}.metadata
metadataFile := fmt.Sprintf(".%s.metadata", rpmFile.Name())
metadata, err := w.Filesystem.Create(metadataFile)
if err != nil {
log.Fatalf("could not create metadata file: %v", err)
}
for _, source := range md.SourcesToIgnore {
sourcePath := source.Name
_, err := w.Filesystem.Stat(sourcePath)
if source.Expired || err != nil {
continue
}
sourceFile, err := w.Filesystem.Open(sourcePath)
if err != nil {
log.Fatalf("could not open ignored source file %s: %v", sourcePath, err)
}
sourceFileBts, err := ioutil.ReadAll(sourceFile)
if err != nil {
log.Fatalf("could not read the whole of ignored source file: %v", err)
}
source.HashFunction.Reset()
_, err = source.HashFunction.Write(sourceFileBts)
if err != nil {
log.Fatalf("could not write bytes to hash function: %v", err)
}
checksum := hex.EncodeToString(source.HashFunction.Sum(nil))
checksumLine := fmt.Sprintf("%s %s\n", checksum, sourcePath)
_, err = metadata.Write([]byte(checksumLine))
if err != nil {
log.Fatalf("could not write to metadata file: %v", err)
}
if data.StrContains(alreadyUploadedBlobs, checksum) {
continue
}
if !pd.BlobStorage.Exists(checksum) && !pd.NoStorageUpload {
pd.BlobStorage.Write(checksum, sourceFileBts)
log.Printf("wrote %s to blob storage", checksum)
}
alreadyUploadedBlobs = append(alreadyUploadedBlobs, checksum)
}
_, err = w.Add(metadataFile)
if err != nil {
log.Fatalf("could not add metadata file: %v", err)
}
lastFilesToAdd := []string{".gitignore", "SPECS"}
for _, f := range lastFilesToAdd {
_, err := w.Filesystem.Stat(f)
if err == nil {
_, err := w.Add(f)
if err != nil {
log.Fatalf("could not add %s: %v", f, err)
}
}
}
if pd.TmpFsMode != "" {
continue
}
pd.Importer.PostProcess(md)
// show status
status, _ := w.Status()
log.Printf("successfully processed:\n%s", status)
statusLines := strings.Split(status.String(), "\n")
for _, line := range statusLines {
trimmed := strings.TrimSpace(line)
if strings.HasPrefix(trimmed, "D") {
path := strings.TrimPrefix(trimmed, "D ")
_, err := w.Remove(path)
if err != nil {
log.Fatalf("could not delete extra file %s: %v", path, err)
}
}
}
var hashes []plumbing.Hash
var pushRefspecs []config.RefSpec
head, err := repo.Head()
if err != nil {
hashes = nil
pushRefspecs = append(pushRefspecs, "*:*")
} else {
log.Printf("tip %s", head.String())
hashes = append(hashes, head.Hash())
refOrigin := "refs/heads/" + md.PushBranch
pushRefspecs = append(pushRefspecs, config.RefSpec(fmt.Sprintf("HEAD:%s", refOrigin)))
}
// we are now finished with the tree and are going to push it to the src Repo
// create import commit
commit, err := w.Commit("import "+pd.Importer.ImportName(pd, md), &git.CommitOptions{
Author: &object.Signature{
Name: pd.GitCommitterName,
Email: pd.GitCommitterEmail,
When: time.Now(),
},
Parents: hashes,
})
if err != nil {
log.Fatalf("could not commit object: %v", err)
}
obj, err := repo.CommitObject(commit)
if err != nil {
log.Fatalf("could not get commit object: %v", err)
}
log.Printf("committed:\n%s", obj.String())
_, err = repo.CreateTag(newTag, commit, &git.CreateTagOptions{
Tagger: &object.Signature{
Name: pd.GitCommitterName,
Email: pd.GitCommitterEmail,
When: time.Now(),
},
Message: "import " + md.TagBranch + " from " + pd.RpmLocation,
SignKey: nil,
})
if err != nil {
log.Fatalf("could not create tag: %v", err)
}
pushRefspecs = append(pushRefspecs, config.RefSpec("HEAD:"+plumbing.NewTagReferenceName(newTag)))
err = repo.Push(&git.PushOptions{
RemoteName: "origin",
Auth: pd.Authenticator,
RefSpecs: pushRefspecs,
Force: true,
})
if err != nil {
log.Fatalf("could not push to remote: %v", err)
}
hashString := obj.Hash.String()
latestHashForBranch[md.PushBranch] = hashString
}
err := json.NewEncoder(os.Stdout).Encode(latestHashForBranch)
if err != nil {
log.Fatalf("could not print hashes")
}
}

View File

@ -1,187 +0,0 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
import (
"bytes"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/cavaliercoder/go-cpio"
"github.com/cavaliercoder/go-rpm"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
)
type SrpmMode struct{}
func (s *SrpmMode) RetrieveSource(pd *data.ProcessData) *data.ModeData {
cmd := exec.Command("rpm2cpio", pd.RpmLocation)
cpioBytes, err := cmd.Output()
if err != nil {
log.Fatalf("could not convert to cpio (maybe rpm2cpio is missing): %v", err)
}
// create in memory git repository
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
log.Fatalf("could not init git Repo: %v", err)
}
// read the rpm in cpio format
buf := bytes.NewReader(cpioBytes)
r := cpio.NewReader(buf)
fileWrites := map[string][]byte{}
for {
hdr, err := r.Next()
if err == io.EOF {
// end of cpio archive
break
}
if err != nil {
log.Fatalln(err)
}
bts, err := ioutil.ReadAll(r)
if err != nil {
log.Fatalf("could not copy file to virtual filesystem: %v", err)
}
fileWrites[hdr.Name] = bts
}
w, err := repo.Worktree()
if err != nil {
log.Fatalf("could not get Worktree: %v", err)
}
// create structure
err = w.Filesystem.MkdirAll("SPECS", 0755)
if err != nil {
log.Fatalf("could not create SPECS dir in vfs: %v", err)
}
err = w.Filesystem.MkdirAll("SOURCES", 0755)
if err != nil {
log.Fatalf("could not create SOURCES dir in vfs: %v", err)
}
f, err := os.Open(pd.RpmLocation)
if err != nil {
log.Fatalf("could not open the file again: %v", err)
}
rpmFile, err := rpm.ReadPackageFile(f)
if err != nil {
log.Fatalf("could not read package, invalid?: %v", err)
}
var sourcesToIgnore []*data.IgnoredSource
for _, source := range rpmFile.Source() {
if strings.Contains(source, ".tar") {
sourcesToIgnore = append(sourcesToIgnore, &data.IgnoredSource{
Name: source,
HashFunction: sha256.New(),
})
}
}
branch := fmt.Sprintf("%s%d", pd.BranchPrefix, pd.Version)
return &data.ModeData{
Repo: repo,
Worktree: w,
RpmFile: rpmFile,
FileWrites: fileWrites,
Branches: []string{branch},
SourcesToIgnore: sourcesToIgnore,
}
}
func (s *SrpmMode) WriteSource(_ *data.ProcessData, md *data.ModeData) {
for fileName, contents := range md.FileWrites {
var newPath string
if filepath.Ext(fileName) == ".spec" {
newPath = filepath.Join("SPECS", fileName)
} else {
newPath = filepath.Join("SOURCES", fileName)
}
mode := os.FileMode(0666)
for _, file := range md.RpmFile.Files() {
if file.Name() == fileName {
mode = file.Mode()
}
}
// add the file to the virtual filesystem
// we will move it to correct destination later
f, err := md.Worktree.Filesystem.OpenFile(newPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
if err != nil {
log.Fatalf("could not create file %s: %v", fileName, err)
}
_, err = f.Write(contents)
if err != nil {
log.Fatalf("could not write to file %s: %v", fileName, err)
}
_ = f.Close()
// don't add ignored file to git
if data.IgnoredContains(md.SourcesToIgnore, fileName) {
continue
}
_, err = md.Worktree.Add(newPath)
if err != nil {
log.Fatalf("could not add source file: %v", err)
}
}
// add sources to ignore (remote sources)
gitIgnore, err := md.Worktree.Filesystem.Create(".gitignore")
if err != nil {
log.Fatalf("could not create .gitignore: %v", err)
}
for _, ignore := range md.SourcesToIgnore {
line := fmt.Sprintf("SOURCES/%s\n", ignore)
_, err := gitIgnore.Write([]byte(line))
if err != nil {
log.Fatalf("could not write line to .gitignore: %v", err)
}
}
err = gitIgnore.Close()
if err != nil {
log.Fatalf("could not close .gitignore: %v", err)
}
}
func (s *SrpmMode) PostProcess(_ *data.ModeData) {}
func (s *SrpmMode) ImportName(pd *data.ProcessData, _ *data.ModeData) string {
return filepath.Base(pd.RpmLocation)
}

View File

@ -21,122 +21,189 @@
package modulemd
import (
"fmt"
"github.com/go-git/go-billy/v5"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)
type ServiceLevelType string
const (
ServiceLevelRawhide ServiceLevelType = "rawhide"
ServiceLevelStableAPI ServiceLevelType = "stable_api"
ServiceLevelBugFixes ServiceLevelType = "bug_fixes"
ServiceLevelSecurityFixes ServiceLevelType = "security_fixes"
)
type ServiceLevel struct {
Eol string `yaml:"eol,omitempty"`
}
type License struct {
Module []string `yaml:"module,omitempty"`
Content []string `yaml:"content,omitempty"`
}
type Dependencies struct {
BuildRequires map[string][]string `yaml:"buildrequires,omitempty,omitempty"`
Requires map[string][]string `yaml:"requires,omitempty,omitempty"`
}
type References struct {
Community string `yaml:"community,omitempty"`
Documentation string `yaml:"documentation,omitempty"`
Tracker string `yaml:"tracker,omitempty"`
}
type Profile struct {
Description string `yaml:"description,omitempty"`
Rpms []string `yaml:"rpms,omitempty"`
}
type API struct {
Rpms []string `yaml:"rpms,omitempty"`
}
type BuildOptsRPM struct {
Macros string `yaml:"macros,omitempty"`
Whitelist []string `yaml:"whitelist,omitempty"`
}
type BuildOpts struct {
Rpms *BuildOptsRPM `yaml:"rpms,omitempty"`
Arches []string `yaml:"arches,omitempty"`
}
type ComponentRPM struct {
Name string `yaml:"name,omitempty"`
Rationale string `yaml:"rationale,omitempty"`
Repository string `yaml:"repository,omitempty"`
Cache string `yaml:"cache,omitempty"`
Ref string `yaml:"ref,omitempty"`
Buildonly bool `yaml:"buildonly,omitempty"`
Buildroot bool `yaml:"buildroot,omitempty"`
SrpmBuildroot bool `yaml:"srpm-buildroot,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
Arches []string `yaml:"arches,omitempty"`
Multilib []string `yaml:"multilib,omitempty"`
}
type ComponentModule struct {
Rationale string `yaml:"rationale,omitempty"`
Repository string `yaml:"repository,omitempty"`
Ref string `yaml:"ref,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
}
type Components struct {
Rpms map[string]*ComponentRPM `yaml:"rpms,omitempty"`
Modules map[string]*ComponentModule `yaml:"modules,omitempty"`
}
type ArtifactsRPMMap struct {
Name string `yaml:"name,omitempty"`
Epoch int `yaml:"epoch,omitempty"`
Version float64 `yaml:"version,omitempty"`
Release string `yaml:"release,omitempty"`
Arch string `yaml:"arch,omitempty"`
Nevra string `yaml:"nevra,omitempty"`
}
type Artifacts struct {
Rpms []string `yaml:"rpms,omitempty"`
RpmMap map[string]map[string]*ArtifactsRPMMap `yaml:"rpm-map,omitempty"`
}
type Data struct {
Name string `yaml:"name,omitempty"`
Stream string `yaml:"stream,omitempty"`
Version string `yaml:"version,omitempty"`
StaticContext bool `yaml:"static_context,omitempty"`
Context string `yaml:"context,omitempty"`
Arch string `yaml:"arch,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
ServiceLevels map[ServiceLevelType]*ServiceLevel `yaml:"servicelevels,omitempty"`
License *License `yaml:"license,omitempty"`
Xmd map[string]map[string]string `yaml:"xmd,omitempty"`
Dependencies []*Dependencies `yaml:"dependencies,omitempty"`
References *References `yaml:"references,omitempty"`
Profiles map[string]*Profile `yaml:"profiles,omitempty"`
Profile map[string]*Profile `yaml:"profile,omitempty"`
API *API `yaml:"api,omitempty"`
Filter *API `yaml:"filter,omitempty"`
BuildOpts *BuildOpts `yaml:"buildopts,omitempty"`
Components *Components `yaml:"components,omitempty"`
Artifacts *Artifacts `yaml:"artifacts,omitempty"`
}
type ModuleMd struct {
Document string `yaml:"document,omitempty"`
Version int `yaml:"version,omitempty"`
Data struct {
Name string `yaml:"name,omitempty"`
Stream string `yaml:"stream,omitempty"`
Version int64 `yaml:"version,omitempty"`
StaticContext bool `yaml:"static_context,omitempty"`
Context string `yaml:"context,omitempty"`
Arch string `yaml:"arch,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Servicelevels struct {
Rawhide struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"rawhide,omitempty"`
StableAPI struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"stable_api,omitempty"`
BugFixes struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"bug_fixes,omitempty"`
SecurityFixes struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"security_fixes,omitempty"`
} `yaml:"servicelevels,omitempty"`
License struct {
Module []string `yaml:"module,omitempty"`
Content []string `yaml:"content,omitempty"`
} `yaml:"license,omitempty"`
Xmd map[string]interface{} `yaml:"xmd,omitempty"`
Dependencies []struct {
Buildrequires map[string][]string `yaml:"buildrequires,omitempty,omitempty"`
Requires map[string][]string `yaml:"requires,omitempty,omitempty"`
} `yaml:"dependencies,omitempty"`
References struct {
Community string `yaml:"community,omitempty"`
Documentation string `yaml:"documentation,omitempty"`
Tracker string `yaml:"tracker,omitempty"`
} `yaml:"references,omitempty"`
Profiles map[string]*struct {
Description string `yaml:"description,omitempty"`
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"profiles,omitempty"`
Profile map[string]*struct {
Description string `yaml:"description,omitempty"`
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"profile,omitempty"`
API struct {
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"api,omitempty"`
Filter struct {
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"filter,omitempty"`
Buildopts struct {
Rpms struct {
Macros string `yaml:"macros,omitempty"`
Whitelist []string `yaml:"whitelist,omitempty"`
} `yaml:"rpms,omitempty"`
Arches []string `yaml:"arches,omitempty"`
} `yaml:"buildopts,omitempty"`
Components struct {
Rpms map[string]*struct {
Name string `yaml:"name,omitempty"`
Rationale string `yaml:"rationale,omitempty"`
Repository string `yaml:"repository,omitempty"`
Cache string `yaml:"cache,omitempty"`
Ref string `yaml:"ref,omitempty"`
Buildonly bool `yaml:"buildonly,omitempty"`
Buildroot bool `yaml:"buildroot,omitempty"`
SrpmBuildroot bool `yaml:"srpm-buildroot,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
Arches []string `yaml:"arches,omitempty"`
Multilib []string `yaml:"multilib,omitempty"`
} `yaml:"rpms,omitempty"`
Modules map[string]*struct {
Rationale string `yaml:"rationale,omitempty"`
Repository string `yaml:"repository,omitempty"`
Ref string `yaml:"ref,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
} `yaml:"modules,omitempty"`
} `yaml:"components,omitempty"`
Artifacts struct {
Rpms []string `yaml:"rpms,omitempty"`
RpmMap map[string]map[string]*struct {
Name string `yaml:"name,omitempty"`
Epoch int `yaml:"epoch,omitempty"`
Version float64 `yaml:"version,omitempty"`
Release string `yaml:"release,omitempty"`
Arch string `yaml:"arch,omitempty"`
Nevra string `yaml:"nevra,omitempty"`
} `yaml:"rpm-map,omitempty"`
} `yaml:"artifacts,omitempty"`
} `yaml:"data,omitempty"`
Data *Data `yaml:"data,omitempty"`
}
func Parse(input []byte) (*ModuleMd, error) {
var ret ModuleMd
err := yaml.Unmarshal(input, &ret)
type DetectVersionDocument struct {
Document string `yaml:"document,omitempty"`
Version int `yaml:"version,omitempty"`
}
type DefaultsData struct {
Module string `yaml:"module,omitempty"`
Stream string `yaml:"stream,omitempty"`
Profiles map[string][]string `yaml:"profiles,omitempty"`
}
type Defaults struct {
Document string `yaml:"document,omitempty"`
Version int `yaml:"version,omitempty"`
Data *DefaultsData `yaml:"data,omitempty"`
}
type NotBackwardsCompatibleModuleMd struct {
V2 *ModuleMd
V3 *V3
}
func Parse(input []byte) (*NotBackwardsCompatibleModuleMd, error) {
var detect DetectVersionDocument
err := yaml.Unmarshal(input, &detect)
if err != nil {
return nil, err
return nil, fmt.Errorf("error detecting document version: %s", err)
}
var ret NotBackwardsCompatibleModuleMd
if detect.Version == 2 {
var v2 ModuleMd
err = yaml.Unmarshal(input, &v2)
if err != nil {
return nil, fmt.Errorf("error parsing modulemd: %s", err)
}
ret.V2 = &v2
} else if detect.Version == 3 {
var v3 V3
err = yaml.Unmarshal(input, &v3)
if err != nil {
return nil, fmt.Errorf("error parsing modulemd: %s", err)
}
ret.V3 = &v3
}
return &ret, nil
}
func (m *ModuleMd) Marshal(fs billy.Filesystem, path string) error {
bts, err := yaml.Marshal(m)
func (m *NotBackwardsCompatibleModuleMd) Marshal(fs billy.Filesystem, path string) error {
var bts []byte
var err error
if m.V2 != nil {
bts, err = yaml.Marshal(m.V2)
}
if m.V3 != nil {
bts, err = yaml.Marshal(m.V3)
}
if err != nil {
return err
}

32
modulemd/v3.go Normal file
View File

@ -0,0 +1,32 @@
package modulemd
type V3 struct {
Document string `yaml:"document,omitempty"`
Version int `yaml:"version,omitempty"`
Data *V3Data `yaml:"data,omitempty"`
}
type Configurations struct {
Context string `yaml:"context,omitempty"`
Platform string `yaml:"platform,omitempty"`
BuildRequires map[string][]string `yaml:"buildrequires,omitempty"`
Requires map[string][]string `yaml:"requires,omitempty"`
BuildOpts *BuildOpts `yaml:"buildopts,omitempty"`
}
type V3Data struct {
Name string `yaml:"name,omitempty"`
Stream string `yaml:"stream,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
License []string `yaml:"license,omitempty"`
Xmd map[string]map[string]string `yaml:"xmd,omitempty"`
Configurations []*Configurations `yaml:"configurations,omitempty"`
References *References `yaml:"references,omitempty"`
Profiles map[string]*Profile `yaml:"profiles,omitempty"`
Profile map[string]*Profile `yaml:"profile,omitempty"`
API *API `yaml:"api,omitempty"`
Filter *API `yaml:"filter,omitempty"`
Demodularized *API `yaml:"demodularized,omitempty"`
Components *Components `yaml:"components,omitempty"`
}

View File

@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0-devel
// protoc v3.14.0
// protoc-gen-go v1.27.1
// protoc v3.19.3
// source: cfg.proto
package srpmprocpb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type SpecChange_FileOperation_Type int32
const (
@ -418,6 +413,7 @@ type SpecChange struct {
SearchAndReplace []*SpecChange_SearchAndReplaceOperation `protobuf:"bytes,3,rep,name=search_and_replace,json=searchAndReplace,proto3" json:"search_and_replace,omitempty"`
Append []*SpecChange_AppendOperation `protobuf:"bytes,4,rep,name=append,proto3" json:"append,omitempty"`
NewField []*SpecChange_NewFieldOperation `protobuf:"bytes,5,rep,name=new_field,json=newField,proto3" json:"new_field,omitempty"`
DisableAutoAlign bool `protobuf:"varint,6,opt,name=disable_auto_align,json=disableAutoAlign,proto3" json:"disable_auto_align,omitempty"`
}
func (x *SpecChange) Reset() {
@ -487,6 +483,13 @@ func (x *SpecChange) GetNewField() []*SpecChange_NewFieldOperation {
return nil
}
func (x *SpecChange) GetDisableAutoAlign() bool {
if x != nil {
return x.DisableAutoAlign
}
return false
}
type Patch struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -1105,7 +1108,7 @@ var file_cfg_proto_rawDesc = []byte{
0x0b, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0f,
0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, 0x72, 0x65, 0x65, 0x18,
0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x66, 0x72, 0x6f, 0x6d, 0x50, 0x61, 0x74, 0x63, 0x68,
0x54, 0x72, 0x65, 0x65, 0x22, 0xae, 0x08, 0x0a, 0x0a, 0x53, 0x70, 0x65, 0x63, 0x43, 0x68, 0x61,
0x54, 0x72, 0x65, 0x65, 0x22, 0xdc, 0x08, 0x0a, 0x0a, 0x53, 0x70, 0x65, 0x63, 0x43, 0x68, 0x61,
0x6e, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x22, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x53, 0x70, 0x65,
0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x65, 0x72,
@ -1128,75 +1131,78 @@ var file_cfg_proto_rawDesc = []byte{
0x0b, 0x32, 0x26, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x53, 0x70, 0x65,
0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x4e, 0x65, 0x77, 0x46, 0x69, 0x65, 0x6c, 0x64,
0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x46, 0x69,
0x65, 0x6c, 0x64, 0x1a, 0xf9, 0x01, 0x0a, 0x0d, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72,
0x6f, 0x63, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x46, 0x69,
0x6c, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65,
0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x61, 0x64, 0x64, 0x18, 0x03, 0x20,
0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, 0x18, 0x0a, 0x06, 0x64, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x70,
0x72, 0x65, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, 0x64, 0x64, 0x54, 0x6f,
0x50, 0x72, 0x65, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06,
0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2a, 0x0a, 0x04, 0x54,
0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00,
0x12, 0x0a, 0x0a, 0x06, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05,
0x50, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a,
0x72, 0x0a, 0x12, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x6c, 0x6f, 0x67, 0x4f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x75, 0x74, 0x68,
0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x75,
0x74, 0x68, 0x6f, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x1a, 0xd3, 0x01, 0x0a, 0x19, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x6e,
0x64, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x16, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x48, 0x00, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x03, 0x61, 0x6e, 0x79,
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x21, 0x0a,
0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68,
0x12, 0x1d, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x18, 0x04, 0x20,
0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x73, 0x57, 0x69, 0x74, 0x68, 0x12,
0x12, 0x0a, 0x04, 0x66, 0x69, 0x6e, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66,
0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x06,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0c, 0x0a,
0x01, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x6e, 0x42, 0x0c, 0x0a, 0x0a, 0x69,
0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x70, 0x70,
0x65, 0x6e, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05,
0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65,
0x6c, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x3b, 0x0a, 0x11, 0x4e, 0x65, 0x77, 0x46,
0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a,
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x33, 0x0a, 0x05, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, 0x12,
0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69,
0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x8e, 0x02, 0x0a, 0x03, 0x43,
0x66, 0x67, 0x12, 0x2b, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x52,
0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12,
0x28, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x10, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x03, 0x61, 0x64, 0x64,
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f,
0x63, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, 0x31, 0x0a, 0x09, 0x6c, 0x6f,
0x6f, 0x6b, 0x61, 0x73, 0x69, 0x64, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e,
0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x61, 0x73, 0x69,
0x64, 0x65, 0x52, 0x09, 0x6c, 0x6f, 0x6f, 0x6b, 0x61, 0x73, 0x69, 0x64, 0x65, 0x12, 0x35, 0x0a,
0x0b, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x53, 0x70,
0x65, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x63, 0x43, 0x68,
0x61, 0x6e, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x06, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x50,
0x61, 0x74, 0x63, 0x68, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x42, 0x2f, 0x5a, 0x2d, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f, 0x63, 0x6b, 0x79, 0x2d,
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2f, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2f, 0x70,
0x62, 0x3b, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x65, 0x6c, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61,
0x75, 0x74, 0x6f, 0x5f, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52,
0x10, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x41, 0x6c, 0x69, 0x67,
0x6e, 0x1a, 0xf9, 0x01, 0x0a, 0x0d, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63,
0x2e, 0x53, 0x70, 0x65, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x46, 0x69, 0x6c, 0x65,
0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x61, 0x64, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
0x08, 0x48, 0x00, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, 0x18, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x70, 0x72, 0x65,
0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, 0x64, 0x64, 0x54, 0x6f, 0x50, 0x72,
0x65, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01,
0x28, 0x05, 0x52, 0x05, 0x6e, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2a, 0x0a, 0x04, 0x54, 0x79, 0x70,
0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0a,
0x0a, 0x06, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x61,
0x74, 0x63, 0x68, 0x10, 0x02, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x72, 0x0a,
0x12, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x6c, 0x6f, 0x67, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x5f, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x5f, 0x65,
0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x75, 0x74, 0x68,
0x6f, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x1a, 0xd3, 0x01, 0x0a, 0x19, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x6e, 0x64, 0x52,
0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x16, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00,
0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x03, 0x61, 0x6e, 0x79, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x21, 0x0a, 0x0b, 0x73,
0x74, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x48, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x12, 0x1d,
0x0a, 0x09, 0x65, 0x6e, 0x64, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28,
0x08, 0x48, 0x00, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x73, 0x57, 0x69, 0x74, 0x68, 0x12, 0x12, 0x0a,
0x04, 0x66, 0x69, 0x6e, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6e,
0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x6e,
0x18, 0x07, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x6e, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65,
0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x65, 0x6e,
0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69,
0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x3b, 0x0a, 0x11, 0x4e, 0x65, 0x77, 0x46, 0x69, 0x65,
0x6c, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x22, 0x33, 0x0a, 0x05, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04,
0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08,
0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x8e, 0x02, 0x0a, 0x03, 0x43, 0x66, 0x67,
0x12, 0x2b, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x11, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x52, 0x65, 0x70,
0x6c, 0x61, 0x63, 0x65, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x28, 0x0a,
0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e,
0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x03, 0x61, 0x64, 0x64, 0x18, 0x03,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e,
0x41, 0x64, 0x64, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, 0x31, 0x0a, 0x09, 0x6c, 0x6f, 0x6f, 0x6b,
0x61, 0x73, 0x69, 0x64, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x72,
0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x61, 0x73, 0x69, 0x64, 0x65,
0x52, 0x09, 0x6c, 0x6f, 0x6f, 0x6b, 0x61, 0x73, 0x69, 0x64, 0x65, 0x12, 0x35, 0x0a, 0x0b, 0x73,
0x70, 0x65, 0x63, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x14, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x53, 0x70, 0x65, 0x63,
0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x63, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x06, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x50, 0x61, 0x74,
0x63, 0x68, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f, 0x63, 0x6b, 0x79, 0x2d, 0x6c, 0x69,
0x6e, 0x75, 0x78, 0x2f, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2f, 0x70, 0x62, 0x3b,
0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

249
pb/response.pb.go Normal file
View File

@ -0,0 +1,249 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.19.3
// source: response.proto
package srpmprocpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type VersionRelease struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
Release string `protobuf:"bytes,2,opt,name=release,proto3" json:"release,omitempty"`
}
func (x *VersionRelease) Reset() {
*x = VersionRelease{}
if protoimpl.UnsafeEnabled {
mi := &file_response_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *VersionRelease) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VersionRelease) ProtoMessage() {}
func (x *VersionRelease) ProtoReflect() protoreflect.Message {
mi := &file_response_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VersionRelease.ProtoReflect.Descriptor instead.
func (*VersionRelease) Descriptor() ([]byte, []int) {
return file_response_proto_rawDescGZIP(), []int{0}
}
func (x *VersionRelease) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
func (x *VersionRelease) GetRelease() string {
if x != nil {
return x.Release
}
return ""
}
type ProcessResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
BranchCommits map[string]string `protobuf:"bytes,1,rep,name=branch_commits,json=branchCommits,proto3" json:"branch_commits,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
BranchVersions map[string]*VersionRelease `protobuf:"bytes,2,rep,name=branch_versions,json=branchVersions,proto3" json:"branch_versions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *ProcessResponse) Reset() {
*x = ProcessResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_response_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ProcessResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ProcessResponse) ProtoMessage() {}
func (x *ProcessResponse) ProtoReflect() protoreflect.Message {
mi := &file_response_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ProcessResponse.ProtoReflect.Descriptor instead.
func (*ProcessResponse) Descriptor() ([]byte, []int) {
return file_response_proto_rawDescGZIP(), []int{1}
}
func (x *ProcessResponse) GetBranchCommits() map[string]string {
if x != nil {
return x.BranchCommits
}
return nil
}
func (x *ProcessResponse) GetBranchVersions() map[string]*VersionRelease {
if x != nil {
return x.BranchVersions
}
return nil
}
var File_response_proto protoreflect.FileDescriptor
var file_response_proto_rawDesc = []byte{
0x0a, 0x0e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x08, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x22, 0x44, 0x0a, 0x0e, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
0x22, 0xdd, 0x02, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x63,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x73,
0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x43, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0d, 0x62, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x56, 0x0a, 0x0f, 0x62, 0x72, 0x61,
0x6e, 0x63, 0x68, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x50, 0x72,
0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x72,
0x61, 0x6e, 0x63, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x52, 0x0e, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x73, 0x1a, 0x40, 0x0a, 0x12, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x43, 0x6f, 0x6d, 0x6d, 0x69,
0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x1a, 0x5b, 0x0a, 0x13, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x72,
0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72,
0x6f, 0x63, 0x6b, 0x79, 0x2d, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2f, 0x73, 0x72, 0x70, 0x6d, 0x70,
0x72, 0x6f, 0x63, 0x2f, 0x70, 0x62, 0x3b, 0x73, 0x72, 0x70, 0x6d, 0x70, 0x72, 0x6f, 0x63, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_response_proto_rawDescOnce sync.Once
file_response_proto_rawDescData = file_response_proto_rawDesc
)
func file_response_proto_rawDescGZIP() []byte {
file_response_proto_rawDescOnce.Do(func() {
file_response_proto_rawDescData = protoimpl.X.CompressGZIP(file_response_proto_rawDescData)
})
return file_response_proto_rawDescData
}
var file_response_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_response_proto_goTypes = []interface{}{
(*VersionRelease)(nil), // 0: srpmproc.VersionRelease
(*ProcessResponse)(nil), // 1: srpmproc.ProcessResponse
nil, // 2: srpmproc.ProcessResponse.BranchCommitsEntry
nil, // 3: srpmproc.ProcessResponse.BranchVersionsEntry
}
var file_response_proto_depIdxs = []int32{
2, // 0: srpmproc.ProcessResponse.branch_commits:type_name -> srpmproc.ProcessResponse.BranchCommitsEntry
3, // 1: srpmproc.ProcessResponse.branch_versions:type_name -> srpmproc.ProcessResponse.BranchVersionsEntry
0, // 2: srpmproc.ProcessResponse.BranchVersionsEntry.value:type_name -> srpmproc.VersionRelease
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_response_proto_init() }
func file_response_proto_init() {
if File_response_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_response_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VersionRelease); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_response_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ProcessResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_response_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_response_proto_goTypes,
DependencyIndexes: file_response_proto_depIdxs,
MessageInfos: file_response_proto_msgTypes,
}.Build()
File_response_proto = out.File
file_response_proto_rawDesc = nil
file_response_proto_goTypes = nil
file_response_proto_depIdxs = nil
}

View File

@ -21,7 +21,7 @@
package blob
type Storage interface {
Write(path string, content []byte)
Read(path string) []byte
Exists(path string) bool
Write(path string, content []byte) error
Read(path string) ([]byte, error)
Exists(path string) (bool, error)
}

View File

@ -21,8 +21,8 @@
package file
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
@ -37,38 +37,50 @@ func New(path string) *File {
}
}
func (f *File) Write(path string, content []byte) {
w, err := os.OpenFile(filepath.Join(f.path, path), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
func (f *File) Write(path string, content []byte) error {
w, err := os.OpenFile(filepath.Join(f.path, path), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0o644)
if err != nil {
log.Fatalf("could not open file: %v", err)
return fmt.Errorf("could not open file: %v", err)
}
_, err = w.Write(content)
if err != nil {
log.Fatalf("could not write file to file: %v", err)
return fmt.Errorf("could not write file to file: %v", err)
}
// Close, just like writing a file.
if err := w.Close(); err != nil {
log.Fatalf("could not close file writer to source: %v", err)
return fmt.Errorf("could not close file writer to source: %v", err)
}
return nil
}
func (f *File) Read(path string) []byte {
r, err := os.OpenFile(filepath.Join(f.path, path), os.O_RDONLY, 0644)
func (f *File) Read(path string) ([]byte, error) {
r, err := os.OpenFile(filepath.Join(f.path, path), os.O_RDONLY, 0o644)
if err != nil {
return nil
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
body, err := ioutil.ReadAll(r)
if err != nil {
return nil
return nil, err
}
return body
return body, nil
}
func (f *File) Exists(path string) bool {
func (f *File) Exists(path string) (bool, error) {
_, err := os.Stat(filepath.Join(f.path, path))
return !os.IsNotExist(err)
if !os.IsNotExist(err) {
if !os.IsExist(err) {
return false, err
}
return true, nil
}
return false, nil
}

View File

@ -21,64 +21,67 @@
package gcs
import (
"cloud.google.com/go/storage"
"context"
"fmt"
"io/ioutil"
"log"
"cloud.google.com/go/storage"
)
type GCS struct {
bucket *storage.BucketHandle
}
func New(name string) *GCS {
func New(name string) (*GCS, error) {
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
log.Fatalf("could not create gcloud client: %v", err)
return nil, fmt.Errorf("could not create gcloud client: %v", err)
}
return &GCS{
bucket: client.Bucket(name),
}
}, nil
}
func (g *GCS) Write(path string, content []byte) {
func (g *GCS) Write(path string, content []byte) error {
ctx := context.Background()
obj := g.bucket.Object(path)
w := obj.NewWriter(ctx)
_, err := w.Write(content)
if err != nil {
log.Fatalf("could not write file to gcs: %v", err)
return fmt.Errorf("could not write file to gcs: %v", err)
}
// Close, just like writing a file.
if err := w.Close(); err != nil {
log.Fatalf("could not close gcs writer to source: %v", err)
return fmt.Errorf("could not close gcs writer to source: %v", err)
}
return nil
}
func (g *GCS) Read(path string) []byte {
func (g *GCS) Read(path string) ([]byte, error) {
ctx := context.Background()
obj := g.bucket.Object(path)
r, err := obj.NewReader(ctx)
if err != nil {
return nil
return nil, err
}
body, err := ioutil.ReadAll(r)
if err != nil {
return nil
return nil, err
}
return body
return body, nil
}
func (g *GCS) Exists(path string) bool {
func (g *GCS) Exists(path string) (bool, error) {
ctx := context.Background()
obj := g.bucket.Object(path)
_, err := obj.NewReader(ctx)
return err == nil
return err == nil, nil
}

View File

@ -22,12 +22,15 @@ package s3
import (
"bytes"
"io/ioutil"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"io/ioutil"
"log"
"github.com/spf13/viper"
)
type S3 struct {
@ -36,7 +39,29 @@ type S3 struct {
}
func New(name string) *S3 {
sess := session.Must(session.NewSession())
awsCfg := &aws.Config{}
if accessKey := viper.GetString("s3-access-key"); accessKey != "" {
awsCfg.Credentials = credentials.NewStaticCredentials(accessKey, viper.GetString("s3-secret-key"), "")
}
if endpoint := viper.GetString("s3-endpoint"); endpoint != "" {
awsCfg.Endpoint = aws.String(endpoint)
}
if region := viper.GetString("s3-region"); region != "" {
awsCfg.Region = aws.String(region)
}
if disableSsl := viper.GetBool("s3-disable-ssl"); disableSsl {
awsCfg.DisableSSL = aws.Bool(true)
}
if forcePathStyle := viper.GetBool("s3-force-path-style"); forcePathStyle {
awsCfg.S3ForcePathStyle = aws.Bool(true)
}
sess := session.Must(session.NewSession(awsCfg))
uploader := s3manager.NewUploader(sess)
return &S3{
@ -45,7 +70,7 @@ func New(name string) *S3 {
}
}
func (s *S3) Write(path string, content []byte) {
func (s *S3) Write(path string, content []byte) error {
buf := bytes.NewBuffer(content)
_, err := s.uploader.Upload(&s3manager.UploadInput{
@ -54,31 +79,38 @@ func (s *S3) Write(path string, content []byte) {
Body: buf,
})
if err != nil {
log.Fatalf("failed to upload file to s3, %v", err)
return err
}
return nil
}
func (s *S3) Read(path string) []byte {
func (s *S3) Read(path string) ([]byte, error) {
obj, err := s.uploader.S3.GetObject(&s3.GetObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(path),
})
if err != nil {
return nil
s3err, ok := err.(awserr.Error)
if !ok || s3err.Code() != s3.ErrCodeNoSuchKey {
return nil, err
}
return nil, nil
}
body, err := ioutil.ReadAll(obj.Body)
if err != nil {
return nil
return nil, err
}
return body
return body, nil
}
func (s *S3) Exists(path string) bool {
func (s *S3) Exists(path string) (bool, error) {
_, err := s.uploader.S3.GetObject(&s3.GetObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(path),
})
return err == nil
return err == nil, nil
}

View File

@ -21,22 +21,22 @@
package data
import (
"github.com/cavaliercoder/go-rpm"
"github.com/go-git/go-git/v5"
"hash"
"github.com/go-git/go-git/v5"
)
type ImportMode interface {
RetrieveSource(pd *ProcessData) *ModeData
WriteSource(pd *ProcessData, md *ModeData)
PostProcess(md *ModeData)
RetrieveSource(pd *ProcessData) (*ModeData, error)
WriteSource(pd *ProcessData, md *ModeData) error
PostProcess(md *ModeData) error
ImportName(pd *ProcessData, md *ModeData) string
}
type ModeData struct {
Name string
Repo *git.Repository
Worktree *git.Worktree
RpmFile *rpm.PackageFile
FileWrites map[string][]byte
TagBranch string
PushBranch string

View File

@ -21,16 +21,18 @@
package data
import (
"log"
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/rocky-linux/srpmproc/pkg/blob"
)
type FsCreatorFunc func(branch string) (billy.Filesystem, error)
type ProcessData struct {
RpmLocation string
UpstreamPrefix string
SshKeyLocation string
SshUser string
Version int
GitCommitterName string
GitCommitterEmail string
@ -39,7 +41,7 @@ type ProcessData struct {
ImportBranchPrefix string
BranchPrefix string
SingleTag string
Authenticator *ssh.PublicKeys
Authenticator transport.AuthMethod
Importer ImportMode
BlobStorage blob.Storage
NoDupMode bool
@ -48,8 +50,15 @@ type ProcessData struct {
NoStorageDownload bool
NoStorageUpload bool
ManualCommits []string
UpstreamPrefixHttps string
ModuleFallbackStream string
AllowStreamBranches bool
FsCreator func(branch string) billy.Filesystem
BranchSuffix string
StrictBranchMode bool
FsCreator FsCreatorFunc
CdnUrl string
Log *log.Logger
PackageVersion string
PackageRelease string
TaglessMode bool
Cdn string
ModuleBranchNames bool
}

View File

@ -26,45 +26,51 @@ import (
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"github.com/go-git/go-billy/v5"
"fmt"
"hash"
"io"
"log"
"os"
"path/filepath"
"github.com/go-git/go-billy/v5"
)
func CopyFromFs(from billy.Filesystem, to billy.Filesystem, path string) {
func CopyFromFs(from billy.Filesystem, to billy.Filesystem, path string) error {
read, err := from.ReadDir(path)
if err != nil {
log.Fatalf("could not read dir: %v", err)
return fmt.Errorf("could not read dir: %v", err)
}
for _, fi := range read {
fullPath := filepath.Join(path, fi.Name())
if fi.IsDir() {
_ = to.MkdirAll(fullPath, 0755)
CopyFromFs(from, to, fullPath)
_ = to.MkdirAll(fullPath, 0o755)
err := CopyFromFs(from, to, fullPath)
if err != nil {
return err
}
} else {
_ = to.Remove(fullPath)
f, err := to.OpenFile(fullPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, fi.Mode())
if err != nil {
log.Fatalf("could not open file: %v", err)
return fmt.Errorf("could not open file: %v", err)
}
oldFile, err := from.Open(fullPath)
if err != nil {
log.Fatalf("could not open from file: %v", err)
return fmt.Errorf("could not open from file: %v", err)
}
_, err = io.Copy(f, oldFile)
if err != nil {
log.Fatalf("could not copy from oldFile to new: %v", err)
return fmt.Errorf("could not copy from oldFile to new: %v", err)
}
}
}
return nil
}
func IgnoredContains(a []*IgnoredSource, b string) bool {
@ -87,9 +93,9 @@ func StrContains(a []string, b string) bool {
return false
}
// check if content and checksum matches
// CompareHash checks if content and checksum matches
// returns the hash type if success else nil
func CompareHash(content []byte, checksum string) hash.Hash {
func (pd *ProcessData) CompareHash(content []byte, checksum string) hash.Hash {
var hashType hash.Hash
switch len(checksum) {
@ -117,7 +123,7 @@ func CompareHash(content []byte, checksum string) hash.Hash {
calculated := hex.EncodeToString(hashType.Sum(nil))
if calculated != checksum {
log.Printf("wanted checksum %s, but got %s", checksum, calculated)
pd.Log.Printf("wanted checksum %s, but got %s", checksum, calculated)
return nil
}

View File

@ -28,8 +28,8 @@ import (
"path/filepath"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
// returns right if not empty, else left
@ -50,7 +50,7 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree
case *srpmprocpb.Add_File:
filePath = checkAddPrefix(eitherString(filepath.Base(addType.File), add.Name))
fPatch, err := patchTree.Filesystem.OpenFile(addType.File, os.O_RDONLY, 0644)
fPatch, err := patchTree.Filesystem.OpenFile(addType.File, os.O_RDONLY, 0o644)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FROM:%s", addType.File))
}
@ -62,9 +62,13 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree
break
case *srpmprocpb.Add_Lookaside:
filePath = checkAddPrefix(eitherString(filepath.Base(addType.Lookaside), add.Name))
replacingBytes = pd.BlobStorage.Read(addType.Lookaside)
var err error
replacingBytes, err = pd.BlobStorage.Read(addType.Lookaside)
if err != nil {
return err
}
hashFunction := data.CompareHash(replacingBytes, addType.Lookaside)
hashFunction := pd.CompareHash(replacingBytes, addType.Lookaside)
if hashFunction == nil {
return errors.New(fmt.Sprintf("LOOKASIDE_HASH_DOES_NOT_MATCH:%s", addType.Lookaside))
}
@ -76,7 +80,7 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree
break
}
f, err := pushTree.Filesystem.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f, err := pushTree.Filesystem.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_DESTINATION:%s", filePath))
}

View File

@ -25,8 +25,8 @@ import (
"fmt"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func del(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, _ *git.Worktree, pushTree *git.Worktree) error {

View File

@ -21,15 +21,12 @@
package directives
import (
"encoding/json"
"log"
"os"
"path/filepath"
"strings"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func checkAddPrefix(file string) string {
@ -41,8 +38,8 @@ func checkAddPrefix(file string) string {
return filepath.Join("SOURCES", file)
}
func Apply(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) {
var errs []string
func Apply(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) []error {
var errs []error
directives := []func(*srpmprocpb.Cfg, *data.ProcessData, *data.ModeData, *git.Worktree, *git.Worktree) error{
replace,
@ -56,16 +53,13 @@ func Apply(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTr
for _, directive := range directives {
err := directive(cfg, pd, md, patchTree, pushTree)
if err != nil {
errs = append(errs, err.Error())
errs = append(errs, err)
}
}
if len(errs) > 0 {
err := json.NewEncoder(os.Stdout).Encode(errs)
if err != nil {
log.Fatal(errs)
}
os.Exit(1)
return errs
}
return nil
}

View File

@ -33,8 +33,8 @@ import (
"time"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
@ -128,7 +128,7 @@ func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patc
}
path := filepath.Join("SOURCES", fmt.Sprintf("%s.tar.gz", directive.ArchiveName))
pushF, err := pushTree.Filesystem.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
pushF, err := pushTree.Filesystem.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0o644)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_CREATE_TAR_FILE:%s", path))
}

View File

@ -24,15 +24,14 @@ import (
"bytes"
"errors"
"fmt"
"log"
"github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
func patch(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
for _, patch := range cfg.Patch {
patchFile, err := patchTree.Filesystem.Open(patch.File)
if err != nil {
@ -40,7 +39,7 @@ func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree
}
files, _, err := gitdiff.Parse(patchFile)
if err != nil {
log.Printf("could not parse patch file: %v", err)
pd.Log.Printf("could not parse patch file: %v", err)
return errors.New(fmt.Sprintf("COULD_NOT_PARSE_PATCH_FILE:%s", patch.File))
}
@ -58,7 +57,7 @@ func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree
err = gitdiff.NewApplier(patchSubjectFile).ApplyFile(&output, patchedFile)
if err != nil {
log.Printf("could not apply patch: %v", err)
pd.Log.Printf("could not apply patch: %v", err)
return errors.New(fmt.Sprintf("COULD_NOT_APPLY_PATCH_WITH_SUBJECT:%s", srcPath))
}
}

View File

@ -27,8 +27,8 @@ import (
"os"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
@ -51,7 +51,7 @@ func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchT
switch replacing := replace.Replacing.(type) {
case *srpmprocpb.Replace_WithFile:
fPatch, err := patchTree.Filesystem.OpenFile(replacing.WithFile, os.O_RDONLY, 0644)
fPatch, err := patchTree.Filesystem.OpenFile(replacing.WithFile, os.O_RDONLY, 0o644)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_REPLACING:%s", replacing.WithFile))
}
@ -73,13 +73,16 @@ func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchT
}
break
case *srpmprocpb.Replace_WithLookaside:
bts := pd.BlobStorage.Read(replacing.WithLookaside)
hasher := data.CompareHash(bts, replacing.WithLookaside)
bts, err := pd.BlobStorage.Read(replacing.WithLookaside)
if err != nil {
return err
}
hasher := pd.CompareHash(bts, replacing.WithLookaside)
if hasher == nil {
return errors.New("LOOKASIDE_FILE_AND_HASH_NOT_MATCHING")
}
_, err := f.Write(bts)
_, err = f.Write(bts)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_WRITE_LOOKASIDE:%s", filePath))
}

View File

@ -33,17 +33,15 @@ import (
"time"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
const (
sectionChangelog = "%changelog"
)
var (
sections = []string{"%description", "%prep", "%build", "%install", "%files", "%changelog"}
)
var sections = []string{"%description", "%prep", "%build", "%install", "%files", "%changelog"}
type sourcePatchOperationInLoopRequest struct {
cfg *srpmprocpb.Cfg
@ -105,7 +103,7 @@ func sourcePatchOperationAfterLoop(req *sourcePatchOperationAfterLoopRequest) (b
case *srpmprocpb.SpecChange_FileOperation_Add:
fieldNum := *req.lastNum + 1
field := fmt.Sprintf("%s%d", req.expectedField, fieldNum)
spaces := calculateSpaces(req.longestField, len(field))
spaces := calculateSpaces(req.longestField, len(field), req.cfg.SpecChange.DisableAutoAlign)
*req.newLines = append(*req.newLines, fmt.Sprintf("%s:%s%s", field, spaces, file.Name))
if req.expectedField == "Patch" && file.AddToPrep {
@ -132,7 +130,10 @@ func sourcePatchOperationAfterLoop(req *sourcePatchOperationAfterLoopRequest) (b
return false, nil
}
func calculateSpaces(longestField int, fieldLength int) string {
func calculateSpaces(longestField int, fieldLength int, disableAutoAlign bool) string {
if disableAutoAlign {
return " "
}
return strings.Repeat(" ", longestField+8-fieldLength)
}
@ -209,7 +210,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
return errors.New("COULD_NOT_STAT_SPEC_FILE")
}
specFile, err := pushTree.Filesystem.OpenFile(filePath, os.O_RDONLY, 0644)
specFile, err := pushTree.Filesystem.OpenFile(filePath, os.O_RDONLY, 0o644)
if err != nil {
return errors.New("COULD_NOT_READ_SPEC_FILE")
}
@ -234,7 +235,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
hasPatch := false
version := ""
importName := strings.Replace(pd.Importer.ImportName(pd, md), md.RpmFile.Name(), "1", 1)
importName := strings.Replace(pd.Importer.ImportName(pd, md), md.Name, "1", 1)
importNameSplit := strings.SplitN(importName, "-", 2)
if len(importNameSplit) == 2 {
versionSplit := strings.SplitN(importNameSplit[1], ".el", 2)
@ -284,7 +285,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
for field, nfm := range newFieldMemory {
for value, lineNum := range nfm {
if lineNum != 0 {
newLine := fmt.Sprintf("%s:%s%s", field, calculateSpaces(longestField, len(field)), value)
newLine := fmt.Sprintf("%s:%s%s", field, calculateSpaces(longestField, len(field), cfg.SpecChange.DisableAutoAlign), value)
setFASlice(futureAdditions, lineNum+1, newLine)
}
}
@ -339,7 +340,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
}
}
spaces := calculateSpaces(longestField, len(field))
spaces := calculateSpaces(longestField, len(field), cfg.SpecChange.DisableAutoAlign)
err := sourcePatchOperationInLoop(&sourcePatchOperationInLoopRequest{
cfg: cfg,
@ -410,7 +411,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
var innerNewLines []string
for field, nfm := range newFieldMemory {
for value, ln := range nfm {
newLine := fmt.Sprintf("%s:%s%s", field, calculateSpaces(longestField, len(field)), value)
newLine := fmt.Sprintf("%s:%s%s", field, calculateSpaces(longestField, len(field), cfg.SpecChange.DisableAutoAlign), value)
if ln == 0 {
if isNextLineSection(lineNum, lines) {
innerNewLines = append(innerNewLines, newLine)

53
pkg/misc/regex.go Normal file
View File

@ -0,0 +1,53 @@
package misc
import (
"fmt"
"path/filepath"
"regexp"
"strings"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func GetTagImportRegex(pd *data.ProcessData) *regexp.Regexp {
branchRegex := regexp.QuoteMeta(fmt.Sprintf("%s%d%s", pd.ImportBranchPrefix, pd.Version, pd.BranchSuffix))
if !pd.StrictBranchMode {
branchRegex += "(?:.+|)"
} else {
branchRegex += "(?:-stream-.+|)"
}
initialVerRegex := regexp.QuoteMeta(filepath.Base(pd.RpmLocation)) + "-"
if pd.PackageVersion != "" {
initialVerRegex += regexp.QuoteMeta(pd.PackageVersion) + "-"
} else {
initialVerRegex += ".+-"
}
if pd.PackageRelease != "" {
initialVerRegex += regexp.QuoteMeta(pd.PackageRelease)
} else {
initialVerRegex += ".+"
}
regex := fmt.Sprintf("(?i)refs/tags/(imports/(%s)/(%s))", branchRegex, initialVerRegex)
return regexp.MustCompile(regex)
}
// Given a git reference in tagless mode (like "refs/heads/c9s", or "refs/heads/stream-httpd-2.4-rhel-9.1.0"), determine
// if we are ok with importing that reference. We are looking for the traditional <prefix><version><suffix> pattern, like "c9s", and also the
// modular "stream-<NAME>-<VERSION>-rhel-<VERSION> branch pattern as well
func TaglessRefOk(tag string, pd *data.ProcessData) bool {
// First case is very easy: if we are exactly "refs/heads/<prefix><version><suffix>" , then this is def. a branch we should import
if tag == fmt.Sprintf("refs/heads/%s%d%s", pd.ImportBranchPrefix, pd.Version, pd.BranchSuffix) {
return true
}
// Less easy: if a modular branch is present (starts w/ "stream-"), we need to check if it's part of our major version, and return true if it is
// (major version means we look for the text "rhel-X." in the branch name, like "rhel-9.1.0")
if strings.HasPrefix(tag, "refs/heads/stream-") && strings.Contains(tag, fmt.Sprintf("rhel-%d.", pd.Version)) {
return true
}
return false
}

520
pkg/modes/git.go Normal file
View File

@ -0,0 +1,520 @@
// Copyright (c) 2021 The Srpmproc Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package modes
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"path/filepath"
"sort"
"strings"
"text/template"
"time"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/rocky-linux/srpmproc/pkg/misc"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/pkg/data"
)
type remoteTarget struct {
remote string
when time.Time
}
// Struct to define the possible template values ( {{.Value}} in CDN URL strings:
type Lookaside struct {
Name string
Branch string
Hash string
Hashtype string
Filename string
}
type remoteTargetSlice []remoteTarget
func (p remoteTargetSlice) Len() int {
return len(p)
}
func (p remoteTargetSlice) Less(i, j int) bool {
return p[i].when.Before(p[j].when)
}
func (p remoteTargetSlice) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
type GitMode struct{}
func (g *GitMode) RetrieveSource(pd *data.ProcessData) (*data.ModeData, error) {
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
return nil, fmt.Errorf("could not init git Repo: %v", err)
}
w, err := repo.Worktree()
if err != nil {
return nil, fmt.Errorf("could not get Worktree: %v", err)
}
refspec := config.RefSpec("+refs/heads/*:refs/remotes/*")
remote, err := repo.CreateRemote(&config.RemoteConfig{
Name: "upstream",
URLs: []string{fmt.Sprintf("%s.git", pd.RpmLocation)},
Fetch: []config.RefSpec{refspec},
})
if err != nil {
return nil, fmt.Errorf("could not create remote: %v", err)
}
fetchOpts := &git.FetchOptions{
Auth: pd.Authenticator,
RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags,
Force: true,
}
err = remote.Fetch(fetchOpts)
if err != nil {
if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired {
fetchOpts.Auth = nil
err = remote.Fetch(fetchOpts)
if err != nil {
return nil, fmt.Errorf("could not fetch upstream: %v", err)
}
} else {
return nil, fmt.Errorf("could not fetch upstream: %v", err)
}
}
var branches remoteTargetSlice
latestTags := map[string]*remoteTarget{}
tagAdd := func(tag *object.Tag) error {
if strings.HasPrefix(tag.Name, fmt.Sprintf("imports/%s%d", pd.ImportBranchPrefix, pd.Version)) {
refSpec := fmt.Sprintf("refs/tags/%s", tag.Name)
if misc.GetTagImportRegex(pd).MatchString(refSpec) {
match := misc.GetTagImportRegex(pd).FindStringSubmatch(refSpec)
exists := latestTags[match[2]]
if exists != nil && exists.when.After(tag.Tagger.When) {
return nil
}
latestTags[match[2]] = &remoteTarget{
remote: refSpec,
when: tag.Tagger.When,
}
}
}
return nil
}
// In case of "tagless mode", we need to get the head ref of the branch instead
// This is a kind of alternative implementation of the above tagAdd assignment
refAdd := func(tag *object.Tag) error {
if misc.TaglessRefOk(tag.Name, pd) {
pd.Log.Printf("Tagless mode: Identified tagless commit for import: %s\n", tag.Name)
refSpec := fmt.Sprintf(tag.Name)
// We split the string by "/", the branch name we're looking for to pass to latestTags is always last
// (ex: "refs/heads/c9s" ---> we want latestTags[c9s]
tmpRef := strings.Split(refSpec, "/")
tmpBranchName := tmpRef[(len(tmpRef) - 1)]
latestTags[tmpBranchName] = &remoteTarget{
remote: refSpec,
when: tag.Tagger.When,
}
}
return nil
}
tagIter, err := repo.TagObjects()
if err != nil {
return nil, fmt.Errorf("could not get tag objects: %v", err)
}
// tagless mode means we use "refAdd" (add commit by reference)
// normal mode means we can rely on "tagAdd" (the tag should be present for us in the source repo)
if pd.TaglessMode {
_ = tagIter.ForEach(refAdd)
} else {
_ = tagIter.ForEach(tagAdd)
}
listOpts := &git.ListOptions{
Auth: pd.Authenticator,
}
list, err := remote.List(listOpts)
if err != nil {
if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired {
listOpts.Auth = nil
list, err = remote.List(listOpts)
if err != nil {
return nil, fmt.Errorf("could not list upstream: %v", err)
}
} else {
return nil, fmt.Errorf("could not list upstream: %v", err)
}
}
for _, ref := range list {
if ref.Hash().IsZero() {
continue
}
commit, err := repo.CommitObject(ref.Hash())
if err != nil {
continue
}
// Call refAdd instead of tagAdd in the case of TaglessMode enabled
if pd.TaglessMode {
_ = refAdd(&object.Tag{
Name: string(ref.Name()),
Tagger: commit.Committer,
})
} else {
_ = tagAdd(&object.Tag{
Name: strings.TrimPrefix(string(ref.Name()), "refs/tags/"),
Tagger: commit.Committer,
})
}
}
for _, branch := range latestTags {
pd.Log.Printf("tag: %s", strings.TrimPrefix(branch.remote, "refs/tags/"))
branches = append(branches, *branch)
}
sort.Sort(branches)
var sortedBranches []string
for _, branch := range branches {
sortedBranches = append(sortedBranches, branch.remote)
}
return &data.ModeData{
Name: filepath.Base(pd.RpmLocation),
Repo: repo,
Worktree: w,
FileWrites: nil,
Branches: sortedBranches,
}, nil
}
func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
remote, err := md.Repo.Remote("upstream")
if err != nil && !pd.TaglessMode {
return fmt.Errorf("could not get upstream remote: %v", err)
}
var refspec config.RefSpec
var branchName string
// In the case of tagless mode, we already have the transformed repo sitting in the worktree,
// and don't need to perform any checkout or fetch operations
if !pd.TaglessMode {
if strings.HasPrefix(md.TagBranch, "refs/heads") {
refspec = config.RefSpec(fmt.Sprintf("+%s:%s", md.TagBranch, md.TagBranch))
branchName = strings.TrimPrefix(md.TagBranch, "refs/heads/")
} else {
match := misc.GetTagImportRegex(pd).FindStringSubmatch(md.TagBranch)
branchName = match[2]
refspec = config.RefSpec(fmt.Sprintf("+refs/heads/%s:%s", branchName, md.TagBranch))
fmt.Println("Found branchname that does not start w/ refs/heads :: ", branchName)
}
pd.Log.Printf("checking out upstream refspec %s", refspec)
fetchOpts := &git.FetchOptions{
Auth: pd.Authenticator,
RemoteName: "upstream",
RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags,
Force: true,
}
err = remote.Fetch(fetchOpts)
if err != nil && err != git.NoErrAlreadyUpToDate {
if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired {
fetchOpts.Auth = nil
err = remote.Fetch(fetchOpts)
if err != nil && err != git.NoErrAlreadyUpToDate {
return fmt.Errorf("could not fetch upstream: %v", err)
}
} else {
return fmt.Errorf("could not fetch upstream: %v", err)
}
}
err = md.Worktree.Checkout(&git.CheckoutOptions{
Branch: plumbing.ReferenceName(md.TagBranch),
Force: true,
})
if err != nil {
return fmt.Errorf("could not checkout source from git: %v", err)
}
_, err = md.Worktree.Add(".")
if err != nil {
return fmt.Errorf("could not add Worktree: %v", err)
}
}
if pd.TaglessMode {
branchName = fmt.Sprintf("%s%d%s", pd.ImportBranchPrefix, pd.Version, pd.BranchSuffix)
}
metadataPath := ""
ls, err := md.Worktree.Filesystem.ReadDir(".")
if err != nil {
return fmt.Errorf("could not read directory: %v", err)
}
for _, f := range ls {
if strings.HasSuffix(f.Name(), ".metadata") {
if metadataPath != "" {
return fmt.Errorf("multiple metadata files found")
}
metadataPath = f.Name()
}
}
if metadataPath == "" {
metadataPath = fmt.Sprintf(".%s.metadata", md.Name)
}
metadataFile, err := md.Worktree.Filesystem.Open(metadataPath)
if err != nil {
pd.Log.Printf("warn: could not open metadata file, so skipping: %v", err)
return nil
}
fileBytes, err := ioutil.ReadAll(metadataFile)
if err != nil {
return fmt.Errorf("could not read metadata file: %v", err)
}
client := &http.Client{
Transport: &http.Transport{
DisableCompression: false,
},
}
fileContent := strings.Split(string(fileBytes), "\n")
for _, line := range fileContent {
if strings.TrimSpace(line) == "" {
continue
}
lineInfo := strings.SplitN(line, " ", 2)
hash := strings.TrimSpace(lineInfo[0])
path := strings.TrimSpace(lineInfo[1])
var body []byte
if md.BlobCache[hash] != nil {
body = md.BlobCache[hash]
pd.Log.Printf("retrieving %s from cache", hash)
} else {
fromBlobStorage, err := pd.BlobStorage.Read(hash)
if err != nil {
return err
}
if fromBlobStorage != nil && !pd.NoStorageDownload {
body = fromBlobStorage
pd.Log.Printf("downloading %s from blob storage", hash)
} else {
url := ""
// We need to figure out the hashtype for templating purposes:
hashType := "sha512"
switch len(hash) {
case 128:
hashType = "sha512"
case 64:
hashType = "sha256"
case 40:
hashType = "sha1"
case 32:
hashType = "md5"
}
// need the name of the file without "SOURCES/":
fileName := strings.Split(path, "/")[1]
// Feed our template info to ProcessUrl and transform to the real values: ( {{.Name}}, {{.Branch}}, {{.Hash}}, {{.Hashtype}}, {{.Filename}} )
url, hasTemplate := ProcessUrl(pd.CdnUrl, md.Name, branchName, hash, hashType, fileName)
var req *http.Request
var resp *http.Response
// Download the --cdn-url given, but *only* if it contains template strings ( {{.Name}} , {{.Hash}} , etc. )
// Otherwise we need to fall back to the traditional cdn-url patterns
if hasTemplate {
pd.Log.Printf("downloading %s", url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return fmt.Errorf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err = client.Do(req)
if err != nil {
return fmt.Errorf("could not download dist-git file: %v", err)
}
}
// Default cdn-url: If we don't have a templated download string, try the default <SITE>/<PKG>/<BRANCH>/<HASH> pattern:
if resp == nil || resp.StatusCode != http.StatusOK {
url = fmt.Sprintf("%s/%s/%s/%s", pd.CdnUrl, md.Name, branchName, hash)
pd.Log.Printf("Attempting default URL: %s", url)
req, err = http.NewRequest("GET", url, nil)
if err != nil {
return fmt.Errorf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err = client.Do(req)
if err != nil {
return fmt.Errorf("could not download dist-git file: %v", err)
}
}
// If the default URL fails, we have one more pattern to try. The simple <SITE>/<HASH> pattern
// If this one fails, we are truly lost, and have to bail out w/ an error:
if resp == nil || resp.StatusCode != http.StatusOK {
url = fmt.Sprintf("%s/%s", pd.CdnUrl, hash)
pd.Log.Printf("Attempting 2nd fallback URL: %s", url)
req, err = http.NewRequest("GET", url, nil)
if err != nil {
return fmt.Errorf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err = client.Do(req)
if err != nil {
return fmt.Errorf("could not download dist-git file: %v", err)
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("could not download dist-git file (status code %d): %v", resp.StatusCode, err)
}
}
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("could not read the whole dist-git file: %v", err)
}
err = resp.Body.Close()
if err != nil {
return fmt.Errorf("could not close body handle: %v", err)
}
}
md.BlobCache[hash] = body
}
f, err := md.Worktree.Filesystem.Create(path)
if err != nil {
return fmt.Errorf("could not open file pointer: %v", err)
}
hasher := pd.CompareHash(body, hash)
if hasher == nil {
return fmt.Errorf("checksum in metadata does not match dist-git file")
}
md.SourcesToIgnore = append(md.SourcesToIgnore, &data.IgnoredSource{
Name: path,
HashFunction: hasher,
})
_, err = f.Write(body)
if err != nil {
return fmt.Errorf("could not copy dist-git file to in-tree: %v", err)
}
_ = f.Close()
}
return nil
}
func (g *GitMode) PostProcess(md *data.ModeData) error {
for _, source := range md.SourcesToIgnore {
_, err := md.Worktree.Filesystem.Stat(source.Name)
if err == nil {
err := md.Worktree.Filesystem.Remove(source.Name)
if err != nil {
return fmt.Errorf("could not remove dist-git file: %v", err)
}
}
}
_, err := md.Worktree.Add(".")
if err != nil {
return fmt.Errorf("could not add git sources: %v", err)
}
return nil
}
func (g *GitMode) ImportName(pd *data.ProcessData, md *data.ModeData) string {
if misc.GetTagImportRegex(pd).MatchString(md.TagBranch) {
match := misc.GetTagImportRegex(pd).FindStringSubmatch(md.TagBranch)
return match[3]
}
return strings.Replace(strings.TrimPrefix(md.TagBranch, "refs/heads/"), "%", "_", -1)
}
// Given a cdnUrl string as input, return same string, but with substituted
// template values ( {{.Name}} , {{.Hash}}, {{.Filename}}, etc. )
func ProcessUrl(cdnUrl string, name string, branch string, hash string, hashtype string, filename string) (string, bool) {
tmpUrl := Lookaside{name, branch, hash, hashtype, filename}
// Return cdnUrl as-is if we don't have any templates ("{{ .Variable }}") to process:
if !(strings.Contains(cdnUrl, "{{") && strings.Contains(cdnUrl, "}}")) {
return cdnUrl, false
}
// If we run into trouble with our template parsing, we'll just return the cdnUrl, exactly as we found it
tmpl, err := template.New("").Parse(cdnUrl)
if err != nil {
return cdnUrl, false
}
var result bytes.Buffer
err = tmpl.Execute(&result, tmpUrl)
if err != nil {
log.Fatalf("ERROR: Could not process CDN URL template(s) from URL string: %s\n", cdnUrl)
}
return result.String(), true
}

6
pkg/rpmutils/regex.go Normal file
View File

@ -0,0 +1,6 @@
package rpmutils
import "regexp"
// Nvr is a regular expression that matches a NVR.
var Nvr = regexp.MustCompile("^(\\S+)-([\\w~%.+]+)-(\\w+(?:\\.[\\w~%+]+)+?)(?:\\.rpm)?$")

123
pkg/srpmproc/fetch.go Normal file
View File

@ -0,0 +1,123 @@
package srpmproc
import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"path/filepath"
"strings"
"github.com/go-git/go-billy/v5"
"github.com/rocky-linux/srpmproc/pkg/blob"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, storage blob.Storage) error {
pd := &data.ProcessData{
Log: log.New(logger, "", log.LstdFlags),
}
metadataPath := ""
ls, err := fs.ReadDir(dir)
if err != nil {
return err
}
for _, f := range ls {
if strings.HasSuffix(f.Name(), ".metadata") {
if metadataPath != "" {
return errors.New("multiple metadata files found")
}
metadataPath = filepath.Join(dir, f.Name())
}
}
if metadataPath == "" {
return errors.New("no metadata file found")
}
metadataFile, err := fs.Open(metadataPath)
if err != nil {
return fmt.Errorf("could not open metadata file: %v", err)
}
fileBytes, err := ioutil.ReadAll(metadataFile)
if err != nil {
return fmt.Errorf("could not read metadata file: %v", err)
}
client := &http.Client{
Transport: &http.Transport{
DisableCompression: false,
},
}
fileContent := strings.Split(string(fileBytes), "\n")
for _, line := range fileContent {
if strings.TrimSpace(line) == "" {
continue
}
lineInfo := strings.SplitN(line, " ", 2)
hash := strings.TrimSpace(lineInfo[0])
path := strings.TrimSpace(lineInfo[1])
url := fmt.Sprintf("%s/%s", cdnUrl, hash)
if storage != nil {
url = hash
}
pd.Log.Printf("downloading %s", url)
var body []byte
if storage != nil {
body, err = storage.Read(hash)
if err != nil {
return fmt.Errorf("could not read blob: %v", err)
}
} else {
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return fmt.Errorf("could not create new http request: %v", err)
}
req.Header.Set("Accept-Encoding", "*")
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("could not download dist-git file: %v", err)
}
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("could not read the whole dist-git file: %v", err)
}
err = resp.Body.Close()
if err != nil {
return fmt.Errorf("could not close body handle: %v", err)
}
}
hasher := pd.CompareHash(body, hash)
if hasher == nil {
return fmt.Errorf("checksum in metadata does not match dist-git file")
}
err = fs.MkdirAll(filepath.Join(dir, filepath.Dir(path)), 0o755)
if err != nil {
return fmt.Errorf("could not create all directories")
}
f, err := fs.Create(filepath.Join(dir, path))
if err != nil {
return fmt.Errorf("could not open file pointer: %v", err)
}
_, err = f.Write(body)
if err != nil {
return fmt.Errorf("could not copy dist-git file to in-tree: %v", err)
}
_ = f.Close()
}
return nil
}

View File

@ -18,36 +18,48 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"path/filepath"
"strings"
"time"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/rocky-linux/srpmproc/pkg/misc"
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/internal/directives"
"github.com/rocky-linux/srpmproc/modulemd"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
"github.com/rocky-linux/srpmproc/pkg/directives"
"google.golang.org/protobuf/encoding/prototext"
)
func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) {
func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
// check CFG patches
_, err := patchTree.Filesystem.Stat("ROCKY/CFG")
// use PATCHES directory if it exists otherwise ROCKY/CFG
cfgdir := "PATCHES"
_, err := patchTree.Filesystem.Stat(cfgdir)
if err != nil {
cfgdir = "ROCKY/CFG"
}
_, err = patchTree.Filesystem.Stat(cfgdir)
if err == nil {
// iterate through patches
infos, err := patchTree.Filesystem.ReadDir("ROCKY/CFG")
infos, err := patchTree.Filesystem.ReadDir(cfgdir)
if err != nil {
log.Fatalf("could not walk patches: %v", err)
return fmt.Errorf("could not walk patches: %v", err)
}
for _, info := range infos {
@ -56,48 +68,68 @@ func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree
continue
}
log.Printf("applying directive %s", info.Name())
filePath := filepath.Join("ROCKY/CFG", info.Name())
pd.Log.Printf("applying directive %s", info.Name())
filePath := filepath.Join(cfgdir, info.Name())
directive, err := patchTree.Filesystem.Open(filePath)
if err != nil {
log.Fatalf("could not open directive file %s: %v", info.Name(), err)
return fmt.Errorf("could not open directive file %s: %v", info.Name(), err)
}
directiveBytes, err := ioutil.ReadAll(directive)
directiveBytes, err := io.ReadAll(directive)
if err != nil {
log.Fatalf("could not read directive file: %v", err)
return fmt.Errorf("could not read directive file: %v", err)
}
var cfg srpmprocpb.Cfg
err = prototext.Unmarshal(directiveBytes, &cfg)
if err != nil {
log.Fatalf("could not unmarshal cfg file: %v", err)
return fmt.Errorf("could not unmarshal cfg file: %v", err)
}
directives.Apply(&cfg, pd, md, patchTree, pushTree)
errs := directives.Apply(&cfg, pd, md, patchTree, pushTree)
if errs != nil {
err := json.NewEncoder(os.Stdout).Encode(errs)
if err != nil {
return err
}
return fmt.Errorf("directives could not be applied")
}
}
}
return nil
}
func applyPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) {
func applyPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
// check if patches exist
_, err := patchTree.Filesystem.Stat("ROCKY")
if err == nil {
cfgPatches(pd, md, patchTree, pushTree)
cfgdir := "PATCHES"
_, err := patchTree.Filesystem.Stat(cfgdir)
if err != nil {
cfgdir = "ROCKY"
}
_, err = patchTree.Filesystem.Stat(cfgdir)
if err == nil {
err := cfgPatches(pd, md, patchTree, pushTree)
if err != nil {
return err
}
}
return nil
}
func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) {
func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) error {
// fetch patch repository
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
log.Fatalf("could not create new dist Repo: %v", err)
return fmt.Errorf("could not create new dist Repo: %v", err)
}
w, err := repo.Worktree()
if err != nil {
log.Fatalf("could not get dist Worktree: %v", err)
return fmt.Errorf("could not get dist Worktree: %v", err)
}
remoteUrl := fmt.Sprintf("%s/patch/%s.git", pd.UpstreamPrefix, gitlabify(md.RpmFile.Name()))
remoteUrl := fmt.Sprintf("%s/patch/%s.git", pd.UpstreamPrefix, gitlabify(md.Name))
refspec := config.RefSpec(fmt.Sprintf("+refs/heads/*:refs/remotes/origin/*"))
_, err = repo.CreateRemote(&config.RemoteConfig{
@ -106,10 +138,11 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) {
Fetch: []config.RefSpec{refspec},
})
if err != nil {
log.Fatalf("could not create remote: %v", err)
return fmt.Errorf("could not create remote: %v", err)
}
fetchOptions := &git.FetchOptions{
Auth: pd.Authenticator,
RemoteName: "origin",
RefSpecs: []config.RefSpec{refspec},
}
@ -119,41 +152,59 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) {
err = repo.Fetch(fetchOptions)
refName := plumbing.NewBranchReferenceName(md.PushBranch)
log.Printf("set reference to ref: %s", refName)
pd.Log.Printf("set reference to ref: %s", refName)
if err != nil {
// no patches active
log.Println("info: patch repo not found")
return
} else {
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", "main"),
Force: true,
})
// common patches found, apply them
if err == nil {
applyPatches(pd, md, w, md.Worktree)
if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired {
fetchOptions.Auth = nil
err = repo.Fetch(fetchOptions)
if err != nil {
// no patches active
log.Println("info: patch repo not found")
return nil
}
} else {
log.Println("info: no common patches found")
}
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch),
Force: true,
})
// branch specific patches found, apply them
if err == nil {
applyPatches(pd, md, w, md.Worktree)
} else {
log.Println("info: no branch specific patches found")
// no patches active
log.Println("info: patch repo not found")
return nil
}
}
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", "main"),
Force: true,
})
// common patches found, apply them
if err == nil {
err := applyPatches(pd, md, w, md.Worktree)
if err != nil {
return err
}
} else {
log.Println("info: no common patches found")
}
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch),
Force: true,
})
// branch specific patches found, apply them
if err == nil {
err := applyPatches(pd, md, w, md.Worktree)
if err != nil {
return err
}
} else {
log.Println("info: no branch specific patches found")
}
return nil
}
func getTipStream(pd *data.ProcessData, module string, pushBranch string, origPushBranch string, tries int) string {
func getTipStream(pd *data.ProcessData, module string, pushBranch string, origPushBranch string, tries int) (string, error) {
repo, err := git.Init(memory.NewStorage(), memfs.New())
if err != nil {
log.Fatalf("could not init git Repo: %v", err)
return "", fmt.Errorf("could not init git Repo: %v", err)
}
remoteUrl := fmt.Sprintf("%s/rpms/%s.git", pd.UpstreamPrefix, gitlabify(module))
@ -164,21 +215,21 @@ func getTipStream(pd *data.ProcessData, module string, pushBranch string, origPu
Fetch: []config.RefSpec{refspec},
})
if err != nil {
log.Fatalf("could not create remote: %v", err)
return "", fmt.Errorf("could not create remote: %v", err)
}
list, err := remote.List(&git.ListOptions{
Auth: pd.Authenticator,
})
if err != nil {
log.Printf("could not import module: %s", module)
pd.Log.Printf("could not import module: %s", module)
if tries < 3 {
log.Printf("could not get rpm refs. will retry in 3s. %v", err)
pd.Log.Printf("could not get rpm refs. will retry in 3s. %v", err)
time.Sleep(3 * time.Second)
return getTipStream(pd, module, pushBranch, origPushBranch, tries+1)
}
log.Fatalf("could not get rpm refs. import the rpm before the module: %v", err)
return "", fmt.Errorf("could not get rpm refs. import the rpm before the module: %v", err)
}
var tipHash string
@ -235,48 +286,82 @@ func getTipStream(pd *data.ProcessData, module string, pushBranch string, origPu
for _, ref := range list {
log.Println(pushBranch, ref.Name())
}
log.Fatal("could not find tip hash")
return "", fmt.Errorf("could not find tip hash")
}
return strings.TrimSpace(tipHash)
return strings.TrimSpace(tipHash), nil
}
func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) {
func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) error {
// special case for platform.yaml
_, err := md.Worktree.Filesystem.Open("platform.yaml")
if err == nil {
return
return nil
}
mdTxtPath := "SOURCES/modulemd.src.txt"
f, err := md.Worktree.Filesystem.Open(mdTxtPath)
if err != nil {
mdTxtPath = "SOURCES/modulemd.txt"
mdTxtPath := ""
var f billy.File
// tagless mode implies we're looking for CentOS Stream modules, which are generally "SOURCES/NAME.yaml" (copied to SOURCES/ from import)
// if not tagless mode, proceed as usual with SOURCES/modulemd.*.txt
if pd.TaglessMode {
mdTxtPath = fmt.Sprintf("SOURCES/%s.yaml", md.Name)
f, err = md.Worktree.Filesystem.Open(mdTxtPath)
if err != nil {
log.Fatalf("could not open modulemd file: %v", err)
mdTxtPath = fmt.Sprintf("SOURCES/%s.yml", md.Name)
f, err = md.Worktree.Filesystem.Open(mdTxtPath)
if err != nil {
return fmt.Errorf("could not open modulemd file: %v", err)
}
}
} else {
mdTxtPath = "SOURCES/modulemd.src.txt"
f, err = md.Worktree.Filesystem.Open(mdTxtPath)
if err != nil {
mdTxtPath = "SOURCES/modulemd.txt"
f, err = md.Worktree.Filesystem.Open(mdTxtPath)
if err != nil {
return fmt.Errorf("could not open modulemd file: %v", err)
}
}
}
content, err := ioutil.ReadAll(f)
content, err := io.ReadAll(f)
if err != nil {
log.Fatalf("could not read modulemd file: %v", err)
return fmt.Errorf("could not read modulemd file: %v", err)
}
module, err := modulemd.Parse(content)
if err != nil {
log.Fatalf("could not parse modulemd file: %v", err)
return fmt.Errorf("could not parse modulemd file: %v", err)
}
// Get stream branch from tag
match := tagImportRegex.FindStringSubmatch(md.TagBranch)
streamBranch := strings.Split(match[2], "-")
// Force stream to be the same as stream name in branch
module.Data.Stream = streamBranch[len(streamBranch)-1]
// (in tagless mode we are trusting the "Stream: <VERSION>" text in the source YAML to be accurate)
if !pd.TaglessMode {
match := misc.GetTagImportRegex(pd).FindStringSubmatch(md.TagBranch)
streamBranch := strings.Split(match[2], "-")
// Force stream to be the same as stream name in branch
if module.V2 != nil {
module.V2.Data.Stream = streamBranch[len(streamBranch)-1]
}
if module.V3 != nil {
module.V3.Data.Stream = streamBranch[len(streamBranch)-1]
}
}
var components *modulemd.Components
if module.V2 != nil {
components = module.V2.Data.Components
}
if module.V3 != nil {
components = module.V3.Data.Components
}
log.Println("This module contains the following rpms:")
for name := range module.Data.Components.Rpms {
log.Printf("\t- %s", name)
for name := range components.Rpms {
pd.Log.Printf("\t- %s", name)
}
defaultBranch := md.PushBranch
@ -284,7 +369,7 @@ func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) {
defaultBranch = fmt.Sprintf("%s%d-stream-%s", pd.BranchPrefix, pd.Version, pd.ModuleFallbackStream)
}
for name, rpm := range module.Data.Components.Rpms {
for name, rpm := range components.Rpms {
var tipHash string
var pushBranch string
@ -308,26 +393,40 @@ func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) {
} else if strings.HasPrefix(rpm.Ref, "rhel-") {
pushBranch = defaultBranch
} else {
log.Fatal("could not recognize modulemd ref")
return fmt.Errorf("could not recognize modulemd ref")
}
tipHash = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
tipHash, err = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
if err != nil {
return err
}
if tipHash == "0000000000000000000000000000000000000000" {
pushBranch = defaultBranch
tipHash = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
tipHash, err = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
if err != nil {
return err
}
}
// If we got this far, we're good. This means the repos, branches, and commits exist.
// If this option is on, just use the branch name.
if pd.ModuleBranchNames {
tipHash = md.PushBranch
}
rpm.Ref = tipHash
}
rootModule := fmt.Sprintf("%s.yaml", md.RpmFile.Name())
rootModule := fmt.Sprintf("%s.yaml", md.Name)
err = module.Marshal(md.Worktree.Filesystem, rootModule)
if err != nil {
log.Fatalf("could not marshal root modulemd: %v", err)
return fmt.Errorf("could not marshal root modulemd: %v", err)
}
_, err = md.Worktree.Add(rootModule)
if err != nil {
log.Fatalf("could not add root modulemd: %v", err)
return fmt.Errorf("could not add root modulemd: %v", err)
}
return nil
}

1377
pkg/srpmproc/process.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -134,6 +134,7 @@ message SpecChange {
repeated SearchAndReplaceOperation search_and_replace = 3;
repeated AppendOperation append = 4;
repeated NewFieldOperation new_field = 5;
bool disable_auto_align = 6;
}
message Patch {

15
proto/response.proto Normal file
View File

@ -0,0 +1,15 @@
syntax = "proto3";
option go_package = "github.com/rocky-linux/srpmproc/pb;srpmprocpb";
package srpmproc;
message VersionRelease {
string version = 1;
string release = 2;
}
message ProcessResponse {
map<string, string> branch_commits = 1;
map<string, VersionRelease> branch_versions = 2;
}