-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-tarball.sh
executable file
·164 lines (132 loc) · 2.42 KB
/
make-tarball.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
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
158
159
160
161
162
#!/bin/bash
set -e
CWD=$(pwd)
PKGDIR=$CWD/packages
WORKDIR=$CWD/work/fun_plug
D=$WORKDIR/sysroot
CPREFIX=/ffp
FUNPKG=$CWD/source/funpkg/files/ffp/sbin/funpkg
TAR=tar-1.13
# helper functions
die()
{
cat <<EOF
FATAL: $@
EOF
exit 1
}
find_pkg()
{
_pkg=$(cd $PKGDIR; ls -1 $1-*.tgz | egrep "$1"'-[^-]*-[^-]*.tgz$' | tail -n 1)
[ -r "$PKGDIR/$_pkg" ] || die "$1: No package found"
echo "$PKGDIR/$_pkg"
}
unpack_pkg()
{
_pkg="$1"
shift 1
_cmd="tar xzf $_pkg -C $D $@"
echo $_cmd
eval $_cmd
}
install_pkg()
{
_cmd="/bin/sh $FUNPKG -D $D -i $1"
echo $_cmd
eval $_cmd
}
list_libs()
{
tar tzf $1 | egrep '/lib/lib.*\.so'
}
list_terminfo()
{
_filter=
while [ $# -gt 0 ]; do
_filter="$_filter| egrep '/share/termifo/.*/$1\$'"
shift 1
done
tar tzf $1 $_filter
}
# Checks
[ -x "$FUNPKG" ] || die "funpkg not found"
[ -d "$PKGDIR" ] || die "packages directory not found"
which $TAR >/dev/null 2>/dev/null || die "$TAR not found"
# Cleanup
echo "clean..."
rm -rf $WORKDIR
mkdir -p $WORKDIR $D
# busybox and links
echo "busybox..."
cd $D
tar xzf $(find_pkg busybox)
/bin/sh .$CPREFIX/bin/install-busybox-links.sh
# stripped program packages and core libs
plist=(
uclibc
e2fsprogs
file
libiconv
ncurses
sqlite
)
for p in ${plist[*]}; do
pkg=$(find_pkg $p)
unpack_pkg $pkg \
--exclude=.$CPREFIX/include \
--exclude=.$CPREFIX/lib/pkgconfig \
--exclude=\*.la --exclude=\*.a --exclude=\*.o \
--exclude=.$CPREFIX/lib/preloadable_\*
done
plist=(
expat
gcc
libusb
libxml2
openssl
pcre
readline
tcp_wrappers
zlib
)
for p in ${plist[*]}; do
pkg=$(find_pkg $p)
list_libs $pkg | unpack_pkg $pkg -T -
done
cd $D
find .$CPREFIX >$WORKDIR/fun_plug.list
mkdir -p $D$CPREFIX/var/packages
mv $WORKDIR/fun_plug.list $D$CPREFIX/var/packages/fun_plug-0.5-$(date '+%y_%m_%d')
# pre-installed packages
plist=(
busybox
dialog
dns323-utils
ffp-scripts
funpkg
groff
less
lighttpd
lsof
man
mediatomb
nfs-utils
ntp
openssh
portmap
rcorder
rsync
shadow
strace
unfs3
usbutils
#vim
)
for p in ${plist[*]}; do
pkg=$(find_pkg $p)
install_pkg $pkg
done
# tarball
echo "fun_plug.tgz ..."
$TAR cf - -C $D$CPREFIX --owner=root --group=root . | gzip -9 -c >$CWD/fun_plug.tgz
du -k $CWD/fun_plug.tgz