Browse code

use apt-ftparchive and reprepro to enable apt-pinning;

Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2015/09/02 10:26:56
Showing 1 changed files
... ...
@@ -20,21 +20,70 @@ APTDIR=$DOCKER_RELEASE_DIR/apt/repo
20 20
 # setup the apt repo (if it does not exist)
21 21
 mkdir -p "$APTDIR/conf" "$APTDIR/db"
22 22
 
23
+# supported arches/sections
24
+arches=( amd64 i386 )
25
+components=( main testing experimental )
26
+
23 27
 # create/update distributions file
24
-if [[ ! -f "$APTDIR/conf/distributions" ]]; then
28
+if [ ! -f "$APTDIR/conf/distributions" ]; then
25 29
 	for suite in $(exec contrib/reprepro/suites.sh); do
26 30
 		cat <<-EOF
27 31
 		Origin: Docker
28 32
 		Suite: $suite
29 33
 		Codename: $suite
30
-		Architectures: amd64 i386
31
-		Components: main testing experimental
34
+		Architectures: ${arches[*]}
35
+		Components: ${components[*]}
32 36
 		Description: Docker APT Repository
33 37
 
34 38
 		EOF
35 39
 	done > "$APTDIR/conf/distributions"
36 40
 fi
37 41
 
42
+# create/update distributions file
43
+if [ ! -f "$APTDIR/conf/apt-ftparchive.conf" ]; then
44
+	cat <<-EOF > "$APTDIR/conf/apt-ftparchive.conf"
45
+	Dir {
46
+		ArchiveDir "${APTDIR}";
47
+		CacheDir "${APTDIR}/db";
48
+	};
49
+
50
+	Default {
51
+		Packages::Compress ". gzip bzip2";
52
+		Sources::Compress ". gzip bzip2";
53
+		Contents::Compress ". gzip bzip2";
54
+	};
55
+
56
+	TreeDefault {
57
+		BinCacheDB "packages-\$(SECTION)-\$(ARCH).db";
58
+		Directory "pool/\$(SECTION)";
59
+		Packages "\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages";
60
+		SrcDirectory "pool/\$(SECTION)";
61
+		Sources "\$(DIST)/\$(SECTION)/source/Sources";
62
+		Contents "\$(DIST)/\$(SECTION)/Contents-\$(ARCH)";
63
+		FileList "$APTDIR/\$(DIST)/\$(SECTION)/filelist";
64
+	};
65
+	EOF
66
+
67
+	for suite in $(exec contrib/reprepro/suites.sh); do
68
+		cat <<-EOF
69
+		Tree "dists/${suite}" {
70
+			Sections "main testing experimental";
71
+			Architectures "${arches[*]}";
72
+		}
73
+
74
+		EOF
75
+	done >> "$APTDIR/conf/apt-ftparchive.conf"
76
+fi
77
+
78
+if [ ! -f "$APTDIR/conf/docker-engine-release.conf" ]; then
79
+	cat <<-EOF > "$APTDIR/conf/docker-engine-release.conf"
80
+	APT::FTPArchive::Release::Origin "Docker";
81
+	APT::FTPArchive::Release::Components "${components[*]}";
82
+	APT::FTPArchive::Release::Label "Docker APT Repository";
83
+	APT::FTPArchive::Release::Architectures "${arches[*]}";
84
+	EOF
85
+fi
86
+
38 87
 # set the component and priority for the version being released
39 88
 component="main"
40 89
 priority=700
... ...
@@ -69,4 +118,35 @@ for dir in contrib/builder/deb/*/; do
69 69
 	reprepro -v $options \
70 70
 		-S docker-engine -P "$priority" -C "$component" \
71 71
 		-b "$APTDIR" includedeb "$codename" "${DEBFILE[@]}"
72
+
73
+	# update the filelist for this codename/component
74
+	find "$APTDIR/pool/$component" \
75
+		-name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist"
76
+done
77
+
78
+
79
+# run the apt-ftparchive commands so we can have pinning
80
+apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf"
81
+
82
+for dir in contrib/builder/deb/*/; do
83
+	version="$(basename "$dir")"
84
+	codename="${version//debootstrap-}"	
85
+
86
+	apt-ftparchive \
87
+		-o "APT::FTPArchive::Release::Codename=$codename" \
88
+		-o "APT::FTPArchive::Release::Suite=$codename" \
89
+		-c "$APTDIR/conf/docker-engine-release.conf" \
90
+		release \
91
+		"$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release"
92
+
93
+	for arch in "${arches[@]}"; do
94
+		apt-ftparchive \
95
+			-o "APT::FTPArchive::Release::Codename=$codename" \
96
+			-o "APT::FTPArchive::Release::Suite=$codename" \
97
+			-o "APT::FTPArchive::Release::Component=$component" \
98
+			-o "APT::FTPArchive::Release::Architecture=$arch" \
99
+			-c "$APTDIR/conf/docker-engine-release.conf" \
100
+			release \
101
+			"$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release"
102
+	done
72 103
 done