Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Release Engineering
Public
srpmproc
Commits
49a37518
Commit
49a37518
authored
Mar 18, 2021
by
Mustafa Gezen
Browse files
Better tmpfs mode
parent
8db8d620
Changes
4
Hide whitespace changes
Inline
Side-by-side
cmd/srpmproc/main.go
View file @
49a37518
...
...
@@ -11,7 +11,6 @@ import (
"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"
"io/ioutil"
"log"
"os"
"os/user"
...
...
@@ -38,7 +37,7 @@ var (
singleTag
string
noDupMode
bool
moduleMode
bool
tmpFsMode
bool
tmpFsMode
string
noStorageDownload
bool
noStorageUpload
bool
)
...
...
@@ -96,20 +95,17 @@ func mn(_ *cobra.Command, _ []string) {
log
.
Fatalf
(
"could not get git authenticator: %v"
,
err
)
}
fsCreator
:=
func
()
billy
.
Filesystem
{
fsCreator
:=
func
(
branch
string
)
billy
.
Filesystem
{
return
memfs
.
New
()
}
if
tmpFsMode
{
tmpBaseDir
,
err
:=
ioutil
.
TempDir
(
os
.
TempDir
(),
"srpmproc-*"
)
if
err
!=
nil
{
log
.
Fatalf
(
"could not create temp dir: %v"
,
err
)
}
log
.
Printf
(
"using temp dir: %s"
,
tmpBaseDir
)
fsCreator
=
func
()
billy
.
Filesystem
{
tmpDir
,
err
:=
ioutil
.
TempDir
(
tmpBaseDir
,
"*"
)
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 t
e
mp dir: %v"
,
err
)
log
.
Fatalf
(
"could not create tmp
fs
dir: %v"
,
err
)
}
return
osfs
.
New
(
tmpDir
)
}
...
...
@@ -160,7 +156,7 @@ func main() {
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"
)
root
.
Flags
()
.
Bool
Var
(
&
tmpFsMode
,
"tmpfs-mode"
,
false
,
"If
enabled
, packages are imported and patched but not pushed"
)
root
.
Flags
()
.
String
Var
(
&
tmpFsMode
,
"tmpfs-mode"
,
""
,
"If
set
, packages are imported
to path
and patched but not pushed"
)
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"
)
...
...
internal/data/process.go
View file @
49a37518
...
...
@@ -24,8 +24,8 @@ type ProcessData struct {
BlobStorage
blob
.
Storage
NoDupMode
bool
ModuleMode
bool
TmpFsMode
bool
TmpFsMode
string
NoStorageDownload
bool
NoStorageUpload
bool
FsCreator
func
()
billy
.
Filesystem
FsCreator
func
(
branch
string
)
billy
.
Filesystem
}
internal/patch.go
View file @
49a37518
...
...
@@ -87,18 +87,21 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) {
log
.
Fatalf
(
"could not create remote: %v"
,
err
)
}
err
=
repo
.
Fetch
(
&
git
.
FetchOptions
{
fetchOptions
:=
&
git
.
FetchOptions
{
RemoteName
:
"origin"
,
RefSpecs
:
[]
config
.
RefSpec
{
refspec
},
Auth
:
pd
.
Authenticator
,
})
}
if
!
strings
.
HasPrefix
(
pd
.
UpstreamPrefix
,
"http"
)
{
fetchOptions
.
Auth
=
pd
.
Authenticator
}
err
=
repo
.
Fetch
(
fetchOptions
)
refName
:=
plumbing
.
NewBranchReferenceName
(
md
.
PushBranch
)
log
.
Printf
(
"set reference to ref: %s"
,
refName
)
if
err
!=
nil
{
// no patches active
log
.
Println
(
"info: patch
R
epo not found"
)
log
.
Println
(
"info: patch
r
epo not found"
)
return
}
else
{
err
=
w
.
Checkout
(
&
git
.
CheckoutOptions
{
...
...
internal/process.go
View file @
49a37518
...
...
@@ -101,17 +101,6 @@ func ProcessRPM(pd *data.ProcessData) {
continue
}
rpmFile
:=
md
.
RpmFile
// create new Repo for final dist
repo
,
err
:=
git
.
Init
(
memory
.
NewStorage
(),
pd
.
FsCreator
())
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
)
}
var
matchString
string
if
!
tagImportRegex
.
MatchString
(
md
.
TagBranch
)
{
if
pd
.
ModuleMode
{
...
...
@@ -133,6 +122,17 @@ func ProcessRPM(pd *data.ProcessData) {
md
.
PushBranch
=
pd
.
BranchPrefix
+
strings
.
TrimPrefix
(
match
[
2
],
pd
.
ImportBranchPrefix
)
newTag
:=
"imports/"
+
pd
.
BranchPrefix
+
strings
.
TrimPrefix
(
match
[
1
],
"imports/"
+
pd
.
ImportBranchPrefix
)
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
{
...
...
@@ -275,7 +275,7 @@ func ProcessRPM(pd *data.ProcessData) {
}
}
if
pd
.
TmpFsMode
{
if
pd
.
TmpFsMode
!=
""
{
continue
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment