Skip to content

Instantly share code, notes, and snippets.

@willkelly
Last active August 29, 2015 14:10
Show Gist options
  • Save willkelly/37290f04bac8d173f11c to your computer and use it in GitHub Desktop.
Save willkelly/37290f04bac8d173f11c to your computer and use it in GitHub Desktop.

What is Aptly

Aptly is software for managing apt repositories.

Features we use

  • Quick package addition / removal.

  • Snapshotting of repository states with good repo diffing.

  • Repository publishing

  • distribution / architecture management

Features we don't use, but you might

  • Convenient repository mirroring with strong filtering

  • Dependency management for package imports from other repositories.

Other options

  • dpkg-scanpackages is the simplest approach to package repository creation. It will scan for recursively scan for packages and generate the appropriate Packages file but does not assist in gpg signatures or laying out debs in a pool structure.

  • reprepro is a more full featured repository management tool with the ability to assist in maintaining a pool structure for your repository, db backed packages file generation, multiple distribution management, and assistance in signing releases. It does not have aptly's mirroring or snapshotting features.

Our use case

We build packages for our staging environment on every merge into master. Once the packages have been built, we update the repository.

Once the staging packages are made, jenkins will run ansible on the staging servers, automatically bringing us up to the latest code. Once this code has been tested and validated as good and users are comfortable with a production deploy, the staging packages are synced to an s3 repository used by our production servers. Ansible can then be triggered via jenkins to update the production code base.

Our problems

  • dpkg-scanpackages, our previous repo management tool, can take minutes to scan through large repositories and generate appropriate information for a Packages file.

  • parallel builds can result in available packages changing in the middle of a dpkg-scanpackage run, so package updates needed to be coordinated to avoid generating incorrect Packages files. Avoiding races is never fun.

Using Aptly

Making an aptly repo

aptly repo create --comment "coolest repo ever" \
  --distribution "staging" --component "main" "my_repo"

Adding packages

aptly repo add staging some_deb.deb

Publishing a repository

aptly publish repo --gpg-key "0DF43F03" --architectures "amd64,i386" my_repo

Working with snapshots

Create a snapshot

aptly snapshot create snapshot1 from repo my_repo

Diff two snapshots

$ aptly snapshot diff snapshot1 snapshot2
Arch   | Package                                  | Version in A                             | Version in B
+ all    | ipython                                  | -                                        | 2.3.0-1
+ all    | libgdal-doc                              | -                                        | 1.11.0-15pl
+ all    | python-django-waffle                     | -                                        | 0.10
+ all    | python-docutils                          | -                                        | 0.11-1
+ all    | python-dotenv                            | -                                        | 0.0.2
+ all    | python-dotenv                            | -                                        | 0.0.2-1
+ all    | python-elasticsearch                     | -                                        | 1.2.0
+ all    | python-execnet                           | -                                        | 1.1
+ all    | python-execnet                           | -                                        | 1.1-1
+ all    | python-flask                             | -                                        | 0.10.1
+ all    | python-flask                             | -                                        | 0.10.1-1

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment