├── README.md ├── conf ├── bblayers.conf.sample ├── distro │ └── openwrt.conf ├── layer.conf └── local.conf.sample └── recipes-core ├── base-files-openwrt ├── base-files-openwrt_git.bb └── files │ ├── LICENSE │ └── fix-network-config.patch ├── busybox ├── busybox_%.bbappend └── files │ ├── 220-add_lock_util.patch │ ├── 250-date-k-flag.patch │ └── lock.cfg ├── dnsmasq ├── dnsmasq_%.bbappend └── files │ ├── dhcp.conf │ ├── dnsmasq.conf │ ├── dnsmasq.hotplug │ └── dnsmasq.init ├── fstools ├── files │ ├── fix-bsd.patch │ ├── fstab.default │ ├── fstab.init │ ├── mount.hotplug │ └── snapshot └── fstools_git.bb ├── images └── openwrt-image-base.bb ├── initscripts └── initscripts_%.bbappend ├── iwinfo ├── files │ ├── fix-make.patch │ └── luajit.patch └── iwinfo_git.bb ├── jsonfiler ├── files │ └── fix-lemon.patch └── jsonfilter_git.bb ├── libubox ├── files │ └── luajit.patch └── libubox_git.bb ├── lua-socket ├── files │ └── lua-socket_2.0.2-make.patch └── lua-socket_2.0.2.bb ├── luajit ├── files │ └── pkgconfig │ │ └── luajit.pc └── luajit_%.bbappend ├── luci ├── files │ ├── fix-compile-luajit.patch │ ├── fix-compile.patch │ └── luajit.patch └── luci_git.bb ├── luci2 └── luci2_git.bb ├── netifd ├── files │ ├── files │ │ ├── etc │ │ │ ├── hotplug.d │ │ │ │ └── iface │ │ │ │ │ └── 00-netstate │ │ │ └── init.d │ │ │ │ └── network │ │ ├── lib │ │ │ ├── netifd │ │ │ │ ├── dhcp.script │ │ │ │ └── proto │ │ │ │ │ └── dhcp.sh │ │ │ └── network │ │ │ │ └── config.sh │ │ ├── sbin │ │ │ ├── devstatus │ │ │ ├── ifdown │ │ │ ├── ifstatus │ │ │ └── ifup │ │ └── usr │ │ │ └── share │ │ │ └── udhcpc │ │ │ └── default.script │ └── fix-compile.patch └── netifd_git.bb ├── packagegroups └── packagegroup-openwrt-boot.bb ├── procd ├── files │ ├── hotplug-preinit.json │ ├── hotplug.json │ ├── nand.sh │ ├── procd.sh │ └── reload_config └── procd_git.bb ├── rpcd ├── files │ ├── rpcd.config │ └── rpcd.init └── rpcd_git.bb ├── ubox ├── files │ ├── 100-insmod-segfault.patch │ └── log.init └── ubox_git.bb ├── ubus ├── files │ └── luajit.patch └── ubus_git.bb ├── uci ├── files │ ├── luajit.patch │ └── uci.sh └── uci_git.bb ├── uhttpd ├── files │ └── luajit.patch └── uhttpd_git.bb ├── uhttpd2 ├── files │ ├── fix-bsd.patch │ ├── luajit.patch │ ├── ubus.default │ ├── uhttpd.config │ └── uhttpd.init └── uhttpd2_git.bb ├── update-rc.d ├── files │ └── single_runlevel.patch └── update-rc.d_%.bbappend └── ustream-ssl └── ustream-ssl_git.bb /README.md: -------------------------------------------------------------------------------- 1 | # meta-openwrt 2 | OpenWRT core as Yocto layer 3 | 4 | Overview. 5 | 6 | This is the layer containing most used recipes of Openwrt. 7 | Openwrt has it`s own implementation of init, message bus, http server, web interface and sets of system utils and libraries. 8 | Anyway it activly uses busybox, iptbales and other common linux components. 9 | To get more information about OpenWrt please see: http://wiki.openwrt.org/doc/techref/architecture. 10 | The main idea behind this layer was to allow using OE build system together with OpenWrt base packages set. 11 | 12 | Build requirements. 13 | 14 | This layer requiired: 15 | * bitbake 16 | * oe-core 17 | * meta-openembedded mostly for lua/luajit 18 | 19 | Build instructions. 20 | 21 | 1. mkdir sources 22 | 2. git clone git://git.openembedded.org/openembedded-core sources/oe-core -b daisy 23 | 3. git clone git://git.openembedded.org/bitbake sources/oe-core/bitbake -b 1.22 24 | 4. git clone git://git.openembedded.org/meta-openembedded sources/meta-oe -b daisy 25 | 5. git clone git@github.com:MentorEmbedded/meta-openwrt.git sources/meta-openwrt 26 | 6. TEMPLATECONF=../sources/meta-openwrt/conf . ./source/oe-core/oe-init-build-env 27 | 7. bitbake openwrt-image-base 28 | -------------------------------------------------------------------------------- /conf/bblayers.conf.sample: -------------------------------------------------------------------------------- 1 | # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf 2 | # changes incompatibly 3 | LCONF_VERSION = "5" 4 | 5 | BBPATH = "${TOPDIR}" 6 | BBFILES ?= "" 7 | 8 | BBLAYERS ?= " \ 9 | ##OEROOT##/meta \ 10 | ##OEROOT##/../meta-oe/meta-phyton \ 11 | ##OEROOT##/../meta-oe/meta-networking \ 12 | ##OEROOT##/../meta-oe/meta-oe \ 13 | ##OEROOT##/../meta-openwrt \ 14 | " 15 | 16 | BBLAYERS_NON_REMOVABLE ?= " \ 17 | ##OEROOT##/meta \ 18 | " 19 | 20 | -------------------------------------------------------------------------------- /conf/distro/openwrt.conf: -------------------------------------------------------------------------------- 1 | DISTRO = "openwrt" 2 | DISTRO_NAME = "Openwrt" 3 | DISTRO_VERSION = "0.0.0" 4 | DISTRO_CODENAME = "experementall" 5 | SDK_VENDOR = "-openwrt" 6 | SDK_VERSION := "${@'${DISTRO_VERSION}'}" 7 | 8 | MAINTAINER = "Valentin.Sitdikov@mentor.com" 9 | 10 | TARGET_VENDOR = "-openwrt" 11 | 12 | LOCALCONF_VERSION = "1" 13 | LAYER_CONF_VERSION ?= "5" 14 | 15 | # Override these in poky based distros 16 | OPENWRT_DEFAULT_DISTRO_FEATURES = "" 17 | OPENWRT_DEFAULT_EXTRA_RDEPENDS = "packagegroup-core-boot" 18 | OPENWRT_DEFAULT_EXTRA_RRECOMMENDS = "kernel-module-af-packet" 19 | 20 | DISTRO_FEATURES ?= "${DISTRO_FEATURES_DEFAULT} ${DISTRO_FEATURES_LIBC} ${POKY_DEFAULT_DISTRO_FEATURES}" 21 | 22 | PREFERRED_VERSION_linux-yocto ?= "3.14%" 23 | PREFERRED_VERSION_linux-yocto_qemux86 ?= "3.14%" 24 | PREFERRED_VERSION_linux-yocto_qemux86-64 ?= "3.14%" 25 | PREFERRED_VERSION_linux-yocto_qemuarm ?= "3.14%" 26 | PREFERRED_VERSION_linux-yocto_qemumips ?= "3.14%" 27 | PREFERRED_VERSION_linux-yocto_qemumips64 ?= "3.14%" 28 | PREFERRED_VERSION_linux-yocto_qemuppc ?= "3.14%" 29 | 30 | SDK_NAME = "${DISTRO}-${TCLIBC}-${SDK_ARCH}-${IMAGE_BASENAME}-${TUNE_PKGARCH}" 31 | SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}" 32 | 33 | EXTRAOPKGCONFIG = "openwrt-feed-config-opkg" 34 | 35 | DISTRO_EXTRA_RDEPENDS += " ${OPENWRT_DEFAULT_EXTRA_RDEPENDS}" 36 | DISTRO_EXTRA_RRECOMMENDS += " ${OPENERT_DEFAULT_EXTRA_RRECOMMENDS}" 37 | 38 | OPENWRTQEMUDEPS = "${@base_contains("INCOMPATIBLE_LICENSE", "GPLv3", "", "qemu-config",d)}" 39 | DISTRO_EXTRA_RDEPENDS_append_qemuarm = " ${OPENWRTQEMUDEPS}" 40 | DISTRO_EXTRA_RDEPENDS_append_qemumips = " ${OPENWRTQEMUDEPS}" 41 | DISTRO_EXTRA_RDEPENDS_append_qemuppc = " ${OPENWRTQEMUDEPS}" 42 | DISTRO_EXTRA_RDEPENDS_append_qemux86 = " ${OPENWRTQEMUDEPS}" 43 | DISTRO_EXTRA_RDEPENDS_append_qemux86-64 = " ${OPENWRTQEMUDEPS}" 44 | 45 | TCLIBCAPPEND = "" 46 | 47 | QEMU_TARGETS ?= "arm i386 mips mipsel ppc x86_64" 48 | # Other QEMU_TARGETS "mips64 mips64el sh4" 49 | 50 | PREMIRRORS ??= "\ 51 | bzr://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 52 | cvs://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 53 | git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 54 | hg://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 55 | osc://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 56 | p4://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 57 | svk://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 58 | svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n" 59 | 60 | MIRRORS =+ "\ 61 | ftp://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 62 | http://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \ 63 | https://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n" 64 | 65 | # The CONNECTIVITY_CHECK_URI's are used to test whether we can succesfully 66 | # fetch from the network (and warn you if not). To disable the test set 67 | # the variable to be empty. 68 | # Git example url: git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD 69 | 70 | CONNECTIVITY_CHECK_URIS ?= " \ 71 | https://eula-downloads.yoctoproject.org/index.php \ 72 | http://bugzilla.yoctoproject.org/report.cgi" 73 | 74 | SANITY_TESTED_DISTROS ?= " \ 75 | Poky-1.4 \n \ 76 | Poky-1.5 \n \ 77 | Poky-1.6 \n \ 78 | Ubuntu-12.04 \n \ 79 | Ubuntu-13.10 \n \ 80 | Ubuntu-14.04 \n \ 81 | Fedora-19 \n \ 82 | Fedora-20 \n \ 83 | CentOS-6.4 \n \ 84 | CentOS-6.5 \n \ 85 | Debian-7.0 \n \ 86 | Debian-7.1 \n \ 87 | Debian-7.2 \n \ 88 | Debian-7.3 \n \ 89 | Debian-7.4 \n \ 90 | SUSE-LINUX-12.2 \n \ 91 | openSUSE-project-12.3 \n \ 92 | openSUSE-project-13.1 \n \ 93 | " 94 | 95 | # Default hash policy for distro 96 | BB_SIGNATURE_HANDLER ?= 'OEBasicHash' 97 | # 98 | # OELAYOUT_ABI allows us to notify users when the format of TMPDIR changes in 99 | # an incompatible way. Such changes should usually be detailed in the commit 100 | # that breaks the format and have been previously discussed on the mailing list 101 | # with general agreement from the core team. 102 | # 103 | OELAYOUT_ABI = "8" 104 | 105 | # add openwrt sanity bbclass 106 | #INHERIT += "openwrt-sanity" 107 | 108 | # QA check settings - a little stricter than the OE-Core defaults 109 | WARN_QA = "textrel files-invalid incompatible-license xorg-driver-abi libdir \ 110 | unknown-configure-option" 111 | ERROR_QA = "dev-so debug-deps dev-deps debug-files arch pkgconfig la perms \ 112 | useless-rpaths rpaths staticdev ldflags pkgvarcheck already-stripped \ 113 | compile-host-path dep-cmp installed-vs-shipped install-host-path \ 114 | packages-list perm-config perm-line perm-link pkgv-undefined \ 115 | pn-overrides split-strip var-undefined version-going-backwards" 116 | 117 | export localstatedir = "${base_prefix}/tmp" 118 | 119 | -------------------------------------------------------------------------------- /conf/layer.conf: -------------------------------------------------------------------------------- 1 | # We have a conf and classes directory, add to BBPATH 2 | BBPATH := "${BBPATH}:${LAYERDIR}" 3 | 4 | # We have a recipes directory, add to BBFILES 5 | BBFILES := "${BBFILES} ${LAYERDIR}/recipes-core/*/*.bb ${LAYERDIR}/recipes-core/*/*.bbappend" 6 | 7 | BBFILE_COLLECTIONS += "appliance" 8 | BBFILE_PATTERN_appliance := "^${LAYERDIR}/" 9 | BBFILE_PRIORITY_appliance = "1" 10 | -------------------------------------------------------------------------------- /conf/local.conf.sample: -------------------------------------------------------------------------------- 1 | # 2 | # This file is your local configuration file and is where all local user settings 3 | # are placed. The comments in this file give some guide to the options a new user 4 | # to the system might want to change but pretty much any configuration option can 5 | # be set in this file. More adventurous users can look at local.conf.extended 6 | # which contains other examples of configuration which can be placed in this file 7 | # but new users likely won't need any of them initially. 8 | # 9 | # Lines starting with the '#' character are commented out and in some cases the 10 | # default values are provided as comments to show people example syntax. Enabling 11 | # the option is a question of removing the # character and making any change to the 12 | # variable as required. 13 | 14 | # 15 | # Parallelism Options 16 | # 17 | # These two options control how much parallelism BitBake should use. The first 18 | # option determines how many tasks bitbake should run in parallel: 19 | # 20 | #BB_NUMBER_THREADS ?= "4" 21 | # 22 | # Default to setting automatically based on cpu count 23 | BB_NUMBER_THREADS ?= "${@oe.utils.cpu_count()}" 24 | # 25 | # The second option controls how many processes make should run in parallel when 26 | # running compile tasks: 27 | # 28 | #PARALLEL_MAKE ?= "-j 4" 29 | # 30 | # Default to setting automatically based on cpu count 31 | PARALLEL_MAKE ?= "-j ${@oe.utils.cpu_count()}" 32 | # 33 | # For a quad-core machine, BB_NUMBER_THREADS = "4", PARALLEL_MAKE = "-j 4" would 34 | # be appropriate for example. 35 | 36 | # 37 | # Machine Selection 38 | # 39 | # You need to select a specific machine to target the build with. There are a selection 40 | # of emulated machines available which can boot and run in the QEMU emulator: 41 | # 42 | #MACHINE ?= "qemuarm" 43 | #MACHINE ?= "qemumips" 44 | #MACHINE ?= "qemuppc" 45 | #MACHINE ?= "qemux86" 46 | #MACHINE ?= "qemux86-64" 47 | # 48 | # This sets the default machine to be qemux86 if no other machine is selected: 49 | MACHINE ??= "qemuarm" 50 | 51 | # 52 | # Where to place downloads 53 | # 54 | # During a first build the system will download many different source code tarballs 55 | # from various upstream projects. This can take a while, particularly if your network 56 | # connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you 57 | # can preserve this directory to speed up this part of subsequent builds. This directory 58 | # is safe to share between multiple builds on the same machine too. 59 | # 60 | # The default is a downloads directory under TOPDIR which is the build directory. 61 | # 62 | #DL_DIR ?= "${TOPDIR}/downloads" 63 | 64 | # 65 | # Where to place shared-state files 66 | # 67 | # BitBake has the capability to accelerate builds based on previously built output. 68 | # This is done using "shared state" files which can be thought of as cache objects 69 | # and this option determines where those files are placed. 70 | # 71 | # You can wipe out TMPDIR leaving this directory intact and the build would regenerate 72 | # from these files if no changes were made to the configuration. If changes were made 73 | # to the configuration, only shared state files where the state was still valid would 74 | # be used (done using checksums). 75 | # 76 | # The default is a sstate-cache directory under TOPDIR. 77 | # 78 | #SSTATE_DIR ?= "${TOPDIR}/sstate-cache" 79 | 80 | # 81 | # Where to place the build output 82 | # 83 | # This option specifies where the bulk of the building work should be done and 84 | # where BitBake should place its temporary files and output. Keep in mind that 85 | # this includes the extraction and compilation of many applications and the toolchain 86 | # which can use Gigabytes of hard disk space. 87 | # 88 | # The default is a tmp directory under TOPDIR. 89 | # 90 | #TMPDIR = "${TOPDIR}/tmp" 91 | 92 | 93 | # 94 | # Package Management configuration 95 | # 96 | # This variable lists which packaging formats to enable. Multiple package backends 97 | # can be enabled at once and the first item listed in the variable will be used 98 | # to generate the root filesystems. 99 | # Options are: 100 | # - 'package_deb' for debian style deb files 101 | # - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager) 102 | # - 'package_rpm' for rpm style packages 103 | # E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk" 104 | # We default to ipk: 105 | PACKAGE_CLASSES ?= "package_ipk" 106 | 107 | # 108 | # SDK/ADT target architecture 109 | # 110 | # This variable specifies the architecture to build SDK/ADT items for and means 111 | # you can build the SDK packages for architectures other than the machine you are 112 | # running the build on (i.e. building i686 packages on an x86_64 host). 113 | # Supported values are i686 and x86_64 114 | #SDKMACHINE ?= "i686" 115 | 116 | # 117 | # Extra image configuration defaults 118 | # 119 | # The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated 120 | # images. Some of these options are added to certain image types automatically. The 121 | # variable can contain the following options: 122 | # "dbg-pkgs" - add -dbg packages for all installed packages 123 | # (adds symbol information for debugging/profiling) 124 | # "dev-pkgs" - add -dev packages for all installed packages 125 | # (useful if you want to develop against libs in the image) 126 | # "ptest-pkgs" - add -ptest packages for all ptest-enabled packages 127 | # (useful if you want to run the package test suites) 128 | # "tools-sdk" - add development tools (gcc, make, pkgconfig etc.) 129 | # "tools-debug" - add debugging tools (gdb, strace) 130 | # "eclipse-debug" - add Eclipse remote debugging support 131 | # "tools-profile" - add profiling tools (oprofile, exmap, lttng, valgrind) 132 | # "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.) 133 | # "debug-tweaks" - make an image suitable for development 134 | # e.g. ssh root access has a blank password 135 | # There are other application targets that can be used here too, see 136 | # meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details. 137 | # We default to enabling the debugging tweaks. 138 | EXTRA_IMAGE_FEATURES = "debug-tweaks" 139 | 140 | # 141 | # Additional image features 142 | # 143 | # The following is a list of additional classes to use when building images which 144 | # enable extra features. Some available options which can be included in this variable 145 | # are: 146 | # - 'buildstats' collect build statistics 147 | # - 'image-mklibs' to reduce shared library files size for an image 148 | # - 'image-prelink' in order to prelink the filesystem image 149 | # - 'image-swab' to perform host system intrusion detection 150 | # NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink 151 | # NOTE: mklibs also needs to be explicitly enabled for a given image, see local.conf.extended 152 | USER_CLASSES ?= "buildstats image-mklibs image-prelink" 153 | 154 | 155 | # 156 | # Runtime testing of images 157 | # 158 | # The build system can test booting virtual machine images under qemu (an emulator) 159 | # after any root filesystems are created and run tests against those images. To 160 | # enable this uncomment this line. See classes/testimage(-auto).bbclass for 161 | # further details. 162 | #TEST_IMAGE = "1" 163 | # 164 | # Interactive shell configuration 165 | # 166 | # Under certain circumstances the system may need input from you and to do this it 167 | # can launch an interactive shell. It needs to do this since the build is 168 | # multithreaded and needs to be able to handle the case where more than one parallel 169 | # process may require the user's attention. The default is iterate over the available 170 | # terminal types to find one that works. 171 | # 172 | # Examples of the occasions this may happen are when resolving patches which cannot 173 | # be applied, to use the devshell or the kernel menuconfig 174 | # 175 | # Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none 176 | # Note: currently, Konsole support only works for KDE 3.x due to the way 177 | # newer Konsole versions behave 178 | #OE_TERMINAL = "auto" 179 | # By default disable interactive patch resolution (tasks will just fail instead): 180 | PATCHRESOLVE = "noop" 181 | 182 | # 183 | # Disk Space Monitoring during the build 184 | # 185 | # Monitor the disk space during the build. If there is less that 1GB of space or less 186 | # than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully 187 | # shutdown the build. If there is less that 100MB or 1K inodes, perform a hard abort 188 | # of the build. The reason for this is that running completely out of space can corrupt 189 | # files and damages the build in ways which may not be easily recoverable. 190 | BB_DISKMON_DIRS = "\ 191 | STOPTASKS,${TMPDIR},1G,100K \ 192 | STOPTASKS,${DL_DIR},1G,100K \ 193 | STOPTASKS,${SSTATE_DIR},1G,100K \ 194 | ABORT,${TMPDIR},100M,1K \ 195 | ABORT,${DL_DIR},100M,1K \ 196 | ABORT,${SSTATE_DIR},100M,1K" 197 | 198 | # 199 | # Shared-state files from other locations 200 | # 201 | # As mentioned above, shared state files are prebuilt cache data objects which can 202 | # used to accelerate build time. This variable can be used to configure the system 203 | # to search other mirror locations for these objects before it builds the data itself. 204 | # 205 | # This can be a filesystem directory, or a remote url such as http or ftp. These 206 | # would contain the sstate-cache results from previous builds (possibly from other 207 | # machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the 208 | # cache locations to check for the shared objects. 209 | # NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH 210 | # at the end as shown in the examples below. This will be substituted with the 211 | # correct path within the directory structure. 212 | #SSTATE_MIRRORS ?= "\ 213 | #file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \ 214 | #file://.* file:///some/local/dir/sstate/PATH" 215 | 216 | 217 | # 218 | # Qemu configuration 219 | # 220 | # By default qemu will build with a builtin VNC server where graphical output can be 221 | # seen. The two lines below enable the SDL backend too. This assumes there is a 222 | # libsdl library available on your build system. 223 | PACKAGECONFIG_pn-qemu-native = "sdl" 224 | PACKAGECONFIG_pn-nativesdk-qemu = "sdl" 225 | ASSUME_PROVIDED += "libsdl-native" 226 | 227 | 228 | # CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to 229 | # track the version of this file when it was generated. This can safely be ignored if 230 | # this doesn't mean anything to you. 231 | CONF_VERSION = "1" 232 | 233 | DISTRO ?= "openwrt" 234 | -------------------------------------------------------------------------------- /recipes-core/base-files-openwrt/base-files-openwrt_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Base files from openwrt project" 2 | HOMEPAGE = "http://wiki.openwrt.org/" 3 | LICENSE = "GPLv2" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=94d55d512a9ba36caa9b7df079bae19f" 5 | 6 | SRC_URI = "git://git.openwrt.org/14.07/openwrt.git;protocol=git;branch=master" 7 | SRC_URI += "file://LICENSE" 8 | SRC_URI += "file://fix-network-config.patch" 9 | 10 | SRCREV = "229d60fdb45c34902d402938e231c006f7c73931" 11 | S = "${WORKDIR}/git" 12 | 13 | PR="r1" 14 | 15 | DEPENDS = "" 16 | 17 | FILES_${PN} = "*" 18 | 19 | do_compile () { 20 | : 21 | } 22 | 23 | do_install () { 24 | cp -a ${S}/package/base-files/files/* ${D} 25 | mkdir -p ${D}/CONTROL 26 | mkdir -p ${D}/dev 27 | mkdir -p ${D}/etc/crontabs 28 | mkdir -p ${D}/etc/rc.d 29 | mkdir -p ${D}/overlay 30 | mkdir -p ${D}/lib/firmware 31 | mkdir -p ${D}/mnt 32 | mkdir -p ${D}/proc 33 | mkdir -p ${D}/tmp 34 | mkdir -p ${D}/usr/lib 35 | mkdir -p ${D}/usr/bin 36 | mkdir -p ${D}/sys 37 | mkdir -p ${D}/www 38 | mkdir -p ${D}/root 39 | ln -sf /proc/mounts ${D}/etc/mtab 40 | mkdir -p ${D}/etc 41 | rm -rf ${D}/var 42 | #ln -sf ./tmp ${D}/var 43 | ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ ${D}/etc/ 44 | chmod 0600 ${D}/etc/shadow 45 | chmod 1777 ${D}/tmp 46 | 47 | } 48 | 49 | PACKAGE_ARCH = "${MACHINE_ARCH}" 50 | CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]} ${sysconfdir}/shells" 51 | 52 | -------------------------------------------------------------------------------- /recipes-core/base-files-openwrt/files/LICENSE: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007-2014 OpenWrt.org 3 | # Copyright (C) 2010 Vertical Communications 4 | # 5 | # This is free software, licensed under the GNU General Public License v2. 6 | 7 | -------------------------------------------------------------------------------- /recipes-core/base-files-openwrt/files/fix-network-config.patch: -------------------------------------------------------------------------------- 1 | Index: git/package/base-files/files/etc/config/network 2 | =================================================================== 3 | --- git.orig/package/base-files/files/etc/config/network 4 | +++ git/package/base-files/files/etc/config/network 5 | @@ -8,11 +8,9 @@ config interface loopback 6 | 7 | config interface lan 8 | option ifname eth0 9 | - option type bridge 10 | option proto static 11 | - option ipaddr 192.168.1.1 12 | + option ipaddr 192.168.7.2 13 | option netmask 255.255.255.0 14 | - option ip6assign 60 15 | 16 | config interface wan6 17 | option ifname @wan 18 | -------------------------------------------------------------------------------- /recipes-core/busybox/busybox_%.bbappend: -------------------------------------------------------------------------------- 1 | # Example use of configuration fragments for busybox, which uses the same 2 | # mechanism as the linux-yocto kernel recipe. 3 | # 4 | # The entries here will override any entries in the base busybox recipe 5 | # 6 | # More details can be found in the Kernel Dev Manual 7 | # http://www.yoctoproject.org/docs/current/kernel-dev/kernel-dev.html#changing-the-configuration 8 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 9 | 10 | SRC_URI += " \ 11 | file://lock.cfg \ 12 | file://220-add_lock_util.patch \ 13 | file://250-date-k-flag.patch \ 14 | " 15 | 16 | do_install_append () { 17 | rm ${D}/usr/share/udhcpc/default.script 18 | } 19 | -------------------------------------------------------------------------------- /recipes-core/busybox/files/220-add_lock_util.patch: -------------------------------------------------------------------------------- 1 | --- a/include/applets.src.h 2 | +++ b/include/applets.src.h 3 | @@ -212,6 +212,7 @@ IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, 4 | IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP)) 5 | IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 6 | IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP)) 7 | +IF_LOCK(APPLET(lock, BB_DIR_BIN, BB_SUID_DROP)) 8 | IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP)) 9 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ 10 | IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE)) 11 | --- a/miscutils/Config.src 12 | +++ b/miscutils/Config.src 13 | @@ -419,6 +419,12 @@ config FEATURE_HDPARM_HDIO_GETSET_DMA 14 | help 15 | Enables the 'hdparm -d' option to get/set using_dma flag. 16 | 17 | +config LOCK 18 | + bool "lock" 19 | + default n 20 | + help 21 | + Small utility for using locks in scripts 22 | + 23 | config MAKEDEVS 24 | bool "makedevs" 25 | default y 26 | --- a/miscutils/Kbuild.src 27 | +++ b/miscutils/Kbuild.src 28 | @@ -29,6 +29,7 @@ lib-$(CONFIG_INOTIFYD) += inotifyd.o 29 | lib-$(CONFIG_FEATURE_LAST_SMALL)+= last.o 30 | lib-$(CONFIG_FEATURE_LAST_FANCY)+= last_fancy.o 31 | lib-$(CONFIG_LESS) += less.o 32 | +lib-$(CONFIG_LOCK) += lock.o 33 | lib-$(CONFIG_MAKEDEVS) += makedevs.o 34 | lib-$(CONFIG_MAN) += man.o 35 | lib-$(CONFIG_MICROCOM) += microcom.o 36 | --- /dev/null 37 | +++ b/miscutils/lock.c 38 | @@ -0,0 +1,135 @@ 39 | +/* 40 | + * Copyright (C) 2006 Felix Fietkau 41 | + * 42 | + * This is free software, licensed under the GNU General Public License v2. 43 | + */ 44 | +#include 45 | +#include 46 | +#include 47 | +#include 48 | +#include 49 | +#include 50 | +#include 51 | +#include "busybox.h" 52 | + 53 | +//usage:#define lock_trivial_usage NOUSAGE_STR 54 | +//usage:#define lock_full_usage "" 55 | + 56 | +static int unlock = 0; 57 | +static int shared = 0; 58 | +static int waitonly = 0; 59 | +static int fd; 60 | +static char *file; 61 | + 62 | +static void usage(char *name) 63 | +{ 64 | + fprintf(stderr, "Usage: %s [-suw] \n" 65 | + " -s Use shared locking\n" 66 | + " -u Unlock\n" 67 | + " -w Wait for the lock to become free, don't acquire lock\n" 68 | + "\n", name); 69 | + exit(1); 70 | +} 71 | + 72 | +static void exit_unlock(int sig) 73 | +{ 74 | + flock(fd, LOCK_UN); 75 | + exit(0); 76 | +} 77 | + 78 | +static int do_unlock(void) 79 | +{ 80 | + FILE *f; 81 | + int i; 82 | + 83 | + if ((f = fopen(file, "r")) == NULL) 84 | + return 0; 85 | + 86 | + fscanf(f, "%d", &i); 87 | + if (i > 0) 88 | + kill(i, SIGTERM); 89 | + 90 | + fclose(f); 91 | + 92 | + return 0; 93 | +} 94 | + 95 | +static int do_lock(void) 96 | +{ 97 | + int pid; 98 | + char pidstr[8]; 99 | + 100 | + if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) { 101 | + if ((fd = open(file, O_RDWR)) < 0) { 102 | + fprintf(stderr, "Can't open %s\n", file); 103 | + return 1; 104 | + } 105 | + } 106 | + 107 | + if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) { 108 | + fprintf(stderr, "Can't lock %s\n", file); 109 | + return 1; 110 | + } 111 | + 112 | + pid = fork(); 113 | + 114 | + if (pid < 0) 115 | + return -1; 116 | + 117 | + if (pid == 0) { 118 | + signal(SIGKILL, exit_unlock); 119 | + signal(SIGTERM, exit_unlock); 120 | + signal(SIGINT, exit_unlock); 121 | + if (waitonly) 122 | + exit_unlock(0); 123 | + else 124 | + while (1) 125 | + sleep(1); 126 | + } else { 127 | + if (!waitonly) { 128 | + lseek(fd, 0, SEEK_SET); 129 | + ftruncate(fd, 0); 130 | + sprintf(pidstr, "%d\n", pid); 131 | + write(fd, pidstr, strlen(pidstr)); 132 | + close(fd); 133 | + } 134 | + 135 | + return 0; 136 | + } 137 | + return 0; 138 | +} 139 | + 140 | +int lock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 141 | +int lock_main(int argc, char **argv) 142 | +{ 143 | + char **args = &argv[1]; 144 | + int c = argc - 1; 145 | + 146 | + while ((*args != NULL) && (*args)[0] == '-') { 147 | + char *ch = *args; 148 | + while (*(++ch) > 0) { 149 | + switch(*ch) { 150 | + case 'w': 151 | + waitonly = 1; 152 | + break; 153 | + case 's': 154 | + shared = 1; 155 | + break; 156 | + case 'u': 157 | + unlock = 1; 158 | + break; 159 | + } 160 | + } 161 | + c--; 162 | + args++; 163 | + } 164 | + 165 | + if (c != 1) 166 | + usage(argv[0]); 167 | + 168 | + file = *args; 169 | + if (unlock) 170 | + return do_unlock(); 171 | + else 172 | + return do_lock(); 173 | +} 174 | -------------------------------------------------------------------------------- /recipes-core/busybox/files/250-date-k-flag.patch: -------------------------------------------------------------------------------- 1 | --- a/coreutils/date.c 2 | +++ b/coreutils/date.c 3 | @@ -123,6 +123,7 @@ 4 | //usage: IF_FEATURE_DATE_ISOFMT( 5 | //usage: "\n -D FMT Use FMT for -d TIME conversion" 6 | //usage: ) 7 | +//usage: "\n -k Set Kernel timezone from localtime and exit" 8 | //usage: "\n" 9 | //usage: "\nRecognized TIME formats:" 10 | //usage: "\n hh:mm[:ss]" 11 | @@ -138,6 +139,7 @@ 12 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" 13 | 14 | #include "libbb.h" 15 | +#include 16 | #if ENABLE_FEATURE_DATE_NANO 17 | # include 18 | #endif 19 | @@ -148,8 +150,9 @@ enum { 20 | OPT_UTC = (1 << 2), /* u */ 21 | OPT_DATE = (1 << 3), /* d */ 22 | OPT_REFERENCE = (1 << 4), /* r */ 23 | - OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */ 24 | - OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */ 25 | + OPT_KERNELTZ = (1 << 5), /* k */ 26 | + OPT_TIMESPEC = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* I */ 27 | + OPT_HINT = (1 << 7) * ENABLE_FEATURE_DATE_ISOFMT, /* D */ 28 | }; 29 | 30 | static void maybe_set_utc(int opt) 31 | @@ -167,12 +170,15 @@ static const char date_longopts[] ALIGN1 32 | /* "universal\0" No_argument "u" */ 33 | "date\0" Required_argument "d" 34 | "reference\0" Required_argument "r" 35 | + "set-kernel-tz\0" No_argument "k" 36 | ; 37 | #endif 38 | 39 | int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 40 | int date_main(int argc UNUSED_PARAM, char **argv) 41 | { 42 | + time_t tt; 43 | + struct timezone tz; 44 | struct timespec ts; 45 | struct tm tm_time; 46 | char buf_fmt_dt2str[64]; 47 | @@ -187,7 +193,7 @@ int date_main(int argc UNUSED_PARAM, cha 48 | opt_complementary = "d--s:s--d" 49 | IF_FEATURE_DATE_ISOFMT(":R--I:I--R"); 50 | IF_LONG_OPTS(applet_long_options = date_longopts;) 51 | - opt = getopt32(argv, "Rs:ud:r:" 52 | + opt = getopt32(argv, "Rs:ud:r:k" 53 | IF_FEATURE_DATE_ISOFMT("I::D:"), 54 | &date_str, &date_str, &filename 55 | IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt)); 56 | @@ -244,6 +250,31 @@ int date_main(int argc UNUSED_PARAM, cha 57 | if (*argv) 58 | bb_show_usage(); 59 | 60 | + /* Setting of kernel timezone was requested */ 61 | + if (opt & OPT_KERNELTZ) { 62 | + tt = time(NULL); 63 | + localtime_r(&tt, &tm_time); 64 | + 65 | + /* workaround warp_clock() on first invocation */ 66 | + memset(&tz, 0, sizeof(tz)); 67 | + settimeofday(NULL, &tz); 68 | + 69 | + memset(&tz, 0, sizeof(tz)); 70 | +#if defined(__USE_BSD) || defined(__USE_MISC) 71 | + tz.tz_minuteswest = -(tm_time.tm_gmtoff / 60); 72 | +#else 73 | + tz.tz_minuteswest = -(tm_time.__tm_gmtoff / 60); 74 | +#endif 75 | + 76 | + if (settimeofday(NULL, &tz)) 77 | + { 78 | + bb_perror_msg("can't set kernel time zone"); 79 | + return EXIT_FAILURE; 80 | + } 81 | + 82 | + return EXIT_SUCCESS; 83 | + } 84 | + 85 | /* Now we have parsed all the information except the date format 86 | * which depends on whether the clock is being set or read */ 87 | 88 | -------------------------------------------------------------------------------- /recipes-core/busybox/files/lock.cfg: -------------------------------------------------------------------------------- 1 | CONFIG_LOCK=y 2 | -------------------------------------------------------------------------------- /recipes-core/dnsmasq/dnsmasq_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 2 | 3 | SRC_URI += "file://dhcp.conf" 4 | SRC_URI += "file://dnsmasq.conf" 5 | SRC_URI += "file://dnsmasq.hotplug" 6 | SRC_URI += "file://dnsmasq.init" 7 | 8 | RDEPENDS_${PN} += "jsonfilter" 9 | 10 | do_install_append () { 11 | mkdir -p ${D}/etc/config ${D}/etc/init.d ${D}/etc/hotplug.d/iface 12 | mkdir -p ${D}/tmp/hosts 13 | cp ${WORKDIR}/dhcp.conf ${D}/etc/config/dhcp 14 | cp ${WORKDIR}/dnsmasq.conf ${D}/etc/ 15 | cp ${WORKDIR}/dnsmasq.init ${D}/etc/init.d/dnsmasq 16 | cp ${WORKDIR}/dnsmasq.hotplug ${D}/etc/hotplug.d/iface/25-dnsmasq 17 | } 18 | 19 | -------------------------------------------------------------------------------- /recipes-core/dnsmasq/files/dhcp.conf: -------------------------------------------------------------------------------- 1 | config dnsmasq 2 | option domainneeded 1 3 | option boguspriv 1 4 | option filterwin2k 0 # enable for dial on demand 5 | option localise_queries 1 6 | option rebind_protection 1 # disable if upstream must serve RFC1918 addresses 7 | option rebind_localhost 1 # enable for RBL checking and similar services 8 | #list rebind_domain example.lan # whitelist RFC1918 responses for domains 9 | option local '/lan/' 10 | option domain 'lan' 11 | option expandhosts 1 12 | option nonegcache 0 13 | option authoritative 1 14 | option readethers 1 15 | option leasefile '/tmp/dhcp.leases' 16 | option resolvfile '/tmp/resolv.conf.auto' 17 | #list server '/mycompany.local/1.2.3.4' 18 | #option nonwildcard 1 19 | #list interface br-lan 20 | #list notinterface lo 21 | #list bogusnxdomain '64.94.110.11' 22 | 23 | config dhcp lan 24 | option interface lan 25 | option start 100 26 | option limit 150 27 | option leasetime 12h 28 | 29 | config dhcp wan 30 | option interface wan 31 | option ignore 1 32 | -------------------------------------------------------------------------------- /recipes-core/dnsmasq/files/dnsmasq.conf: -------------------------------------------------------------------------------- 1 | # Change the following lines if you want dnsmasq to serve SRV 2 | # records. 3 | # You may add multiple srv-host lines. 4 | # The fields are ,,,, 5 | 6 | # A SRV record sending LDAP for the example.com domain to 7 | # ldapserver.example.com port 289 8 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389 9 | 10 | # Two SRV records for LDAP, each with different priorities 11 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1 12 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2 13 | 14 | # A SRV record indicating that there is no LDAP server for the domain 15 | # example.com 16 | #srv-host=_ldap._tcp.example.com 17 | 18 | # The following line shows how to make dnsmasq serve an arbitrary PTR 19 | # record. This is useful for DNS-SD. 20 | # The fields are , 21 | #ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services" 22 | 23 | # Change the following lines to enable dnsmasq to serve TXT records. 24 | # These are used for things like SPF and zeroconf. 25 | # The fields are ,,... 26 | 27 | #Example SPF. 28 | #txt-record=example.com,"v=spf1 a -all" 29 | 30 | #Example zeroconf 31 | #txt-record=_http._tcp.example.com,name=value,paper=A4 32 | 33 | # Provide an alias for a "local" DNS name. Note that this _only_ works 34 | # for targets which are names from DHCP or /etc/hosts. Give host 35 | # "bert" another name, bertrand 36 | # The fields are , 37 | #cname=bertand,bert 38 | -------------------------------------------------------------------------------- /recipes-core/dnsmasq/files/dnsmasq.hotplug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ "$ACTION" = ifup ] || exit 0 4 | 5 | /etc/init.d/dnsmasq enabled && /etc/init.d/dnsmasq start 6 | -------------------------------------------------------------------------------- /recipes-core/dnsmasq/files/dnsmasq.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2007-2012 OpenWrt.org 3 | 4 | START=60 5 | 6 | USE_PROCD=1 7 | PROG=/usr/sbin/dnsmasq 8 | 9 | DNS_SERVERS="" 10 | DOMAIN="" 11 | 12 | ADD_LOCAL_DOMAIN=1 13 | ADD_LOCAL_HOSTNAME=1 14 | 15 | CONFIGFILE="/var/etc/dnsmasq.conf" 16 | HOSTFILE="/tmp/hosts/dhcp" 17 | TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf" 18 | 19 | xappend() { 20 | local value="$1" 21 | 22 | echo "${value#--}" >> $CONFIGFILE 23 | } 24 | 25 | dhcp_calc() { 26 | local ip="$1" 27 | local res=0 28 | 29 | while [ -n "$ip" ]; do 30 | part="${ip%%.*}" 31 | res="$(($res * 256))" 32 | res="$(($res + $part))" 33 | [ "${ip%.*}" != "$ip" ] && ip="${ip#*.}" || ip= 34 | done 35 | echo "$res" 36 | } 37 | 38 | dhcp_check() { 39 | local ifname="$1" 40 | local stamp="/var/run/dnsmasq.$ifname.dhcp" 41 | local rv=0 42 | 43 | [ -s "$stamp" ] && return $(cat "$stamp") 44 | 45 | udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0 46 | 47 | [ $rv -eq 1 ] && \ 48 | logger -t dnsmasq \ 49 | "found already running DHCP-server on interface '$ifname'" \ 50 | "refusing to start, use 'option force 1' to override" 51 | 52 | echo $rv > "$stamp" 53 | return $rv 54 | } 55 | 56 | log_once() { 57 | pidof dnsmasq >/dev/null || \ 58 | logger -t dnsmasq "$@" 59 | } 60 | 61 | append_bool() { 62 | local section="$1" 63 | local option="$2" 64 | local value="$3" 65 | local _loctmp 66 | config_get_bool _loctmp "$section" "$option" 0 67 | [ $_loctmp -gt 0 ] && xappend "$value" 68 | } 69 | 70 | append_parm() { 71 | local section="$1" 72 | local option="$2" 73 | local switch="$3" 74 | local _loctmp 75 | config_get _loctmp "$section" "$option" 76 | [ -z "$_loctmp" ] && return 0 77 | xappend "$switch=$_loctmp" 78 | } 79 | 80 | append_server() { 81 | xappend "--server=$1" 82 | } 83 | 84 | append_address() { 85 | xappend "--address=$1" 86 | } 87 | 88 | append_interface() { 89 | local ifname=$(uci_get_state network "$1" ifname "$1") 90 | xappend "--interface=$ifname" 91 | } 92 | 93 | append_notinterface() { 94 | local ifname=$(uci_get_state network "$1" ifname "$1") 95 | xappend "--except-interface=$ifname" 96 | } 97 | 98 | append_addnhosts() { 99 | xappend "--addn-hosts=$1" 100 | } 101 | 102 | append_bogusnxdomain() { 103 | xappend "--bogus-nxdomain=$1" 104 | } 105 | 106 | dnsmasq() { 107 | local cfg="$1" 108 | append_bool "$cfg" authoritative "--dhcp-authoritative" 109 | append_bool "$cfg" nodaemon "--no-daemon" 110 | append_bool "$cfg" domainneeded "--domain-needed" 111 | append_bool "$cfg" filterwin2k "--filterwin2k" 112 | append_bool "$cfg" nohosts "--no-hosts" 113 | append_bool "$cfg" nonegcache "--no-negcache" 114 | append_bool "$cfg" strictorder "--strict-order" 115 | append_bool "$cfg" logqueries "--log-queries" 116 | append_bool "$cfg" noresolv "--no-resolv" 117 | append_bool "$cfg" localise_queries "--localise-queries" 118 | append_bool "$cfg" readethers "--read-ethers" 119 | append_bool "$cfg" dbus "--enable-dbus" 120 | append_bool "$cfg" boguspriv "--bogus-priv" 121 | append_bool "$cfg" expandhosts "--expand-hosts" 122 | append_bool "$cfg" enable_tftp "--enable-tftp" 123 | append_bool "$cfg" nonwildcard "--bind-interfaces" 124 | append_bool "$cfg" fqdn "--dhcp-fqdn" 125 | append_bool "$cfg" proxydnssec "--proxy-dnssec" 126 | 127 | append_parm "$cfg" dhcpscript "--dhcp-script" 128 | append_parm "$cfg" cachesize "--cache-size" 129 | append_parm "$cfg" dnsforwardmax "--dns-forward-max" 130 | append_parm "$cfg" port "--port" 131 | append_parm "$cfg" ednspacket_max "--edns-packet-max" 132 | append_parm "$cfg" dhcpleasemax "--dhcp-lease-max" 133 | append_parm "$cfg" "queryport" "--query-port" 134 | append_parm "$cfg" "domain" "--domain" 135 | append_parm "$cfg" "local" "--server" 136 | config_list_foreach "$cfg" "server" append_server 137 | config_list_foreach "$cfg" "address" append_address 138 | config_list_foreach "$cfg" "interface" append_interface 139 | config_list_foreach "$cfg" "notinterface" append_notinterface 140 | config_list_foreach "$cfg" "addnhosts" append_addnhosts 141 | config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain 142 | append_parm "$cfg" "leasefile" "--dhcp-leasefile" 143 | append_parm "$cfg" "resolvfile" "--resolv-file" 144 | append_parm "$cfg" "tftp_root" "--tftp-root" 145 | append_parm "$cfg" "dhcp_boot" "--dhcp-boot" 146 | append_parm "$cfg" "local_ttl" "--local-ttl" 147 | 148 | config_get DOMAIN "$cfg" domain 149 | 150 | config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1 151 | config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1 152 | 153 | config_get_bool readethers "$cfg" readethers 154 | [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers 155 | 156 | config_get leasefile $cfg leasefile 157 | [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile" 158 | config_get_bool cachelocal "$cfg" cachelocal 1 159 | 160 | config_get hostsfile "$cfg" dhcphostsfile 161 | [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile" 162 | 163 | mkdir -p /tmp/hosts /tmp/dnsmasq.d 164 | xappend "--addn-hosts=/tmp/hosts" 165 | xappend "--conf-dir=/tmp/dnsmasq.d" 166 | 167 | local rebind 168 | config_get_bool rebind "$cfg" rebind_protection 1 169 | [ $rebind -gt 0 ] && { 170 | log_once \ 171 | "DNS rebinding protection is active," \ 172 | "will discard upstream RFC1918 responses!" 173 | xappend "--stop-dns-rebind" 174 | 175 | local rebind_localhost 176 | config_get_bool rebind_localhost "$cfg" rebind_localhost 0 177 | [ $rebind_localhost -gt 0 ] && { 178 | log_once "Allowing 127.0.0.0/8 responses" 179 | xappend "--rebind-localhost-ok" 180 | } 181 | 182 | append_rebind_domain() { 183 | log_once "Allowing RFC1918 responses for domain $1" 184 | xappend "--rebind-domain-ok=$1" 185 | } 186 | 187 | config_list_foreach "$cfg" rebind_domain append_rebind_domain 188 | } 189 | 190 | config_get_bool dnssec "$cfg" dnssec 0 191 | [ "$dnssec" -gt 0 ] && { 192 | xappend "--conf-file=$TRUSTANCHORSFILE" 193 | xappend "--dnssec" 194 | append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned" 195 | } 196 | 197 | dhcp_option_add "$cfg" "" 0 198 | 199 | xappend "--dhcp-broadcast=tag:needs-broadcast" 200 | 201 | echo >> $CONFIGFILE 202 | } 203 | 204 | dhcp_subscrid_add() { 205 | local cfg="$1" 206 | 207 | config_get networkid "$cfg" networkid 208 | [ -n "$networkid" ] || return 0 209 | 210 | config_get subscriberid "$cfg" subscriberid 211 | [ -n "$subscriberid" ] || return 0 212 | 213 | xappend "--dhcp-subscrid=$networkid,$subscriberid" 214 | 215 | config_get_bool force "$cfg" force 0 216 | 217 | dhcp_option_add "$cfg" "$networkid" "$force" 218 | } 219 | 220 | dhcp_remoteid_add() { 221 | local cfg="$1" 222 | 223 | config_get networkid "$cfg" networkid 224 | [ -n "$networkid" ] || return 0 225 | 226 | config_get remoteid "$cfg" remoteid 227 | [ -n "$remoteid" ] || return 0 228 | 229 | xappend "--dhcp-remoteid=$networkid,$remoteid" 230 | 231 | config_get_bool force "$cfg" force 0 232 | 233 | dhcp_option_add "$cfg" "$networkid" "$force" 234 | } 235 | 236 | dhcp_circuitid_add() { 237 | local cfg="$1" 238 | 239 | config_get networkid "$cfg" networkid 240 | [ -n "$networkid" ] || return 0 241 | 242 | config_get circuitid "$cfg" circuitid 243 | [ -n "$circuitid" ] || return 0 244 | 245 | xappend "--dhcp-circuitid=$networkid,$circuitid" 246 | 247 | config_get_bool force "$cfg" force 0 248 | 249 | dhcp_option_add "$cfg" "$networkid" "$force" 250 | } 251 | 252 | dhcp_userclass_add() { 253 | local cfg="$1" 254 | 255 | config_get networkid "$cfg" networkid 256 | [ -n "$networkid" ] || return 0 257 | 258 | config_get userclass "$cfg" userclass 259 | [ -n "$userclass" ] || return 0 260 | 261 | xappend "--dhcp-userclass=$networkid,$userclass" 262 | 263 | config_get_bool force "$cfg" force 0 264 | 265 | dhcp_option_add "$cfg" "$networkid" "$force" 266 | } 267 | 268 | dhcp_vendorclass_add() { 269 | local cfg="$1" 270 | 271 | config_get networkid "$cfg" networkid 272 | [ -n "$networkid" ] || return 0 273 | 274 | config_get vendorclass "$cfg" vendorclass 275 | [ -n "$vendorclass" ] || return 0 276 | 277 | xappend "--dhcp-vendorclass=$networkid,$vendorclass" 278 | 279 | config_get_bool force "$cfg" force 0 280 | 281 | dhcp_option_add "$cfg" "$networkid" "$force" 282 | } 283 | 284 | dhcp_host_add() { 285 | local cfg="$1" 286 | 287 | config_get_bool force "$cfg" force 0 288 | 289 | config_get networkid "$cfg" networkid 290 | [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" "$force" 291 | 292 | config_get name "$cfg" name 293 | config_get ip "$cfg" ip 294 | [ -n "$ip" -o -n "$name" ] || return 0 295 | 296 | config_get_bool dns "$cfg" dns 0 297 | [ "$dns" = "1" -a -n "$ip" -a -n "$name" ] && { 298 | echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE 299 | } 300 | 301 | config_get mac "$cfg" mac 302 | if [ -n "$mac" ]; then 303 | # --dhcp-host=00:20:e0:3b:13:af,192.168.0.199,lap 304 | macs="" 305 | for m in $mac; do append macs "$m" ","; done 306 | else 307 | # --dhcp-host=lap,192.168.0.199 308 | [ -n "$name" ] || return 0 309 | macs="$name" 310 | name="" 311 | fi 312 | 313 | config_get tag "$cfg" tag 314 | 315 | config_get_bool broadcast "$cfg" broadcast 0 316 | [ "$broadcast" = "0" ] && broadcast= 317 | 318 | xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}" 319 | } 320 | 321 | dhcp_tag_add() { 322 | local cfg="$1" 323 | 324 | tag="$cfg" 325 | 326 | [ -n "$tag" ] || return 0 327 | 328 | config_get_bool force "$cfg" force 0 329 | [ "$force" = "0" ] && force= 330 | 331 | config_get option "$cfg" dhcp_option 332 | for o in $option; do 333 | xappend "--dhcp-option${force:+-force}=tag:$tag,$o" 334 | done 335 | } 336 | 337 | dhcp_mac_add() { 338 | local cfg="$1" 339 | 340 | config_get networkid "$cfg" networkid 341 | [ -n "$networkid" ] || return 0 342 | 343 | config_get mac "$cfg" mac 344 | [ -n "$mac" ] || return 0 345 | 346 | xappend "--dhcp-mac=$networkid,$mac" 347 | 348 | dhcp_option_add "$cfg" "$networkid" 349 | } 350 | 351 | dhcp_boot_add() { 352 | local cfg="$1" 353 | 354 | config_get networkid "$cfg" networkid 355 | 356 | config_get filename "$cfg" filename 357 | [ -n "$filename" ] || return 0 358 | 359 | config_get servername "$cfg" servername 360 | [ -n "$servername" ] || return 0 361 | 362 | config_get serveraddress "$cfg" serveraddress 363 | [ -n "$serveraddress" ] || return 0 364 | 365 | xappend "--dhcp-boot=${networkid:+net:$networkid,}$filename,$servername,$serveraddress" 366 | 367 | config_get_bool force "$cfg" force 0 368 | 369 | dhcp_option_add "$cfg" "$networkid" "$force" 370 | } 371 | 372 | 373 | dhcp_add() { 374 | local cfg="$1" 375 | config_get net "$cfg" interface 376 | [ -n "$net" ] || return 0 377 | 378 | config_get dhcpv4 "$cfg" dhcpv4 379 | [ "$dhcpv4" != "disabled" ] || return 0 380 | 381 | config_get networkid "$cfg" networkid 382 | [ -n "$networkid" ] || networkid="$net" 383 | 384 | network_get_subnet subnet "$net" || return 0 385 | network_get_device ifname "$net" || return 0 386 | network_get_protocol proto "$net" || return 0 387 | 388 | [ "$cachelocal" = "0" ] && network_get_dnsserver dnsserver "$net" && { 389 | DNS_SERVERS="$DNS_SERVERS $dnsserver" 390 | } 391 | 392 | append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0 393 | 394 | # Do not support non-static interfaces for now 395 | [ static = "$proto" ] || return 0 396 | 397 | # Override interface netmask with dhcp config if applicable 398 | config_get netmask "$cfg" netmask "${subnet##*/}" 399 | 400 | #check for an already active dhcp server on the interface, unless 'force' is set 401 | config_get_bool force "$cfg" force 0 402 | [ $force -gt 0 ] || dhcp_check "$ifname" || return 0 403 | 404 | config_get start "$cfg" start 405 | config_get limit "$cfg" limit 406 | config_get leasetime "$cfg" leasetime 407 | config_get options "$cfg" options 408 | config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1 409 | 410 | leasetime="${leasetime:-12h}" 411 | start="$(dhcp_calc "${start:-100}")" 412 | limit="${limit:-150}" 413 | [ "$limit" -gt 0 ] && limit=$((limit-1)) 414 | eval "$(ipcalc.sh "${subnet%%/*}" $netmask $start $limit)" 415 | if [ "$dynamicdhcp" = "0" ]; then END="static"; fi 416 | xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}" 417 | 418 | dhcp_option_add "$cfg" "$networkid" 419 | } 420 | 421 | dhcp_option_add() { 422 | local cfg="$1" 423 | local networkid="$2" 424 | local force="$3" 425 | 426 | [ "$force" = "0" ] && force= 427 | 428 | config_get dhcp_option "$cfg" dhcp_option 429 | for o in $dhcp_option; do 430 | xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o" 431 | done 432 | 433 | } 434 | 435 | dhcp_domain_add() { 436 | local cfg="$1" 437 | local ip name names record 438 | 439 | config_get names "$cfg" name "$2" 440 | [ -n "$names" ] || return 0 441 | 442 | config_get ip "$cfg" ip "$3" 443 | [ -n "$ip" ] || return 0 444 | 445 | for name in $names; do 446 | record="${record:+$record }$name" 447 | done 448 | 449 | echo "$ip $record" >> $HOSTFILE 450 | } 451 | 452 | dhcp_srv_add() { 453 | local cfg="$1" 454 | 455 | config_get srv "$cfg" srv 456 | [ -n "$srv" ] || return 0 457 | 458 | config_get target "$cfg" target 459 | [ -n "$target" ] || return 0 460 | 461 | config_get port "$cfg" port 462 | [ -n "$port" ] || return 0 463 | 464 | config_get class "$cfg" class 465 | config_get weight "$cfg" weight 466 | 467 | local service="$srv,$target,$port${class:+,$class${weight:+,$weight}}" 468 | 469 | xappend "--srv-host=$service" 470 | } 471 | 472 | dhcp_mx_add() { 473 | local cfg="$1" 474 | local domain relay pref 475 | 476 | config_get domain "$cfg" domain 477 | [ -n "$domain" ] || return 0 478 | 479 | config_get relay "$cfg" relay 480 | [ -n "$relay" ] || return 0 481 | 482 | config_get pref "$cfg" pref 0 483 | 484 | local service="$domain,$relay,$pref" 485 | 486 | xappend "--mx-host=$service" 487 | } 488 | 489 | dhcp_cname_add() { 490 | local cfg="$1" 491 | local cname target 492 | 493 | config_get cname "$cfg" cname 494 | [ -n "$cname" ] || return 0 495 | 496 | config_get target "$cfg" target 497 | [ -n "$target" ] || return 0 498 | 499 | xappend "--cname=${cname},${target}" 500 | } 501 | 502 | dhcp_hostrecord_add() { 503 | local cfg="$1" 504 | local names addresses record val 505 | 506 | config_get names "$cfg" name "$2" 507 | if [ -z "$names" ]; then 508 | return 0 509 | fi 510 | 511 | config_get addresses "$cfg" ip "$3" 512 | if [ -z "$addresses" ]; then 513 | return 0 514 | fi 515 | 516 | for val in $names $addresses; do 517 | record="${record:+$record,}$val" 518 | done 519 | 520 | xappend "--host-record=$record" 521 | } 522 | 523 | service_triggers() 524 | { 525 | procd_add_reload_trigger "dhcp" 526 | } 527 | 528 | boot() { 529 | # Will be launched through hotplug 530 | return 0 531 | } 532 | 533 | start_service() { 534 | include /lib/functions 535 | 536 | config_load dhcp 537 | 538 | procd_open_instance 539 | procd_set_param command $PROG -C $CONFIGFILE -k 540 | procd_set_param file $CONFIGFILE 541 | procd_set_param respawn 542 | procd_close_instance 543 | 544 | # before we can call xappend 545 | mkdir -p $(dirname $CONFIGFILE) 546 | 547 | echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE 548 | echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE 549 | 550 | # if we did this last, we could override auto-generated config 551 | [ -f /etc/dnsmasq.conf ] && { 552 | xappend "--conf-file=/etc/dnsmasq.conf" 553 | } 554 | 555 | args="" 556 | config_foreach dnsmasq dnsmasq 557 | config_foreach dhcp_host_add host 558 | echo >> $CONFIGFILE 559 | config_foreach dhcp_boot_add boot 560 | config_foreach dhcp_mac_add mac 561 | config_foreach dhcp_tag_add tag 562 | config_foreach dhcp_vendorclass_add vendorclass 563 | config_foreach dhcp_userclass_add userclass 564 | config_foreach dhcp_circuitid_add circuitid 565 | config_foreach dhcp_remoteid_add remoteid 566 | config_foreach dhcp_subscrid_add subscrid 567 | config_foreach dhcp_domain_add domain 568 | config_foreach dhcp_hostrecord_add hostrecord 569 | 570 | # add own hostname 571 | local lanaddr 572 | [ $ADD_LOCAL_HOSTNAME -eq 1 ] && network_get_ipaddr lanaddr "lan" && { 573 | local hostname="$(uci_get system @system[0] hostname OpenWrt)" 574 | dhcp_domain_add "" "$hostname" "$lanaddr" 575 | } 576 | 577 | echo >> $CONFIGFILE 578 | config_foreach dhcp_srv_add srvhost 579 | config_foreach dhcp_mx_add mxhost 580 | echo >> $CONFIGFILE 581 | 582 | config_get odhcpd_is_active odhcpd maindhcp 583 | if [ "$odhcpd_is_active" != "1" ]; then 584 | config_foreach dhcp_add dhcp 585 | fi 586 | 587 | echo >> $CONFIGFILE 588 | config_foreach dhcp_cname_add cname 589 | echo >> $CONFIGFILE 590 | 591 | rm -f /tmp/resolv.conf 592 | [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && { 593 | echo "search $DOMAIN" >> /tmp/resolv.conf 594 | } 595 | DNS_SERVERS="$DNS_SERVERS 127.0.0.1" 596 | for DNS_SERVER in $DNS_SERVERS ; do 597 | echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf 598 | done 599 | } 600 | 601 | reload_service() { 602 | rc_procd start_service "$@" 603 | return 0 604 | } 605 | 606 | stop_service() { 607 | [ -f /tmp/resolv.conf ] && { 608 | rm -f /tmp/resolv.conf 609 | ln -s /tmp/resolv.conf.auto /tmp/resolv.conf 610 | } 611 | rm -f /var/run/dnsmasq.*.dhcp 612 | } 613 | -------------------------------------------------------------------------------- /recipes-core/fstools/files/fix-bsd.patch: -------------------------------------------------------------------------------- 1 | Index: git/libblkid-tiny/mkdev.c 2 | =================================================================== 3 | --- git.orig/libblkid-tiny/mkdev.c 4 | +++ git/libblkid-tiny/mkdev.c 5 | @@ -12,7 +12,7 @@ 6 | * GNU General Public License for more details. 7 | */ 8 | 9 | -#define _BSD_SOURCE 10 | +#define _DEFAULT_SOURCE 11 | 12 | #include 13 | #include 14 | -------------------------------------------------------------------------------- /recipes-core/fstools/files/fstab.default: -------------------------------------------------------------------------------- 1 | [ ! -f /etc/config/fstab ] && ( block detect > /etc/config/fstab ) 2 | exit 0 3 | -------------------------------------------------------------------------------- /recipes-core/fstools/files/fstab.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # (C) 2013 openwrt.org 3 | 4 | START=40 5 | 6 | start() { 7 | echo "this file has been obseleted. please call \"/sbin/block mount\" directly" 8 | /sbin/block mount 9 | } 10 | 11 | stop() { 12 | echo "this file has been obseleted. please call \"/sbin/block umount\" directly" 13 | /sbin/block umount 14 | } 15 | -------------------------------------------------------------------------------- /recipes-core/fstools/files/mount.hotplug: -------------------------------------------------------------------------------- 1 | /sbin/block hotplug 2 | -------------------------------------------------------------------------------- /recipes-core/fstools/files/snapshot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2014 OpenWrt.org 3 | 4 | 5 | do_snapshot_unpack() { 6 | echo "- snapshot -" 7 | mkdir /tmp/snapshot 8 | cd /tmp/snapshot 9 | snapshot_tool read 10 | block=`ls block*.tar.gz 2> /dev/null` 11 | [ -z "$block" ] || for a in $block; do 12 | tar xzf $a -C / 13 | rm -f $a 14 | done 15 | } 16 | 17 | do_config_unpack() { 18 | echo "- config -" 19 | snapshot_tool config_read 20 | [ -f /tmp/config.tar.gz ] && { 21 | tar xzf /tmp/config.tar.gz -C / 22 | rm -f /tmp/config.tar.gz 23 | } 24 | } 25 | 26 | do_snapshot_push() { 27 | cd /volatile 28 | tar czf /tmp/snapshot.tar.gz * 29 | snapshot_tool write 30 | reboot 31 | } 32 | 33 | do_config_push() { 34 | cd /volatile 35 | tar czf /tmp/config.tar.gz * 36 | snapshot_tool config_write 37 | } 38 | 39 | do_snapshot_upgrade() { 40 | opkg update 41 | [ $? == 0 ] || exit 1 42 | 43 | opkg list-upgradable 44 | [ $? == 0 ] || exit 2 45 | 46 | UPDATES=`opkg list-upgradable | cut -d" " -f1` 47 | [ -z "${UPDATES}" ] && exit 0 48 | 49 | opkg upgrade ${UPDATES} 50 | [ $? == 0 ] || exit 3 51 | 52 | do_snapshot_push 53 | sleep 5 54 | reboot 55 | sleep 10 56 | } 57 | 58 | do_convert_jffs2() { 59 | snapshot_tool write 60 | sleep 2 61 | reboot -f 62 | } 63 | 64 | do_convert() { 65 | . /lib/functions.sh 66 | . /lib/upgrade/common.sh 67 | ubus call system upgrade 68 | touch /tmp/sysupgrade 69 | cd /overlay 70 | tar czf /tmp/snapshot.tar.gz * 71 | kill_remaining TERM 72 | sleep 3 73 | kill_remaining KILL 74 | run_ramfs '. /sbin/snapshot; do_convert_jffs2' 75 | } 76 | 77 | [ -n "$(cat /proc/mounts|grep /overlay|grep jffs2)" ] && { 78 | case $1 in 79 | convert) 80 | do_convert 81 | ;; 82 | esac 83 | } 84 | 85 | [ -d /volatile ] && { 86 | case $1 in 87 | push) 88 | do_snapshot_push 89 | ;; 90 | config) 91 | do_config_push 92 | ;; 93 | upgrade) 94 | do_snapshot_upgrade 95 | ;; 96 | info) 97 | snapshot_tool info 98 | ;; 99 | esac 100 | } 101 | 102 | [ "$SNAPSHOT" = "magic" ] && { 103 | case $1 in 104 | unpack) 105 | do_snapshot_unpack 106 | ;; 107 | config_unpack) 108 | do_config_unpack 109 | ;; 110 | esac 111 | } 112 | -------------------------------------------------------------------------------- /recipes-core/fstools/fstools_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "OpenWrt filesystem tools" 2 | HOMEPAGE = "http://wiki.openwrt.org/" 3 | LICENSE = "LGPLv2" 4 | LIC_FILES_CHKSUM = "file://block.c;beginline=1;endline=14;md5=45e915598006ba7929c617cda79ab0fc" 5 | 6 | SRC_URI = "git://nbd.name/fstools.git;protocol=git;branch=master" 7 | SRC_URI += "file://fstab.init" 8 | SRC_URI += "file://fstab.default" 9 | SRC_URI += "file://mount.hotplug" 10 | SRC_URI += "file://snapshot" 11 | SRC_URI += "file://fix-bsd.patch" 12 | 13 | SRCREV = "914b023e71559e033ec5a1f9840511eb1ccaf386" 14 | S = "${WORKDIR}/git" 15 | 16 | inherit cmake 17 | 18 | PR="r1" 19 | 20 | DEPENDS = "ubox libubox" 21 | PACKAGES += "libfstools" 22 | FILES_${PN} = "/sbin ${sysconfdir} /usr/sbin" 23 | FILES_${PN}-dev = "/usr/lib /usr/include" 24 | FILES_libfstools = "${base_libdir}" 25 | RDEPENDS_${PN} += "libfstools libubox libuci" 26 | RDEPENDS_libfstools += "libubox" 27 | 28 | do_install_append () { 29 | mkdir -p ${D}/sbin ${D}/lib ${D}/usr/sbin ${D}/etc/hotplug.d/block ${D}/etc/init.d/ ${D}/etc/uci-defaults/ 30 | 31 | #FIXME: install directly to /sbin from build not using mv 32 | mv ${D}/usr/sbin/{mount_root,jffs2reset,snapshot_tool} ${D}/sbin/ 33 | install ${D}/usr/lib/libfstools.so ${D}/lib/ 34 | install ${WORKDIR}/snapshot ${D}/sbin/ 35 | 36 | install ${WORKDIR}/fstab.init ${D}/etc/init.d/fstab 37 | install ${WORKDIR}/fstab.default ${D}/etc/uci-defaults/10-fstab 38 | install ${WORKDIR}/mount.hotplug ${D}/etc/hotplug.d/block/10-mount 39 | 40 | #FIXME: install directly to /sbin from build not using mv 41 | mv ${D}/usr/sbin/block ${D}/sbin/ 42 | install ${D}/usr/lib/libblkid-tiny.so ${D}/lib/ 43 | ln -s /sbin/block ${D}/usr/sbin/swapon 44 | ln -s /sbin/block ${D}/usr/sbin/swapoff 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /recipes-core/images/openwrt-image-base.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "openwrt minimal image" 2 | 3 | IMAGE_INSTALL = "packagegroup-openwrt-boot rpcd uci iwinfo uhttpd2 luci luci2 luajit dnsmasq netifd strace" 4 | IMAGE_FEATURES += "" 5 | 6 | LICENSE = "MIT" 7 | 8 | inherit core-image 9 | 10 | fix_image () { 11 | #not needed the only things to be done is to set localstatedir = /tmp 12 | #rm -rf ${IMAGE_ROOTFS}/var 13 | if false 14 | then 15 | ln -sf ../init.d/log ${IMAGE_ROOTFS}/etc/rc.d/K89log 16 | ln -sf ../init.d/boot ${IMAGE_ROOTFS}/etc/rc.d/K98boot 17 | ln -sf ../init.d/umount ${IMAGE_ROOTFS}/etc/rc.d/K99umount 18 | ln -sf ../init.d/sysfixtime ${IMAGE_ROOTFS}/etc/rc.d/S00sysfixtime 19 | ln -sf ../init.d/boot ${IMAGE_ROOTFS}/etc/rc.d/S10boot 20 | ln -sf ../init.d/system ${IMAGE_ROOTFS}/etc/rc.d/S10system 21 | ln -sf ../init.d/sysctl ${IMAGE_ROOTFS}/etc/rc.d/S11sysctl 22 | ln -sf ../init.d/log ${IMAGE_ROOTFS}/etc/rc.d/S12log 23 | ln -sf ../init.d/rpcd ${IMAGE_ROOTFS}/etc/rc.d/S12rpcd 24 | ln -sf ../init.d/done ${IMAGE_ROOTFS}/etc/rc.d/S95done 25 | fi 26 | pushd ${IMAGE_ROOTFS} 27 | for script in ./etc/init.d/* 28 | do 29 | grep '#!/bin/sh /etc/rc.common' $script >/dev/null || continue 30 | IPKG_INSTROOT=${IMAGE_ROOTFS} $(which bash) ./etc/rc.common $script enable 31 | done || true 32 | popd 33 | 34 | #FIXME: put the below to sysvinit.bb instead 35 | echo "::sysinit:/etc/init.d/rcS S boot" > ${IMAGE_ROOTFS}/etc/inittab 36 | echo "::shutdown:/etc/init.d/rcS K shutdown" >> ${IMAGE_ROOTFS}/etc/inittab 37 | echo "tts/0::askfirst:/bin/ash --login" >> ${IMAGE_ROOTFS}/etc/inittab 38 | 39 | tmp="${SERIAL_CONSOLES}" 40 | for i in $tmp 41 | do 42 | j=`echo ${i} | sed s/\;/\ /g` 43 | label=`echo ${i} | sed -e 's/^.*;tty//' -e 's/;.*//'` 44 | echo "tty${label}::askfirst:/bin/ash --login" >> ${IMAGE_ROOTFS}/etc/inittab 45 | done 46 | #echo "ttyAMA0::askfirst:/bin/ash --login" >> ${IMAGE_ROOTFS}/etc/inittab 47 | 48 | echo "tty1::askfirst:/bin/ash --login" >> ${IMAGE_ROOTFS}/etc/inittab 49 | } 50 | 51 | IMAGE_PREPROCESS_COMMAND_append = "fix_image" 52 | -------------------------------------------------------------------------------- /recipes-core/initscripts/initscripts_%.bbappend: -------------------------------------------------------------------------------- 1 | do_install_append () { 2 | if test -d ${D}/var 3 | then 4 | mv ${D}/var ${D}/${localstatedir} 5 | fi 6 | } 7 | -------------------------------------------------------------------------------- /recipes-core/iwinfo/files/fix-make.patch: -------------------------------------------------------------------------------- 1 | Index: git/Makefile 2 | =================================================================== 3 | --- git.orig/Makefile 4 | +++ git/Makefile 5 | @@ -3,18 +3,19 @@ IWINFO_CFLAGS = $(CFLAGS) -std=gnu9 6 | IWINFO_LDFLAGS = -luci 7 | 8 | IWINFO_LIB = libiwinfo.so 9 | -IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared 10 | +IWINFO_LIB_LDFLAGS = -Wl,--soname=libiwinfo.so.0 $(LDFLAGS) -shared -luci 11 | IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o 12 | 13 | -IWINFO_LUA = iwinfo.so 14 | +IWINFO_LUA = luaiwinfo.so 15 | IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua 16 | IWINFO_LUA_OBJ = iwinfo_lua.o 17 | 18 | IWINFO_CLI = iwinfo 19 | -IWINFO_CLI_LDFLAGS = $(LDFLAGS) -L. -liwinfo 20 | +IWINFO_CLI_LDFLAGS = -L. -liwinfo $(LDFLAGS) 21 | IWINFO_CLI_OBJ = iwinfo_cli.o 22 | 23 | 24 | + 25 | ifneq ($(filter wl,$(IWINFO_BACKENDS)),) 26 | IWINFO_CFLAGS += -DUSE_WL 27 | IWINFO_LIB_OBJ += iwinfo_wl.o 28 | @@ -36,8 +37,10 @@ endif 29 | %.o: %.c 30 | $(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $< 31 | 32 | -compile: clean $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ) 33 | - $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB) $(IWINFO_LIB_OBJ) 34 | +compile: $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ) 35 | + $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB).0.0 $(IWINFO_LIB_OBJ) 36 | + ln -sf $(IWINFO_LIB).0.0 $(IWINFO_LIB) 37 | + ln -sf $(IWINFO_LIB).0.0 $(IWINFO_LIB).0 38 | $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA) $(IWINFO_LUA_OBJ) 39 | $(CC) $(IWINFO_LDFLAGS) $(IWINFO_CLI_LDFLAGS) -o $(IWINFO_CLI) $(IWINFO_CLI_OBJ) 40 | 41 | Index: git/include/iwinfo.h 42 | =================================================================== 43 | --- git.orig/include/iwinfo.h 44 | +++ git/include/iwinfo.h 45 | @@ -181,10 +181,10 @@ struct iwinfo_ops { 46 | void (*close)(void); 47 | }; 48 | 49 | -const char * iwinfo_type(const char *ifname); 50 | -const struct iwinfo_ops * iwinfo_backend(const char *ifname); 51 | -const struct iwinfo_ops * iwinfo_backend_by_name(const char *name); 52 | -void iwinfo_finish(void); 53 | +extern const char * iwinfo_type(const char *ifname); 54 | +extern const struct iwinfo_ops * iwinfo_backend(const char *ifname); 55 | +extern const struct iwinfo_ops * iwinfo_backend_by_name(const char *name); 56 | +extern void iwinfo_finish(void); 57 | 58 | extern const struct iwinfo_ops wext_ops; 59 | extern const struct iwinfo_ops madwifi_ops; 60 | -------------------------------------------------------------------------------- /recipes-core/iwinfo/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/Makefile 2 | =================================================================== 3 | --- git.orig/Makefile 4 | +++ git/Makefile 5 | @@ -1,5 +1,5 @@ 6 | IWINFO_BACKENDS = $(BACKENDS) 7 | -IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude 8 | +IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude $(shell pkg-config --cflags luajit) 9 | IWINFO_LDFLAGS = -luci 10 | 11 | IWINFO_LIB = libiwinfo.so 12 | @@ -7,8 +7,8 @@ IWINFO_LIB_LDFLAGS = -Wl,--soname=libiwi 13 | IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o 14 | 15 | IWINFO_LUA = luaiwinfo.so 16 | -IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua 17 | -IWINFO_LUA_OBJ = iwinfo_lua.o 18 | +IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo $(shell pkg-config --libs luajit) 19 | +IWINFO_LUA_OBJ = iwinfo_lua.o 20 | 21 | IWINFO_CLI = iwinfo 22 | IWINFO_CLI_LDFLAGS = -L. -liwinfo $(LDFLAGS) 23 | -------------------------------------------------------------------------------- /recipes-core/iwinfo/iwinfo_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Generalized Wireless Information Library (iwinfo)" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/howto/wireless.utilities" 3 | LICENSE = "GPLv2" 4 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/iwinfo.git;protocol=git;branch=master" 7 | SRC_URI += "file://fix-make.patch" 8 | SRC_URI += "file://luajit.patch" 9 | 10 | SRCREV = "6e67940be59e1aee5d275dd61172b257cb34d726" 11 | S = "${WORKDIR}/git" 12 | 13 | PR="r1" 14 | 15 | DEPENDS = "uci luajit" 16 | PACKAGES += "libiwinfo" 17 | RDEPENDS_${PN} = "libiwinfo" 18 | 19 | FILES_${PN} = "/usr/bin" 20 | FILES_${PN}-dev = "/usr/include /usr/lib/libiwinfo.so" 21 | FILES_libiwinfo = "/usr/lib/libiwinfo.so.0.0 /usr/lib/libiwinfo.so.0" 22 | 23 | do_compile () { 24 | oe_runmake 'FPIC=-fPIC' compile 25 | } 26 | 27 | do_install () { 28 | mkdir -p ${D}/${libdir} ${D}/usr/bin 29 | install ${B}/libiwinfo.so.0.0 ${D}/${libdir} 30 | cp -a ${B}/libiwinfo.so.0 ${D}/${libdir} 31 | cp -a ${B}/libiwinfo.so ${D}/${libdir} 32 | cp -a ${B}/include ${D}/usr/ 33 | install ${B}/iwinfo ${D}/usr/bin 34 | } 35 | 36 | -------------------------------------------------------------------------------- /recipes-core/jsonfiler/files/fix-lemon.patch: -------------------------------------------------------------------------------- 1 | Index: git/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/CMakeLists.txt 4 | +++ git/CMakeLists.txt 5 | @@ -1,7 +1,7 @@ 6 | cmake_minimum_required(VERSION 2.6) 7 | 8 | PROJECT(jsonpath C) 9 | -ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-error=unused-variable -ffunction-sections -D_GNU_SOURCE) 10 | +ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wno-error=unused-variable -ffunction-sections -D_GNU_SOURCE) 11 | 12 | SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,--gc-sections") 13 | 14 | @@ -24,22 +24,15 @@ IF(JSONC_FOUND) 15 | ENDIF() 16 | 17 | ADD_CUSTOM_COMMAND( 18 | - OUTPUT contrib/lemon 19 | - DEPENDS contrib/lemon.c contrib/lempar.c 20 | - COMMAND gcc -o contrib/lemon contrib/lemon.c 21 | - COMMENT "Generating lemon parser generator" 22 | -) 23 | - 24 | -ADD_CUSTOM_COMMAND( 25 | - OUTPUT parser.c 26 | - DEPENDS parser.y contrib/lemon 27 | - COMMAND ./contrib/lemon parser.y 28 | + OUTPUT ${CMAKE_SOURCE_DIR}/parser.c ${CMAKE_SOURCE_DIR}/parser.h 29 | + DEPENDS ${CMAKE_SOURCE_DIR}/parser.y 30 | + COMMAND lemon ${CMAKE_SOURCE_DIR}/parser.y 31 | COMMENT "Generating parser.c" 32 | ) 33 | 34 | SET_PROPERTY(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "lemon;parser.h;parser.out") 35 | SET_SOURCE_FILES_PROPERTIES("parser.c" PROPERTIES GENERATED TRUE) 36 | -ADD_EXECUTABLE(jsonpath main.c ast.c lexer.c parser.c matcher.c) 37 | +ADD_EXECUTABLE(jsonpath main.c ast.c lexer.c parser.c matcher.c parser.y) 38 | TARGET_LINK_LIBRARIES(jsonpath ubox ${json}) 39 | 40 | INSTALL(TARGETS jsonpath RUNTIME DESTINATION bin) 41 | -------------------------------------------------------------------------------- /recipes-core/jsonfiler/jsonfilter_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Json filter" 2 | HOMEPAGE = "http://wiki.openwrt.org/" 3 | LICENSE = "ISC" 4 | LIC_FILES_CHKSUM = "file://main.c;beginline=1;endline=15;md5=60fb698e1ae531930b377e9f77d3ba1f" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/jsonpath.git;protocol=git;branch=master" 7 | SRC_URI += "file://fix-lemon.patch" 8 | 9 | SRCREV = "cdc760c58077f44fc40adbbe41e1556a67c1b9a9" 10 | S = "${WORKDIR}/git" 11 | B = "${WORKDIR}/git" 12 | PR="r1" 13 | 14 | inherit cmake 15 | 16 | DEPENDS = "libubox json-c lemon-native" 17 | 18 | FILES_${PN} = "/usr/bin" 19 | 20 | do_install_append () { 21 | mv ${D}/usr/bin/jsonpath ${D}/usr/bin/jsonfilter 22 | } 23 | -------------------------------------------------------------------------------- /recipes-core/libubox/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/lua/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/lua/CMakeLists.txt 4 | +++ git/lua/CMakeLists.txt 5 | @@ -8,7 +8,7 @@ IF(NOT LUA_CFLAGS) 6 | FIND_PROGRAM(PKG_CONFIG pkg-config) 7 | IF(PKG_CONFIG) 8 | EXECUTE_PROCESS( 9 | - COMMAND pkg-config --silence-errors --cflags lua5.1 10 | + COMMAND pkg-config --silence-errors --cflags luajit 11 | OUTPUT_VARIABLE LUA_CFLAGS 12 | OUTPUT_STRIP_TRAILING_WHITESPACE 13 | ) 14 | Index: git/examples/uloop-example.lua 15 | =================================================================== 16 | --- git.orig/examples/uloop-example.lua 17 | +++ git/examples/uloop-example.lua 18 | @@ -1,4 +1,4 @@ 19 | -#!/usr/bin/env lua 20 | +#!/usr/bin/env luajit 21 | 22 | local socket = require "socket" 23 | 24 | Index: git/lua/uloop.c 25 | =================================================================== 26 | --- git.orig/lua/uloop.c 27 | +++ git/lua/uloop.c 28 | @@ -129,7 +129,7 @@ static int ul_timer(lua_State *L) 29 | lua_pushvalue(L, -1); 30 | lua_setmetatable(L, -3); 31 | lua_pushvalue(L, -2); 32 | - luaI_openlib(L, NULL, timer_m, 1); 33 | + luaL_openlib(L, NULL, timer_m, 1); 34 | lua_pushvalue(L, -2); 35 | 36 | memset(tout, 0, sizeof(*tout)); 37 | @@ -248,7 +248,7 @@ static int ul_ufd_add(lua_State *L) 38 | lua_pushvalue(L, -1); 39 | lua_setmetatable(L, -3); 40 | lua_pushvalue(L, -2); 41 | - luaI_openlib(L, NULL, ufd_m, 1); 42 | + luaL_openlib(L, NULL, ufd_m, 1); 43 | lua_pushvalue(L, -2); 44 | 45 | memset(ufd, 0, sizeof(*ufd)); 46 | -------------------------------------------------------------------------------- /recipes-core/libubox/libubox_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Basic utility library" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/uci" 3 | LICENSE = "ISC BSD-3c" 4 | LIC_FILES_CHKSUM = "file://uloop.c;beginline=4;endline=17;md5=ae045d075c7d6dde096232b6130a5202" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/libubox.git;protocol=git;branch=master" 7 | SRC_URI += "file://luajit.patch" 8 | 9 | SRCREV = "b8d9b382e39823850331edc2a92379173daf1be3" 10 | S = "${WORKDIR}/git" 11 | 12 | inherit cmake 13 | 14 | PR="r1" 15 | 16 | DEPENDS = "json-c luajit" 17 | RDEPENDS_${PN} = "lua-socket" 18 | EXTRA_OECMAKE = "-DLUAPATH=/usr/lib/lua/5.1" 19 | 20 | FILES_${PN} += "/usr/lib/lua/5.1 /lib/ /usr/share" 21 | FILES_${PN}-dbg += "/usr/lib/lua/5.1/.debug" 22 | FILES_${PN}-dev = "/usr/lib/*.so /usr/include" 23 | 24 | do_install_append () { 25 | mkdir ${D}/lib 26 | install ${D}/usr/lib/libubox.so ${D}/lib 27 | install ${D}/usr/lib/libblobmsg_json.so ${D}/lib 28 | install ${D}/usr/lib/libjson_script.so ${D}/lib 29 | install ${S}/examples/uloop-example.lua ${D}/usr/lib/lua/5.1/ 30 | } 31 | 32 | -------------------------------------------------------------------------------- /recipes-core/lua-socket/files/lua-socket_2.0.2-make.patch: -------------------------------------------------------------------------------- 1 | Index: luasocket-2.0.2/config 2 | =================================================================== 3 | --- luasocket-2.0.2.orig/config 2007-10-15 06:21:05.000000000 +0200 4 | +++ luasocket-2.0.2/config 2010-11-20 23:36:34.000000000 +0100 5 | @@ -49,11 +49,10 @@ 6 | #------ 7 | # Compiler and linker settings 8 | # for Linux 9 | -CC=gcc 10 | -DEF=-DLUASOCKET_DEBUG 11 | -CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic 12 | -LDFLAGS=-O -shared -fpic 13 | -LD=gcc 14 | +#DEF=-DLUASOCKET_DEBUG 15 | +CFLAGS += -fPIC -O2 `pkg-config --cflags luajit` 16 | +LDFLAGS += -shared -fPIC -O2 `pkg-config --libs luajit` 17 | +LD=$(CC) 18 | 19 | #------ 20 | # End of makefile configuration 21 | -------------------------------------------------------------------------------- /recipes-core/lua-socket/lua-socket_2.0.2.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "LuaSocket is the most comprehensive networking support library for the Lua language." 2 | LICENSE = "MIT" 3 | HOMEPAGE = "http://luaforge.net/projects/luasocket" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=9a2d4d6957816b949774b39793409af1" 5 | 6 | DEPENDS += "luajit" 7 | RDEPENDS_${PN} += "luajit" 8 | 9 | PR = "r0" 10 | S = "${WORKDIR}/luasocket-${PV}" 11 | 12 | SRC_URI = "http://luaforge.net/frs/download.php/2664/luasocket-${PV}.tar.gz \ 13 | file://lua-socket_${PV}-make.patch" 14 | 15 | LUA_LIB_DIR = "${libdir}/lua/5.1" 16 | LUA_SHARE_DIR = "${datadir}/lua/5.1" 17 | 18 | FILES_${PN}-dbg = "${LUA_LIB_DIR}/mime/.debug/core.so \ 19 | ${LUA_LIB_DIR}/socket/.debug/core.so\ 20 | /usr/src" 21 | 22 | FILES_${PN} = "${LUA_LIB_DIR}/mime/core.so \ 23 | ${LUA_LIB_DIR}/socket/core.so \ 24 | ${LUA_SHARE_DIR}/*.lua \ 25 | ${LUA_SHARE_DIR}/socket/*.lua" 26 | 27 | EXTRA_OEMAKE = "MYFLAGS='${CFLAGS} ${LDFLAGS}'" 28 | 29 | do_install() { 30 | oe_runmake install INSTALL_TOP_SHARE=${D}${LUA_SHARE_DIR} INSTALL_TOP_LIB=${D}${LUA_LIB_DIR} 31 | install -d ${D}/${docdir}/${PN}-${PV} 32 | install -m 0644 doc/*.html ${D}/${docdir}/${PN}-${PV} 33 | } 34 | 35 | SRC_URI[md5sum] = "41445b138deb7bcfe97bff957503da8e" 36 | SRC_URI[sha256sum] = "4fd9c775cfd98841299851e29b30176caf289370fea1ff1e00bb67c2d6842ca6" 37 | -------------------------------------------------------------------------------- /recipes-core/luajit/files/pkgconfig/luajit.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr 2 | libdir=${prefix}/lib 3 | includedir=${prefix}/include/luajit-2.0 4 | 5 | Name: luajit 6 | Description: Luajit language engine 7 | Version: 2.x.x 8 | Requires: 9 | Libs: -L${libdir} -lluajit-5.1 10 | Libs.private: -lm 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /recipes-core/luajit/luajit_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 2 | 3 | SRC_URI += "file://pkgconfig" 4 | 5 | inherit pkgconfig 6 | 7 | do_install_append () { 8 | cp -a ${WORKDIR}/pkgconfig ${D}/usr/lib 9 | } 10 | -------------------------------------------------------------------------------- /recipes-core/luci/files/fix-compile-luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/build/config.mk 2 | =================================================================== 3 | --- git.orig/build/config.mk 4 | +++ git/build/config.mk 5 | @@ -2,8 +2,8 @@ LUAC = luac 6 | LUAC_OPTIONS = -s 7 | LUA_TARGET ?= source 8 | 9 | -LUA_MODULEDIR = /usr/lib/lua/5.1 10 | -LUA_LIBRARYDIR = /usr/lib/lua/5.1 11 | +LUA_MODULEDIR = /usr/local/share/lua/5.1 12 | +LUA_LIBRARYDIR = /usr/lib/lua/5.1 13 | 14 | LUCI_MODULEDIR = $(LUA_MODULEDIR)/luci 15 | LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci 16 | Index: git/contrib/package/luci-addons/Makefile 17 | =================================================================== 18 | --- git.orig/contrib/package/luci-addons/Makefile 19 | +++ git/contrib/package/luci-addons/Makefile 20 | @@ -273,7 +273,7 @@ endef 21 | MAKE_FLAGS += \ 22 | MODULES="$(LUCI_SELECTED_MODULES)" \ 23 | LUA_TARGET="$(LUA_TARGET)" \ 24 | - LUA_SHLIBS="-llua -lm -ldl -lcrypt" \ 25 | + LUA_SHLIBS="-lluajit -lm -ldl -lcrypt" \ 26 | CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \ 27 | LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \ 28 | NIXIO_TLS="$(NIXIO_TLS)" OS="Linux" 29 | Index: git/contrib/package/luci/Makefile 30 | =================================================================== 31 | --- git.orig/contrib/package/luci/Makefile 32 | +++ git/contrib/package/luci/Makefile 33 | @@ -396,7 +396,7 @@ endef 34 | MAKE_FLAGS += \ 35 | MODULES="$(LUCI_SELECTED_MODULES)" \ 36 | LUA_TARGET="$(LUA_TARGET)" \ 37 | - LUA_SHLIBS="-llua -lm -ldl -lcrypt" \ 38 | + LUA_SHLIBS="-lluajit -lm -ldl -lcrypt" \ 39 | CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \ 40 | LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \ 41 | NIXIO_TLS="$(NIXIO_TLS)" OS="Linux" 42 | Index: git/libs/nixio/Makefile 43 | =================================================================== 44 | --- git.orig/libs/nixio/Makefile 45 | +++ git/libs/nixio/Makefile 46 | @@ -61,7 +61,7 @@ ifneq (,$(NIXIO_CROSS_CC)) 47 | CC:=$(NIXIO_CROSS_CC) 48 | endif 49 | NIXIO_OBJ += src/mingw-compat.o 50 | - NIXIO_LDFLAGS_POST:=-llua -lssl -lcrypto -lws2_32 -lgdi32 51 | + NIXIO_LDFLAGS_POST:=-lluajit -lssl -lcrypto -lws2_32 -lgdi32 52 | FPIC:= 53 | EXTRA_CFLAGS += -D_WIN32_WINNT=0x0501 54 | LUA_CFLAGS:= 55 | Index: git/libs/nixio/axTLS/bindings/lua/Makefile 56 | =================================================================== 57 | --- git.orig/libs/nixio/axTLS/bindings/lua/Makefile 58 | +++ git/libs/nixio/axTLS/bindings/lua/Makefile 59 | @@ -52,7 +52,7 @@ include $(AXTLS_HOME)/config/makefile.po 60 | CFLAGS += -funit-at-a-time 61 | 62 | $(TARGET) : $(OBJ) 63 | - $(LD) $(LDFLAGS) $(LDSHARED) -o $@ $^ -L$(AXTLS_HOME)/$(STAGE) -L$(CONFIG_LUA_CORE)/lib -laxtls -llua 64 | + $(LD) $(LDFLAGS) $(LDSHARED) -o $@ $^ -L$(AXTLS_HOME)/$(STAGE) -L$(CONFIG_LUA_CORE)/lib -laxtls -lluajit 65 | 66 | CFLAGS += -I $(CONFIG_LUA_CORE)/include 67 | else 68 | -------------------------------------------------------------------------------- /recipes-core/luci/files/fix-compile.patch: -------------------------------------------------------------------------------- 1 | Index: git/contrib/uci/Makefile 2 | =================================================================== 3 | --- git.orig/contrib/uci/Makefile 4 | +++ /dev/null 5 | @@ -1,43 +0,0 @@ 6 | -include ../../build/config.mk 7 | -include ../../build/gccconfig.mk 8 | - 9 | -UCI_VERSION = 0.8.0 10 | -#UCI_SITE = http://mirror2.openwrt.org/sources 11 | -#UCI_DIR = uci-$(UCI_VERSION) 12 | -#UCI_FILE = $(UCI_DIR).tar.gz 13 | -#UCI_URL = $(UCI_SITE)/$(UCI_FILE) 14 | -UCI_GITREV = aa3ab8012bfbf793d2884c08ea924545a04e9544 15 | -UCI_SITE = http://nbd.name 16 | -UCI_DIR = uci.git 17 | -UCI_FILE = uci-$(UCI_VERSION)$(UCI_APPEND).tar.gz 18 | -UCI_URL = $(UCI_SITE)/gitweb.cgi?p=uci.git;a=snapshot;h=$(UCI_GITREV) 19 | -UCI_PATCHDIR = patches 20 | - 21 | -all: compile 22 | - 23 | -include ../../build/module.mk 24 | - 25 | -$(UCI_FILE): 26 | - wget -O $@ "$(UCI_URL)" || rm -f $@ 27 | - 28 | -$(UCI_DIR)/.prepared: $(UCI_FILE) 29 | - rm -rf $(UCI_DIR) 30 | - tar xvfz $(UCI_FILE) 31 | - (cd $(UCI_PATCHDIR); ls *.patch | sort > series) || true 32 | - [ -f "$(UCI_PATCHDIR)/series" ] && while read patch; do \ 33 | - patch -d $(UCI_DIR) -p1 < $(UCI_PATCHDIR)/$$patch; \ 34 | - done < $(UCI_PATCHDIR)/series || true 35 | - touch $@ 36 | - 37 | -compile: $(UCI_DIR)/.prepared 38 | - $(MAKE) -C $(UCI_DIR) CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" OS="$(OS)" 39 | - mkdir -p dist/usr/lib dist/usr/bin 40 | - $(MAKE) -C $(UCI_DIR) install DESTDIR=../dist prefix=/usr 41 | - $(MAKE) -C $(UCI_DIR)/lua CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" OS="$(OS)" 42 | - $(MAKE) -C $(UCI_DIR)/lua install DESTDIR=../../dist luadir=$(LUA_LIBRARYDIR) 43 | - 44 | -compile-all: compile 45 | - 46 | -clean: 47 | - rm -rf $(UCI_PATCHDIR)/series 48 | - rm -rf $(UCI_DIR) $(UCI_FILE) 49 | Index: git/contrib/uhttpd/Makefile 50 | =================================================================== 51 | --- git.orig/contrib/uhttpd/Makefile 52 | +++ /dev/null 53 | @@ -1,30 +0,0 @@ 54 | -include ../../build/config.mk 55 | -include ../../build/gccconfig.mk 56 | - 57 | -UHTTPD_SRC = svn://svn.openwrt.org/openwrt/branches/backfire/package/uhttpd/src 58 | -UHTTPD_DIR = uhttpd-src 59 | -UHTTPD_PATCHDIR = patches 60 | - 61 | -all: compile 62 | - 63 | -include ../../build/module.mk 64 | - 65 | -$(UHTTPD_DIR)/Makefile: 66 | - svn co $(UHTTPD_SRC) $(UHTTPD_DIR) 67 | - 68 | -$(UHTTPD_DIR)/.prepared: $(UHTTPD_DIR)/Makefile 69 | - (cd $(UHTTPD_PATCHDIR); ls *.patch | sort > series) || true 70 | - [ -f "$(UHTTPD_PATCHDIR)/series" ] && while read patch; do \ 71 | - patch -d $(UHTTPD_DIR) -p1 < $(UHTTPD_PATCHDIR)/$$patch; \ 72 | - done < $(UHTTPD_PATCHDIR)/series || true 73 | - touch $@ 74 | - 75 | -compile: $(UHTTPD_DIR)/.prepared 76 | - (cd $(UHTTPD_DIR); $(MAKE) LUA_SUPPORT=0 TLS_SUPPORT=0 CGI_SUPPORT=1) 77 | - mkdir -p dist/usr/sbin 78 | - cp $(UHTTPD_DIR)/uhttpd dist/usr/sbin 79 | - 80 | -compile-all: compile 81 | - 82 | -clean: 83 | - rm -rf $(UHTTPD_DIR) 84 | Index: git/build/config.mk 85 | =================================================================== 86 | --- git.orig/build/config.mk 87 | +++ git/build/config.mk 88 | @@ -2,8 +2,8 @@ LUAC = luac 89 | LUAC_OPTIONS = -s 90 | LUA_TARGET ?= source 91 | 92 | -LUA_MODULEDIR = /usr/lib/lua 93 | -LUA_LIBRARYDIR = /usr/lib/lua 94 | +LUA_MODULEDIR = /usr/lib/lua/5.1 95 | +LUA_LIBRARYDIR = /usr/lib/lua/5.1 96 | 97 | LUCI_MODULEDIR = $(LUA_MODULEDIR)/luci 98 | LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci 99 | -------------------------------------------------------------------------------- /recipes-core/luci/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/modules/base/luasrc/dispatcher.lua 2 | =================================================================== 3 | --- git.orig/modules/base/luasrc/dispatcher.lua 4 | +++ git/modules/base/luasrc/dispatcher.lua 5 | @@ -286,7 +286,7 @@ function dispatch(request) 6 | 7 | local function _ifattr(cond, key, val) 8 | if cond then 9 | - local env = getfenv(3) 10 | + local env = getfenv(httpdispatch) 11 | local scope = (type(env.self) == "table") and env.self 12 | return string.format( 13 | ' %s="%s"', tostring(key), 14 | Index: git/modules/base/htdocs/cgi-bin/luci 15 | =================================================================== 16 | --- git.orig/modules/base/htdocs/cgi-bin/luci 17 | +++ git/modules/base/htdocs/cgi-bin/luci 18 | @@ -1,5 +1,5 @@ 19 | -#!/usr/bin/lua 20 | +#!/usr/bin/luajit 21 | require "luci.cacheloader" 22 | require "luci.sgi.cgi" 23 | luci.dispatcher.indexcache = "/tmp/luci-indexcache" 24 | -luci.sgi.cgi.run() 25 | \ No newline at end of file 26 | +luci.sgi.cgi.run() 27 | Index: git/modules/base/luasrc/cbi/datatypes.lua 28 | =================================================================== 29 | --- git.orig/modules/base/luasrc/cbi/datatypes.lua 30 | +++ git/modules/base/luasrc/cbi/datatypes.lua 31 | @@ -341,5 +341,5 @@ function maxlength(val, max) 32 | end 33 | 34 | function phonedigit(val) 35 | - return (val:match("^[0-9\*#!%.]+$") ~= nil) 36 | + return (val:match("^[0-9\\*#!%.]+$") ~= nil) 37 | end 38 | Index: git/applications/luci-splash/luasrc/controller/splash/splash.lua 39 | =================================================================== 40 | --- git.orig/applications/luci-splash/luasrc/controller/splash/splash.lua 41 | +++ git/applications/luci-splash/luasrc/controller/splash/splash.lua 42 | @@ -52,7 +52,7 @@ end 43 | 44 | function action_activate() 45 | local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1" 46 | - local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$")) 47 | + local mac = luci.sys.net.ip4mac(ip:match("^[\\[::ffff:]*(%d+.%d+%.%d+%.%d+)\\]*$")) 48 | local uci_state = require "luci.model.uci".cursor_state() 49 | local blacklisted = false 50 | if mac and luci.http.formvalue("accept") then 51 | Index: git/build/gccconfig.mk 52 | =================================================================== 53 | --- git.orig/build/gccconfig.mk 54 | +++ git/build/gccconfig.mk 55 | @@ -1,8 +1,8 @@ 56 | OS ?= $(shell uname) 57 | 58 | -LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1 || pkg-config --silence-errors --libs lua-5.1 || pkg-config --silence-errors --libs lua) 59 | +LUA_SHLIBS = $(shell pkg-config --silence-errors --libs luajit) 60 | LUA_LIBS = $(if $(LUA_SHLIBS),$(LUA_SHLIBS),$(firstword $(wildcard /usr/lib/liblua.a /usr/local/lib/liblua.a /opt/local/lib/liblua.a))) 61 | -LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1 || pkg-config --silence-errors --cflags lua-5.1 || pkg-config --silence-errors --cflags lua) 62 | +LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags luajit) 63 | 64 | CC = gcc 65 | AR = ar 66 | Index: git/modules/base/luasrc/cbi.lua 67 | =================================================================== 68 | --- git.orig/modules/base/luasrc/cbi.lua 69 | +++ git/modules/base/luasrc/cbi.lua 70 | @@ -243,12 +243,15 @@ end 71 | function Node._run_hooks(self, ...) 72 | local f 73 | local r = false 74 | - for _, f in ipairs(arg) do 75 | - if type(self[f]) == "function" then 76 | - self[f](self) 77 | - r = true 78 | + if arg ~= nil 79 | + then 80 | + for _, f in ipairs(arg) do 81 | + if type(self[f]) == "function" then 82 | + self[f](self) 83 | + r = true 84 | + end 85 | end 86 | - end 87 | + end 88 | return r 89 | end 90 | 91 | -------------------------------------------------------------------------------- /recipes-core/luci/luci_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Generalized Wireless Information Library (iwinfo)" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/howto/wireless.utilities" 3 | LICENSE = "Apache-2.0" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2b42edef8fa55315f34f2370b4715ca9" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/luci.git;protocol=git;branch=luci-0.12" 7 | SRC_URI += "file://fix-compile.patch" 8 | SRC_URI += "file://fix-compile-luajit.patch" 9 | SRC_URI += "file://luajit.patch" 10 | 11 | SRCREV = "f1e2a26f4d315aaa7db5ac88e529a4854911f387" 12 | S = "${WORKDIR}/git" 13 | 14 | PR="r1" 15 | 16 | DEPENDS = "uci luajit" 17 | 18 | EXTRA_OEMAKE='CC="${CC}"' 19 | #PARALLEL_MAKE = "" 20 | FILES_${PN} += "/" 21 | FILES_${PN}-dbg += " \ 22 | /usr/lib/lua/5.1/.debug/ \ 23 | /usr/lib/lua/5.1/luci/template/.debug \ 24 | /usr/local/share/lua/5.1/.debug/ \ 25 | /usr/local/share/lua/5.1/luci/template/.debug \ 26 | " 27 | 28 | do_compile () { 29 | oe_runmake 30 | } 31 | 32 | do_install () { 33 | oe_runmake hostcopy 34 | cp -a ${B}/host/* ${D} 35 | rm -rf ${D}/tmp 36 | rm -rf ${D}/var 37 | chmod a+x ${D}/www/cgi-bin/luci 38 | } 39 | 40 | -------------------------------------------------------------------------------- /recipes-core/luci2/luci2_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Basic utility library" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/uci" 3 | LICENSE = "Apache-2.0" 4 | LIC_FILES_CHKSUM = "file://../Makefile;beginline=1;endline=5;md5=3ce05a39dbd458b46a410c5a9f266107" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/luci2/ui.git;protocol=git;branch=master" 7 | 8 | SRCREV = "e452ca693af5278ff2ddc69b6f8ed0f346c98fb1" 9 | S = "${WORKDIR}/git/luci2/src/" 10 | S_LUCI2 = "${WORKDIR}/git/luci2/" 11 | 12 | inherit cmake 13 | 14 | PR="r1" 15 | 16 | DEPENDS = "rpcd uhttpd2 libubox ubus" 17 | FILES_${PN} += "/usr /www" 18 | FILES_${PN}-dbg += "/usr/libexec/.debug /usr/lib/rpcd/.debug" 19 | 20 | do_install_append () { 21 | mkdir -p ${D}/www ${D}/usr/share/rpcd ${D}/usr/lib/rpcd ${D}/www/cgi-bin 22 | cp -a ${S_LUCI2}/htdocs/* ${D}/www/ 23 | cp -a ${S_LUCI2}/share/* ${D}/usr/share/rpcd/ 24 | mv ${D}/usr/lib/{luci2.so,bwmon.so} ${D}/usr/lib/rpcd/ 25 | mv ${D}/usr/sbin ${D}/usr/libexec 26 | ln -sf /usr/libexec/luci2-io ${D}/www/cgi-bin/luci-upload 27 | ln -sf /usr/libexec/luci2-io ${D}/www/cgi-bin/luci-backup 28 | 29 | } 30 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/etc/hotplug.d/iface/00-netstate: -------------------------------------------------------------------------------- 1 | [ ifup = "$ACTION" ] && { 2 | uci_toggle_state network "$INTERFACE" up 1 3 | [ -n "$DEVICE" ] && { 4 | uci_toggle_state network "$INTERFACE" device "$(uci -q get network.$INTERFACE.ifname)" 5 | uci_toggle_state network "$INTERFACE" ifname "$DEVICE" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/etc/init.d/network: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=20 4 | STOP=90 5 | 6 | USE_PROCD=1 7 | 8 | init_switch() { 9 | setup_switch() { return 0; } 10 | 11 | include /lib/network 12 | setup_switch 13 | } 14 | 15 | start_service() { 16 | init_switch 17 | 18 | procd_open_instance 19 | procd_set_param command /sbin/netifd 20 | procd_set_param respawn 21 | procd_set_param watch network.interface 22 | [ -e /proc/sys/kernel/core_pattern ] && { 23 | procd_set_param limits core="unlimited" 24 | echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern 25 | } 26 | procd_close_instance 27 | } 28 | 29 | reload_service() { 30 | init_switch 31 | ubus call network reload 32 | /sbin/wifi reload_legacy 33 | } 34 | 35 | stop_service() { 36 | /sbin/wifi down 37 | } 38 | 39 | service_running() { 40 | ubus -t 30 wait_for network.interface 41 | /sbin/wifi reload_legacy 42 | } 43 | 44 | validate_atm_bridge_section() 45 | { 46 | uci_validate_section network "atm-bridge" "${1}" \ 47 | 'unit:uinteger:0' \ 48 | 'vci:range(32, 65535):35' \ 49 | 'vpi:range(0, 255):8' \ 50 | 'atmdev:uinteger:0' \ 51 | 'encaps:or("llc", "vc"):llc' \ 52 | 'payload:or("bridged", "routed"):bridged' 53 | } 54 | 55 | validate_route_section() 56 | { 57 | uci_validate_section network route "${1}" \ 58 | 'interface:string' \ 59 | 'target:cidr4' \ 60 | 'netmask:netmask4' \ 61 | 'gateway:ip4addr' \ 62 | 'metric:uinteger' \ 63 | 'mtu:uinteger' \ 64 | 'table:or(range(0,65535),string)' 65 | } 66 | 67 | validate_route6_section() 68 | { 69 | uci_validate_section network route6 "${1}" \ 70 | 'interface:string' \ 71 | 'target:cidr6' \ 72 | 'gateway:ip6addr' \ 73 | 'metric:uinteger' \ 74 | 'mtu:uinteger' \ 75 | 'table:or(range(0,65535),string)' 76 | } 77 | 78 | validate_rule_section() 79 | { 80 | uci_validate_section network rule "${1}" \ 81 | 'in:string' \ 82 | 'out:string' \ 83 | 'src:cidr4' \ 84 | 'dest:cidr4' \ 85 | 'tos:range(0,31)' \ 86 | 'mark:string' \ 87 | 'invert:bool' \ 88 | 'lookup:or(range(0,65535),string)' \ 89 | 'goto:range(0,65535)' \ 90 | 'action:or("prohibit", "unreachable", "blackhole", "throw")' 91 | } 92 | 93 | validate_rule6_section() 94 | { 95 | uci_validate_section network rule6 "${1}" \ 96 | 'in:string' \ 97 | 'out:string' \ 98 | 'src:cidr6' \ 99 | 'dest:cidr6' \ 100 | 'tos:range(0,31)' \ 101 | 'mark:string' \ 102 | 'invert:bool' \ 103 | 'lookup:or(range(0,65535),string)' \ 104 | 'goto:range(0,65535)' \ 105 | 'action:or("prohibit", "unreachable", "blackhole", "throw")' 106 | } 107 | 108 | validate_switch_section() 109 | { 110 | uci_validate_section network switch "${1}" \ 111 | 'name:string' \ 112 | 'enable:bool' \ 113 | 'enable_vlan:bool' \ 114 | 'reset:bool' 115 | } 116 | 117 | validate_switch_vlan() 118 | { 119 | uci_validate_section network switch_vlan "${1}" \ 120 | 'device:string' \ 121 | 'vlan:uinteger' \ 122 | 'ports:list(ports)' 123 | } 124 | 125 | service_triggers() 126 | { 127 | procd_add_reload_trigger network wireless 128 | 129 | procd_open_validate 130 | validate_atm_bridge_section 131 | validate_route_section 132 | validate_route6_section 133 | validate_rule_section 134 | validate_rule6_section 135 | validate_switch_section 136 | validate_switch_vlan 137 | procd_close_validate 138 | } 139 | 140 | restart() { 141 | ifdown -a 142 | sleep 1 143 | trap '' TERM 144 | stop "$@" 145 | start "$@" 146 | } 147 | 148 | shutdown() { 149 | ifdown -a 150 | stop 151 | } 152 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/lib/netifd/dhcp.script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1 3 | 4 | . /lib/functions.sh 5 | . /lib/netifd/netifd-proto.sh 6 | 7 | set_classless_routes() { 8 | local max=128 9 | local type 10 | while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do 11 | proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2" 12 | max=$(($max-1)) 13 | shift 2 14 | done 15 | } 16 | 17 | setup_interface () { 18 | proto_init_update "*" 1 19 | proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}" 20 | # TODO: apply $broadcast 21 | 22 | for i in $router; do 23 | proto_add_ipv4_route 0.0.0.0 0 "$i" 24 | done 25 | 26 | # CIDR STATIC ROUTES (rfc3442) 27 | [ -n "$staticroutes" ] && set_classless_routes $staticroutes 28 | [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes 29 | 30 | for dns in $dns; do 31 | proto_add_dns_server "$dns" 32 | done 33 | for domain in $domain; do 34 | proto_add_dns_search "$domain" 35 | done 36 | 37 | proto_add_data 38 | [ -n "$ZONE" ] && json_add_string zone "$ZONE" 39 | proto_close_data 40 | 41 | proto_send_update "$INTERFACE" 42 | 43 | 44 | if [ "$IFACE6RD" != 0 -a -n "$ip6rd" ]; then 45 | local v4mask="${ip6rd%% *}" 46 | ip6rd="${ip6rd#* }" 47 | local ip6rdprefixlen="${ip6rd%% *}" 48 | ip6rd="${ip6rd#* }" 49 | local ip6rdprefix="${ip6rd%% *}" 50 | ip6rd="${ip6rd#* }" 51 | local ip6rdbr="${ip6rd%% *}" 52 | 53 | [ -n "$ZONE" ] || ZONE=$(fw3 -q network $INTERFACE) 54 | [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD=${INTERFACE}_6rd 55 | 56 | json_init 57 | json_add_string name "$IFACE6RD" 58 | json_add_string ifname "@$INTERFACE" 59 | json_add_string proto "6rd" 60 | json_add_string peeraddr "$ip6rdbr" 61 | json_add_int ip4prefixlen "$v4mask" 62 | json_add_string ip6prefix "$ip6rdprefix" 63 | json_add_int ip6prefixlen "$ip6rdprefixlen" 64 | json_add_string tunlink "$INTERFACE" 65 | [ -n "$IFACE6RD_DELEGATE" ] && json_add_boolean delegate "$IFACE6RD_DELEGATE" 66 | [ -n "$ZONE6RD" ] || ZONE6RD=$ZONE 67 | [ -n "$ZONE6RD" ] && json_add_string zone "$ZONE6RD" 68 | json_close_object 69 | 70 | ubus call network add_dynamic "$(json_dump)" 71 | fi 72 | 73 | # TODO 74 | # [ -n "$ntpsrv" ] && change_state network "$ifc" lease_ntpsrv "$ntpsrv" 75 | # [ -n "$timesvr" ] && change_state network "$ifc" lease_timesrv "$timesvr" 76 | # [ -n "$hostname" ] && change_state network "$ifc" lease_hostname "$hostname" 77 | # [ -n "$timezone" ] && change_state network "$ifc" lease_timezone "$timezone" 78 | } 79 | 80 | deconfig_interface() { 81 | proto_init_update "*" 0 82 | proto_send_update "$INTERFACE" 83 | } 84 | 85 | case "$1" in 86 | deconfig) 87 | deconfig_interface 88 | ;; 89 | renew|bound) 90 | setup_interface 91 | ;; 92 | esac 93 | 94 | # user rules 95 | [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user 96 | 97 | exit 0 98 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/lib/netifd/proto/dhcp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . /lib/functions.sh 4 | . ../netifd-proto.sh 5 | init_proto "$@" 6 | 7 | proto_dhcp_init_config() { 8 | renew_handler=1 9 | 10 | proto_config_add_string 'ipaddr:ipaddr' 11 | proto_config_add_string 'hostname:hostname' 12 | proto_config_add_string clientid 13 | proto_config_add_string vendorid 14 | proto_config_add_boolean 'broadcast:bool' 15 | proto_config_add_string 'reqopts:list(string)' 16 | proto_config_add_string iface6rd 17 | proto_config_add_string sendopts 18 | proto_config_add_boolean delegate 19 | proto_config_add_string zone6rd 20 | proto_config_add_string zone 21 | } 22 | 23 | proto_dhcp_setup() { 24 | local config="$1" 25 | local iface="$2" 26 | 27 | local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone 28 | json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone 29 | 30 | local opt dhcpopts 31 | for opt in $reqopts; do 32 | append dhcpopts "-O $opt" 33 | done 34 | 35 | for opt in $sendopts; do 36 | append dhcpopts "-x $opt" 37 | done 38 | 39 | [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= 40 | [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" 41 | [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd" 42 | [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212" 43 | [ -n "$zone6rd" ] && proto_export "ZONE6RD=$zone6rd" 44 | [ -n "$zone" ] && proto_export "ZONE=$zone" 45 | [ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0" 46 | 47 | proto_export "INTERFACE=$config" 48 | proto_run_command "$config" udhcpc \ 49 | -p /var/run/udhcpc-$iface.pid \ 50 | -s /lib/netifd/dhcp.script \ 51 | -f -t 0 -i "$iface" \ 52 | ${ipaddr:+-r $ipaddr} \ 53 | ${hostname:+-H $hostname} \ 54 | ${vendorid:+-V $vendorid} \ 55 | $clientid $broadcast $dhcpopts 56 | } 57 | 58 | proto_dhcp_renew() { 59 | local interface="$1" 60 | # SIGUSR1 forces udhcpc to renew its lease 61 | local sigusr1="$(kill -l SIGUSR1)" 62 | [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1 63 | } 64 | 65 | proto_dhcp_teardown() { 66 | local interface="$1" 67 | proto_kill_command "$interface" 68 | } 69 | 70 | add_protocol dhcp 71 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/lib/network/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2011 OpenWrt.org 3 | 4 | . /usr/share/libubox/jshn.sh 5 | 6 | find_config() { 7 | local device="$1" 8 | local ifdev ifl3dev ifobj 9 | for ifobj in `ubus list network.interface.\*`; do 10 | interface="${ifobj##network.interface.}" 11 | ( 12 | json_load "$(ifstatus $interface)" 13 | json_get_var ifdev device 14 | json_get_var ifl3dev l3_device 15 | if [[ "$device" = "$ifdev" ]] || [[ "$device" = "$ifl3dev" ]]; then 16 | echo "$interface" 17 | exit 0 18 | else 19 | exit 1 20 | fi 21 | ) && return 22 | done 23 | } 24 | 25 | unbridge() { 26 | return 27 | } 28 | 29 | ubus_call() { 30 | json_init 31 | local _data="$(ubus -S call "$1" "$2")" 32 | [ -z "$_data" ] && return 1 33 | json_load "$_data" 34 | return 0 35 | } 36 | 37 | 38 | fixup_interface() { 39 | local config="$1" 40 | local ifname type device l3dev 41 | 42 | config_get type "$config" type 43 | config_get ifname "$config" ifname 44 | config_get device "$config" device "$ifname" 45 | [ "bridge" = "$type" ] && ifname="br-$config" 46 | config_set "$config" device "$ifname" 47 | ubus_call "network.interface.$config" status || return 0 48 | json_get_var l3dev l3_device 49 | [ -n "$l3dev" ] && ifname="$l3dev" 50 | json_init 51 | config_set "$config" ifname "$ifname" 52 | config_set "$config" device "$device" 53 | } 54 | 55 | scan_interfaces() { 56 | config_load network 57 | config_foreach fixup_interface interface 58 | } 59 | 60 | prepare_interface_bridge() { 61 | local config="$1" 62 | 63 | [ -n "$config" ] || return 0 64 | ubus call network.interface."$config" prepare 65 | } 66 | 67 | setup_interface() { 68 | local iface="$1" 69 | local config="$2" 70 | 71 | [ -n "$config" ] || return 0 72 | ubus call network.interface."$config" add_device "{ \"name\": \"$iface\" }" 73 | } 74 | 75 | do_sysctl() { 76 | [ -n "$2" ] && \ 77 | sysctl -n -e -w "$1=$2" >/dev/null || \ 78 | sysctl -n -e "$1" 79 | } 80 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/sbin/devstatus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . /usr/share/libubox/jshn.sh 3 | DEVICE="$1" 4 | 5 | [ -n "$DEVICE" ] || { 6 | echo "Usage: $0 " 7 | exit 1 8 | } 9 | 10 | json_init 11 | json_add_string name "$DEVICE" 12 | ubus call network.device status "$(json_dump)" 13 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/sbin/ifdown: -------------------------------------------------------------------------------- 1 | ifup -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/sbin/ifstatus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | INTERFACE="$1" 3 | 4 | [ -n "$INTERFACE" ] || { 5 | echo "Usage: $0 " 6 | exit 1 7 | } 8 | 9 | ubus -S list "network.interface.$INTERFACE" >/dev/null || { 10 | echo "Interface $INTERFACE not found" 11 | exit 1 12 | } 13 | ubus call network.interface status "{ \"interface\" : \"$INTERFACE\" }" 14 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/sbin/ifup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ifup_all= 4 | setup_wifi= 5 | 6 | if_call() { 7 | local interface="$1" 8 | for mode in $modes; do 9 | ubus call network.interface $mode "{ \"interface\" : \"$interface\" }" 10 | done 11 | } 12 | 13 | case "$0" in 14 | *ifdown) modes=down;; 15 | *ifup) 16 | modes="down up" 17 | setup_wifi=1 18 | ;; 19 | *) echo "Invalid command: $0";; 20 | esac 21 | 22 | while :; do 23 | case "$1" in 24 | -a) 25 | ifup_all=1 26 | shift 27 | ;; 28 | -w) 29 | setup_wifi= 30 | shift 31 | ;; 32 | *) 33 | break 34 | ;; 35 | esac 36 | done 37 | 38 | [ "$modes" = "down up" ] && ubus call network reload 39 | if [ -n "$ifup_all" ]; then 40 | for interface in `ubus -S list 'network.interface.*'`; do 41 | if_call "${interface##network.interface.}" 42 | done 43 | [ -n "$setup_wifi" ] && /sbin/wifi up 44 | exit 45 | else 46 | ubus -S list "network.interface.$1" > /dev/null || { 47 | echo "Interface $1 not found" 48 | exit 49 | } 50 | if_call "$1" 51 | fi 52 | 53 | if [ -n "$setup_wifi" ] && grep -sq config /etc/config/wireless; then 54 | . /lib/functions.sh 55 | 56 | find_related_radios() { 57 | local wdev wnet 58 | config_get wdev "$1" device 59 | config_get wnet "$1" network 60 | 61 | if [ -n "$wdev" ]; then 62 | for wnet in $wnet; do 63 | if [ "$wnet" = "$network" ]; then 64 | append radio_devs "$wdev" "$N" 65 | fi 66 | done 67 | fi 68 | } 69 | 70 | local radio_devs 71 | local network="$1" 72 | config_load wireless 73 | config_foreach find_related_radios wifi-iface 74 | 75 | local dev 76 | for dev in $(echo "$radio_devs" | sort -u); do 77 | /sbin/wifi up "$dev" 78 | done 79 | fi 80 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/files/usr/share/udhcpc/default.script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1 3 | 4 | set_classless_routes() { 5 | local max=128 6 | local type 7 | while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do 8 | [ ${1##*/} -eq 32 ] && type=host || type=net 9 | echo "udhcpc: adding route for $type $1 via $2" 10 | route add -$type "$1" gw "$2" dev "$interface" 11 | max=$(($max-1)) 12 | shift 2 13 | done 14 | } 15 | 16 | setup_interface() { 17 | echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}" 18 | ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+} 19 | 20 | [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && { 21 | echo "udhcpc: setting default routers: $router" 22 | 23 | local valid_gw="" 24 | for i in $router ; do 25 | route add default gw $i dev $interface 26 | valid_gw="${valid_gw:+$valid_gw|}$i" 27 | done 28 | 29 | eval $(route -n | awk ' 30 | /^0.0.0.0\W{9}('$valid_gw')\W/ {next} 31 | /^0.0.0.0/ {print "route del -net "$1" gw "$2";"} 32 | ') 33 | } 34 | 35 | # CIDR STATIC ROUTES (rfc3442) 36 | [ -n "$staticroutes" ] && set_classless_routes $staticroutes 37 | [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes 38 | } 39 | 40 | 41 | applied= 42 | case "$1" in 43 | deconfig) 44 | ifconfig "$interface" 0.0.0.0 45 | ;; 46 | renew) 47 | setup_interface update 48 | ;; 49 | bound) 50 | setup_interface ifup 51 | ;; 52 | esac 53 | 54 | # user rules 55 | [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /recipes-core/netifd/files/fix-compile.patch: -------------------------------------------------------------------------------- 1 | Index: git/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/CMakeLists.txt 4 | +++ git/CMakeLists.txt 5 | @@ -1,7 +1,19 @@ 6 | cmake_minimum_required(VERSION 2.6) 7 | 8 | PROJECT(netifd C) 9 | -ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations) 10 | + 11 | +IF(NOT LINL_CFLAGS) 12 | + FIND_PROGRAM(PKG_CONFIG pkg-config) 13 | + IF(PKG_CONFIG) 14 | + EXECUTE_PROCESS( 15 | + COMMAND pkg-config --silence-errors --cflags libnl-3.0 16 | + OUTPUT_VARIABLE LIBNL_CFLAGS 17 | + OUTPUT_STRIP_TRAILING_WHITESPACE 18 | + ) 19 | + ENDIF() 20 | +ENDIF() 21 | + 22 | +ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations ${LIBNL_CFLAGS}) 23 | 24 | SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") 25 | 26 | -------------------------------------------------------------------------------- /recipes-core/netifd/netifd_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Network Interface Daemon" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/netifd" 3 | LICENSE = "GPLv2" 4 | LIC_FILES_CHKSUM = "file://main.c;beginline=1;endline=13;md5=572cd47ba0e377b26331e67e9f3bc4b3" 5 | 6 | SRC_URI = "git://git.openwrt.org/project/netifd.git;protocol=git;branch=master" 7 | SRC_URI += "file://files" 8 | SRC_URI += "file://fix-compile.patch" 9 | 10 | SRCREV = "46c569989f984226916fec28dd8ef152a664043e" 11 | S = "${WORKDIR}/git" 12 | 13 | inherit cmake 14 | 15 | PR="r1" 16 | 17 | DEPENDS = "ubus uci libubox libnl" 18 | FILES_${PN} += "/lib /usr/share" 19 | 20 | do_install_append () { 21 | cp -a ${WORKDIR}/files/* ${D}/ 22 | mv ${D}/usr/sbin/netifd ${D}/sbin 23 | cp -a ${S}/scripts/* ${D}/lib/netifd 24 | rmdir ${D}/usr/sbin 25 | } 26 | -------------------------------------------------------------------------------- /recipes-core/packagegroups/packagegroup-openwrt-boot.bb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007 OpenedHand Ltd. 3 | # 4 | 5 | SUMMARY = "Minimal boot requirements" 6 | DESCRIPTION = "The minimal set of packages required to boot the system" 7 | LICENSE = "MIT" 8 | PR = "r17" 9 | 10 | inherit packagegroup 11 | 12 | PACKAGE_ARCH = "${MACHINE_ARCH}" 13 | 14 | # 15 | # Set by the machine configuration with packages essential for device bootup 16 | # 17 | MACHINE_ESSENTIAL_EXTRA_RDEPENDS ?= "" 18 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS ?= "" 19 | 20 | # For backwards compatibility after rename 21 | RPROVIDES_${PN} = "task-core-boot" 22 | RREPLACES_${PN} = "task-core-boot" 23 | RCONFLICTS_${PN} = "task-core-boot" 24 | 25 | # Distro can override the following VIRTUAL-RUNTIME providers: 26 | VIRTUAL-RUNTIME_dev_manager ?= "udev" 27 | VIRTUAL-RUNTIME_login_manager ?= "busybox" 28 | VIRTUAL-RUNTIME_init_manager ?= "procd" 29 | VIRTUAL-RUNTIME_keymaps ?= "keymaps" 30 | 31 | SYSVINIT_SCRIPTS = "${@base_contains('MACHINE_FEATURES', 'rtc', 'busybox-hwclock', '', d)} \ 32 | modutils-initscripts \ 33 | init-ifupdown \ 34 | " 35 | 36 | RDEPENDS_${PN} = "\ 37 | base-files-openwrt \ 38 | base-passwd \ 39 | busybox \ 40 | fstools \ 41 | uci \ 42 | ${@base_contains("MACHINE_FEATURES", "keyboard", "${VIRTUAL-RUNTIME_keymaps}", "", d)} \ 43 | ${VIRTUAL-RUNTIME_login_manager} \ 44 | ${VIRTUAL-RUNTIME_init_manager} \ 45 | ${VIRTUAL-RUNTIME_dev_manager} \ 46 | ${MACHINE_ESSENTIAL_EXTRA_RDEPENDS}" 47 | 48 | RRECOMMENDS_${PN} = "\ 49 | ${MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS}" 50 | -------------------------------------------------------------------------------- /recipes-core/procd/files/hotplug-preinit.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ "case", "ACTION", { 3 | "add": [ 4 | [ "if", 5 | [ "has", "FIRMWARE" ], 6 | [ 7 | [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ], 8 | [ "load-firmware", "/lib/firmware" ], 9 | [ "return" ] 10 | ] 11 | ], 12 | ], 13 | }, ], 14 | [ "if", 15 | [ "and", 16 | [ "eq", "SUBSYSTEM", "button" ], 17 | ], 18 | [ "exec", "/etc/rc.button/failsafe" ] 19 | ], 20 | ] 21 | -------------------------------------------------------------------------------- /recipes-core/procd/files/hotplug.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ "case", "ACTION", { 3 | "add": [ 4 | [ "if", 5 | [ "and", 6 | [ "has", "MAJOR" ], 7 | [ "has", "MINOR" ], 8 | ], 9 | [ 10 | [ "if", 11 | [ "or", 12 | [ "eq", "DEVNAME", 13 | [ "null", "full", "ptmx", "zero" ], 14 | ], 15 | [ "regex", "DEVNAME", 16 | [ "^gpio", "^hvc" ], 17 | ], 18 | ], 19 | [ 20 | [ "makedev", "/dev/%DEVNAME%", "0666" ], 21 | [ "return" ], 22 | ] 23 | ], 24 | [ "if", 25 | [ "or", 26 | [ "eq", "DEVNAME", "mapper/control" ], 27 | [ "regex", "DEVPATH", "^ppp" ], 28 | ], 29 | [ 30 | [ "makedev", "/dev/%DEVNAME%", "0600" ], 31 | [ "return" ], 32 | ], 33 | ], 34 | [ "if", 35 | [ "has", "DEVNAME" ], 36 | [ "makedev", "/dev/%DEVNAME%", "0644" ], 37 | ], 38 | ], 39 | ], 40 | [ "if", 41 | [ "has", "FIRMWARE" ], 42 | [ 43 | [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ], 44 | [ "load-firmware", "/lib/firmware" ], 45 | [ "return" ] 46 | ] 47 | ], 48 | ], 49 | "remove" : [ 50 | [ "if", 51 | [ "and", 52 | [ "has", "DEVNAME" ], 53 | [ "has", "MAJOR" ], 54 | [ "has", "MINOR" ], 55 | ], 56 | [ "rm", "/dev/%DEVNAME%" ] 57 | ] 58 | ] 59 | } ], 60 | [ "if", 61 | [ "eq", "SUBSYSTEM", "platform" ], 62 | [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ] 63 | ], 64 | [ "if", 65 | [ "and", 66 | [ "has", "BUTTON" ], 67 | [ "eq", "SUBSYSTEM", "button" ], 68 | ], 69 | [ "exec", "/etc/rc.button/%BUTTON%" ] 70 | ], 71 | [ "if", 72 | [ "eq", "SUBSYSTEM", 73 | [ "net", "input", "usb", "ieee1394", "block", "atm", "zaptel", "tty", "button" ] 74 | ], 75 | [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ] 76 | ], 77 | [ "if", 78 | [ "and", 79 | [ "eq", "SUBSYSTEM", "usb-serial" ], 80 | [ "regex", "DEVNAME", 81 | [ "^ttyUSB", "^ttyACM" ] 82 | ], 83 | ], 84 | [ "exec", "/sbin/hotplug-call", "tty" ] 85 | ], 86 | ] 87 | -------------------------------------------------------------------------------- /recipes-core/procd/files/nand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2014 OpenWrt.org 3 | # 4 | 5 | . /lib/functions.sh 6 | 7 | # 'kernel' partition on NAND contains the kernel 8 | CI_KERNPART="kernel" 9 | 10 | # 'ubi' partition on NAND contains UBI 11 | CI_UBIPART="ubi" 12 | 13 | ubi_mknod() { 14 | local dir="$1" 15 | local dev="/dev/$(basename $dir)" 16 | 17 | [ -e "$dev" ] && return 0 18 | 19 | local devid="$(cat $dir/dev)" 20 | local major="${devid%%:*}" 21 | local minor="${devid##*:}" 22 | mknod "$dev" c $major $minor 23 | } 24 | 25 | nand_find_volume() { 26 | local ubidevdir ubivoldir 27 | ubidevdir="/sys/devices/virtual/ubi/$1" 28 | [ ! -d "$ubidevdir" ] && return 1 29 | for ubivoldir in $ubidevdir/${1}_*; do 30 | [ ! -d "$ubivoldir" ] && continue 31 | if [ "$( cat $ubivoldir/name )" = "$2" ]; then 32 | basename $ubivoldir 33 | ubi_mknod "$ubivoldir" 34 | return 0 35 | fi 36 | done 37 | } 38 | 39 | nand_find_ubi() { 40 | local ubidevdir ubidev mtdnum 41 | mtdnum="$( find_mtd_index $1 )" 42 | [ ! "$mtdnum" ] && return 1 43 | for ubidevdir in /sys/devices/virtual/ubi/ubi*; do 44 | [ ! -d "$ubidevdir" ] && continue 45 | cmtdnum="$( cat $ubidevdir/mtd_num )" 46 | [ ! "$mtdnum" ] && continue 47 | if [ "$mtdnum" = "$cmtdnum" ]; then 48 | ubidev=$( basename $ubidevdir ) 49 | ubi_mknod "$ubidevdir" 50 | echo $ubidev 51 | return 0 52 | fi 53 | done 54 | } 55 | 56 | nand_get_magic_long() { 57 | dd if="$1" skip=$2 bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' 58 | } 59 | 60 | get_magic_long_tar() { 61 | ( tar xf $1 $2 -O | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null 62 | } 63 | 64 | identify_magic() { 65 | local magic=$1 66 | case "$magic" in 67 | "55424923") 68 | echo "ubi" 69 | ;; 70 | "31181006") 71 | echo "ubifs" 72 | ;; 73 | "68737173") 74 | echo "squashfs" 75 | ;; 76 | "d00dfeed") 77 | echo "fit" 78 | ;; 79 | "4349"*) 80 | echo "combined" 81 | ;; 82 | *) 83 | echo "unknown $magic" 84 | ;; 85 | esac 86 | } 87 | 88 | 89 | identify() { 90 | identify_magic $(nand_get_magic_long "$1" "${2:-0}") 91 | } 92 | 93 | identify_tar() { 94 | identify_magic $(get_magic_long_tar "$1" "$2") 95 | } 96 | 97 | nand_restore_config() { 98 | sync 99 | local ubidev=$( nand_find_ubi $CI_UBIPART ) 100 | local ubivol="$( nand_find_volume $ubidev rootfs_data )" 101 | [ ! "$ubivol" ] && 102 | ubivol="$( nand_find_volume $ubidev rootfs )" 103 | mkdir /tmp/new_root 104 | if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then 105 | echo "mounting ubifs $ubivol failed" 106 | rmdir /tmp/new_root 107 | return 1 108 | fi 109 | mv "$1" "/tmp/new_root/sysupgrade.tgz" 110 | umount /tmp/new_root 111 | sync 112 | rmdir /tmp/new_root 113 | } 114 | 115 | nand_upgrade_prepare_ubi() { 116 | local rootfs_length="$1" 117 | local rootfs_type="$2" 118 | local has_kernel="${3:-0}" 119 | local has_env="${4:-0}" 120 | 121 | local mtdnum="$( find_mtd_index "$CI_UBIPART" )" 122 | if [ ! "$mtdnum" ]; then 123 | echo "cannot find ubi mtd partition $CI_UBIPART" 124 | return 1 125 | fi 126 | 127 | local ubidev="$( nand_find_ubi "$CI_UBIPART" )" 128 | if [ ! "$ubidev" ]; then 129 | ubiattach -m "$mtdnum" 130 | sync 131 | ubidev="$( nand_find_ubi "$CI_UBIPART" )" 132 | fi 133 | 134 | if [ ! "$ubidev" ]; then 135 | ubiformat /dev/mtd$mtdnum -y 136 | ubiattach -m "$mtdnum" 137 | sync 138 | ubidev="$( nand_find_ubi "$CI_UBIPART" )" 139 | [ "$has_env" -gt 0 ] && { 140 | ubimkvol /dev/$ubidev -n 0 -N ubootenv -s 1MiB 141 | ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB 142 | } 143 | fi 144 | 145 | local kern_ubivol="$( nand_find_volume $ubidev kernel )" 146 | local root_ubivol="$( nand_find_volume $ubidev rootfs )" 147 | local data_ubivol="$( nand_find_volume $ubidev rootfs_data )" 148 | 149 | # remove ubiblock device of rootfs 150 | local root_ubiblk="ubiblock${root_ubivol:3}" 151 | if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then 152 | echo "removing $root_ubiblk" 153 | if ! ubiblock -r /dev/$root_ubivol; then 154 | echo "cannot remove $root_ubiblk" 155 | return 1; 156 | fi 157 | fi 158 | 159 | # kill volumes 160 | [ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N kernel || true 161 | [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs || true 162 | [ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true 163 | 164 | # update kernel 165 | if [ "$has_kernel" = "1" ]; then 166 | if ! ubimkvol /dev/$ubidev -N kernel -s $kernel_length; then 167 | echo "cannot create kernel volume" 168 | return 1; 169 | fi 170 | fi 171 | 172 | # update rootfs 173 | local root_size_param 174 | if [ "$rootfs_type" = "ubifs" ]; then 175 | root_size_param="-m" 176 | else 177 | root_size_param="-s $rootfs_length" 178 | fi 179 | if ! ubimkvol /dev/$ubidev -N rootfs $root_size_param; then 180 | echo "cannot create rootfs volume" 181 | return 1; 182 | fi 183 | 184 | # create rootfs_data for non-ubifs rootfs 185 | if [ "$rootfs_type" != "ubifs" ]; then 186 | if ! ubimkvol /dev/$ubidev -N rootfs_data -m; then 187 | echo "cannot initialize rootfs_data volume" 188 | return 1 189 | fi 190 | fi 191 | sync 192 | return 0 193 | } 194 | 195 | nand_do_upgrade_success() { 196 | local conf_tar="/tmp/sysupgrade.tgz" 197 | 198 | sync 199 | [ -f "$conf_tar" ] && nand_restore_config "$conf_tar" 200 | echo "sysupgrade successful" 201 | reboot -f 202 | } 203 | 204 | nand_upgrade_ubinized() { 205 | local ubi_file="$1" 206 | local mtdnum="$(find_mtd_index "$CI_UBIPART")" 207 | 208 | [ ! "$mtdnum" ] && { 209 | CI_UBIPART="rootfs" 210 | mtdnum="$(find_mtd_index "$CI_UBIPART")" 211 | } 212 | 213 | if [ ! "$mtdnum" ]; then 214 | echo "cannot find mtd device $CI_UBIPART" 215 | reboot -f 216 | fi 217 | 218 | local mtddev="/dev/mtd${mtdnum}" 219 | ubidetach -p "${mtddev}" || true 220 | sync 221 | ubiformat "${mtddev}" -y -f "${ubi_file}" 222 | ubiattach -p "${mtddev}" 223 | nand_do_upgrade_success 224 | } 225 | 226 | nand_upgrade_ubifs() { 227 | local rootfs_length=`(cat $1 | wc -c) 2> /dev/null` 228 | 229 | nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" 230 | 231 | local ubidev="$( nand_find_ubi "$CI_UBIPART" )" 232 | local root_ubivol="$(nand_find_volume $ubidev rootfs)" 233 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 234 | 235 | nand_do_upgrade_success 236 | } 237 | 238 | nand_upgrade_tar() { 239 | local tar_file="$1" 240 | local board_name="$(cat /tmp/sysinfo/board_name)" 241 | local kernel_mtd="$(find_mtd_index $CI_KERNPART)" 242 | 243 | local kernel_length=`(tar xf $tar_file sysupgrade-$board_name/kernel -O | wc -c) 2> /dev/null` 244 | local rootfs_length=`(tar xf $tar_file sysupgrade-$board_name/root -O | wc -c) 2> /dev/null` 245 | 246 | local rootfs_type="$(identify_tar "$tar_file" sysupgrade-$board_name/root)" 247 | 248 | local has_kernel=1 249 | local has_env=0 250 | 251 | [ "kernel_length" = 0 -o -z "$kernel_mtd" ] || { 252 | tar xf $tar_file sysupgrade-$board_name/kernel -O | mtd write - $CI_KERNPART 253 | } 254 | [ "kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0 255 | 256 | nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "$has_kernel" "$has_env" 257 | 258 | local ubidev="$( nand_find_ubi "$CI_UBIPART" )" 259 | [ "$has_kernel" = "1" ] && { 260 | local kern_ubivol="$(nand_find_volume $ubidev kernel)" 261 | tar xf $tar_file sysupgrade-$board_name/kernel -O | \ 262 | ubiupdatevol /dev/$kern_ubivol -s $kernel_length - 263 | } 264 | 265 | local root_ubivol="$(nand_find_volume $ubidev rootfs)" 266 | tar xf $tar_file sysupgrade-$board_name/root -O | \ 267 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length - 268 | 269 | nand_do_upgrade_success 270 | } 271 | 272 | nand_do_upgrade_stage2() { 273 | local file_type=$(identify $1) 274 | 275 | [ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART="rootfs" 276 | 277 | [ "$file_type" == "ubi" ] && nand_upgrade_ubinized $1 278 | [ "$file_type" == "ubifs" ] && nand_upgrade_ubifs $1 279 | nand_upgrade_tar $1 280 | } 281 | 282 | nand_upgrade_stage2() { 283 | [ $1 = "nand" ] && { 284 | [ -f "$2" ] && { 285 | touch /tmp/sysupgrade 286 | 287 | killall -9 telnetd 288 | killall -9 dropbear 289 | killall -9 ash 290 | 291 | kill_remaining TERM 292 | sleep 3 293 | kill_remaining KILL 294 | 295 | sleep 1 296 | 297 | if [ -n "$(rootfs_type)" ]; then 298 | v "Switching to ramdisk..." 299 | run_ramfs ". /lib/functions.sh; include /lib/upgrade; nand_do_upgrade_stage2 $2" 300 | else 301 | nand_do_upgrade_stage2 $2 302 | fi 303 | return 0 304 | } 305 | echo "Nand upgrade failed" 306 | exit 1 307 | } 308 | } 309 | 310 | nand_upgrade_stage1() { 311 | [ -f /tmp/sysupgrade-nand-path ] && { 312 | path="$(cat /tmp/sysupgrade-nand-path)" 313 | [ "$SAVE_CONFIG" != 1 -a -f "$CONF_TAR" ] && 314 | rm $CONF_TAR 315 | 316 | ubus call system nandupgrade "{\"path\": \"$path\" }" 317 | exit 0 318 | } 319 | } 320 | append sysupgrade_pre_upgrade nand_upgrade_stage1 321 | 322 | nand_do_platform_check() { 323 | local board_name="$1" 324 | local tar_file="$2" 325 | local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null` 326 | local file_type="$(identify $2)" 327 | 328 | [ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && { 329 | echo "Invalid sysupgrade file." 330 | return 1 331 | } 332 | 333 | echo -n $2 > /tmp/sysupgrade-nand-path 334 | cp /sbin/upgraded /tmp/ 335 | 336 | return 0 337 | } 338 | -------------------------------------------------------------------------------- /recipes-core/procd/files/procd.sh: -------------------------------------------------------------------------------- 1 | # procd API: 2 | # 3 | # procd_open_service(name, [script]): 4 | # Initialize a new procd command message containing a service with one or more instances 5 | # 6 | # procd_close_service() 7 | # Send the command message for the service 8 | # 9 | # procd_open_instance([name]): 10 | # Add an instance to the service described by the previous procd_open_service call 11 | # 12 | # procd_set_param(type, [value...]) 13 | # Available types: 14 | # command: command line (array). 15 | # respawn info: array with 3 values $restart_timeout $fail_hreshold $max_fail 16 | # env: environment variable (passed to the process) 17 | # data: arbitrary name/value pairs for detecting config changes (table) 18 | # file: configuration files (array) 19 | # netdev: bound network device (detects ifindex changes) 20 | # limits: resource limits (passed to the process) 21 | # 22 | # No space separation is done for arrays/tables - use one function argument per command line argument 23 | # 24 | # procd_close_instance(): 25 | # Complete the instance being prepared 26 | # 27 | # procd_kill(service, [instance]): 28 | # Kill a service instance (or all instances) 29 | # 30 | 31 | . $IPKG_INSTROOT/usr/share/libubox/jshn.sh 32 | 33 | _PROCD_SERVICE= 34 | 35 | _procd_call() { 36 | local old_cb 37 | 38 | json_set_namespace procd old_cb 39 | "$@" 40 | json_set_namespace $old_cb 41 | } 42 | 43 | _procd_wrapper() { 44 | while [ -n "$1" ]; do 45 | eval "$1() { _procd_call _$1 \"\$@\"; }" 46 | shift 47 | done 48 | } 49 | 50 | _procd_ubus_call() { 51 | local cmd="$1" 52 | 53 | [ -n "$PROCD_DEBUG" ] && json_dump >&2 54 | ubus call service "$cmd" "$(json_dump)" 55 | json_cleanup 56 | } 57 | 58 | _procd_open_service() { 59 | local name="$1" 60 | local script="$2" 61 | 62 | _PROCD_SERVICE="$name" 63 | _PROCD_INSTANCE_SEQ=0 64 | 65 | json_init 66 | json_add_string name "$name" 67 | [ -n "$script" ] && json_add_string script "$script" 68 | json_add_object instances 69 | } 70 | 71 | _procd_close_service() { 72 | json_close_object 73 | service_triggers 74 | _procd_ubus_call set 75 | } 76 | 77 | _procd_add_array_data() { 78 | while [ "$#" -gt 0 ]; do 79 | json_add_string "" "$1" 80 | shift 81 | done 82 | } 83 | 84 | _procd_add_array() { 85 | json_add_array "$1" 86 | shift 87 | _procd_add_array_data "$@" 88 | json_close_array 89 | } 90 | 91 | _procd_add_table_data() { 92 | while [ -n "$1" ]; do 93 | local var="${1%%=*}" 94 | local val="${1#*=}" 95 | [[ "$1" == "$val" ]] && val= 96 | json_add_string "$var" "$val" 97 | shift 98 | done 99 | } 100 | 101 | _procd_add_table() { 102 | json_add_object "$1" 103 | shift 104 | _procd_add_table_data "$@" 105 | json_close_object 106 | } 107 | 108 | _procd_open_instance() { 109 | local name="$1"; shift 110 | 111 | _PROCD_INSTANCE_SEQ="$(($_PROCD_INSTANCE_SEQ + 1))" 112 | name="${name:-instance$_PROCD_INSTANCE_SEQ}" 113 | json_add_object "$name" 114 | } 115 | 116 | _procd_open_trigger() { 117 | json_add_array "triggers" 118 | } 119 | 120 | _procd_open_validate() { 121 | json_add_array "validate" 122 | } 123 | 124 | _procd_set_param() { 125 | local type="$1"; shift 126 | 127 | case "$type" in 128 | env|data|limits) 129 | _procd_add_table "$type" "$@" 130 | ;; 131 | command|netdev|file|respawn|watch) 132 | _procd_add_array "$type" "$@" 133 | ;; 134 | error) 135 | json_add_array "$type" 136 | json_add_string "" "$@" 137 | json_close_array 138 | ;; 139 | nice) 140 | json_add_int "$type" "$1" 141 | ;; 142 | esac 143 | } 144 | 145 | _procd_add_interface_trigger() { 146 | json_add_array 147 | _procd_add_array_data "$1" 148 | shift 149 | 150 | json_add_array 151 | _procd_add_array_data "if" 152 | 153 | json_add_array 154 | _procd_add_array_data "eq" "interface" "$1" 155 | shift 156 | json_close_array 157 | 158 | json_add_array 159 | _procd_add_array_data "run_script" "$@" 160 | json_close_array 161 | 162 | json_close_array 163 | 164 | json_close_array 165 | } 166 | 167 | _procd_add_reload_interface_trigger() { 168 | local script=$(readlink "$initscript") 169 | local name=$(basename ${script:-$initscript}) 170 | 171 | _procd_open_trigger 172 | _procd_add_interface_trigger "interface.*" $1 /etc/init.d/$name reload 173 | _procd_close_trigger 174 | } 175 | 176 | _procd_add_config_trigger() { 177 | json_add_array 178 | _procd_add_array_data "$1" 179 | shift 180 | 181 | json_add_array 182 | _procd_add_array_data "if" 183 | 184 | json_add_array 185 | _procd_add_array_data "eq" "package" "$1" 186 | shift 187 | json_close_array 188 | 189 | json_add_array 190 | _procd_add_array_data "run_script" "$@" 191 | json_close_array 192 | 193 | json_close_array 194 | 195 | json_close_array 196 | } 197 | 198 | _procd_add_reload_trigger() { 199 | local script=$(readlink "$initscript") 200 | local name=$(basename ${script:-$initscript}) 201 | local file 202 | 203 | _procd_open_trigger 204 | for file in "$@"; do 205 | _procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload 206 | done 207 | _procd_close_trigger 208 | } 209 | 210 | _procd_add_validation() { 211 | _procd_open_validate 212 | $@ 213 | _procd_close_validate 214 | } 215 | 216 | _procd_append_param() { 217 | local type="$1"; shift 218 | local _json_no_warning=1 219 | 220 | json_select "$type" 221 | [ $? = 0 ] || { 222 | _procd_set_param "$type" "$@" 223 | return 224 | } 225 | case "$type" in 226 | env|data|limits) 227 | _procd_add_table_data "$@" 228 | ;; 229 | command|netdev|file|respawn|watch) 230 | _procd_add_array_data "$@" 231 | ;; 232 | error) 233 | json_add_string "" "$@" 234 | ;; 235 | esac 236 | json_select .. 237 | } 238 | 239 | _procd_close_instance() { 240 | json_close_object 241 | } 242 | 243 | _procd_close_trigger() { 244 | json_close_array 245 | } 246 | 247 | _procd_close_validate() { 248 | json_close_array 249 | } 250 | 251 | _procd_add_instance() { 252 | _procd_open_instance 253 | _procd_set_param command "$@" 254 | _procd_close_instance 255 | } 256 | 257 | _procd_kill() { 258 | local service="$1" 259 | local instance="$2" 260 | 261 | json_init 262 | [ -n "$service" ] && json_add_string name "$service" 263 | [ -n "$instance" ] && json_add_string instance "$instance" 264 | _procd_ubus_call delete 265 | } 266 | 267 | procd_open_data() { 268 | local name="$1" 269 | json_set_namespace procd __procd_old_cb 270 | json_add_object data 271 | } 272 | 273 | procd_close_data() { 274 | json_close_object 275 | json_set_namespace $__procd_old_cb 276 | } 277 | 278 | _procd_set_config_changed() { 279 | local package="$1" 280 | 281 | json_init 282 | json_add_string type config.change 283 | json_add_object data 284 | json_add_string package "$package" 285 | json_close_object 286 | 287 | ubus call service event "$(json_dump)" 288 | } 289 | 290 | uci_validate_section() 291 | { 292 | local _package="$1" 293 | local _type="$2" 294 | local _name="$3" 295 | local _result 296 | local _error 297 | shift; shift; shift 298 | _result=`/sbin/validate_data "$_package" "$_type" "$_name" "$@" 2> /dev/null` 299 | _error=$? 300 | eval "$_result" 301 | [ "$_error" = "0" ] || `/sbin/validate_data "$_package" "$_type" "$_name" "$@" 1> /dev/null` 302 | return $_error 303 | } 304 | 305 | _procd_wrapper \ 306 | procd_open_service \ 307 | procd_close_service \ 308 | procd_add_instance \ 309 | procd_add_config_trigger \ 310 | procd_add_interface_trigger \ 311 | procd_add_reload_trigger \ 312 | procd_add_reload_interface_trigger \ 313 | procd_add_interface_reload \ 314 | procd_open_trigger \ 315 | procd_close_trigger \ 316 | procd_open_instance \ 317 | procd_close_instance \ 318 | procd_open_validate \ 319 | procd_close_validate \ 320 | procd_set_param \ 321 | procd_append_param \ 322 | procd_add_validation \ 323 | procd_set_config_changed \ 324 | procd_kill 325 | -------------------------------------------------------------------------------- /recipes-core/procd/files/reload_config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf /var/run/config.check 3 | mkdir -p /var/run/config.check 4 | for config in /etc/config/*; do 5 | file=${config##*/} 6 | uci show "${file##*/}" > /var/run/config.check/$file 7 | done 8 | MD5FILE=/var/run/config.md5 9 | [ -f $MD5FILE ] && { 10 | for c in `md5sum -c $MD5FILE 2>/dev/null| grep FAILED | cut -d: -f1`; do 11 | ubus call service event "{ \"type\": \"config.change\", \"data\": { \"package\": \"$(basename $c)\" }}" 12 | done 13 | } 14 | md5sum /var/run/config.check/* > $MD5FILE 15 | rm -rf /var/run/config.check 16 | -------------------------------------------------------------------------------- /recipes-core/procd/procd_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "OpenWrt system process manager" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/procd" 3 | LICENSE = "LGPLv2" 4 | LIC_FILES_CHKSUM = "file://procd.c;beginline=1;endline=13;md5=61e3657604f131a859b57a40f27a9d8e" 5 | 6 | SRC_URI = "git://nbd.name/luci2/procd.git;protocol=git;branch=master" 7 | SRC_URI += "file://reload_config" 8 | SRC_URI += "file://hotplug*.json" 9 | SRC_URI += "file://procd.sh" 10 | 11 | SRCREV = "27159f21f76b973a9fa3ec92b8fee2e390d43a43" 12 | S = "${WORKDIR}/git" 13 | 14 | inherit cmake 15 | 16 | PR="r1" 17 | 18 | DEPENDS = "ubus" 19 | RDEPENDS_${PN} = "fstools ubox ubus libubox libubus" 20 | 21 | ALTERNATIVE_${PN} = "init" 22 | 23 | ALTERNATIVE_PRIORITY = "200" 24 | 25 | ALTERNATIVE_LINK_NAME[init] = "/usr/sbin/init" 26 | ALTERNATIVE_PRIORITY[init] = "50" 27 | FILES_${PN} += "/lib /sbin" 28 | 29 | do_install_append () { 30 | mkdir -p ${D}/etc ${D}/lib/functions 31 | mv ${D}/usr/sbin ${D}/sbin 32 | install ${WORKDIR}/reload_config ${D}/sbin/ 33 | install ${WORKDIR}/hotplug*.json ${D}/etc/ 34 | install ${WORKDIR}/procd.sh ${D}/lib/functions/ 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /recipes-core/rpcd/files/rpcd.config: -------------------------------------------------------------------------------- 1 | 2 | config login 3 | option username 'root' 4 | option password '$p$root' 5 | list read '*' 6 | list write '*' 7 | 8 | -------------------------------------------------------------------------------- /recipes-core/rpcd/files/rpcd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=12 4 | 5 | USE_PROCD=1 6 | NAME=rpcd 7 | PROG=/sbin/rpcd 8 | 9 | start_service() { 10 | procd_open_instance 11 | procd_set_param command "$PROG" 12 | procd_close_instance 13 | } 14 | 15 | stop() { 16 | service_stop /sbin/rpcd 17 | } 18 | 19 | reload() { 20 | service_reload /sbin/rpcd 21 | } 22 | -------------------------------------------------------------------------------- /recipes-core/rpcd/rpcd_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "This package provides the UBUS RPC backend server to expose various functionality to frontend programs via JSON-RPC." 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/rpcd" 3 | LICENSE = "ISC" 4 | LIC_FILES_CHKSUM = "file://main.c;beginline=1;endline=18;md5=da5faf55ed0618f0dde1c88e76a0fc74" 5 | 6 | SRC_URI = "git://nbd.name/luci2/rpcd.git;protocol=git;branch=master" 7 | SRC_URI += "file://rpcd.init" 8 | SRC_URI += "file://rpcd.config" 9 | 10 | SRCREV = "311c85e7d9a8f7fee17e65afc371f4fd0c8cd588" 11 | S = "${WORKDIR}/git" 12 | 13 | inherit cmake 14 | 15 | PR="r1" 16 | 17 | DEPENDS = "ubus uci iwinfo" 18 | 19 | #FIXME: put plugins to the correct place 20 | FILES_${PN} += "/usr/lib/*.so" 21 | 22 | #FIXME: install rpcd directly to /sbin from makefile instead of usig mv 23 | do_install_append () { 24 | mkdir -p ${D}/${sysconfdir}/init.d ${D}/${sysconfdir}/config ${D}/usr/share/rpcd/acl.d 25 | install ${WORKDIR}/rpcd.config ${D}/${sysconfdir}/config/rpcd 26 | install ${WORKDIR}/rpcd.init ${D}/${sysconfdir}/init.d/rpcd 27 | install ${WORKDIR}/rpcd.init ${D}/${sysconfdir}/init.d/rpcd 28 | install ${S}/unauthenticated.json ${D}/usr/share/rpcd/acl.d 29 | cp -a ${S}/include ${D}/usr/include 30 | mv ${D}/usr/sbin ${D}/sbin 31 | } 32 | 33 | -------------------------------------------------------------------------------- /recipes-core/ubox/files/100-insmod-segfault.patch: -------------------------------------------------------------------------------- 1 | --- a/kmodloader.c 2 | +++ b/kmodloader.c 3 | @@ -605,6 +605,9 @@ static int main_insmod(int argc, char ** 4 | cur += sprintf(cur, "%s", argv[i]); 5 | } 6 | 7 | + if (init_module_folders()) 8 | + return -1; 9 | + 10 | if (get_module_path(argv[1])) { 11 | name = argv[1]; 12 | } else if (!get_module_path(name)) { 13 | -------------------------------------------------------------------------------- /recipes-core/ubox/files/log.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2013 OpenWrt.org 3 | 4 | # start after and stop before networking 5 | START=12 6 | STOP=89 7 | PIDCOUNT=0 8 | 9 | USE_PROCD=1 10 | PROG=/sbin/logread 11 | 12 | validate_log_section() 13 | { 14 | uci_validate_section system system "${1}" \ 15 | 'log_file:string' \ 16 | 'log_size:uinteger' \ 17 | 'log_ip:ipaddr' \ 18 | 'log_remote:bool:1' \ 19 | 'log_port:port:514' \ 20 | 'log_proto:or("tcp", "udp"):udp' \ 21 | 'log_prefix:string' 22 | } 23 | 24 | validate_log_daemon() 25 | { 26 | uci_validate_section system system "${1}" \ 27 | 'log_size:uinteger:0' \ 28 | 'log_buffer_size:uinteger:0' 29 | } 30 | 31 | start_service_daemon() 32 | { 33 | local log_buffer_size log_size 34 | validate_log_daemon "${1}" 35 | [ $log_buffer_size -eq 0 -a $log_size -gt 0 ] && log_buffer_size=$log_size 36 | [ $log_buffer_size -eq 0 ] && log_buffer_size=16 37 | procd_open_instance 38 | procd_set_param command "/sbin/logd" 39 | procd_append_param command -S "${log_buffer_size}" 40 | procd_set_param respawn 41 | procd_close_instance 42 | } 43 | 44 | start_service_file() 45 | { 46 | PIDCOUNT="$(( ${PIDCOUNT} + 1))" 47 | local pid_file="/var/run/logread.${PIDCOUNT}.pid" 48 | local log_file log_size 49 | 50 | validate_log_section "${1}" || { 51 | echo "validation failed" 52 | return 1 53 | } 54 | [ -z "${log_file}" ] && return 55 | 56 | procd_open_instance 57 | procd_set_param command "$PROG" -f -F "$log_file" -p "$pid_file" 58 | [ -n "${log_size}" ] && procd_append_param command -S "$log_size" 59 | procd_close_instance 60 | } 61 | 62 | start_service_remote() 63 | { 64 | PIDCOUNT="$(( ${PIDCOUNT} + 1))" 65 | local pid_file="/var/run/logread.${PIDCOUNT}.pid" 66 | local log_ip log_port log_proto log_prefix log_remote 67 | 68 | validate_log_section "${1}" || { 69 | echo "validation failed" 70 | return 1 71 | } 72 | [ "${log_remote}" -ne 0 ] || return 73 | [ -z "${log_ip}" ] && return 74 | 75 | procd_open_instance 76 | procd_set_param command "$PROG" -f -r "$log_ip" "${log_port}" -p "$pid_file" 77 | [ "${log_proto}" != "udp" ] || procd_append_param command -u 78 | [ -z "${log_prefix}" ] || procd_append_param command -P "${log_prefix}" 79 | procd_close_instance 80 | } 81 | 82 | service_triggers() 83 | { 84 | procd_add_reload_trigger "system" 85 | procd_add_validation validate_log_section 86 | } 87 | 88 | start_service() 89 | { 90 | config_load system 91 | config_foreach start_service_daemon system 92 | config_foreach start_service_file system 93 | config_foreach start_service_remote system 94 | } 95 | -------------------------------------------------------------------------------- /recipes-core/ubox/ubox_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "OpenWrt system helper toolbox" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/ubox" 3 | LICENSE = "GPLv2" 4 | LIC_FILES_CHKSUM = "file://kmodloader.c;beginline=1;endline=13;md5=61e3657604f131a859b57a40f27a9d8e" 5 | 6 | SRC_URI = "git://nbd.name/luci2/ubox.git;protocol=git;branch=master" 7 | SRC_URI += "file://100-insmod-segfault.patch" 8 | SRC_URI += "file://log.init" 9 | 10 | SRCREV = "31f0ff358b360ee461d845c1b3b5e5d38fa27925" 11 | S = "${WORKDIR}/git" 12 | 13 | inherit cmake 14 | 15 | PR="r1" 16 | 17 | RDEPENDS_${PN} += "libvalidate ubus libubus libubox libuci" 18 | 19 | DEPENDS = "ubus libubox uci" 20 | PACKAGES += "libvalidate" 21 | FILES_${PN} = "${bindir} ${sysconfdir} /sbin /usr/sbin" 22 | FILES_${PN}-dev = "/usr/include /usr/lib" 23 | FILES_libvalidate = "${base_libdir}" 24 | 25 | do_install_append () { 26 | mkdir -p ${D}/usr/sbin ${D}/lib/ ${D}/etc/init.d/ ${D}/sbin 27 | 28 | mv ${D}/usr/sbin/{kmodloader,logd,logread,validate_data} ${D}/sbin/ 29 | install ${WORKDIR}/log.init ${D}/etc/init.d/log 30 | install ${D}/usr/lib/libvalidate.so ${D}/${base_libdir} 31 | 32 | ln -s /sbin/kmodloader ${D}/usr/sbin/rmmod 33 | ln -s /sbin/kmodloader ${D}/usr/sbin/insmod 34 | ln -s /sbin/kmodloader ${D}/usr/sbin/lsmod 35 | ln -s /sbin/kmodloader ${D}/usr/sbin/modinfo 36 | ln -s /sbin/kmodloader ${D}/usr/sbin/modprobe 37 | 38 | } 39 | -------------------------------------------------------------------------------- /recipes-core/ubus/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/lua/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/lua/CMakeLists.txt 4 | +++ git/lua/CMakeLists.txt 5 | @@ -8,7 +8,7 @@ IF(NOT LUA_CFLAGS) 6 | FIND_PROGRAM(PKG_CONFIG pkg-config) 7 | IF(PKG_CONFIG) 8 | EXECUTE_PROCESS( 9 | - COMMAND pkg-config --silence-errors --cflags lua5.1 10 | + COMMAND pkg-config --silence-errors --cflags luajit 11 | OUTPUT_VARIABLE LUA_CFLAGS 12 | OUTPUT_STRIP_TRAILING_WHITESPACE 13 | ) 14 | Index: git/lua/test.lua 15 | =================================================================== 16 | --- git.orig/lua/test.lua 17 | +++ git/lua/test.lua 18 | @@ -1,4 +1,4 @@ 19 | -#!/usr/bin/env lua 20 | +#!/usr/bin/env luajit 21 | 22 | require "ubus" 23 | require "uloop" 24 | Index: git/lua/test_client.lua 25 | =================================================================== 26 | --- git.orig/lua/test_client.lua 27 | +++ git/lua/test_client.lua 28 | @@ -1,4 +1,4 @@ 29 | -#!/usr/bin/env lua 30 | +#!/usr/bin/env luajit 31 | 32 | require "ubus" 33 | require "uloop" 34 | -------------------------------------------------------------------------------- /recipes-core/ubus/ubus_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "OpenWrt RPC daemon" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/ubus" 3 | LICENSE = "LGPLv2" 4 | LIC_FILES_CHKSUM = "file://ubusd.c;beginline=1;endline=12;md5=1b6a7aecd35bdd25de35da967668485d" 5 | 6 | SRC_URI = "git://nbd.name/luci2/ubus.git;protocol=git;branch=master" 7 | SRC_URI += "file://luajit.patch" 8 | 9 | SRCREV = "2d660c519d2fcff95248da9f4fd9b37d61f9eb09" 10 | S = "${WORKDIR}/git" 11 | 12 | inherit cmake 13 | 14 | PR="r1" 15 | 16 | DEPENDS = "libubox luajit" 17 | EXTRA_OECMAKE = "-DLUAPATH=/usr/lib/lua/5.1" 18 | PACKAGES += "libubus" 19 | RDEPENDS_${PN} += "libubox libubus" 20 | RDEPENDS_libubus += "libubox" 21 | 22 | FILES_${PN} = "/usr/lib/lua/5.1 /bin /sbin" 23 | FILES_${PN}-dev = "/usr/include /usr/lib/lib*.so" 24 | FILES_libubus = "${base_libdir}" 25 | FILES_${PN}-dbg += "/usr/lib/lua/5.1/.debug" 26 | 27 | 28 | do_install_append () { 29 | mkdir -p ${D}/lib 30 | 31 | install ${D}/usr/lib/libubus.so ${D}/${base_libdir} 32 | mv ${D}/usr/sbin ${D}/sbin 33 | mv ${D}/usr/bin ${D}/bin 34 | install ${S}/lua/test.lua ${D}/usr/lib/lua/5.1 35 | install ${S}/lua/test_client.lua ${D}/usr/lib/lua/5.1 36 | } 37 | -------------------------------------------------------------------------------- /recipes-core/uci/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/lua/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/lua/CMakeLists.txt 4 | +++ git/lua/CMakeLists.txt 5 | @@ -8,7 +8,7 @@ IF(NOT LUA_CFLAGS) 6 | FIND_PROGRAM(PKG_CONFIG pkg-config) 7 | IF(PKG_CONFIG) 8 | EXECUTE_PROCESS( 9 | - COMMAND pkg-config --silence-errors --cflags lua5.1 10 | + COMMAND pkg-config --silence-errors --cflags luajit 11 | OUTPUT_VARIABLE LUA_CFLAGS 12 | OUTPUT_STRIP_TRAILING_WHITESPACE 13 | ) 14 | -------------------------------------------------------------------------------- /recipes-core/uci/files/uci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Shell script compatibility wrappers for /sbin/uci 3 | # 4 | # Copyright (C) 2008-2010 OpenWrt.org 5 | # Copyright (C) 2008 Felix Fietkau 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | CONFIG_APPEND= 22 | uci_load() { 23 | local PACKAGE="$1" 24 | local DATA 25 | local RET 26 | local VAR 27 | 28 | _C=0 29 | if [ -z "$CONFIG_APPEND" ]; then 30 | for VAR in $CONFIG_LIST_STATE; do 31 | export ${NO_EXPORT:+-n} CONFIG_${VAR}= 32 | export ${NO_EXPORT:+-n} CONFIG_${VAR}_LENGTH= 33 | done 34 | export ${NO_EXPORT:+-n} CONFIG_LIST_STATE= 35 | export ${NO_EXPORT:+-n} CONFIG_SECTIONS= 36 | export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0 37 | export ${NO_EXPORT:+-n} CONFIG_SECTION= 38 | fi 39 | 40 | DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)" 41 | RET="$?" 42 | [ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA" 43 | unset DATA 44 | 45 | ${CONFIG_SECTION:+config_cb} 46 | return "$RET" 47 | } 48 | 49 | uci_set_default() { 50 | local PACKAGE="$1" 51 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0 52 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE" 53 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE" 54 | } 55 | 56 | uci_revert_state() { 57 | local PACKAGE="$1" 58 | local CONFIG="$2" 59 | local OPTION="$3" 60 | 61 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}" 62 | } 63 | 64 | uci_set_state() { 65 | local PACKAGE="$1" 66 | local CONFIG="$2" 67 | local OPTION="$3" 68 | local VALUE="$4" 69 | 70 | [ "$#" = 4 ] || return 0 71 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE" 72 | } 73 | 74 | uci_toggle_state() { 75 | uci_revert_state "$1" "$2" "$3" 76 | uci_set_state "$1" "$2" "$3" "$4" 77 | } 78 | 79 | uci_set() { 80 | local PACKAGE="$1" 81 | local CONFIG="$2" 82 | local OPTION="$3" 83 | local VALUE="$4" 84 | 85 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE" 86 | } 87 | 88 | uci_get_state() { 89 | uci_get "$1" "$2" "$3" "$4" "/var/state" 90 | } 91 | 92 | uci_get() { 93 | local PACKAGE="$1" 94 | local CONFIG="$2" 95 | local OPTION="$3" 96 | local DEFAULT="$4" 97 | local STATE="$5" 98 | 99 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}" 100 | RET="$?" 101 | [ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT" 102 | return "$RET" 103 | } 104 | 105 | uci_add() { 106 | local PACKAGE="$1" 107 | local TYPE="$2" 108 | local CONFIG="$3" 109 | 110 | if [ -z "$CONFIG" ]; then 111 | export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")" 112 | else 113 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE" 114 | export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG" 115 | fi 116 | } 117 | 118 | uci_rename() { 119 | local PACKAGE="$1" 120 | local CONFIG="$2" 121 | local VALUE="$3" 122 | 123 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE" 124 | } 125 | 126 | uci_remove() { 127 | local PACKAGE="$1" 128 | local CONFIG="$2" 129 | local OPTION="$3" 130 | 131 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}" 132 | } 133 | 134 | uci_commit() { 135 | local PACKAGE="$1" 136 | /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE 137 | } 138 | -------------------------------------------------------------------------------- /recipes-core/uci/uci_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Unified Configuration Interface" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/techref/uci" 3 | LICENSE = "LGPLv2" 4 | LIC_FILES_CHKSUM = "file://libuci.c;beginline=1;endline=13;md5=0ee862ed12171ee619c8c2eb7eff77f2" 5 | 6 | SRC_URI = "git://nbd.name/uci.git;protocol=git;branch=master" 7 | SRC_URI += "file://uci.sh" 8 | SRC_URI += "file://luajit.patch" 9 | 10 | SRCREV = "556215152a216c179fe2ca7db9b1de7036ceda60" 11 | S = "${WORKDIR}/git" 12 | 13 | 14 | inherit cmake 15 | 16 | PR="r1" 17 | DEPENDS = "libubox luajit" 18 | 19 | EXTRA_OECMAKE = "-DLUAPATH=/usr/lib/lua/5.1" 20 | RDEPENDS_${PN} += "libuci" 21 | 22 | PACKAGES += "libuci" 23 | FILES_${PN} = "/usr/lib/lua/5.1 /usr/bin /sbin " 24 | FILES_${PN}-dev = "/usr/include /usr/lib/libuci.so" 25 | FILES_libuci = "${base_libdir}" 26 | FILES_${PN}-dbg += "/usr/lib/lua/5.1/.debug" 27 | 28 | 29 | do_install_append () { 30 | mkdir -p ${D}/lib ${D}/lib/config ${D}/sbin 31 | install ${D}/usr/lib/libuci.so ${D}/${base_libdir} 32 | install ${WORKDIR}/uci.sh ${D}/${base_libdir}/config 33 | install ${D}/usr/bin/uci ${D}/sbin 34 | } 35 | -------------------------------------------------------------------------------- /recipes-core/uhttpd/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/CMakeLists.txt 4 | +++ git/CMakeLists.txt 5 | @@ -74,7 +74,7 @@ IF(LUA_SUPPORT) 6 | 7 | IF(NOT LUA_CFLAGS AND PKG_CONFIG) 8 | EXECUTE_PROCESS( 9 | - COMMAND pkg-config --silence-errors --cflags lua5.1 10 | + COMMAND pkg-config --silence-errors --cflags luajit 11 | OUTPUT_VARIABLE LUA_CFLAGS 12 | OUTPUT_STRIP_TRAILING_WHITESPACE 13 | ) 14 | @@ -82,7 +82,7 @@ IF(LUA_SUPPORT) 15 | 16 | IF(NOT LUA_LIBS AND PKG_CONFIG) 17 | EXECUTE_PROCESS( 18 | - COMMAND pkg-config --silence-errors --libs lua5.1 19 | + COMMAND pkg-config --silence-errors --libs luajit 20 | OUTPUT_VARIABLE LUA_LIBS 21 | OUTPUT_STRIP_TRAILING_WHITESPACE 22 | ) 23 | -------------------------------------------------------------------------------- /recipes-core/uhttpd/uhttpd_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Unified Configuration Interface" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/uci" 3 | LICENSE = "Apache-2.0" 4 | LIC_FILES_CHKSUM = "file://uhttpd.c;beginline=1;endline=18;md5=758f7437f8a009878b38d879168c334e" 5 | 6 | SRC_URI = "git://nbd.name/uhttpd.git;protocol=git;branch=master" 7 | SRC_URI += "file://luajit.patch" 8 | 9 | SRCREV = "99f729378f69b2985c559bc8639b2edd06d75233" 10 | S = "${WORKDIR}/git" 11 | 12 | inherit cmake 13 | 14 | PR="r1" 15 | 16 | DEPENDS = "ubus luajit" 17 | 18 | #FIXME: put plugins to the correct place 19 | FILES_${PN} += "/usr/lib/*.so" 20 | 21 | 22 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/files/fix-bsd.patch: -------------------------------------------------------------------------------- 1 | Index: git/main.c 2 | =================================================================== 3 | --- git.orig/main.c 4 | +++ git/main.c 5 | @@ -17,7 +17,7 @@ 6 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 7 | */ 8 | 9 | -#define _BSD_SOURCE 10 | +#define _DEFAULT_SOURCE 11 | #define _GNU_SOURCE 12 | #define _XOPEN_SOURCE 700 13 | #include 14 | Index: git/file.c 15 | =================================================================== 16 | --- git.orig/file.c 17 | +++ git/file.c 18 | @@ -17,7 +17,7 @@ 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 | */ 21 | 22 | -#define _BSD_SOURCE 23 | +#define _DEFAULT_SOURCE 24 | #define _DARWIN_C_SOURCE 25 | #define _XOPEN_SOURCE 700 26 | 27 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/files/luajit.patch: -------------------------------------------------------------------------------- 1 | Index: git/CMakeLists.txt 2 | =================================================================== 3 | --- git.orig/CMakeLists.txt 4 | +++ git/CMakeLists.txt 5 | @@ -41,7 +41,7 @@ IF(LUA_SUPPORT) 6 | 7 | IF(NOT LUA_CFLAGS AND PKG_CONFIG) 8 | EXECUTE_PROCESS( 9 | - COMMAND pkg-config --silence-errors --cflags lua5.1 10 | + COMMAND pkg-config --silence-errors --cflags luajit 11 | OUTPUT_VARIABLE LUA_CFLAGS 12 | OUTPUT_STRIP_TRAILING_WHITESPACE 13 | ) 14 | @@ -49,14 +49,14 @@ IF(LUA_SUPPORT) 15 | 16 | IF(NOT LUA_LIBS AND PKG_CONFIG) 17 | EXECUTE_PROCESS( 18 | - COMMAND pkg-config --silence-errors --libs lua5.1 19 | + COMMAND pkg-config --silence-errors --libs luajit 20 | OUTPUT_VARIABLE LUA_LIBS 21 | OUTPUT_STRIP_TRAILING_WHITESPACE 22 | ) 23 | ENDIF() 24 | 25 | IF(NOT LUA_LIBS) 26 | - SET(LUA_LIBS "lua") 27 | + SET(LUA_LIBS "luajit") 28 | ENDIF() 29 | 30 | SET(PLUGINS ${PLUGINS} uhttpd_lua) 31 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/files/ubus.default: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then 4 | uci set uhttpd.main.ubus_prefix=/ubus 5 | uci commit uhttpd 6 | fi 7 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/files/uhttpd.config: -------------------------------------------------------------------------------- 1 | # Server configuration 2 | config uhttpd main 3 | 4 | # HTTP listen addresses, multiple allowed 5 | list listen_http 0.0.0.0:80 6 | list listen_http [::]:80 7 | 8 | # HTTPS listen addresses, multiple allowed 9 | list listen_https 0.0.0.0:443 10 | list listen_https [::]:443 11 | 12 | # Server document root 13 | option home /www 14 | 15 | # Reject requests from RFC1918 IP addresses 16 | # directed to the servers public IP(s). 17 | # This is a DNS rebinding countermeasure. 18 | option rfc1918_filter 1 19 | 20 | # Maximum number of concurrent requests. 21 | # If this number is exceeded, further requests are 22 | # queued until the number of running requests drops 23 | # below the limit again. 24 | option max_requests 3 25 | 26 | # Maximum number of concurrent connections. 27 | # If this number is exceeded, further TCP connection 28 | # attempts are queued until the number of active 29 | # connections drops below the limit again. 30 | option max_connections 100 31 | 32 | # Certificate and private key for HTTPS. 33 | # If no listen_https addresses are given, 34 | # the key options are ignored. 35 | option cert /etc/uhttpd.crt 36 | option key /etc/uhttpd.key 37 | 38 | # CGI url prefix, will be searched in docroot. 39 | # Default is /cgi-bin 40 | option cgi_prefix /cgi-bin 41 | 42 | # List of extension->interpreter mappings. 43 | # Files with an associated interpreter can 44 | # be called outside of the CGI prefix and do 45 | # not need to be executable. 46 | # list interpreter ".php=/usr/bin/php-cgi" 47 | # list interpreter ".cgi=/usr/bin/perl" 48 | 49 | # Lua url prefix and handler script. 50 | # Lua support is disabled if no prefix given. 51 | option lua_prefix /luci 52 | option lua_handler /usr/local/share/lua/5.1/luci/sgi/uhttpd.lua 53 | 54 | # Specify the ubus-rpc prefix and socket path. 55 | # option ubus_prefix /ubus 56 | # option ubus_socket /var/run/ubus.sock 57 | 58 | # CGI/Lua timeout, if the called script does not 59 | # write data within the given amount of seconds, 60 | # the server will terminate the request with 61 | # 504 Gateway Timeout response. 62 | option script_timeout 60 63 | 64 | # Network timeout, if the current connection is 65 | # blocked for the specified amount of seconds, 66 | # the server will terminate the associated 67 | # request process. 68 | option network_timeout 30 69 | 70 | # HTTP Keep-Alive, specifies the timeout for persistent 71 | # HTTP/1.1 connections. Setting this to 0 will disable 72 | # persistent HTTP connections. 73 | option http_keepalive 20 74 | 75 | # TCP Keep-Alive, send periodic keep-alive probes 76 | # over established connections to detect dead peers. 77 | # The value is given in seconds to specify the 78 | # interval between subsequent probes. 79 | # Setting this to 0 will disable TCP keep-alive. 80 | option tcp_keepalive 1 81 | 82 | # Basic auth realm, defaults to local hostname 83 | # option realm OpenWrt 84 | 85 | # Configuration file in busybox httpd format 86 | # option config /etc/httpd.conf 87 | 88 | # Do not follow symlinks that point outside of the 89 | # home directory. 90 | # option no_symlinks 0 91 | 92 | # Do not produce directory listings but send 403 93 | # instead if a client requests an url pointing to 94 | # a directory without any index file. 95 | # option no_dirlists 0 96 | 97 | # Do not authenticate any ubus-rpc requests against 98 | # the ubus session/access procedure. 99 | # This is dangerous and should be always left off 100 | # except for development and debug purposes! 101 | # option no_ubusauth 0 102 | 103 | 104 | # Certificate defaults for px5g key generator 105 | config cert px5g 106 | 107 | # Validity time 108 | option days 730 109 | 110 | # RSA key size 111 | option bits 1024 112 | 113 | # Location 114 | option country DE 115 | option state Berlin 116 | option location Berlin 117 | 118 | # Common name 119 | option commonname OpenWrt 120 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/files/uhttpd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2010 Jo-Philipp Wich 3 | 4 | START=50 5 | 6 | USE_PROCD=1 7 | 8 | UHTTPD_BIN="/usr/sbin/uhttpd" 9 | PX5G_BIN="/usr/sbin/px5g" 10 | 11 | append_arg() { 12 | local cfg="$1" 13 | local var="$2" 14 | local opt="$3" 15 | local def="$4" 16 | local val 17 | 18 | config_get val "$cfg" "$var" 19 | [ -n "$val" -o -n "$def" ] && procd_append_param command "$opt" "${val:-$def}" 20 | } 21 | 22 | append_bool() { 23 | local cfg="$1" 24 | local var="$2" 25 | local opt="$3" 26 | local def="$4" 27 | local val 28 | 29 | config_get_bool val "$cfg" "$var" "$def" 30 | [ "$val" = 1 ] && procd_append_param command "$opt" 31 | } 32 | 33 | generate_keys() { 34 | local cfg="$1" 35 | local key="$2" 36 | local crt="$3" 37 | local days bits country state location commonname 38 | 39 | config_get days "$cfg" days 40 | config_get bits "$cfg" bits 41 | config_get country "$cfg" country 42 | config_get state "$cfg" state 43 | config_get location "$cfg" location 44 | config_get commonname "$cfg" commonname 45 | 46 | [ -x "$PX5G_BIN" ] && { 47 | $PX5G_BIN selfsigned -der \ 48 | -days ${days:-730} -newkey rsa:${bits:-1024} -keyout "$UHTTPD_KEY" -out "$UHTTPD_CERT" \ 49 | -subj /C="${country:-DE}"/ST="${state:-Saxony}"/L="${location:-Leipzig}"/CN="${commonname:-OpenWrt}" 50 | } 51 | } 52 | 53 | start_instance() 54 | { 55 | UHTTPD_CERT="" 56 | UHTTPD_KEY="" 57 | 58 | local cfg="$1" 59 | local realm="$(uci_get system.@system[0].hostname)" 60 | local listen http https interpreter indexes path handler 61 | 62 | procd_open_instance 63 | procd_set_param respawn 64 | procd_set_param command "$UHTTPD_BIN" -f 65 | 66 | append_arg "$cfg" home "-h" 67 | append_arg "$cfg" realm "-r" "${realm:-OpenWrt}" 68 | append_arg "$cfg" config "-c" 69 | append_arg "$cfg" cgi_prefix "-x" 70 | [ -f /usr/lib/uhttpd_lua.so ] && { 71 | config_get handler "$cfg" lua_handler 72 | [ -f "$handler" ] && append_arg "$cfg" lua_prefix "-l" && { 73 | procd_append_param command "-L" "$handler" 74 | } 75 | } 76 | [ -f /usr/lib/uhttpd_ubus.so ] && { 77 | append_arg "$cfg" ubus_prefix "-u" 78 | append_arg "$cfg" ubus_socket "-U" 79 | } 80 | append_arg "$cfg" script_timeout "-t" 81 | append_arg "$cfg" network_timeout "-T" 82 | append_arg "$cfg" http_keepalive "-k" 83 | append_arg "$cfg" tcp_keepalive "-A" 84 | append_arg "$cfg" error_page "-E" 85 | append_arg "$cfg" max_requests "-n" 3 86 | append_arg "$cfg" max_connections "-N" 87 | 88 | append_bool "$cfg" no_ubusauth "-a" 0 89 | append_bool "$cfg" no_symlinks "-S" 0 90 | append_bool "$cfg" no_dirlists "-D" 0 91 | append_bool "$cfg" rfc1918_filter "-R" 0 92 | 93 | config_get http "$cfg" listen_http 94 | for listen in $http; do 95 | procd_append_param command -p "$listen" 96 | done 97 | 98 | config_get interpreter "$cfg" interpreter 99 | for path in $interpreter; do 100 | procd_append_param command -i "$path" 101 | done 102 | 103 | config_get indexes "$cfg" index_page 104 | for path in $indexes; do 105 | procd_append_param command -I "$path" 106 | done 107 | 108 | config_get https "$cfg" listen_https 109 | config_get UHTTPD_KEY "$cfg" key /etc/uhttpd.key 110 | config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt 111 | 112 | [ -f /lib/libustream-ssl.so ] && [ -n "$https" ] && { 113 | [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] || { 114 | config_foreach generate_keys cert 115 | } 116 | 117 | [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] && { 118 | append_arg "$cfg" cert "-C" 119 | append_arg "$cfg" key "-K" 120 | 121 | for listen in $https; do 122 | procd_append_param command -s "$listen" 123 | done 124 | } 125 | } 126 | 127 | procd_close_instance 128 | 129 | # Check if daemon is running, if not then 130 | # re-execute in foreground to display error. 131 | # sleep 1 && service_check $UHTTPD_BIN || \ 132 | # $UHTTPD_BIN -f $UHTTPD_ARGS 133 | } 134 | 135 | service_triggers() 136 | { 137 | procd_add_reload_trigger "uhttpd" 138 | } 139 | 140 | start_service() { 141 | config_load uhttpd 142 | config_foreach start_instance uhttpd 143 | } 144 | -------------------------------------------------------------------------------- /recipes-core/uhttpd2/uhttpd2_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "uHTTPd - tiny, single threaded HTTP server" 2 | HOMEPAGE = "http://wiki.openwrt.org/doc/howto/http.uhttpd" 3 | LICENSE = "ISC" 4 | LIC_FILES_CHKSUM = "file://main.c;beginline=1;endline=18;md5=ba30601dd30339f7ff3d0ad681d45679" 5 | 6 | SRC_URI = "git://nbd.name/uhttpd2.git;protocol=git;branch=master" 7 | SRC_URI += "file://ubus.default" 8 | SRC_URI += "file://uhttpd.config" 9 | SRC_URI += "file://uhttpd.init" 10 | SRC_URI += "file://luajit.patch" 11 | SRC_URI += "file://fix-bsd.patch" 12 | 13 | SRCREV = "b9178b9357798ae23a5724333cc6572d14f23958" 14 | S = "${WORKDIR}/git" 15 | 16 | inherit cmake 17 | 18 | PR="r1" 19 | 20 | DEPENDS = "ubus luajit libubox ustream-ssl" 21 | 22 | #FIXME: put plugins to the correct place 23 | FILES_${PN} += "/usr/lib/*.so" 24 | 25 | do_install_append () { 26 | mkdir -p ${D}/${sysconfdir}/config ${D}/${sysconfdir}/init.d ${D}/usr/lib ${D}/etc/uci-defaults 27 | install ${WORKDIR}/uhttpd.config ${D}/${sysconfdir}/config/uhttpd 28 | install ${WORKDIR}/uhttpd.init ${D}/${sysconfdir}/init.d/uhttpd 29 | install ${WORKDIR}/ubus.default ${D}/etc/uci-defaults/00_uhttpd_ubus 30 | mv ${D}/usr/bin ${D}/usr/sbin 31 | install ${B}/uhttpd_lua.so ${D}/usr/lib/ 32 | install ${B}/uhttpd_ubus.so ${D}/usr/lib/ 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /recipes-core/update-rc.d/files/single_runlevel.patch: -------------------------------------------------------------------------------- 1 | Index: git/update-rc.d 2 | =================================================================== 3 | --- git.orig/update-rc.d 4 | +++ git/update-rc.d 5 | @@ -44,7 +44,7 @@ checklinks() 6 | fi 7 | 8 | for i in 0 1 2 3 4 5 6 7 8 9 S; do 9 | - dn="${etcd}${i}.d" 10 | + dn="${etcd}.d" 11 | if [ ! -d $dn ]; then 12 | continue; 13 | fi 14 | @@ -70,7 +70,7 @@ dolink() 15 | startstop=$1 16 | lev=`echo $2 | cut -d/ -f1` 17 | nn=`echo $2 | cut -d/ -f2` 18 | - fn="${etcd}${lev}.d/${startstop}${nn}${bn}" 19 | + fn="${etcd}.d/${startstop}${nn}${bn}" 20 | [ $verbose -eq 1 ] && echo " $fn -> ../init.d/$bn" 21 | if [ $notreally -eq 0 ]; then 22 | mkdir -p `dirname $fn` 23 | -------------------------------------------------------------------------------- /recipes-core/update-rc.d/update-rc.d_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 2 | 3 | SRC_URI += "file://single_runlevel.patch" 4 | -------------------------------------------------------------------------------- /recipes-core/ustream-ssl/ustream-ssl_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "ustream SSL Library" 2 | HOMEPAGE = "http://wiki.openwrt.org" 3 | LICENSE = "ISC" 4 | LIC_FILES_CHKSUM = "file://ustream-ssl.c;beginline=1;endline=17;md5=f633104677420342f142ab4835e04031" 5 | 6 | SRC_URI = "git://nbd.name/ustream-ssl.git;protocol=git;branch=master" 7 | 8 | SRCREV = "a4ca61527236e89eb9efb782fd9bfd04796144e3" 9 | S = "${WORKDIR}/git" 10 | 11 | inherit cmake 12 | 13 | PR="r1" 14 | 15 | DEPENDS = "libubox openssl" 16 | FILES_${PN} = "/lib" 17 | FILES_${PN}-dev = "/usr" 18 | 19 | do_install_append () { 20 | cp -a ${D}/usr/lib ${D}/lib 21 | } 22 | --------------------------------------------------------------------------------