mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-20 12:47:35 +00:00
Allow to customize Origin/Label during publishing. #29
This commit is contained in:
@@ -32,6 +32,8 @@ Example:
|
|||||||
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
||||||
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
||||||
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
||||||
|
cmd.Flag.String("origin", "", "origin name to publish")
|
||||||
|
cmd.Flag.String("label", "", "label to publish")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to publish: %s", err)
|
return fmt.Errorf("unable to publish: %s", err)
|
||||||
}
|
}
|
||||||
|
published.Origin = cmd.Flag.Lookup("origin").Value.String()
|
||||||
|
published.Label = cmd.Flag.Lookup("label").Value.String()
|
||||||
|
|
||||||
duplicate := context.CollectionFactory().PublishedRepoCollection().CheckDuplicate(published)
|
duplicate := context.CollectionFactory().PublishedRepoCollection().CheckDuplicate(published)
|
||||||
if duplicate != nil {
|
if duplicate != nil {
|
||||||
@@ -133,6 +135,8 @@ Example:
|
|||||||
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
|
||||||
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
|
||||||
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
||||||
|
cmd.Flag.String("origin", "", "origin name to publish")
|
||||||
|
cmd.Flag.String("label", "", "label to publish")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-3
@@ -25,6 +25,8 @@ type PublishedRepo struct {
|
|||||||
Prefix string
|
Prefix string
|
||||||
Distribution string
|
Distribution string
|
||||||
Component string
|
Component string
|
||||||
|
Origin string
|
||||||
|
Label string
|
||||||
// Architectures is a list of all architectures published
|
// Architectures is a list of all architectures published
|
||||||
Architectures []string
|
Architectures []string
|
||||||
// SourceKind is "local"/"repo"
|
// SourceKind is "local"/"repo"
|
||||||
@@ -173,7 +175,17 @@ func (p *PublishedRepo) String() string {
|
|||||||
panic("no snapshot/localRepo")
|
panic("no snapshot/localRepo")
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s/%s (%s) [%s] publishes %s", p.Prefix, p.Distribution, p.Component, strings.Join(p.Architectures, ", "), source)
|
var extra string
|
||||||
|
|
||||||
|
if p.Origin != "" {
|
||||||
|
extra += fmt.Sprintf(", origin: %s", p.Origin)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Label != "" {
|
||||||
|
extra += fmt.Sprintf(", label: %s", p.Label)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s/%s (%s%s) [%s] publishes %s", p.Prefix, p.Distribution, p.Component, extra, strings.Join(p.Architectures, ", "), source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key returns unique key identifying PublishedRepo
|
// Key returns unique key identifying PublishedRepo
|
||||||
@@ -367,8 +379,16 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
release := make(Stanza)
|
release := make(Stanza)
|
||||||
release["Origin"] = p.Prefix + " " + p.Distribution
|
if p.Origin == "" {
|
||||||
release["Label"] = p.Prefix + " " + p.Distribution
|
release["Origin"] = p.Prefix + " " + p.Distribution
|
||||||
|
} else {
|
||||||
|
release["Origin"] = p.Origin
|
||||||
|
}
|
||||||
|
if p.Label == "" {
|
||||||
|
release["Label"] = p.Prefix + " " + p.Distribution
|
||||||
|
} else {
|
||||||
|
release["Label"] = p.Label
|
||||||
|
}
|
||||||
release["Codename"] = p.Distribution
|
release["Codename"] = p.Distribution
|
||||||
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
|
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
|
||||||
release["Components"] = p.Component
|
release["Components"] = p.Component
|
||||||
|
|||||||
@@ -274,6 +274,12 @@ func (s *PublishedRepoSuite) TestString(c *C) {
|
|||||||
repo, _ = NewPublishedRepo("", "squeeze", "main", []string{"i386", "amd64"}, s.snapshot, s.factory)
|
repo, _ = NewPublishedRepo("", "squeeze", "main", []string{"i386", "amd64"}, s.snapshot, s.factory)
|
||||||
c.Check(repo.String(), Equals,
|
c.Check(repo.String(), Equals,
|
||||||
"./squeeze (main) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
"./squeeze (main) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||||
|
repo.Origin = "myorigin"
|
||||||
|
c.Check(repo.String(), Equals,
|
||||||
|
"./squeeze (main, origin: myorigin) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||||
|
repo.Label = "mylabel"
|
||||||
|
c.Check(repo.String(), Equals,
|
||||||
|
"./squeeze (main, origin: myorigin, label: mylabel) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PublishedRepoSuite) TestKey(c *C) {
|
func (s *PublishedRepoSuite) TestKey(c *C) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
Published repositories:
|
Published repositories:
|
||||||
* ./maverick (main) [amd64, i386] publishes [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
|
* ./maverick (main) [amd64, i386] publishes [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
|
||||||
* ppa/smira/wheezy (contrib) [amd64] publishes [snap2]: Merged from sources: 'snap1'
|
* ppa/smira/wheezy (contrib) [amd64] publishes [snap2]: Merged from sources: 'snap1'
|
||||||
|
* ppa/tr1/maverick (main, origin: origin1) [amd64, i386] publishes [snap2]: Merged from sources: 'snap1'
|
||||||
|
* ppa/tr2/maverick (main, label: label1) [amd64, i386] publishes [snap2]: Merged from sources: 'snap1'
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
|
||||||
|
Local repo local-repo has been successfully published.
|
||||||
|
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
|
||||||
|
Now you can add following line to apt sources:
|
||||||
|
deb http://your-server/ maverick contrib
|
||||||
|
deb-src http://your-server/ maverick contrib
|
||||||
|
Don't forget to add your GPG key to apt with apt-key.
|
||||||
|
|
||||||
|
You can also use `aptly serve` to publish your repositories over HTTP quickly.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Origin: . maverick
|
||||||
|
Label: label15
|
||||||
|
Codename: maverick
|
||||||
|
Architectures: i386
|
||||||
|
Components: contrib
|
||||||
|
Description: Generated by aptly
|
||||||
|
MD5Sum:
|
||||||
|
SHA1:
|
||||||
|
SHA256:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Loading packages...
|
||||||
|
Generating metadata files and linking package files...
|
||||||
|
Signing file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
Clearsigning file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted:
|
||||||
|
|
||||||
|
Snapshot snap24 has been successfully published.
|
||||||
|
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
|
||||||
|
Now you can add following line to apt sources:
|
||||||
|
deb http://your-server/ squeeze main
|
||||||
|
Don't forget to add your GPG key to apt with apt-key.
|
||||||
|
|
||||||
|
You can also use `aptly serve` to publish your repositories over HTTP quickly.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Origin: aptly24
|
||||||
|
Label: . squeeze
|
||||||
|
Codename: squeeze
|
||||||
|
Architectures: amd64 i386
|
||||||
|
Components: main
|
||||||
|
Description: Generated by aptly
|
||||||
|
MD5Sum:
|
||||||
|
SHA1:
|
||||||
|
SHA256:
|
||||||
@@ -10,7 +10,7 @@ class PublishList1Test(BaseTest):
|
|||||||
|
|
||||||
class PublishList2Test(BaseTest):
|
class PublishList2Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
publish list: several snapshots list
|
publish list: several repos list
|
||||||
"""
|
"""
|
||||||
fixtureDB = True
|
fixtureDB = True
|
||||||
fixturePool = True
|
fixturePool = True
|
||||||
@@ -19,5 +19,7 @@ class PublishList2Test(BaseTest):
|
|||||||
"aptly snapshot merge snap2 snap1",
|
"aptly snapshot merge snap2 snap1",
|
||||||
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1",
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1",
|
||||||
"aptly -architectures=amd64 publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=contrib snap2 ppa/smira",
|
"aptly -architectures=amd64 publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=contrib snap2 ppa/smira",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -origin=origin1 snap2 ppa/tr1",
|
||||||
|
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=label1 snap2 ppa/tr2",
|
||||||
]
|
]
|
||||||
runCmd = "aptly publish list"
|
runCmd = "aptly publish list"
|
||||||
|
|||||||
@@ -340,3 +340,19 @@ class PublishRepo14Test(BaseTest):
|
|||||||
self.check_exists('public/pool/contrib/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
self.check_exists('public/pool/contrib/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
|
||||||
|
|
||||||
|
|
||||||
|
class PublishRepo15Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish repo: custom label
|
||||||
|
"""
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly repo create local-repo",
|
||||||
|
"aptly repo add local-repo ${files}",
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=contrib -label=label15 local-repo"
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishRepo15Test, self).check()
|
||||||
|
|
||||||
|
# verify contents except of sums
|
||||||
|
self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor)
|
||||||
|
|||||||
@@ -556,3 +556,22 @@ class PublishSnapshot23Test(BaseTest):
|
|||||||
]
|
]
|
||||||
runCmd = "aptly publish snapshot -skip-signing snap3"
|
runCmd = "aptly publish snapshot -skip-signing snap3"
|
||||||
gold_processor = BaseTest.expand_environ
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSnapshot24Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish snapshot: custom origin
|
||||||
|
"""
|
||||||
|
fixtureDB = True
|
||||||
|
fixturePool = True
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap24 from mirror gnuplot-maverick",
|
||||||
|
]
|
||||||
|
runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=squeeze -origin=aptly24 snap24"
|
||||||
|
gold_processor = BaseTest.expand_environ
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
super(PublishSnapshot24Test, self).check()
|
||||||
|
|
||||||
|
# verify contents except of sums
|
||||||
|
self.check_file_contents('public/dists/squeeze/Release', 'release', match_prepare=strip_processor)
|
||||||
|
|||||||
Reference in New Issue
Block a user