-
Notifications
You must be signed in to change notification settings - Fork 10
/
recreate_feed
executable file
·53 lines (46 loc) · 1.54 KB
/
recreate_feed
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
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
pkg_dir=$1
if [[ -z $pkg_dir || ! -d $pkg_dir ]] ; then
echo "Usage: recreate_feed <package_directory>"
exit 1
fi
find $pkg_dir -maxdepth 1 -type f -name '*.ipk' | sort | while read pkg ; do
filename=${pkg##*/}
pkgname=${filename%%_*}
echo "Generating index for package $pkgname" >&2
## checking for multiple versions
oldflag=
for other in $pkg_dir/${pkgname}_*; do
if [[ $pkg != $other && $other -nt $pkg ]] ; then
oldflag=y
echo >&2 "Skipped old file: $pkg ($other is newer)"
[[ ! -d $pkg_dir/old ]] && mkdir $pkg_dir/old
mv $pkg $pkg_dir/old/.
break
fi
done
[[ -n $oldflag ]] && continue
file_size=$(stat -c %s $pkg)
md5sum=$(md5sum $pkg | cut -d' ' -f1)
if file -b $pkg | grep -q gzip ; then
tar -xzf $pkg ./control.tar.gz
else
ar x $pkg control.tar.gz
fi
tar zxOf control.tar.gz ./control | egrep -iv "^Filename:|^MD5SUm:|^Size:|^$" | sed -e "/^Depends:/s/(>\([^>=]\)/(>=\1/g" -e "/^Depends:/s/(<\([^<=]\)/(<=\1/g"
echo "Filename: $filename"
echo "Size: $file_size"
echo "MD5Sum: $md5sum"
echo ""
rm control.tar.gz
done >> $pkg_dir/Packages
rm -f $pkg_dir/Packages.gz
gzip $pkg_dir/Packages
# As Packages.gz is created as a new file, the parent dir will be updated
# However gzip will set times of the .gz file to taht of the original file.
# So make sure Packages.gz is 'newer' that its parent dir
touch $pkg_dir/Packages.gz
#
# The End
#