Add new Skeleton.
This commit is contained in:
1078
bsp/board/raspberrypi/configs/busybox.config
Normal file
1078
bsp/board/raspberrypi/configs/busybox.config
Normal file
File diff suppressed because it is too large
Load Diff
12
bsp/board/raspberrypi/main.mk
Normal file
12
bsp/board/raspberrypi/main.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Main rules for Mozart3 targets.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
.PHONY: all
|
||||
all: msg buildroot
|
||||
|
||||
|
||||
include ../../bsp/include/rules.mk
|
||||
include ../../bsp/include/buildroot.mk
|
||||
0
bsp/board/raspberrypi/ovl/boot/.gitkeep
Normal file
0
bsp/board/raspberrypi/ovl/boot/.gitkeep
Normal file
10
bsp/board/raspberrypi/ovl/etc/fstab
Normal file
10
bsp/board/raspberrypi/ovl/etc/fstab
Normal file
@@ -0,0 +1,10 @@
|
||||
# <file system> <mount pt> <type> <options> <dump> <pass>
|
||||
/dev/root / ext2 rw,noauto 0 1
|
||||
proc /proc proc defaults 0 0
|
||||
devpts /dev/pts devpts defaults,gid=5,mode=620 0 0
|
||||
tmpfs /dev/shm tmpfs mode=0777 0 0
|
||||
tmpfs /tmp tmpfs mode=1777 0 0
|
||||
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
||||
sysfs /sys sysfs defaults 0 0
|
||||
/dev/mmcblk0p1 /boot vfat defaults 0 0
|
||||
/dev/mmcblk0p2 /mnt/user vfat defaults 0 2
|
||||
3
bsp/board/raspberrypi/ovl/etc/fw_env.config
Normal file
3
bsp/board/raspberrypi/ovl/etc/fw_env.config
Normal file
@@ -0,0 +1,3 @@
|
||||
# MTD device name Device offset Env. size Flash sector size Number of sectors
|
||||
/dev/mmcblk0 0x88000 0x20000 0x20000
|
||||
#/boot/uboot.env 0x0000 0x4000 0x4000
|
||||
18
bsp/board/raspberrypi/ovl/etc/hotplug-preinit.json
Normal file
18
bsp/board/raspberrypi/ovl/etc/hotplug-preinit.json
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
[ "case", "ACTION", {
|
||||
"add": [
|
||||
[ "if",
|
||||
[ "has", "FIRMWARE" ],
|
||||
[
|
||||
[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
|
||||
[ "load-firmware", "/lib/firmware" ],
|
||||
[ "return" ]
|
||||
]
|
||||
],
|
||||
],
|
||||
}, ],
|
||||
[ "if",
|
||||
[ "eq", "SUBSYSTEM", "button" ],
|
||||
[ "exec", "/etc/rc.button/failsafe" ]
|
||||
],
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
[ ifup = "$ACTION" ] && {
|
||||
uci_toggle_state network "$INTERFACE" up 1
|
||||
[ -n "$DEVICE" ] && {
|
||||
uci_toggle_state network "$INTERFACE" device "$(uci -q get network.$INTERFACE.ifname)"
|
||||
uci_toggle_state network "$INTERFACE" ifname "$DEVICE"
|
||||
}
|
||||
}
|
||||
9
bsp/board/raspberrypi/ovl/etc/hotplug.d/net/00-sysctl
Normal file
9
bsp/board/raspberrypi/ovl/etc/hotplug.d/net/00-sysctl
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$ACTION" = add ]; then
|
||||
for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
|
||||
[ ! -f "$CONF" ] && continue;
|
||||
sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" "$CONF" | \
|
||||
sysctl -e -p - | logger -t sysctl
|
||||
done
|
||||
fi
|
||||
80
bsp/board/raspberrypi/ovl/etc/hotplug.json
Normal file
80
bsp/board/raspberrypi/ovl/etc/hotplug.json
Normal file
@@ -0,0 +1,80 @@
|
||||
[
|
||||
[ "case", "ACTION", {
|
||||
"add": [
|
||||
[ "if",
|
||||
[ "and",
|
||||
[ "has", "MAJOR" ],
|
||||
[ "has", "MINOR" ],
|
||||
],
|
||||
[
|
||||
[ "if",
|
||||
[ "or",
|
||||
[ "eq", "DEVNAME",
|
||||
[ "null", "full", "ptmx", "zero" ],
|
||||
],
|
||||
[ "regex", "DEVNAME",
|
||||
[ "^gpio", "^hvc" ],
|
||||
],
|
||||
],
|
||||
[
|
||||
[ "makedev", "/dev/%DEVNAME%", "0666" ],
|
||||
[ "return" ],
|
||||
]
|
||||
],
|
||||
[ "if",
|
||||
[ "or",
|
||||
[ "eq", "DEVNAME", "mapper/control" ],
|
||||
[ "regex", "DEVPATH", "^ppp" ],
|
||||
],
|
||||
[
|
||||
[ "makedev", "/dev/%DEVNAME%", "0600" ],
|
||||
[ "return" ],
|
||||
],
|
||||
],
|
||||
[ "if",
|
||||
[ "has", "DEVNAME" ],
|
||||
[ "makedev", "/dev/%DEVNAME%", "0644" ],
|
||||
],
|
||||
],
|
||||
],
|
||||
[ "if",
|
||||
[ "has", "FIRMWARE" ],
|
||||
[
|
||||
[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
|
||||
[ "load-firmware", "/lib/firmware" ],
|
||||
[ "return" ]
|
||||
]
|
||||
],
|
||||
],
|
||||
"remove" : [
|
||||
[ "if",
|
||||
[ "and",
|
||||
[ "has", "DEVNAME" ],
|
||||
[ "has", "MAJOR" ],
|
||||
[ "has", "MINOR" ],
|
||||
],
|
||||
[ "rm", "/dev/%DEVNAME%" ]
|
||||
]
|
||||
]
|
||||
} ],
|
||||
[ "if",
|
||||
[ "and",
|
||||
[ "has", "BUTTON" ],
|
||||
[ "eq", "SUBSYSTEM", "button" ],
|
||||
],
|
||||
[ "button", "/etc/rc.button/%BUTTON%" ]
|
||||
],
|
||||
[ "if",
|
||||
[ "and",
|
||||
[ "eq", "SUBSYSTEM", "usb-serial" ],
|
||||
[ "regex", "DEVNAME",
|
||||
[ "^ttyUSB", "^ttyACM" ]
|
||||
]
|
||||
],
|
||||
[ "exec", "/sbin/hotplug-call", "tty" ],
|
||||
[ "if",
|
||||
[ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
|
||||
[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
|
||||
]
|
||||
],
|
||||
]
|
||||
27
bsp/board/raspberrypi/ovl/etc/init.d/boot
Executable file
27
bsp/board/raspberrypi/ovl/etc/init.d/boot
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
|
||||
START=10
|
||||
STOP=98
|
||||
|
||||
boot() {
|
||||
mount -a
|
||||
ConfigState=`fw_printenv is_configured | cut -d'=' -f2`
|
||||
if [ "$ConfigState" = "0" ]; then
|
||||
echo "Reset the Device Name to Factory."
|
||||
mkdir -p /mnt/user/UserSettings/
|
||||
rm /mnt/user/UserSettings/*
|
||||
/usr/local/bin/Device_Name mediaCTRLRenderer.ini mediaCTRLServer.ini SlavePlayer.ini
|
||||
fw_setenv is_configured 1
|
||||
fi
|
||||
# Set our device Hostname using the friendlyName
|
||||
friendlyname=`cat /usr/local/configs/mediaCTRLRenderer.ini | grep friendlyname | cut -f2 -d'='`
|
||||
mac=`fw_printenv ethaddr | cut -f4-6 -d':' | sed s/://g`
|
||||
hostname $friendlyname-$mac
|
||||
echo Device hostname is `hostname`
|
||||
|
||||
# Temporary Hack
|
||||
ifconfig lo up
|
||||
ifconfig eth0 up
|
||||
udhcpc -i eth0
|
||||
}
|
||||
7
bsp/board/raspberrypi/ovl/etc/init.d/umount
Executable file
7
bsp/board/raspberrypi/ovl/etc/init.d/umount
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
STOP=99
|
||||
stop() {
|
||||
sync
|
||||
/bin/umount -a -d -r
|
||||
}
|
||||
3
bsp/board/raspberrypi/ovl/etc/inittab
Normal file
3
bsp/board/raspberrypi/ovl/etc/inittab
Normal file
@@ -0,0 +1,3 @@
|
||||
::sysinit:/etc/init.d/rcS S boot
|
||||
::shutdown:/etc/init.d/rcS K shutdown
|
||||
::respawn:/sbin/getty -L 115200 console vt100
|
||||
3
bsp/board/raspberrypi/ovl/etc/preinit
Normal file
3
bsp/board/raspberrypi/ovl/etc/preinit
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -z "$PREINIT" ] && exec /sbin/init
|
||||
5
bsp/board/raspberrypi/ovl/etc/profile.d/custom.sh
Executable file
5
bsp/board/raspberrypi/ovl/etc/profile.d/custom.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
# Acces aux scripts personnels et code metier.
|
||||
PATH=$PATH:/usr/local/bin
|
||||
|
||||
# Prompt indiquant nom d'hote et repertoire courant.
|
||||
PS1='\h[\W]\$ '
|
||||
143
bsp/board/raspberrypi/ovl/etc/rc.common
Executable file
143
bsp/board/raspberrypi/ovl/etc/rc.common
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2012 OpenWrt.org
|
||||
|
||||
. $IPKG_INSTROOT/lib/functions.sh
|
||||
. $IPKG_INSTROOT/lib/functions/service.sh
|
||||
|
||||
initscript=$1
|
||||
action=${2:-help}
|
||||
shift 2
|
||||
|
||||
start() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
return 0
|
||||
}
|
||||
|
||||
reload() {
|
||||
return 1
|
||||
}
|
||||
|
||||
restart() {
|
||||
trap '' TERM
|
||||
stop "$@"
|
||||
start "$@"
|
||||
}
|
||||
|
||||
boot() {
|
||||
start "$@"
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
stop
|
||||
}
|
||||
|
||||
disable() {
|
||||
name="$(basename "${initscript}")"
|
||||
rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
|
||||
rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
|
||||
}
|
||||
|
||||
enable() {
|
||||
name="$(basename "${initscript}")"
|
||||
disable
|
||||
[ -n "$START" -o -n "$STOP" ] || {
|
||||
echo "/etc/init.d/$name does not have a START or STOP value"
|
||||
return 1
|
||||
}
|
||||
[ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
|
||||
[ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
|
||||
}
|
||||
|
||||
enabled() {
|
||||
name="$(basename "${initscript}")"
|
||||
[ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
Syntax: $initscript [command]
|
||||
|
||||
Available commands:
|
||||
start Start the service
|
||||
stop Stop the service
|
||||
restart Restart the service
|
||||
reload Reload configuration files (or restart if that fails)
|
||||
enable Enable service autostart
|
||||
disable Disable service autostart
|
||||
$EXTRA_HELP
|
||||
EOF
|
||||
}
|
||||
|
||||
# for procd
|
||||
start_service() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
return 0
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
return 0
|
||||
}
|
||||
|
||||
service_running() {
|
||||
return 0
|
||||
}
|
||||
|
||||
${INIT_TRACE:+set -x}
|
||||
|
||||
. "$initscript"
|
||||
|
||||
[ -n "$USE_PROCD" ] && {
|
||||
EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace"
|
||||
|
||||
. $IPKG_INSTROOT/lib/functions/procd.sh
|
||||
basescript=$(readlink "$initscript")
|
||||
rc_procd() {
|
||||
procd_open_service "$(basename ${basescript:-$initscript})" "$initscript"
|
||||
"$@"
|
||||
procd_close_service
|
||||
}
|
||||
|
||||
start() {
|
||||
rc_procd start_service "$@"
|
||||
if eval "type service_started" 2>/dev/null >/dev/null; then
|
||||
service_started
|
||||
fi
|
||||
}
|
||||
|
||||
trace() {
|
||||
TRACE_SYSCALLS=1
|
||||
start "$@"
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop_service "$@"
|
||||
procd_kill "$(basename ${basescript:-$initscript})" "$1"
|
||||
}
|
||||
|
||||
reload() {
|
||||
if eval "type reload_service" 2>/dev/null >/dev/null; then
|
||||
reload_service "$@"
|
||||
else
|
||||
start
|
||||
fi
|
||||
}
|
||||
|
||||
running() {
|
||||
service_running "$@"
|
||||
}
|
||||
}
|
||||
|
||||
ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
|
||||
list_contains ALL_COMMANDS "$action" || action=help
|
||||
[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
|
||||
$action "$@"
|
||||
1
bsp/board/raspberrypi/ovl/etc/rc.d/K99umount
Symbolic link
1
bsp/board/raspberrypi/ovl/etc/rc.d/K99umount
Symbolic link
@@ -0,0 +1 @@
|
||||
../init.d/umount
|
||||
1
bsp/board/raspberrypi/ovl/etc/rc.d/S10boot
Symbolic link
1
bsp/board/raspberrypi/ovl/etc/rc.d/S10boot
Symbolic link
@@ -0,0 +1 @@
|
||||
../init.d/boot
|
||||
353
bsp/board/raspberrypi/ovl/lib/functions.sh
Executable file
353
bsp/board/raspberrypi/ovl/lib/functions.sh
Executable file
@@ -0,0 +1,353 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2014 OpenWrt.org
|
||||
# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
|
||||
debug () {
|
||||
${DEBUG:-:} "$@"
|
||||
}
|
||||
|
||||
# newline
|
||||
N="
|
||||
"
|
||||
|
||||
_C=0
|
||||
NO_EXPORT=1
|
||||
LOAD_STATE=1
|
||||
LIST_SEP=" "
|
||||
|
||||
append() {
|
||||
local var="$1"
|
||||
local value="$2"
|
||||
local sep="${3:- }"
|
||||
|
||||
eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
|
||||
}
|
||||
|
||||
list_contains() {
|
||||
local var="$1"
|
||||
local str="$2"
|
||||
local val
|
||||
|
||||
eval "val=\" \${$var} \""
|
||||
[ "${val%% $str *}" != "$val" ]
|
||||
}
|
||||
|
||||
config_load() {
|
||||
[ -n "$IPKG_INSTROOT" ] && return 0
|
||||
uci_load "$@"
|
||||
}
|
||||
|
||||
reset_cb() {
|
||||
config_cb() { return 0; }
|
||||
option_cb() { return 0; }
|
||||
list_cb() { return 0; }
|
||||
}
|
||||
reset_cb
|
||||
|
||||
package() {
|
||||
return 0
|
||||
}
|
||||
|
||||
config () {
|
||||
local cfgtype="$1"
|
||||
local name="$2"
|
||||
|
||||
export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
|
||||
name="${name:-cfg$CONFIG_NUM_SECTIONS}"
|
||||
append CONFIG_SECTIONS "$name"
|
||||
[ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name"
|
||||
export ${NO_EXPORT:+-n} CONFIG_SECTION="$name"
|
||||
export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
|
||||
}
|
||||
|
||||
option () {
|
||||
local varname="$1"; shift
|
||||
local value="$*"
|
||||
|
||||
export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
|
||||
[ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*"
|
||||
}
|
||||
|
||||
list() {
|
||||
local varname="$1"; shift
|
||||
local value="$*"
|
||||
local len
|
||||
|
||||
config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
|
||||
[ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
|
||||
len=$(($len + 1))
|
||||
config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
|
||||
config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
|
||||
append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP"
|
||||
list_cb "$varname" "$*"
|
||||
}
|
||||
|
||||
config_unset() {
|
||||
config_set "$1" "$2" ""
|
||||
}
|
||||
|
||||
# config_get <variable> <section> <option> [<default>]
|
||||
# config_get <section> <option>
|
||||
config_get() {
|
||||
case "$3" in
|
||||
"") eval echo "\${CONFIG_${1}_${2}:-\${4}}";;
|
||||
*) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
|
||||
esac
|
||||
}
|
||||
|
||||
# config_get_bool <variable> <section> <option> [<default>]
|
||||
config_get_bool() {
|
||||
local _tmp
|
||||
config_get _tmp "$2" "$3" "$4"
|
||||
case "$_tmp" in
|
||||
1|on|true|yes|enabled) _tmp=1;;
|
||||
0|off|false|no|disabled) _tmp=0;;
|
||||
*) _tmp="$4";;
|
||||
esac
|
||||
export ${NO_EXPORT:+-n} "$1=$_tmp"
|
||||
}
|
||||
|
||||
config_set() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local value="$3"
|
||||
local old_section="$CONFIG_SECTION"
|
||||
|
||||
CONFIG_SECTION="$section"
|
||||
option "$option" "$value"
|
||||
CONFIG_SECTION="$old_section"
|
||||
}
|
||||
|
||||
config_foreach() {
|
||||
local ___function="$1"
|
||||
[ "$#" -ge 1 ] && shift
|
||||
local ___type="$1"
|
||||
[ "$#" -ge 1 ] && shift
|
||||
local section cfgtype
|
||||
|
||||
[ -z "$CONFIG_SECTIONS" ] && return 0
|
||||
for section in ${CONFIG_SECTIONS}; do
|
||||
config_get cfgtype "$section" TYPE
|
||||
[ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue
|
||||
eval "$___function \"\$section\" \"\$@\""
|
||||
done
|
||||
}
|
||||
|
||||
config_list_foreach() {
|
||||
[ "$#" -ge 3 ] || return 0
|
||||
local section="$1"; shift
|
||||
local option="$1"; shift
|
||||
local function="$1"; shift
|
||||
local val
|
||||
local len
|
||||
local c=1
|
||||
|
||||
config_get len "${section}" "${option}_LENGTH"
|
||||
[ -z "$len" ] && return 0
|
||||
while [ $c -le "$len" ]; do
|
||||
config_get val "${section}" "${option}_ITEM$c"
|
||||
eval "$function \"\$val\" \"\$@\""
|
||||
c="$(($c + 1))"
|
||||
done
|
||||
}
|
||||
|
||||
insert_modules() {
|
||||
for m in $*; do
|
||||
if [ -f /etc/modules.d/$m ]; then
|
||||
sed 's/^[^#]/insmod &/' /etc/modules.d/$m | ash 2>&- || :
|
||||
else
|
||||
modprobe $m
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
default_prerm() {
|
||||
local name
|
||||
name=$(basename ${1%.*})
|
||||
[ -f /usr/lib/opkg/info/${name}.prerm-pkg ] && . /usr/lib/opkg/info/${name}.prerm-pkg
|
||||
for i in `cat /usr/lib/opkg/info/${name}.list | grep "^/etc/init.d/"`; do
|
||||
$i disable
|
||||
$i stop
|
||||
done
|
||||
}
|
||||
|
||||
add_group_and_user() {
|
||||
local pkgname="$1"
|
||||
local rusers="$(sed -ne 's/^Require-User: *//p' $root/usr/lib/opkg/info/${pkgname}.control 2>/dev/null)"
|
||||
|
||||
if [ -n "$rusers" ]; then
|
||||
local tuple oIFS="$IFS"
|
||||
for tuple in $rusers; do
|
||||
local uid gid uname gname
|
||||
|
||||
IFS=":"
|
||||
set -- $tuple; uname="$1"; gname="$2"
|
||||
IFS="="
|
||||
set -- $uname; uname="$1"; uid="$2"
|
||||
set -- $gname; gname="$1"; gid="$2"
|
||||
IFS="$oIFS"
|
||||
|
||||
if [ -n "$gname" ] && [ -n "$gid" ]; then
|
||||
group_exists "$gname" || group_add "$gname" "$gid"
|
||||
elif [ -n "$gname" ]; then
|
||||
group_add_next "$gname"; gid=$?
|
||||
fi
|
||||
|
||||
if [ -n "$uname" ]; then
|
||||
user_exists "$uname" || user_add "$uname" "$uid" "$gid"
|
||||
fi
|
||||
|
||||
if [ -n "$uname" ] && [ -n "$gname" ]; then
|
||||
group_add_user "$gname" "$uname"
|
||||
fi
|
||||
|
||||
unset uid gid uname gname
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
default_postinst() {
|
||||
local root="${IPKG_INSTROOT}"
|
||||
local pkgname="$(basename ${1%.*})"
|
||||
local ret=0
|
||||
|
||||
add_group_and_user "${pkgname}"
|
||||
|
||||
if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
|
||||
( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
|
||||
ret=$?
|
||||
fi
|
||||
|
||||
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "$root/usr/lib/opkg/info/${pkgname}.list"; then
|
||||
. /lib/functions/system.sh
|
||||
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
|
||||
cd /etc/uci-defaults
|
||||
for i in $(grep -s "^/etc/uci-defaults/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
|
||||
( . "./$(basename $i)" ) && rm -f "$i"
|
||||
done
|
||||
uci commit
|
||||
cd $OLDPWD
|
||||
fi
|
||||
|
||||
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then
|
||||
. /lib/functions/system.sh
|
||||
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
|
||||
cd /etc/uci-defaults
|
||||
for i in $(grep -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"); do
|
||||
( . "./$(basename $i)" ) && rm -f "$i"
|
||||
done
|
||||
uci commit
|
||||
cd $OLDPWD
|
||||
fi
|
||||
|
||||
[ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
|
||||
|
||||
if [ "$PKG_UPGRADE" != "1" ]; then
|
||||
local shell="$(which bash)"
|
||||
for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
|
||||
if [ -n "$root" ]; then
|
||||
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable
|
||||
else
|
||||
"$i" enable
|
||||
"$i" start
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
include() {
|
||||
local file
|
||||
|
||||
for file in $(ls $1/*.sh 2>/dev/null); do
|
||||
. $file
|
||||
done
|
||||
}
|
||||
|
||||
find_mtd_index() {
|
||||
local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
|
||||
local INDEX="${PART##mtd}"
|
||||
|
||||
echo ${INDEX}
|
||||
}
|
||||
|
||||
find_mtd_part() {
|
||||
local INDEX=$(find_mtd_index "$1")
|
||||
local PREFIX=/dev/mtdblock
|
||||
|
||||
[ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
|
||||
echo "${INDEX:+$PREFIX$INDEX}"
|
||||
}
|
||||
|
||||
group_add() {
|
||||
local name="$1"
|
||||
local gid="$2"
|
||||
local rc
|
||||
[ -f "${IPKG_INSTROOT}/etc/group" ] || return 1
|
||||
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/group
|
||||
echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group
|
||||
rc=$?
|
||||
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group
|
||||
return $rc
|
||||
}
|
||||
|
||||
group_exists() {
|
||||
grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group
|
||||
}
|
||||
|
||||
group_add_next() {
|
||||
local gid gids
|
||||
gid=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
|
||||
[ -n "$gid" ] && return $gid
|
||||
gids=$(cat ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
|
||||
gid=100
|
||||
while [ -n "$(echo $gids | grep $gid)" ] ; do
|
||||
gid=$((gid + 1))
|
||||
done
|
||||
group_add $1 $gid
|
||||
return $gid
|
||||
}
|
||||
|
||||
group_add_user() {
|
||||
local grp delim=","
|
||||
grp=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group)
|
||||
[ -z "$(echo $grp | cut -d: -f4 | grep $2)" ] || return
|
||||
[ -n "$(echo $grp | grep ":$")" ] && delim=""
|
||||
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
|
||||
sed -i "s/$grp/$grp$delim$2/g" ${IPKG_INSTROOT}/etc/group
|
||||
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
|
||||
}
|
||||
|
||||
user_add() {
|
||||
local name="${1}"
|
||||
local uid="${2}"
|
||||
local gid="${3}"
|
||||
local desc="${4:-$1}"
|
||||
local home="${5:-/var/run/$1}"
|
||||
local shell="${6:-/bin/false}"
|
||||
local rc
|
||||
[ -z "$uid" ] && {
|
||||
uids=$(cat ${IPKG_INSTROOT}/etc/passwd | cut -d: -f3)
|
||||
uid=100
|
||||
while [ -n "$(echo $uids | grep $uid)" ] ; do
|
||||
uid=$((uid + 1))
|
||||
done
|
||||
}
|
||||
[ -z "$gid" ] && gid=$uid
|
||||
[ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1
|
||||
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
|
||||
echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd
|
||||
echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow
|
||||
rc=$?
|
||||
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
|
||||
return $rc
|
||||
}
|
||||
|
||||
user_exists() {
|
||||
grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd
|
||||
}
|
||||
|
||||
[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
|
||||
442
bsp/board/raspberrypi/ovl/lib/functions/procd.sh
Normal file
442
bsp/board/raspberrypi/ovl/lib/functions/procd.sh
Normal file
@@ -0,0 +1,442 @@
|
||||
# procd API:
|
||||
#
|
||||
# procd_open_service(name, [script]):
|
||||
# Initialize a new procd command message containing a service with one or more instances
|
||||
#
|
||||
# procd_close_service()
|
||||
# Send the command message for the service
|
||||
#
|
||||
# procd_open_instance([name]):
|
||||
# Add an instance to the service described by the previous procd_open_service call
|
||||
#
|
||||
# procd_set_param(type, [value...])
|
||||
# Available types:
|
||||
# command: command line (array).
|
||||
# respawn info: array with 3 values $fail_threshold $restart_timeout $max_fail
|
||||
# env: environment variable (passed to the process)
|
||||
# data: arbitrary name/value pairs for detecting config changes (table)
|
||||
# file: configuration files (array)
|
||||
# netdev: bound network device (detects ifindex changes)
|
||||
# limits: resource limits (passed to the process)
|
||||
# user info: array with 1 values $username
|
||||
# pidfile: file name to write pid into
|
||||
#
|
||||
# No space separation is done for arrays/tables - use one function argument per command line argument
|
||||
#
|
||||
# procd_close_instance():
|
||||
# Complete the instance being prepared
|
||||
#
|
||||
# procd_kill(service, [instance]):
|
||||
# Kill a service instance (or all instances)
|
||||
#
|
||||
|
||||
. $IPKG_INSTROOT/usr/share/libubox/jshn.sh
|
||||
|
||||
_PROCD_SERVICE=
|
||||
|
||||
_procd_call() {
|
||||
local old_cb
|
||||
|
||||
json_set_namespace procd old_cb
|
||||
"$@"
|
||||
json_set_namespace $old_cb
|
||||
}
|
||||
|
||||
_procd_wrapper() {
|
||||
while [ -n "$1" ]; do
|
||||
eval "$1() { _procd_call _$1 \"\$@\"; }"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
_procd_ubus_call() {
|
||||
local cmd="$1"
|
||||
echo "_procd_ubus_call= > ubus call service \"$cmd\" \"$(json_dump)\""
|
||||
[ -n "$PROCD_DEBUG" ] && json_dump >&2
|
||||
ubus call service "$cmd" "$(json_dump)"
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
_procd_open_service() {
|
||||
local name="$1"
|
||||
local script="$2"
|
||||
|
||||
_PROCD_SERVICE="$name"
|
||||
_PROCD_INSTANCE_SEQ=0
|
||||
|
||||
json_init
|
||||
json_add_string name "$name"
|
||||
[ -n "$script" ] && json_add_string script "$script"
|
||||
json_add_object instances
|
||||
}
|
||||
|
||||
_procd_close_service() {
|
||||
json_close_object
|
||||
service_triggers
|
||||
_procd_ubus_call set
|
||||
}
|
||||
|
||||
_procd_add_array_data() {
|
||||
while [ "$#" -gt 0 ]; do
|
||||
json_add_string "" "$1"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
_procd_add_array() {
|
||||
json_add_array "$1"
|
||||
shift
|
||||
_procd_add_array_data "$@"
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_add_table_data() {
|
||||
while [ -n "$1" ]; do
|
||||
local var="${1%%=*}"
|
||||
local val="${1#*=}"
|
||||
[ "$1" = "$val" ] && val=
|
||||
json_add_string "$var" "$val"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
_procd_add_table() {
|
||||
json_add_object "$1"
|
||||
shift
|
||||
_procd_add_table_data "$@"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
_procd_open_instance() {
|
||||
local name="$1"; shift
|
||||
|
||||
_PROCD_INSTANCE_SEQ="$(($_PROCD_INSTANCE_SEQ + 1))"
|
||||
name="${name:-instance$_PROCD_INSTANCE_SEQ}"
|
||||
json_add_object "$name"
|
||||
[ -n "$TRACE_SYSCALLS" ] && json_add_boolean trace "1"
|
||||
}
|
||||
|
||||
_procd_open_trigger() {
|
||||
json_add_array "triggers"
|
||||
}
|
||||
|
||||
_procd_open_validate() {
|
||||
json_add_array "validate"
|
||||
}
|
||||
|
||||
_procd_add_jail() {
|
||||
json_add_object "jail"
|
||||
json_add_string name "$1"
|
||||
|
||||
shift
|
||||
|
||||
for a in $@; do
|
||||
case $a in
|
||||
log) json_add_boolean "log" "1";;
|
||||
ubus) json_add_boolean "ubus" "1";;
|
||||
procfs) json_add_boolean "procfs" "1";;
|
||||
sysfs) json_add_boolean "sysfs" "1";;
|
||||
ronly) json_add_boolean "ronly" "1";;
|
||||
esac
|
||||
done
|
||||
json_add_object "mount"
|
||||
json_close_object
|
||||
json_close_object
|
||||
}
|
||||
|
||||
_procd_add_jail_mount() {
|
||||
local _json_no_warning=1
|
||||
|
||||
json_select "jail"
|
||||
[ $? = 0 ] || return
|
||||
json_select "mount"
|
||||
[ $? = 0 ] || {
|
||||
json_select ..
|
||||
return
|
||||
}
|
||||
for a in $@; do
|
||||
json_add_string "$a" "0"
|
||||
done
|
||||
json_select ..
|
||||
json_select ..
|
||||
}
|
||||
|
||||
_procd_add_jail_mount_rw() {
|
||||
local _json_no_warning=1
|
||||
|
||||
json_select "jail"
|
||||
[ $? = 0 ] || return
|
||||
json_select "mount"
|
||||
[ $? = 0 ] || {
|
||||
json_select ..
|
||||
return
|
||||
}
|
||||
for a in $@; do
|
||||
json_add_string "$a" "1"
|
||||
done
|
||||
json_select ..
|
||||
json_select ..
|
||||
}
|
||||
|
||||
_procd_set_param() {
|
||||
local type="$1"; shift
|
||||
|
||||
case "$type" in
|
||||
env|data|limits)
|
||||
_procd_add_table "$type" "$@"
|
||||
;;
|
||||
command|netdev|file|respawn|watch)
|
||||
_procd_add_array "$type" "$@"
|
||||
;;
|
||||
error)
|
||||
json_add_array "$type"
|
||||
json_add_string "" "$@"
|
||||
json_close_array
|
||||
;;
|
||||
nice)
|
||||
json_add_int "$type" "$1"
|
||||
;;
|
||||
pidfile|user|seccomp|capabilities)
|
||||
json_add_string "$type" "$1"
|
||||
;;
|
||||
stdout|stderr|no_new_privs)
|
||||
json_add_boolean "$type" "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_procd_add_interface_trigger() {
|
||||
json_add_array
|
||||
_procd_add_array_data "$1"
|
||||
shift
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "if"
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "eq" "interface" "$1"
|
||||
shift
|
||||
json_close_array
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "run_script" "$@"
|
||||
json_close_array
|
||||
|
||||
json_close_array
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_add_reload_interface_trigger() {
|
||||
local script=$(readlink "$initscript")
|
||||
local name=$(basename ${script:-$initscript})
|
||||
|
||||
_procd_open_trigger
|
||||
_procd_add_interface_trigger "interface.*" $1 /etc/init.d/$name reload
|
||||
_procd_close_trigger
|
||||
}
|
||||
|
||||
_procd_add_config_trigger() {
|
||||
json_add_array
|
||||
_procd_add_array_data "$1"
|
||||
shift
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "if"
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "eq" "package" "$1"
|
||||
shift
|
||||
json_close_array
|
||||
|
||||
json_add_array
|
||||
_procd_add_array_data "run_script" "$@"
|
||||
json_close_array
|
||||
|
||||
json_close_array
|
||||
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_add_raw_trigger() {
|
||||
json_add_array
|
||||
_procd_add_array_data "$1"
|
||||
shift
|
||||
local timeout=$1
|
||||
shift
|
||||
|
||||
json_add_array
|
||||
json_add_array
|
||||
_procd_add_array_data "run_script" "$@"
|
||||
json_close_array
|
||||
json_close_array
|
||||
|
||||
json_add_int "" "$timeout"
|
||||
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_add_reload_trigger() {
|
||||
local script=$(readlink "$initscript")
|
||||
local name=$(basename ${script:-$initscript})
|
||||
local file
|
||||
|
||||
_procd_open_trigger
|
||||
for file in "$@"; do
|
||||
_procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload
|
||||
done
|
||||
_procd_close_trigger
|
||||
}
|
||||
|
||||
_procd_add_validation() {
|
||||
_procd_open_validate
|
||||
$@
|
||||
_procd_close_validate
|
||||
}
|
||||
|
||||
_procd_append_param() {
|
||||
local type="$1"; shift
|
||||
local _json_no_warning=1
|
||||
|
||||
json_select "$type"
|
||||
[ $? = 0 ] || {
|
||||
_procd_set_param "$type" "$@"
|
||||
return
|
||||
}
|
||||
case "$type" in
|
||||
env|data|limits)
|
||||
_procd_add_table_data "$@"
|
||||
;;
|
||||
command|netdev|file|respawn|watch)
|
||||
_procd_add_array_data "$@"
|
||||
;;
|
||||
error)
|
||||
json_add_string "" "$@"
|
||||
;;
|
||||
esac
|
||||
json_select ..
|
||||
}
|
||||
|
||||
_procd_close_instance() {
|
||||
local respawn_vals
|
||||
_json_no_warning=1
|
||||
if json_select respawn ; then
|
||||
json_get_values respawn_vals
|
||||
if [ -z "$respawn_vals" ]; then
|
||||
local respawn_retry=$(uci_get system.@service[0].respawn_retry)
|
||||
_procd_add_array_data 3600 5 ${respawn_retry:-5}
|
||||
fi
|
||||
json_select ..
|
||||
fi
|
||||
|
||||
json_close_object
|
||||
}
|
||||
|
||||
_procd_close_trigger() {
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_close_validate() {
|
||||
json_close_array
|
||||
}
|
||||
|
||||
_procd_add_instance() {
|
||||
_procd_open_instance
|
||||
_procd_set_param command "$@"
|
||||
_procd_close_instance
|
||||
}
|
||||
|
||||
_procd_kill() {
|
||||
local service="$1"
|
||||
local instance="$2"
|
||||
|
||||
json_init
|
||||
[ -n "$service" ] && json_add_string name "$service"
|
||||
[ -n "$instance" ] && json_add_string instance "$instance"
|
||||
_procd_ubus_call delete
|
||||
}
|
||||
|
||||
procd_open_data() {
|
||||
local name="$1"
|
||||
json_set_namespace procd __procd_old_cb
|
||||
json_add_object data
|
||||
}
|
||||
|
||||
procd_close_data() {
|
||||
json_close_object
|
||||
json_set_namespace $__procd_old_cb
|
||||
}
|
||||
|
||||
_procd_set_config_changed() {
|
||||
local package="$1"
|
||||
|
||||
json_init
|
||||
json_add_string type config.change
|
||||
json_add_object data
|
||||
json_add_string package "$package"
|
||||
json_close_object
|
||||
|
||||
ubus call service event "$(json_dump)"
|
||||
}
|
||||
|
||||
procd_add_mdns_service() {
|
||||
local service proto port
|
||||
service=$1; shift
|
||||
proto=$1; shift
|
||||
port=$1; shift
|
||||
json_add_object "${service}_$port"
|
||||
json_add_string "service" "_$service._$proto.local"
|
||||
json_add_int port "$port"
|
||||
[ -n "$1" ] && {
|
||||
json_add_array txt
|
||||
for txt in $@; do json_add_string "" $txt; done
|
||||
json_select ..
|
||||
}
|
||||
json_select ..
|
||||
}
|
||||
|
||||
procd_add_mdns() {
|
||||
procd_open_data
|
||||
json_add_object "mdns"
|
||||
procd_add_mdns_service $@
|
||||
json_close_object
|
||||
procd_close_data
|
||||
}
|
||||
|
||||
uci_validate_section()
|
||||
{
|
||||
local _package="$1"
|
||||
local _type="$2"
|
||||
local _name="$3"
|
||||
local _result
|
||||
local _error
|
||||
shift; shift; shift
|
||||
_result=`/sbin/validate_data "$_package" "$_type" "$_name" "$@" 2> /dev/null`
|
||||
_error=$?
|
||||
eval "$_result"
|
||||
[ "$_error" = "0" ] || `/sbin/validate_data "$_package" "$_type" "$_name" "$@" 1> /dev/null`
|
||||
return $_error
|
||||
}
|
||||
|
||||
_procd_wrapper \
|
||||
procd_open_service \
|
||||
procd_close_service \
|
||||
procd_add_instance \
|
||||
procd_add_raw_trigger \
|
||||
procd_add_config_trigger \
|
||||
procd_add_interface_trigger \
|
||||
procd_add_reload_trigger \
|
||||
procd_add_reload_interface_trigger \
|
||||
procd_open_trigger \
|
||||
procd_close_trigger \
|
||||
procd_open_instance \
|
||||
procd_close_instance \
|
||||
procd_open_validate \
|
||||
procd_close_validate \
|
||||
procd_add_jail \
|
||||
procd_add_jail_mount \
|
||||
procd_add_jail_mount_rw \
|
||||
procd_set_param \
|
||||
procd_append_param \
|
||||
procd_add_validation \
|
||||
procd_set_config_changed \
|
||||
procd_kill
|
||||
103
bsp/board/raspberrypi/ovl/lib/functions/service.sh
Normal file
103
bsp/board/raspberrypi/ovl/lib/functions/service.sh
Normal file
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# service: simple wrapper around start-stop-daemon
|
||||
#
|
||||
# Usage: service ACTION EXEC ARGS...
|
||||
#
|
||||
# Action:
|
||||
# -C check if EXEC is alive
|
||||
# -S start EXEC, passing it ARGS as its arguments
|
||||
# -K kill EXEC, sending it a TERM signal if not specified otherwise
|
||||
#
|
||||
# Environment variables exposed:
|
||||
# SERVICE_DAEMONIZE run EXEC in background
|
||||
# SERVICE_WRITE_PID create a pid-file and use it for matching
|
||||
# SERVICE_MATCH_EXEC use EXEC command-line for matching (default)
|
||||
# SERVICE_MATCH_NAME use EXEC process name for matching
|
||||
# SERVICE_USE_PID assume EXEC create its own pid-file and use it for matching
|
||||
# SERVICE_NAME process name to use (default to EXEC file part)
|
||||
# SERVICE_PID_FILE pid file to use (default to /var/run/$SERVICE_NAME.pid)
|
||||
# SERVICE_SIG signal to send when using -K
|
||||
# SERVICE_SIG_RELOAD default signal used when reloading
|
||||
# SERVICE_SIG_STOP default signal used when stopping
|
||||
# SERVICE_STOP_TIME time to wait for a process to stop gracefully before killing it
|
||||
# SERVICE_UID user EXEC should be run as
|
||||
# SERVICE_GID group EXEC should be run as
|
||||
#
|
||||
# SERVICE_DEBUG don't do anything, but show what would be done
|
||||
# SERVICE_QUIET don't print anything
|
||||
#
|
||||
|
||||
SERVICE_QUIET=1
|
||||
SERVICE_SIG_RELOAD="HUP"
|
||||
SERVICE_SIG_STOP="TERM"
|
||||
SERVICE_STOP_TIME=5
|
||||
SERVICE_MATCH_EXEC=1
|
||||
|
||||
service() {
|
||||
local ssd
|
||||
local exec
|
||||
local name
|
||||
local start
|
||||
ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}"
|
||||
case "$1" in
|
||||
-C)
|
||||
ssd="$ssd -K -t"
|
||||
;;
|
||||
-S)
|
||||
ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}"
|
||||
start=1
|
||||
;;
|
||||
-K)
|
||||
ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}"
|
||||
;;
|
||||
*)
|
||||
echo "service: unknown ACTION '$1'" 1>&2
|
||||
return 1
|
||||
esac
|
||||
shift
|
||||
exec="$1"
|
||||
[ -n "$exec" ] || {
|
||||
echo "service: missing argument" 1>&2
|
||||
return 1
|
||||
}
|
||||
[ -x "$exec" ] || {
|
||||
echo "service: file '$exec' is not executable" 1>&2
|
||||
return 1
|
||||
}
|
||||
name="${SERVICE_NAME:-${exec##*/}}"
|
||||
[ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \
|
||||
|| ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}"
|
||||
[ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name"
|
||||
ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}"
|
||||
[ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec"
|
||||
shift
|
||||
$ssd${1:+ -- "$@"}
|
||||
}
|
||||
|
||||
service_check() {
|
||||
service -C "$@"
|
||||
}
|
||||
|
||||
service_signal() {
|
||||
SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@"
|
||||
}
|
||||
|
||||
service_start() {
|
||||
service -S "$@"
|
||||
}
|
||||
|
||||
service_stop() {
|
||||
local try
|
||||
SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1
|
||||
while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do
|
||||
service -C "$@" || return 0
|
||||
sleep 1
|
||||
done
|
||||
SERVICE_SIG="KILL" service -K "$@"
|
||||
sleep 1
|
||||
! service -C "$@"
|
||||
}
|
||||
|
||||
service_reload() {
|
||||
SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@"
|
||||
}
|
||||
0
bsp/board/raspberrypi/ovl/mnt/user/.gitkeep
Normal file
0
bsp/board/raspberrypi/ovl/mnt/user/.gitkeep
Normal file
18
bsp/board/raspberrypi/ovl/sbin/hotplug-call
Executable file
18
bsp/board/raspberrypi/ovl/sbin/hotplug-call
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2016 OpenWrt.org
|
||||
|
||||
export HOTPLUG_TYPE="$1"
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
LOGNAME=root
|
||||
USER=root
|
||||
export PATH LOGNAME USER
|
||||
export DEVICENAME="${DEVPATH##*/}"
|
||||
|
||||
[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
|
||||
for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
|
||||
[ -f $script ] && . $script
|
||||
); done
|
||||
}
|
||||
3
bsp/board/raspberrypi/ovl/usr/local/bin/ro
Executable file
3
bsp/board/raspberrypi/ovl/usr/local/bin/ro
Executable file
@@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
mount / -o ro,remount
|
||||
3
bsp/board/raspberrypi/ovl/usr/local/bin/rw
Executable file
3
bsp/board/raspberrypi/ovl/usr/local/bin/rw
Executable file
@@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
mount / -o rw,remount
|
||||
0
bsp/board/raspberrypi/ovl/usr/local/share/.gitkeep
Normal file
0
bsp/board/raspberrypi/ovl/usr/local/share/.gitkeep
Normal file
40
bsp/board/raspberrypi/scripts/post-build.sh
Executable file
40
bsp/board/raspberrypi/scripts/post-build.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
MKIMAGE=$HOST_DIR/usr/bin/mkimage
|
||||
GENEXT2FS=$HOST_DIR/usr/bin/genext2fs
|
||||
|
||||
# Catch post-build Error
|
||||
function error {
|
||||
|
||||
echo "post-build Failed."
|
||||
exit 1;
|
||||
}
|
||||
|
||||
set -e
|
||||
trap error ERR
|
||||
|
||||
echo "==> Mozart3 post-build:"
|
||||
|
||||
echo "AW_STAGING: ${AW_STAGING}"
|
||||
echo "AW_PROJECT: " ${AW_PROJECT}
|
||||
|
||||
# Generate uboot scripts
|
||||
for cmd_file in `ls ${AW_PROJECT}/uboot/*.cmd`
|
||||
do
|
||||
echo "uboot script: $cmd_file"
|
||||
# Get file name without extention.
|
||||
name=`echo "$(basename ${cmd_file})" | cut -d'.' -f1`
|
||||
echo "cmd: $MKIMAGE -C none -A arm -T script -d ${cmd_file} ${BINARIES_DIR}/${name}.scr"
|
||||
$MKIMAGE -C none -A arm -T script -d ${cmd_file} ${BINARIES_DIR}/${name}.scr
|
||||
done
|
||||
|
||||
# Copy the overlay of the target.
|
||||
if [ -d ${PROJECT}/ovl ]; then
|
||||
mkdir -p ${AW_STAGING}/buildroot/target/usr/local/
|
||||
cp -a ${AW_PROJECT}/ovl/* ${AW_STAGING}/buildroot/target/
|
||||
fi
|
||||
|
||||
# Finaly apply post build script of the target if the script exist.
|
||||
if [ -e ${PROJECT}/post-build.sh ]; then
|
||||
${PROJECT}/post-build.sh
|
||||
fi
|
||||
34
bsp/board/raspberrypi/scripts/post-image.sh
Executable file
34
bsp/board/raspberrypi/scripts/post-image.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
GENIMAGE=$HOST_DIR/usr/bin/genimage
|
||||
|
||||
# Catch post-image Error
|
||||
function error {
|
||||
|
||||
echo "post-image Failed."
|
||||
exit 1;
|
||||
}
|
||||
|
||||
set -e
|
||||
trap error ERR
|
||||
|
||||
echo "==> Mozart3 post-image:"
|
||||
|
||||
if [ -e ${PROJECT}/configs/genimage.config ]; then
|
||||
echo "We will generate sdcard image."
|
||||
rm -rf ${BUILD_DIR}/genimage.tmp
|
||||
echo ">> \
|
||||
$GENIMAGE \
|
||||
--rootpath "${TARGET_DIR}" \
|
||||
--tmppath "${BUILD_DIR}/genimage.tmp" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config ${PROJECT}/configs/genimage.config"
|
||||
|
||||
$GENIMAGE \
|
||||
--rootpath "${TARGET_DIR}" \
|
||||
--tmppath "${BUILD_DIR}/genimage.tmp" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config ${PROJECT}/configs/genimage.config
|
||||
fi
|
||||
4
bsp/buildroot_external/Config.in
Normal file
4
bsp/buildroot_external/Config.in
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
menu "Awox Audio Software"
|
||||
source "$BR2_EXTERNAL/Domo.in"
|
||||
endmenu
|
||||
5
bsp/buildroot_external/Domo.in
Normal file
5
bsp/buildroot_external/Domo.in
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
menu "Domo"
|
||||
|
||||
|
||||
endmenu # Domo
|
||||
1
bsp/buildroot_external/external.mk
Normal file
1
bsp/buildroot_external/external.mk
Normal file
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL)/package/*/*.mk))
|
||||
0
bsp/buildroot_external/package/.gitkeep
Normal file
0
bsp/buildroot_external/package/.gitkeep
Normal file
0
bsp/buildroot_external/patches/.gitkeep
Normal file
0
bsp/buildroot_external/patches/.gitkeep
Normal file
30
bsp/include/buildroot.mk
Normal file
30
bsp/include/buildroot.mk
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
BR2_EXTERNAL ?= $(AW_PROJECT)/../../bsp/buildroot_external/
|
||||
|
||||
BR_ENV = BR2_EXTERNAL=$(BR2_EXTERNAL) O=$(AW_STAGING)/buildroot/ WORKSPACE_DIR=$(AW_STAGING) BUILDS_ROOT=$(AW_LOCAL_BUILDS_ROOT) BOARD=$(AW_BOARD) PROJECT=$(AW_PROJECT)
|
||||
|
||||
buildroot.menuconfig: buildroot.config
|
||||
$(MAKE) $(BR_ENV) -C $(AW_PROJECT)/../../bsp/buildroot/ menuconfig
|
||||
cmp -s $(AW_STAGING)/buildroot/.config $(AW_PROJECT)/configs/buildroot.config; \
|
||||
if test $$? -ne 0; then echo "Config Files has changed......"; \
|
||||
cp $(AW_STAGING)/buildroot/.config $(AW_PROJECT)/configs/buildroot.config; \
|
||||
fi
|
||||
|
||||
buildroot: buildroot.config
|
||||
$(MAKE) $(BR_ENV) -C $(AW_PROJECT)/../../bsp/buildroot/
|
||||
|
||||
buildroot.shell: buildroot.config
|
||||
$(eval export $(BR_ENV))
|
||||
cd $(AW_STAGING)/buildroot/; $(BR_ENV) bash
|
||||
|
||||
buildroot.config:
|
||||
@mkdir -p $(AW_STAGING)/buildroot/
|
||||
ifeq ("$(wildcard $(AW_STAGING)/buildroot/.config)","")
|
||||
@cp $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config
|
||||
else
|
||||
cmp -s $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config; \
|
||||
if test $$? -ne 0; then echo "Config Files has changed......"; \
|
||||
cp $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config; \
|
||||
fi
|
||||
endif
|
||||
23
bsp/include/rules.mk
Normal file
23
bsp/include/rules.mk
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
msg:
|
||||
@echo "Building $(AW_PROJECT_NAME) Firmware."
|
||||
|
||||
clean:
|
||||
rm -rf $(AW_STAGING)
|
||||
|
||||
export DEBUG ?= 0
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
$(warning "DEBUG")
|
||||
BUILD_DIR := -debug
|
||||
BUILD_TYPE := Debug
|
||||
export BR2_ENABLE_DEBUG=y
|
||||
else
|
||||
$(warning "RELEASE")
|
||||
BUILD_DIR := -release
|
||||
BUILD_TYPE := Release
|
||||
endif
|
||||
|
||||
export BUILD_TYPE
|
||||
export AW_LOCAL_BUILDS_ROOT ?= $(AW_PROJECT)/../../_builds
|
||||
export AW_STAGING ?= $(AW_LOCAL_BUILDS_ROOT)/$(AW_PROJECT_NAME)$(BUILD_DIR)/
|
||||
Reference in New Issue
Block a user