blob: 3ad327703de2c0c504941aeec0166de396595102 (
plain)
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
|
#!/bin/sh
set -e
if [ $# -ne 3 ]; then
echo "Usage: $0 <src tar> <metadata.yaml> <dst file>"
exit 1
fi
src_tar=$1
metadata_dir=`dirname $2`
metadata=`basename $2`
dst_file=$3
base=`basename $src_tar`
dir=/tmp/build.$$
files_dir=files/
instroot=$dir/rootfs
cache=dl/packages/$ARCH/$SUBARCH
test -e $cache || mkdir -p $cache
OPKG="env LD_PRELOAD= $SDK/staging_dir/host/bin/opkg -o $instroot --cache $cache"
export IPKG_INSTROOT=$instroot
unpack() {
mkdir -p $instroot
cat $src_tar | (cd $instroot && tar -xz)
}
pack() {
echo Pack rootfs
(cd $dir && tar -cz *) > $dst_file
}
pack_squashfs() {
echo Pack rootfs squashfs
mksquashfs $dir $dst_file
}
add_file() {
file=$1
src_dir=$2
dst_dir=$3
src=$src_dir/$file
dst=$dst_dir/$file
if test -d $src; then
test -d $dst || mkdir -p $dst
elif test -f $src; then
cp $src $dst
foo=$(dirname $file)
if [ "$foo" = "./etc/init.d" ]; then
echo Enabling $file
set +e
sh $instroot/etc/rc.common $src enable
set -e
fi
fi
}
add_files() {
src_dir=$1
dst_dir=$2
for f in $(cd $src_dir && find); do
add_file $f $src_dir $dst_dir
done
}
add_package() {
local ipkg=$1
$OPKG install $ipkg
}
add_packages() {
local dir=$1
for f in $dir/*.ipk; do
add_package $f
done
}
update_packages() {
$OPKG update
local upgradable="$($OPKG list-upgradable|cut -d ' ' -f 1)"
for pkg in $upgradable; do
echo Upgrading $pkg
$OPKG upgrade $pkg
done
}
unpack
add_files $files_dir $instroot
add_file $metadata $metadata_dir $dir
add_files templates/ $dir/templates/
add_packages bin/packages/${ARCH}/${SUBARCH}
update_packages
pack
#pack_squashfs
|