# 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 }