good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
a8ddf7ad
Commit
a8ddf7ad
authored
Feb 14, 2019
by
Felix Lange
Committed by
Péter Szilágyi
Feb 14, 2019
Browse files
Options
Downloads
Patches
Plain Diff
build: avoid dput and upload with sftp directly (#19067)
parent
7d24a731
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
build/ci.go
+22
-19
22 additions, 19 deletions
build/ci.go
build/dput-launchpad.cf
+0
-8
0 additions, 8 deletions
build/dput-launchpad.cf
internal/build/util.go
+31
-0
31 additions, 0 deletions
internal/build/util.go
with
53 additions
and
27 deletions
build/ci.go
+
22
−
19
View file @
a8ddf7ad
...
@@ -511,41 +511,44 @@ func doDebianSource(cmdline []string) {
...
@@ -511,41 +511,44 @@ func doDebianSource(cmdline []string) {
debuild
.
Dir
=
pkgdir
debuild
.
Dir
=
pkgdir
build
.
MustRun
(
debuild
)
build
.
MustRun
(
debuild
)
changes
:=
fmt
.
Sprintf
(
"%s_%s_source.changes"
,
meta
.
Name
(),
meta
.
VersionString
())
var
(
changes
=
filepath
.
Join
(
*
workdir
,
changes
)
basename
=
fmt
.
Sprintf
(
"%s_%s"
,
meta
.
Name
(),
meta
.
VersionString
())
source
=
filepath
.
Join
(
*
workdir
,
basename
+
".tar.xz"
)
dsc
=
filepath
.
Join
(
*
workdir
,
basename
+
".dsc"
)
changes
=
filepath
.
Join
(
*
workdir
,
basename
+
"_source.changes"
)
)
if
*
signer
!=
""
{
if
*
signer
!=
""
{
build
.
MustRunCommand
(
"debsign"
,
changes
)
build
.
MustRunCommand
(
"debsign"
,
changes
)
}
}
if
*
upload
!=
""
{
if
*
upload
!=
""
{
u
pload
DebianSource
(
*
workdir
,
*
upload
,
*
sshUser
,
changes
)
ppaU
pload
(
*
workdir
,
*
upload
,
*
sshUser
,
[]
string
{
source
,
dsc
,
changes
}
)
}
}
}
}
}
}
}
}
func
uploadDebianSource
(
workdir
,
ppa
,
sshUser
,
changes
string
)
{
func
ppaUpload
(
workdir
,
ppa
,
sshUser
string
,
files
[]
string
)
{
// Create the dput config file.
dputConfig
:=
filepath
.
Join
(
workdir
,
"dput.cf"
)
p
:=
strings
.
Split
(
ppa
,
"/"
)
p
:=
strings
.
Split
(
ppa
,
"/"
)
if
len
(
p
)
!=
2
{
if
len
(
p
)
!=
2
{
log
.
Fatal
(
"-upload PPA name must contain single /"
)
log
.
Fatal
(
"-upload PPA name must contain single /"
)
}
}
templateData
:=
map
[
string
]
string
{
if
sshUser
==
""
{
"LaunchpadUser"
:
p
[
0
],
sshUser
=
p
[
0
]
"LaunchpadPPA"
:
p
[
1
],
"LaunchpadSSH"
:
sshUser
,
}
}
incomingDir
:=
fmt
.
Sprintf
(
"~%s/ubuntu/%s"
,
p
[
0
],
p
[
1
])
// Create the SSH identity file if it doesn't exist.
var
idfile
string
if
sshkey
:=
getenvBase64
(
"PPA_SSH_KEY"
);
len
(
sshkey
)
>
0
{
if
sshkey
:=
getenvBase64
(
"PPA_SSH_KEY"
);
len
(
sshkey
)
>
0
{
idfile
:=
filepath
.
Join
(
workdir
,
"sshkey"
)
idfile
=
filepath
.
Join
(
workdir
,
"sshkey"
)
if
_
,
err
:=
os
.
Stat
(
idfile
);
os
.
IsNotExist
(
err
)
{
ioutil
.
WriteFile
(
idfile
,
sshkey
,
0600
)
ioutil
.
WriteFile
(
idfile
,
sshkey
,
0600
)
templateData
[
"IdentityFile"
]
=
idfile
}
}
build
.
Render
(
"build/dput-launchpad.cf"
,
dputConfig
,
0644
,
templateData
)
}
// Upload
// Run dput to do the upload.
dest
:=
sshUser
+
"@ppa.launchpad.net"
dput
:=
exec
.
Command
(
"dput"
,
"-c"
,
dputConfig
,
"--no-upload-log"
,
ppa
,
changes
)
if
err
:=
build
.
UploadSFTP
(
idfile
,
dest
,
incomingDir
,
files
);
err
!=
nil
{
dput
.
Stdin
=
strings
.
NewReader
(
"Yes
\n
"
)
// accept SSH host key
log
.
Fatal
(
err
)
build
.
MustRun
(
dput
)
}
}
}
func
getenvBase64
(
variable
string
)
[]
byte
{
func
getenvBase64
(
variable
string
)
[]
byte
{
...
...
This diff is collapsed.
Click to expand it.
build/dput-launchpad.cf
deleted
100644 → 0
+
0
−
8
View file @
7d24a731
[{{.LaunchpadUser}}/{{.LaunchpadPPA}}]
fqdn = ppa.launchpad.net
method = sftp
incoming = ~{{.LaunchpadUser}}/ubuntu/{{.LaunchpadPPA}}/
login = {{.LaunchpadSSH}}
{{ if .IdentityFile }}
ssh_options = IdentityFile {{.IdentityFile}}
{{ end }}
This diff is collapsed.
Click to expand it.
internal/build/util.go
+
31
−
0
View file @
a8ddf7ad
...
@@ -177,3 +177,34 @@ func ExpandPackagesNoVendor(patterns []string) []string {
...
@@ -177,3 +177,34 @@ func ExpandPackagesNoVendor(patterns []string) []string {
}
}
return
patterns
return
patterns
}
}
// UploadSFTP uploads files to a remote host using the sftp command line tool.
// The destination host may be specified either as [user@]host[: or as a URI in
// the form sftp://[user@]host[:port].
func
UploadSFTP
(
identityFile
,
host
,
dir
string
,
files
[]
string
)
error
{
sftp
:=
exec
.
Command
(
"sftp"
)
sftp
.
Stdout
=
nil
sftp
.
Stderr
=
os
.
Stderr
if
identityFile
!=
""
{
sftp
.
Args
=
append
(
sftp
.
Args
,
"-i"
,
identityFile
)
}
sftp
.
Args
=
append
(
sftp
.
Args
,
host
)
fmt
.
Println
(
">>>"
,
strings
.
Join
(
sftp
.
Args
,
" "
))
if
*
DryRunFlag
{
return
nil
}
stdin
,
err
:=
sftp
.
StdinPipe
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"can't create stdin pipe for sftp: %v"
,
err
)
}
if
err
:=
sftp
.
Start
();
err
!=
nil
{
return
err
}
in
:=
io
.
MultiWriter
(
stdin
,
os
.
Stdout
)
for
_
,
f
:=
range
files
{
fmt
.
Fprintln
(
in
,
"put"
,
f
,
path
.
Join
(
dir
,
filepath
.
Base
(
f
)))
}
stdin
.
Close
()
return
sftp
.
Wait
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment