-
Notifications
You must be signed in to change notification settings - Fork 0
/
apt-lab
109 lines (61 loc) · 3.4 KB
/
apt-lab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#################
APTLY on Ubuntu
################
1. Install latest stable Aptly on Ubuntu16.04
# echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/source.list.d/aptly.list
# sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 9E3E53F19C7DE460
# apt-get update
# apt-get install aptly
2. Create GPG key to sigining published repositories.
# gpg --gen-key
3. Create Mirror for Ubuntu Xenial
# aptly mirror create -architectures=amd64 -filter='Priority (required) | Priority (important) | Priority (standard)' xenial-main http://us.archive.ubuntu.com/ubuntu/ xenial main
# aptly mirror create -architectures=amd64 -filter='Priority (required) | Priority (important) | Priority (standard)' xenial-updates http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
# aptly mirror create -architectures=amd64 -filter='Priority (required) | Priority (important) | Priority (standard)' xenial-security http://security.ubuntu.com/ubuntu xenial-security main
4. updating the mirrors
# aptly mirror update xenial-main
# aptly mirror update xenial-updates
# aptly mirror update xenial-security
5. TAKING SNAPSHOTS
# It’s time take snapshots of the mirrors to preserve exact current mirror state.
# aptly snapshot create xenial-main-20180206 from mirror xenial-main
# aptly snapshot create xenial-updates-20180206 from mirror xenial-updates
# aptly snapshot create xenial-security-20180206 from mirror xenial-security
6. MERGING SNAPSHOTS
# Now we can merge snapshots into one, producing "xenial with security updates applied"
# aptly snapshot merge -latest xenial-final-20180206 xenial-main-20180206 xenial-updates-20180206 xenail-security-20180206
## Flag -latest chooses merge strategy: package with latest version “wins”.
7. PUBLISHING REPOSITORY
# Final step: publishing our snapshot as Debian repository, ready to be consumed by apt-get:
# aptly publish snapshot -distribution=xenial wheezy-final-20180206
8. The repository is published to ~/.aptly/public/ directory. You can start any HTTP server to serve this directory as static files, or use aptly built-in webserver for testing:
# aptly serve
9. visalize the objects created and dependencies:
# aptly graph
###################
Using Repositories
###################
1. Import public part of the key that was used to sign the repository into trusted apt keyring on target machine
# gpg --export --armor > my_key.pub
# Copy my_key.pub to target machine and import it into apt keyring
# sudo apt-key add my_key.pub
3. Edit /etc/apt/sources.list and comment out default sources and add aptly server url
# deb http://192.168.100.2:8080/ xenial main
4. Repository is ready to use.
# apt-get update
######################
UPGRADING REPOSITORY
######################
1. Several days after, when I update my mirrors I discover new security updates:
# aptly mirror update xenial-security
2. So it’s time to create new snapshot:
# aptly snapshot create xenial-security-20180207 from mirror xenial-security
3. And do merge once again:
# aptly snapshot merge -latest xenial-final-20180207 xenial-main-20180206 xenial-updates-20180206 xenial-security-20180207
4. Now I can update my published repository by switching it to new snapshot:
# aptly publish switch xenial xenial-final-20180207
################
MAINTENANCE
################
1. You can drop old snapshots as they’re not used anymore.
# aptly db cleanup