blob: b7544647ec0aa7652cec4169f995aa1bb5300fa8 (
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
99
100
101
102
103
|
# This package used to be a sub-package of config.
# This broke the Thud build of MTCAP.
# If the main package in a recipe is needed for an image,
# all packages listed in all of the RDEPENDS for the
# recipe are built, even though they are not used
# on the image. This is a problem, because it might not
# be possible to build a recipe for the current
# machine type.
#
# This package cannot be put on an image because it updates /var/config.
# A backup file is created during the package install called:
# /var/config/var-config-wifi-bt-ap-bkup.tar.gz
# This backup is used to restore /var/config if the
# package is removed.
#
DESCRIPTION = "Add wifi-bt Access Point"
SECTION = "base"
LICENSE = "MIT"
RDEPENDS_${PN} += "bash"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PACKAGE_ARCH = "all"
PR = "r10"
inherit allarch
FILESEXTRAPATHS_prepend := "${THISDIR}/config:"
SRC_URI = "\
file://config-wifi-bt-ap \
"
RDEPENDS_${PN} += " bluez5 bluez5-pand hostapd-cfg dnsmasq rs9113-noarch bash"
do_install () {
cd ${WORKDIR}
install -d ${D}/usr/share
cp -a ${WORKDIR}/config-wifi-bt-ap/usr ${D}/
install -m644 ${WORKDIR}/config-wifi-bt-ap/README ${D}/usr/share/config-wifi-bt-ap/README
echo 'List out files'
find ${D}/usr/share/config-wifi-bt-ap -type f
find ${D}/usr/share/config-wifi-bt-ap -type f | xargs chmod 0644
find ${D}/usr/share/config-wifi-bt-ap | xargs chown root:root
find ${D}/usr/share -type d | xargs chmod 0755
}
FILES_${PN} = "/usr/share/config-wifi-bt-ap"
pkg_postinst_${PN}() {
set -x
if [ -n "$D" ] ; then
echo "ERROR: /var/config should not be on a root image."
exit 1
fi
US="$D/usr/share/config-wifi-bt-ap"
ND="$D/etc/network"
if ! [ -d "${US}/old" ] ; then
mkdir ${US}/old
fi
cd /var/config
# Make a backup
tar -T ${US}/backup.list.txt -cf $D/var/config/var-config-wifi-bt-ap-bkup.tar.gz || true
# Add new interfaces
if ! grep "^auto wifi1$" ${ND}/interfaces ; then
echo >>${ND}/interfaces
cat $US/wifi1.append >>${ND}/interfaces
fi
if ! grep "^auto pan0$" ${ND}/interfaces ; then
echo >>${ND}/interfaces
cat $US/pan0.append >>${ND}/interfaces
fi
# Copy other files into place
cp -a ${US}/var/config /var
# Record files we created
md5sum $(cat ${US}/backup.list.txt) >$D/var/config/bkup-wifi-bt-ap.md5
# Restart daemons
/etc/init.d/dnsmasq stop || true
/etc/init.d/bt-pan stop || true
/etc/init.d/bluetooth stop || true
/etc/init.d/hostapd stop || true
/etc/init.d/rs9113 stop || true
/etc/init.d/rs9113 start
/etc/init.d/bluetooth start
/etc/init.d/hostapd start
/etc/init.d/bt-pan start
/etc/init.d/dnsmasq start
}
pkg_prerm_${PN}() {
cd /var/config
if md5sum -c $D/var/config/bkup-wifi-bt-ap.md5 ; then
if [ -f $D/var/config/var-config-wifi-bt-ap-bkup.tar.gz ] ; then
tar -xf $D/var/config/var-config-wifi-bt-ap-bkup.tar.gz
else
echo Cannot restore anything because backup is missing
fi
else
echo 'Cannot restore old configuration, because it has changed since the backup'
fi
}
|