-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdate_packages.sh
More file actions
executable file
·157 lines (126 loc) · 4.14 KB
/
update_packages.sh
File metadata and controls
executable file
·157 lines (126 loc) · 4.14 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh
TOPDIR=/home/ftp/pub
BASEDIR=$TOPDIR/debian/dists
SCANPKG=$TOPDIR/../bin/dpkg-scanpackages
# ----------- DON'T CHANGE ANYTHING BELOW -----------
# ---------------------------------------------------
TMPFILE=`tempfile`
if [ -z "$1" ]; then
DIRS=`find $BASEDIR/ -name '[a-z]*' -maxdepth 1 | sort`
DIRS=`echo $DIRS`
else
if [ ! -z "$2" ]; then
for dist in $*; do
DIRS="$DIRS $BASEDIR/$dist"
done
else
DIRS="$BASEDIR/$1"
fi
fi
for dir in $DIRS; do
dist=`basename $dir`
cd $TOPDIR || (echo "can't change to top directory!" ; exit 1)
echo "$dir"
ARCHS=`find $dir -type d -name 'binary-*' -maxdepth 1 -exec basename {} \; | grep -v binary-all | sort`
# --------------------------
# Create overrides file(s)
printf " Updating override files in arch: "
for arch in binary-all $ARCHS; do
echo -n "$arch "
echo -n > $dir/.override_$arch
for pkg in `find $dir/$arch -type f -name '*.deb' | sed -e "s@$dir/$arch/@@" | sed -e 's@_[0-9].*@@' | sort`; do
set -- `echo $pkg | sed 's@/@ @'`
printf "%-55s optional %s\n" $2 $1 >> $dir/.override_$arch
done
done
echo
# --------------------------
# Create Links to binary-all
printf " Creating symlinks in arch: "
find $dir -type l -exec rm {} \;
for arch in $ARCHS; do
echo -n "$arch "
for pkg in `find $dir/binary-all -type f -name '*.deb' | sed 's@\./@@'`; do
tmp=`dirname $pkg`
pkg_dir=`basename $tmp | sed 's@binary-all@@'`
pkg_file=`basename $pkg`
if [ ! -h "$dir/$arch/$pkg_dir/$pkg_file" -a \
! -f "$dir/$arch/$pkg_dir/$pkg_file" ]
then
ln -s ../../binary-all/$pkg_dir/$pkg_file $dir/$arch/$pkg_dir/$pkg_file
fi
done
ln -s ../Release $dir/$arch/Release
done
echo
# --------------------------
# Create Packages files
printf " Creating packages file in arch: "
for arch in $ARCHS source; do
# Setup a override from ALL+ARCH
if [ -f "$dir/.override_binary-all" -a -f "$dir/.override_$arch" ]; then
cat $dir/.override_binary-all $dir/.override_$arch | sort > $TMPFILE
fi
if [ -d "$dir/$arch" ]; then
echo -n "$arch"
if echo $arch | grep -q binary; then
# Binary packages
$SCANPKG $dir/$arch $TMPFILE ../ 2> /dev/null | sed "s@$TOPDIR/@@" > $dir/$arch/Packages
$SCANPKG -u $dir/$arch $TMPFILE ../ 2> /dev/null | sed "s@$TOPDIR/@@" >> $dir/$arch/Packages
gzip -9c $dir/$arch/Packages > $dir/$arch/Packages.gz
packages=`cat $dir/$arch/Packages | grep ^Package: | wc -l`
else
# Source packages
# Wrote 272 entries to output Packages file.
dpkg-scansources $dir/$arch $TMPFILE ../ 2> /dev/null | sed "s@$TOPDIR/@@" > $dir/$arch/Sources
gzip -9c $dir/$arch/Sources > $dir/$arch/Sources.gz
packages=`cat $dir/$arch/Sources | grep ^Package: | wc -l`
fi
packages=`echo $packages | sed 's@\ @@g'`
echo -n "/$packages "
fi
done
echo
# --------------------------
# Create the Release file
printf " Creating release file in topdir: "
PKGFILES=`find $dir -name 'Package*' -type f`
if [ -f "$dir/.release" ]; then
cat $dir/.release | sed "s@%DATE1%@`822-date`@" > $dir/Release
else
echo `822-date` > $dir/Release
fi
echo "MD5Sum:" >> $dir/Release
for pkgfile in $PKGFILES; do
file=`echo $pkgfile | sed "s@$BASEDIR/$dist/@@"`
set -- `/bin/ls -l $pkgfile`
size=$5
md5sum=`md5sum $pkgfile | sed 's@\ .*@@'`
printf " $md5sum %17d main/$file\n" $size >> $dir/Release
done
echo -n "md5 "
echo "SHA1:" >> $dir/Release
for pkgfile in $PKGFILES; do
file=`echo $pkgfile | sed "s@$BASEDIR/$dist/@@"`
set -- `/bin/ls -l $pkgfile`
size=$5
sha1=`openssl dgst -sha1 $pkgfile | sed 's@.*\ @@'`
printf " $sha1 %17d main/$file\n" $size >> $dir/Release
done
echo "sha1"
DISKS=`find $dir -type d -name 'disks-*' -maxdepth 1 -exec basename {} \; | sort`
# --------------------------
# Create the 'main' link
printf " Updating current link in disk: "
for disk in $DISKS; do
echo -n "$disk "
(cd $dir/$disk && ln -s . current)
done
echo
if [ ! -f "$dir/main" -a \
! -h "$dir/main" ]
then
(cd $dir && ln -s . main)
fi
done
rm -f $TMPFILE