mkrepo: automating rpm and deb package lifecycle on s3

37
mkrepo Automating package lifecycle on s3 by racktear

Upload: konstantin-nazarov

Post on 16-Jan-2017

320 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: mkrepo: automating rpm and deb package lifecycle on s3

⬢mkrepoAutomating package lifecycle on s3

by 🐦racktear

Page 2: mkrepo: automating rpm and deb package lifecycle on s3

State of packages

Page 3: mkrepo: automating rpm and deb package lifecycle on s3

DockerHub repo popularityubuntu -  4.8k 

nginx - 4.3k 

mysql - 3.2k 

node - 2.9k 

redis - 2.8k 

centos - 2.7k 

Debian derivatives

Page 4: mkrepo: automating rpm and deb package lifecycle on s3

What about Alpine Linux?

$ cat control.tar.gz \ data.tar.gz > \ mypackage-1.0-r0.apk

Page 5: mkrepo: automating rpm and deb package lifecycle on s3

Vintage package formats are here to stay

Page 6: mkrepo: automating rpm and deb package lifecycle on s3

What's the deal with packages?

Ad-hoc builds on a VPS sort of work

Publishing from jenkins is doable, but clunky

Concourse.ci is stateless ⇒ forget about it

Amazon S3 is not usable without repo duplication

Page 7: mkrepo: automating rpm and deb package lifecycle on s3

An ideal repo tool

• Experiment with packages on your laptop

• Run self-hosted repo in one command

• Generate metadata on remote machines/services

• Embed well into CD pipeline

• Run as a service

Page 8: mkrepo: automating rpm and deb package lifecycle on s3

Package repositories

Page 9: mkrepo: automating rpm and deb package lifecycle on s3

Functions

Mapping package names to URIs

Recording package checksums

Proving authorship through signatures

Page 10: mkrepo: automating rpm and deb package lifecycle on s3

Typical repository

foo-1.0.bin

foo-2.1.bin

bar-1.5.bin

Metadatafoo 1.0, sha256=... uri=...

foo 2.1, sha256=... uri=...

bar 1.5, sha256=... uri=...

GPG signature

Metadata.asc

Page 11: mkrepo: automating rpm and deb package lifecycle on s3

Every stack reinvents repository formats :(

Page 12: mkrepo: automating rpm and deb package lifecycle on s3

rpm repo structure

Page 13: mkrepo: automating rpm and deb package lifecycle on s3

rpm repo structure

Top-level xml metadata file

Separate xml file list

Separate xml package mapping

rpm: Binary package files in own format

Page 14: mkrepo: automating rpm and deb package lifecycle on s3

rpm repo structure

/

repodata/

Packages/

repomd.xmlfilelists.xml.gzprimary.xml.gzother.xml.gz

foo-1.2.rpmbar-2.0.rpm...

Page 15: mkrepo: automating rpm and deb package lifecycle on s3

rpm file

Page 16: mkrepo: automating rpm and deb package lifecycle on s3

deb repo structure

Page 17: mkrepo: automating rpm and deb package lifecycle on s3

deb repo structure

Top-level text metadata file

Per-architecture text files with package lists

(optional) Separate text file with file lists

deb: ar package with metadata and content

Page 18: mkrepo: automating rpm and deb package lifecycle on s3

deb repo structure

/

dists/

pool/

Packages

f/foo-1.2-dist1.debb/bar-2.0-dist2.deb...

dist1/component/arch/

dist2/

Release

Page 19: mkrepo: automating rpm and deb package lifecycle on s3

deb file structure

Page 20: mkrepo: automating rpm and deb package lifecycle on s3

control file

/

dists/

pool/

Packages

f/foo-1.2-dist1.debb/bar-2.0-dist2.deb...

dist1/component/arch/

dist2/

Release

control

Page 21: mkrepo: automating rpm and deb package lifecycle on s3

Parsing package metadata

Page 22: mkrepo: automating rpm and deb package lifecycle on s3

Binary

+ struct module

Page 23: mkrepo: automating rpm and deb package lifecycle on s3

struct module

ver, reserved, num_index_entries, num_data_bytes = \ struct.unpack('>BIII', fd.read(13))

Page 24: mkrepo: automating rpm and deb package lifecycle on s3

struct module

This way you can unpack almost any binary

I even did it once for RIP protocol

Also, you can experiment interactively

Page 25: mkrepo: automating rpm and deb package lifecycle on s3

Generating repository

Page 26: mkrepo: automating rpm and deb package lifecycle on s3

Generating rpm repository

Repodata has timestamps

Files have timestamps

No need to re-download old files

Page 27: mkrepo: automating rpm and deb package lifecycle on s3

Generating deb repository

Metadata has no timestamps

Files have timestamps

Not clear how to calculate diff

Page 28: mkrepo: automating rpm and deb package lifecycle on s3

Generating deb repository

Fortunately, Package index documentation states:

Note that the control file of .deb files may contain additional fields not yet documented by policy or not yet documented here which then might also be

found in this file.

Page 29: mkrepo: automating rpm and deb package lifecycle on s3

Generating deb repository

...Size: 3906802FileTime: 1474223050.0 # <- custom field for timestampMD5Sum: 92c2a4SHA1: 257d6e...SHA256: c019a1......

"Packages" metadata file

Page 30: mkrepo: automating rpm and deb package lifecycle on s3

Adapting to modern CD

Page 31: mkrepo: automating rpm and deb package lifecycle on s3

Why store remotely?

Object storage is good candidate for packages

Specialized storage has better guarantees

SOA

Page 32: mkrepo: automating rpm and deb package lifecycle on s3

Travis + s3

Page 33: mkrepo: automating rpm and deb package lifecycle on s3

Concourse + Minio

Page 34: mkrepo: automating rpm and deb package lifecycle on s3

Our concourse pipeline

build.tarantool.org

Page 35: mkrepo: automating rpm and deb package lifecycle on s3

Ideal pipeline

Page 36: mkrepo: automating rpm and deb package lifecycle on s3

Future repository format

• Git-like, with history

• Support for merges or partial updates

• Fast and lightweight

• Transactional

• Extensible through custom metadata