diff options
-rw-r--r-- | recipes-core/multitech/config-wifi-bt-ap_2.3.bb | 99 | ||||
-rw-r--r-- | recipes-core/multitech/config_2.3.bb | 63 |
2 files changed, 99 insertions, 63 deletions
diff --git a/recipes-core/multitech/config-wifi-bt-ap_2.3.bb b/recipes-core/multitech/config-wifi-bt-ap_2.3.bb new file mode 100644 index 0000000..c440022 --- /dev/null +++ b/recipes-core/multitech/config-wifi-bt-ap_2.3.bb @@ -0,0 +1,99 @@ +# 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}() { + 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" + mkdir ${US}/old + cd /var/config + # Make a backup + tar -T ${US}/backup.list.txt -cf $D/var/config/var-config-wifi-bt-ap-bkup.tar.gz + # 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 + /etc/init.d/bt-pan stop + /etc/init.d/bluetooth stop + /etc/init.d/hostapd stop + /etc/init.d/rs9113 stop + /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 +} diff --git a/recipes-core/multitech/config_2.3.bb b/recipes-core/multitech/config_2.3.bb index e0156f1..56084f3 100644 --- a/recipes-core/multitech/config_2.3.bb +++ b/recipes-core/multitech/config_2.3.bb @@ -20,14 +20,12 @@ SRC_URI = "\ file://ppp \ file://config.init \ file://config-mths \ - file://config-wifi-bt-ap \ file://chat_wrapper \ file://chat_wrapper.default \ file://99_radio \ " RDEPENDS_${PN}-mths += "${PN}" -RDEPENDS_${PN}-wifi-bt-ap += " bluez5 bluez5-pand hostapd-cfg dnsmasq rs9113-noarch " CONFFILES_${PN} += "${sysconfdir}/defaults.tar.gz" CONFIGFILES = "network/interfaces ppp" @@ -62,16 +60,6 @@ fakeroot do_install () { install -m 0755 ${WORKDIR}/chat_wrapper ${D}${libexecdir}/ppp/ install -m 0644 ${WORKDIR}/chat_wrapper.default ${D}${sysconfdir}/default/chat_wrapper install -m 0644 ${WORKDIR}/99_radio ${D}${sysconfdir}/default/volatiles - - install -d ${D}/usr/share - cp -a ${WORKDIR}/config-wifi-bt-ap/* ${D}/ - # README does not usually go on an embedded device. - rm ${D}/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} = "${sysconfdir}/defaults.tar.gz ${sysconfdir}/default_pass" @@ -79,7 +67,6 @@ FILES_${PN} += "${sysconfdir}/init.d/config ${sysconfdir}/default ${libexecdir}/ FILES_${PN} += "${sysconfdir}/default/volatiles" FILES_${PN}-mths = "${sysconfdir}/defaults-mths.tar.gz" -FILES_${PN}-wifi-bt-ap = "/usr/share/config-wifi-bt-ap" # Create the hotspot version of defaults.tar.gz pkg_postinst_${PN}-mths() { @@ -107,53 +94,3 @@ pkg_postinst_${PN}-mths() { # Comment out the final line for a trace. rm -rf $X } - - -pkg_postinst_${PN}-wifi-bt-ap() { - US="$D/usr/share/config-wifi-bt-ap" - ND="$D/etc/network" - mkdir ${US}/old - cd /var/config - # Make a backup - tar -T ${US}/backup.list.txt -cf $D/var/config/var-config-wifi-bt-ap-bkup.tar.gz - # 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 - /etc/init.d/bt-pan stop - /etc/init.d/bluetooth stop - /etc/init.d/hostapd stop - /etc/init.d/rs9113 stop - /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}-wifi-bt-ap() { - 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 -} |