-
Notifications
You must be signed in to change notification settings - Fork 116
/
update-repository.sh
executable file
·130 lines (112 loc) · 3.35 KB
/
update-repository.sh
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
script_base_dir=`dirname $0`
if [ $# != 4 ]; then
echo "Usage: $0 PROJECT_NAME DESTINATION ARCHITECTURES CODES"
echo " e.g.: $0 mroonga repositories/ 'i386 amd64' 'lenny unstable hardy karmic'"
exit 1
fi
PROJECT_NAME=$1
DESTINATION=$2
ARCHITECTURES=$3
CODES=$4
run()
{
"$@"
if test $? -ne 0; then
echo "Failed $@"
exit 1
fi
}
update_repository()
{
distribution=$1
code_name=$2
component=$3
rm -rf dists/${code_name}
mkdir -p dists/${code_name}/${component}/binary-i386/
mkdir -p dists/${code_name}/${component}/binary-amd64/
mkdir -p dists/${code_name}/${component}/source/
cat <<EOF > dists/.htaccess
Options +Indexes
EOF
cat <<EOF > dists/${code_name}/${component}/binary-i386/Release
Archive: ${code_name}
Component: ${component}
Origin: The ${PROJECT_NAME} project
Label: The ${PROJECT_NAME} project
Architecture: i386
EOF
cat <<EOF > dists/${code_name}/${component}/binary-amd64/Release
Archive: ${code_name}
Component: ${component}
Origin: The ${PROJECT_NAME} project
Label: The ${PROJECT_NAME} project
Architecture: amd64
EOF
cat <<EOF > dists/${code_name}/${component}/source/Release
Archive: ${code_name}
Component: ${component}
Origin: The ${PROJECT_NAME} project
Label: The ${PROJECT_NAME} project
Architecture: source
EOF
cat <<EOF > generate-${code_name}.conf
Dir::ArchiveDir ".";
Dir::CacheDir ".";
TreeDefault::Directory "pool/${code_name}/${component}";
TreeDefault::SrcDirectory "pool/${code_name}/${component}";
Default::Packages::Extensions ".deb";
Default::Packages::Compress ". gzip bzip2";
Default::Sources::Compress ". gzip bzip2";
Default::Contents::Compress "gzip bzip2";
BinDirectory "dists/${code_name}/${component}/binary-i386" {
Packages "dists/${code_name}/${component}/binary-i386/Packages";
Contents "dists/${code_name}/Contents-i386";
SrcPackages "dists/${code_name}/${component}/source/Sources";
};
BinDirectory "dists/${code_name}/${component}/binary-amd64" {
Packages "dists/${code_name}/${component}/binary-amd64/Packages";
Contents "dists/${code_name}/Contents-amd64";
SrcPackages "dists/${code_name}/${component}/source/Sources";
};
Tree "dists/${code_name}" {
Sections "${component}";
Architectures "i386 amd64 source";
};
EOF
apt-ftparchive generate generate-${code_name}.conf
chmod 644 dists/${code_name}/Contents-*
rm -f dists/${code_name}/Release*
rm -f *.db
cat <<EOF > release-${code_name}.conf
APT::FTPArchive::Release::Origin "The ${PROJECT_NAME} project";
APT::FTPArchive::Release::Label "The ${PROJECT_NAME} project";
APT::FTPArchive::Release::Architectures "i386 amd64";
APT::FTPArchive::Release::Codename "${code_name}";
APT::FTPArchive::Release::Suite "${code_name}";
APT::FTPArchive::Release::Components "${component}";
APT::FTPArchive::Release::Description "${PACKAGE_NAME} packages";
EOF
apt-ftparchive -c release-${code_name}.conf \
release dists/${code_name} > /tmp/Release
mv /tmp/Release dists/${code_name}
}
for code_name in ${CODES}; do
case ${code_name} in
lenny|squeeze|wheezy|unstable)
distribution=debian
component=main
;;
*)
distribution=ubuntu
component=universe
;;
esac
mkdir -p ${DESTINATION}${distribution}
(cd ${DESTINATION}${distribution}
update_repository $distribution $code_name $component) &
if [ "${PARALLEL}" != "yes" ]; then
wait
fi
done
wait