ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/package/base-files/files/usr/lib/os-release b/package/base-files/files/usr/lib/os-release
new file mode 100644
index 0000000..12db2c0
--- /dev/null
+++ b/package/base-files/files/usr/lib/os-release
@@ -0,0 +1,19 @@
+NAME="%D"
+VERSION="%V"
+ID="%d"
+ID_LIKE="lede openwrt"
+PRETTY_NAME="%D %V"
+VERSION_ID="%v"
+HOME_URL="%u"
+BUG_URL="%b"
+SUPPORT_URL="%s"
+BUILD_ID="%R"
+OPENWRT_BOARD="%S"
+OPENWRT_ARCH="%A"
+OPENWRT_TAINTS="%t"
+OPENWRT_DEVICE_MANUFACTURER="%M"
+OPENWRT_DEVICE_MANUFACTURER_URL="%m"
+OPENWRT_DEVICE_PRODUCT="%P"
+OPENWRT_DEVICE_REVISION="%h"
+OPENWRT_RELEASE="%D %V %C"
+OPENWRT_BUILD_DATE="%B"
diff --git a/package/base-files/files/usr/libexec/login.sh b/package/base-files/files/usr/libexec/login.sh
new file mode 100755
index 0000000..e2f898e
--- /dev/null
+++ b/package/base-files/files/usr/libexec/login.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+[ -t 0 ] && {
+ tty_dev=$(readlink /proc/self/fd/0)
+ case "$tty_dev" in
+ /dev/console|/dev/tty[0-9]*)
+ export TERM=${TERM:-linux}
+ ;;
+ /dev/*)
+ export TERM=vt102
+ ;;
+ esac
+}
+
+[ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/login -f root
+
+exec /bin/login
diff --git a/package/base-files/files/usr/libexec/validate_firmware_image b/package/base-files/files/usr/libexec/validate_firmware_image
new file mode 100755
index 0000000..f85fb9e
--- /dev/null
+++ b/package/base-files/files/usr/libexec/validate_firmware_image
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+. /usr/share/libubox/jshn.sh
+
+include /lib/upgrade
+
+VALID=1
+FORCEABLE=1
+ALLOW_BACKUP=1
+
+# Mark image as invalid but still possible to install
+notify_firmware_invalid() {
+ VALID=0
+}
+
+# Mark image as broken (impossible to install)
+notify_firmware_broken() {
+ VALID=0
+ FORCEABLE=0
+}
+
+# Mark image as incompatible with preserving a backup
+notify_firmware_no_backup() {
+ ALLOW_BACKUP=0
+}
+
+# Add result of validation test
+notify_firmware_test_result() {
+ local old_ns
+
+ json_set_namespace validate_firmware_image old_ns
+ json_add_boolean "$1" "$2"
+ json_set_namespace $old_ns
+}
+
+err_to_bool() {
+ [ "$1" -ne 0 ] && echo 0 || echo 1
+}
+
+fwtool_check_signature "$1" >&2
+FWTOOL_SIGNATURE=$?
+[ "$FWTOOL_SIGNATURE" -ne 0 ] && notify_firmware_invalid
+
+fwtool_check_image "$1" >&2
+FWTOOL_DEVICE_MATCH=$?
+[ "$FWTOOL_DEVICE_MATCH" -ne 0 ] && notify_firmware_invalid
+
+json_set_namespace validate_firmware_image old_ns
+json_init
+ json_add_object "tests"
+ json_add_boolean fwtool_signature "$(err_to_bool $FWTOOL_SIGNATURE)"
+ json_add_boolean fwtool_device_match "$(err_to_bool $FWTOOL_DEVICE_MATCH)"
+
+ # Call platform_check_image() here so it can add its test
+ # results and still mark image properly.
+ json_set_namespace $old_ns
+ platform_check_image "$1" >&2 || notify_firmware_invalid
+ json_set_namespace validate_firmware_image old_ns
+ json_close_object
+ json_add_boolean valid "$VALID"
+ json_add_boolean forceable "$FORCEABLE"
+ json_add_boolean allow_backup "$ALLOW_BACKUP"
+json_dump -i
+json_set_namespace $old_ns