mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Using bzip2 generates smaller index files (roughly 20% smaller Packages
files) but it comes with a big performance penalty. When publishing a
debian mirror snapshot (amd64, arm64, armhf, source) without contents
skipping bzip speeds things up around 1.8 times.
```
$ hyperfine -w 1 -L skip-bz2 true,false -m 3 -p "aptly -config aptly.conf publish drop bullseye || true" "aptly -config aptly.conf publish snapshot --skip-bz2={skip-bz2} --skip-contents --skip-signing bullseye"
Benchmark 1: aptly -config aptly.conf publish snapshot --skip-bz2=true --skip-contents --skip-signing bullseye
Time (mean ± σ): 35.567 s ± 0.307 s [User: 39.366 s, System: 10.075 s]
Range (min … max): 35.311 s … 35.907 s 3 runs
Benchmark 2: aptly -config aptly.conf publish snapshot --skip-bz2=false --skip-contents --skip-signing bullseye
Time (mean ± σ): 64.740 s ± 0.135 s [User: 68.565 s, System: 10.129 s]
Range (min … max): 64.596 s … 64.862 s 3 runs
Summary
'aptly -config aptly.conf publish snapshot --skip-bz2=true --skip-contents --skip-signing bullseye' ran
1.82 ± 0.02 times faster than 'aptly -config aptly.conf publish snapshot --skip-bz2=false --skip-contents --skip-signing bullseye'
```
Allow skipping bz2 creation for setups where faster publishing is more
important then Package file size.
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
125 lines
4.1 KiB
Go
125 lines
4.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/aptly-dev/aptly/deb"
|
|
"github.com/smira/commander"
|
|
"github.com/smira/flag"
|
|
)
|
|
|
|
func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
|
|
var err error
|
|
if len(args) < 1 || len(args) > 2 {
|
|
cmd.Usage()
|
|
return commander.ErrCommandError
|
|
}
|
|
|
|
distribution := args[0]
|
|
param := "."
|
|
|
|
if len(args) == 2 {
|
|
param = args[1]
|
|
}
|
|
storage, prefix := deb.ParsePrefix(param)
|
|
|
|
var published *deb.PublishedRepo
|
|
|
|
collectionFactory := context.NewCollectionFactory()
|
|
published, err = collectionFactory.PublishedRepoCollection().ByStoragePrefixDistribution(storage, prefix, distribution)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to update: %s", err)
|
|
}
|
|
|
|
if published.SourceKind != deb.SourceLocalRepo {
|
|
return fmt.Errorf("unable to update: not a local repository publish")
|
|
}
|
|
|
|
err = collectionFactory.PublishedRepoCollection().LoadComplete(published, collectionFactory)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to update: %s", err)
|
|
}
|
|
|
|
components := published.Components()
|
|
for _, component := range components {
|
|
published.UpdateLocalRepo(component)
|
|
}
|
|
|
|
signer, err := getSigner(context.Flags())
|
|
if err != nil {
|
|
return fmt.Errorf("unable to initialize GPG signer: %s", err)
|
|
}
|
|
|
|
forceOverwrite := context.Flags().Lookup("force-overwrite").Value.Get().(bool)
|
|
if forceOverwrite {
|
|
context.Progress().ColoredPrintf("@rWARNING@|: force overwrite mode enabled, aptly might corrupt other published repositories sharing " +
|
|
"the same package pool.\n")
|
|
}
|
|
|
|
if context.Flags().IsSet("skip-contents") {
|
|
published.SkipContents = context.Flags().Lookup("skip-contents").Value.Get().(bool)
|
|
}
|
|
|
|
if context.Flags().IsSet("skip-bz2") {
|
|
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
|
|
}
|
|
|
|
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.Progress(), forceOverwrite)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to publish: %s", err)
|
|
}
|
|
|
|
err = collectionFactory.PublishedRepoCollection().Update(published)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to save to DB: %s", err)
|
|
}
|
|
|
|
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
|
|
if !skipCleanup {
|
|
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, components,
|
|
context.GetPublishedStorage(storage), collectionFactory, context.Progress())
|
|
if err != nil {
|
|
return fmt.Errorf("unable to update: %s", err)
|
|
}
|
|
}
|
|
|
|
context.Progress().Printf("\nPublish for local repo %s has been successfully updated.\n", published.String())
|
|
|
|
return err
|
|
}
|
|
|
|
func makeCmdPublishUpdate() *commander.Command {
|
|
cmd := &commander.Command{
|
|
Run: aptlyPublishUpdate,
|
|
UsageLine: "update <distribution> [[<endpoint>:]<prefix>]",
|
|
Short: "update published local repository",
|
|
Long: `
|
|
Command re-publishes (updates) published local repository. <distribution>
|
|
and <prefix> should be occupied with local repository published
|
|
using command aptly publish repo. Update happens in-place with
|
|
minimum possible downtime for published repository.
|
|
|
|
For multiple component published repositories, all local repositories
|
|
are updated.
|
|
|
|
Example:
|
|
|
|
$ aptly publish update wheezy ppa
|
|
`,
|
|
Flag: *flag.NewFlagSet("aptly-publish-update", flag.ExitOnError),
|
|
}
|
|
cmd.Flag.String("gpg-key", "", "GPG key ID to use when signing the release")
|
|
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("passphrase", "", "GPG passphrase for the key (warning: could be insecure)")
|
|
cmd.Flag.String("passphrase-file", "", "GPG passphrase-file for the key (warning: could be insecure)")
|
|
cmd.Flag.Bool("batch", false, "run GPG with detached tty")
|
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
|
cmd.Flag.Bool("skip-contents", false, "don't generate Contents indexes")
|
|
cmd.Flag.Bool("skip-bz2", false, "don't generate bzipped indexes")
|
|
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
|
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
|
|
|
|
return cmd
|
|
}
|