Implement 'multirom_zip' make target
* This will create install ZIP file to flash via recovery.
This commit is contained in:
@@ -53,3 +53,6 @@ include $(BUILD_EXECUTABLE)
|
||||
|
||||
# Trampoline
|
||||
include $(multirom_local_path)/trampoline/Android.mk
|
||||
|
||||
# ZIP installer
|
||||
include $(multirom_local_path)/install_zip/Android.mk
|
||||
|
||||
@@ -11,4 +11,8 @@ Clone repo to some folder inside Android 4.1.x source tree, I use `/system/extra
|
||||
|
||||
. build/envsetup.h
|
||||
lunch full_grouper-userdebug
|
||||
make multirom trampoline -j4
|
||||
make -j4 multirom trampoline
|
||||
|
||||
To build installation ZIP file, use `multirom_zip` target:
|
||||
|
||||
make -j4 multirom_zip
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# MultiROM device file for Nexus 7
|
||||
|
||||
MULTIROM_THEMES := 800x1280 1280x800
|
||||
BOOT_DEV := /dev/block/platform/sdhci-tegra.3/by-name/LNX
|
||||
|
||||
30
install_zip/Android.mk
Normal file
30
install_zip/Android.mk
Normal file
@@ -0,0 +1,30 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
install_zip_path := $(multirom_local_path)/install_zip
|
||||
|
||||
MULTIROM_ZIP_TARGET := $(PRODUCT_OUT)/multirom
|
||||
MULTIROM_INST_DIR := $(PRODUCT_OUT)/multirom_installer
|
||||
multirom_binary := $(TARGET_ROOT_OUT)/multirom
|
||||
trampoline_binary := $(TARGET_ROOT_OUT)/trampoline
|
||||
|
||||
# include device file
|
||||
include $(multirom_local_path)/device_$(TARGET_DEVICE).mk
|
||||
|
||||
$(MULTIROM_ZIP_TARGET): multirom trampoline signapk
|
||||
@echo ----- Making MultiROM ZIP installer ------
|
||||
rm -rf $(MULTIROM_INST_DIR)
|
||||
mkdir -p $(MULTIROM_INST_DIR)
|
||||
cp -a $(install_zip_path)/prebuilt/* $(MULTIROM_INST_DIR)/
|
||||
cp -a $(TARGET_ROOT_OUT)/multirom $(MULTIROM_INST_DIR)/multirom/
|
||||
cp -a $(TARGET_ROOT_OUT)/trampoline $(MULTIROM_INST_DIR)/multirom/
|
||||
echo $(BOOT_DEV) > $(MULTIROM_INST_DIR)/scripts/bootdev
|
||||
$(install_zip_path)/make_updater_script.sh $(TARGET_DEVICE) $(MULTIROM_INST_DIR)/META-INF/com/google/android
|
||||
rm -f $(MULTIROM_ZIP_TARGET).zip $(MULTIROM_ZIP_TARGET)-unsigned.zip
|
||||
cd $(MULTIROM_INST_DIR) && zip -qr ../$(notdir $@)-unsigned.zip *
|
||||
java -jar $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem $(DEFAULT_SYSTEM_DEV_CERTIFICATE).pk8 $(MULTIROM_ZIP_TARGET)-unsigned.zip $(MULTIROM_ZIP_TARGET).zip
|
||||
@echo ----- Made MultiROM ZIP installer -------- $@.zip
|
||||
|
||||
.PHONY: multirom_zip
|
||||
multirom_zip: $(MULTIROM_ZIP_TARGET)
|
||||
|
||||
9
install_zip/README.md
Normal file
9
install_zip/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# MultiROM ZIP installer
|
||||
This folder contains prebuilt part of the ZIP installer for MultiROM - the file
|
||||
which is flashed in recovery and it installs MultiROM to the device.
|
||||
|
||||
To build the ZIP file, use target `multirom_zip`.
|
||||
|
||||
make multirom_zip
|
||||
|
||||
The zip file is automatically signed with testkey.
|
||||
39
install_zip/make_updater_script.sh
Executable file
39
install_zip/make_updater_script.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
DEVICES=$1
|
||||
SCRIPT_PATH=$2
|
||||
CHECK_PROPS="ro.product.device ro.build.product"
|
||||
|
||||
if [ "$#" -ne "2" ]; then
|
||||
echo "Usage: $0 [device] [path to folder with updater-script]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Some devices have multiple variants, which are almost the same,
|
||||
# Example: grouper and tilapia (WiFi and 3G versions of Nexus 7)
|
||||
case "$DEVICES" in
|
||||
"grouper")
|
||||
DEVICES="${DEVICES} tilapia"
|
||||
;;
|
||||
esac
|
||||
|
||||
fail()
|
||||
{
|
||||
echo make_updater_script.sh has failed: $1
|
||||
exit 1
|
||||
}
|
||||
|
||||
mv ${SCRIPT_PATH}/updater-script ${SCRIPT_PATH}/updater-script-base || fail "Failed to copy updater-script base"
|
||||
|
||||
assert_str="assert("
|
||||
for dev in $DEVICES; do
|
||||
for prop in $CHECK_PROPS; do
|
||||
assert_str="${assert_str}getprop(\"$prop\") == \"$dev\" || "
|
||||
done
|
||||
assert_str="${assert_str}\n "
|
||||
done
|
||||
|
||||
assert_str="${assert_str% || \\n *});\n"
|
||||
|
||||
echo -e "$assert_str" > ${SCRIPT_PATH}/updater-script || fail "Failed to write assert line into updater-script!"
|
||||
cat ${SCRIPT_PATH}/updater-script-base >> ${SCRIPT_PATH}/updater-script || fail "Failed to add base updater-script file!"
|
||||
rm ${SCRIPT_PATH}/updater-script-base
|
||||
BIN
install_zip/prebuilt/META-INF/com/google/android/update-binary
Normal file
BIN
install_zip/prebuilt/META-INF/com/google/android/update-binary
Normal file
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
# Assert check for appropriate device is added during build,
|
||||
# see ../make_updater_script.sh and ../Android.mk
|
||||
|
||||
ui_print("MultiROM for Nexus 7");
|
||||
show_progress(1.00000, 10);
|
||||
|
||||
ui_print("Extracting binaries...");
|
||||
run_program("/sbin/busybox", "mount", "/data");
|
||||
|
||||
delete_recursive("/tmp/multirom");
|
||||
run_program("/sbin/busybox", "mkdir", "/tmp/multirom");
|
||||
package_extract_dir("multirom", "/tmp/multirom/");
|
||||
package_extract_dir("scripts", "/tmp/");
|
||||
|
||||
set_perm(0, 0, 0777, "/tmp/multirom/busybox");
|
||||
set_perm(0, 0, 0777, "/tmp/mkbootimg");
|
||||
set_perm(0, 0, 0777, "/tmp/unpackbootimg");
|
||||
set_perm(0, 0, 0777, "/tmp/lz4");
|
||||
set_perm(0, 0, 0777, "/tmp/extract_multirom.sh");
|
||||
set_perm(0, 0, 0777, "/tmp/inject_boot.sh");
|
||||
|
||||
assert(run_program("/tmp/extract_multirom.sh") == 0);
|
||||
ui_print("Injecting boot image...");
|
||||
assert(run_program("/tmp/inject_boot.sh") == 0);
|
||||
|
||||
ui_print("Cleaning up...");
|
||||
delete_recursive("/tmp/boot");
|
||||
delete_recursive("/tmp/multirom");
|
||||
delete("/tmp/mkbootimg");
|
||||
delete("/tmp/lz4");
|
||||
delete("/tmp/boot.img-cmdline");
|
||||
delete("/tmp/boot.img-ramdisk.gz");
|
||||
delete("/tmp/boot.img-zImage");
|
||||
delete("/tmp/unpackbootimg");
|
||||
delete("/tmp/boot.img");
|
||||
delete("/tmp/newboot.img");
|
||||
delete("/tmp/extract_multirom.sh");
|
||||
delete("/tmp/inject_boot.sh");
|
||||
|
||||
ui_print("Installation complete!");
|
||||
BIN
install_zip/prebuilt/multirom/adbd
Executable file
BIN
install_zip/prebuilt/multirom/adbd
Executable file
Binary file not shown.
BIN
install_zip/prebuilt/multirom/busybox
Executable file
BIN
install_zip/prebuilt/multirom/busybox
Executable file
Binary file not shown.
44
install_zip/prebuilt/multirom/infos/ubuntu.txt
Normal file
44
install_zip/prebuilt/multirom/infos/ubuntu.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
# This file contains info about ROMs capabilites and boot process.
|
||||
# It should be placed in ROM's folder (eg. /media/multirom/roms/*rom_name*)
|
||||
# and must be named "rom_info.txt".
|
||||
# Make sure you got the syntax correct, as the parser is probably pretty
|
||||
# dumb. Lines with comments must start with #. Beware the whitespaces.
|
||||
# If you need to use " character in string, just use it, no need to escape it
|
||||
# MultiROM searches for first and last " on the line.
|
||||
# These comments should not be deleted.
|
||||
|
||||
# So far, the only supported ROM type for these files is kexec-based linux
|
||||
type="kexec"
|
||||
|
||||
# Paths to root of the ROM.
|
||||
# Both image and folder can be specified at one time, MultiROM will use
|
||||
# the one which it can find. If both are present, folder is used.
|
||||
# Must _not_ contain spaces.
|
||||
# Path is from root of the root partition, but you will usually want
|
||||
# to use following alias:
|
||||
# - %m - ROM's folder (eg. /media/multirom/roms/*rom_name*)
|
||||
root_dir="%m/root"
|
||||
root_img="%m/root.img"
|
||||
root_img_fs="ext4"
|
||||
|
||||
# Path to kernel and initrd. Kernel path _must_ be specified.
|
||||
# Paths are relative to the folder in which is this file
|
||||
# Those can be outside the root folder/image, or use %r if it is in there:
|
||||
# kernel_path="%r/boot/vmlinuz"
|
||||
# If ROM is in images, it will mount the image and load it from there.
|
||||
# You can use * _at the end of the filename_ as wildcard character.
|
||||
kernel_path="%r/boot/vmlinuz"
|
||||
initrd_path="%r/boot/initrd.img"
|
||||
|
||||
# Set up the cmdline
|
||||
# img_cmdline and dir_cmdline are appended to base_cmdline.
|
||||
# Several aliases are used:
|
||||
# - %b - base command line from bootloader. You want this as first thing in cmdline.
|
||||
# - %d - root device. is either "UUID=..." (USB drive) or "/dev/mmcblk0p9" or "/dev/mmcblk0p10"
|
||||
# - %r - root fs type
|
||||
# - %s - root directory, from root of the root device
|
||||
# - %i - root image, from root of the root device
|
||||
# - %f - fs of the root image
|
||||
base_cmdline="%b root=%d rootfstype=%r rw console=tty0 access=m2 quiet splash rootflags=defaults,noatime,nodiratime"
|
||||
img_cmdline="loop=%i loopfstype=%f"
|
||||
dir_cmdline="rootsubdir=%s"
|
||||
44
install_zip/prebuilt/multirom/infos/ubuntu_touch.txt
Normal file
44
install_zip/prebuilt/multirom/infos/ubuntu_touch.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
# This file contains info about ROMs capabilites and boot process.
|
||||
# It should be placed in ROM's folder (eg. /media/multirom/roms/*rom_name*)
|
||||
# and must be named "rom_info.txt".
|
||||
# Make sure you got the syntax correct, as the parser is probably pretty
|
||||
# dumb. Lines with comments must start with #. Beware the whitespaces.
|
||||
# If you need to use " character in string, just use it, no need to escape it
|
||||
# MultiROM searches for first and last " on the line.
|
||||
# These comments should not be deleted.
|
||||
|
||||
# So far, the only supported ROM type for these files is kexec-based linux
|
||||
type="kexec"
|
||||
|
||||
# Paths to root of the ROM.
|
||||
# Both image and folder can be specified at one time, MultiROM will use
|
||||
# the one which it can find. If both are present, folder is used.
|
||||
# Must _not_ contain spaces.
|
||||
# Path is from root of the root partition, but you will usually want
|
||||
# to use following alias:
|
||||
# - %m - ROM's folder (eg. /media/multirom/roms/*rom_name*)
|
||||
root_dir="%m"
|
||||
root_img="%m/data.img"
|
||||
root_img_fs="ext4"
|
||||
|
||||
# Path to kernel and initrd. Kernel path _must_ be specified.
|
||||
# Paths are relative to the folder in which is this file
|
||||
# Those can be outside the root folder/image, or use %r if it is in there:
|
||||
# kernel_path="%r/boot/vmlinuz"
|
||||
# If ROM is in images, it will mount the image and load it from there.
|
||||
# You can use * _at the end of the filename_ as wildcard character.
|
||||
kernel_path="zImage"
|
||||
initrd_path="initrd.img"
|
||||
|
||||
# Set up the cmdline
|
||||
# img_cmdline and dir_cmdline are appended to base_cmdline.
|
||||
# Several aliases are used:
|
||||
# - %b - base command line from bootloader. You want this as first thing in cmdline.
|
||||
# - %d - root device. is either "UUID=..." (USB drive) or "/dev/mmcblk0p9" or "/dev/mmcblk0p10"
|
||||
# - %r - root fs type
|
||||
# - %s - root directory, from root of the root device
|
||||
# - %i - root image, from root of the root device
|
||||
# - %f - fs of the root image
|
||||
base_cmdline="%b console=tty1 root=%d rootfstype=%r rw rootflags=defaults,noatime,nodiratime"
|
||||
img_cmdline="loop=%s loopfstype=%f"
|
||||
dir_cmdline="rootsubdir=%s"
|
||||
BIN
install_zip/prebuilt/multirom/kexec
Executable file
BIN
install_zip/prebuilt/multirom/kexec
Executable file
Binary file not shown.
BIN
install_zip/prebuilt/multirom/ntfs-3g
Executable file
BIN
install_zip/prebuilt/multirom/ntfs-3g
Executable file
Binary file not shown.
357
install_zip/prebuilt/multirom/ubuntu-init/init
Executable file
357
install_zip/prebuilt/multirom/ubuntu-init/init
Executable file
@@ -0,0 +1,357 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -d /dev ] || mkdir -m 0755 /dev
|
||||
[ -d /root ] || mkdir -m 0700 /root
|
||||
[ -d /sys ] || mkdir /sys
|
||||
[ -d /proc ] || mkdir /proc
|
||||
[ -d /tmp ] || mkdir /tmp
|
||||
mkdir -p /var/lock
|
||||
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
|
||||
mount -t proc -o nodev,noexec,nosuid proc /proc
|
||||
# Some things don't work properly without /etc/mtab.
|
||||
ln -sf /proc/mounts /etc/mtab
|
||||
|
||||
grep -q '\<quiet\>' /proc/cmdline || echo "Loading, please wait..."
|
||||
|
||||
# Note that this only becomes /dev on the real filesystem if udev's scripts
|
||||
# are used; which they will be, but it's worth pointing out
|
||||
if ! mount -t devtmpfs -o mode=0755 udev /dev; then
|
||||
echo "W: devtmpfs not available, falling back to tmpfs for /dev"
|
||||
mount -t tmpfs -o mode=0755 udev /dev
|
||||
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
|
||||
[ -e /dev/null ] || mknod /dev/null c 1 3
|
||||
fi
|
||||
mkdir /dev/pts
|
||||
mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
|
||||
mount -t tmpfs -o "noexec,nosuid,size=10%,mode=0755" tmpfs /run
|
||||
mkdir /run/initramfs
|
||||
# compatibility symlink for the pre-oneiric locations
|
||||
ln -s /run/initramfs /dev/.initramfs
|
||||
|
||||
# Export the dpkg architecture
|
||||
export DPKG_ARCH=
|
||||
. /conf/arch.conf
|
||||
|
||||
# Set modprobe env
|
||||
export MODPROBE_OPTIONS="-qb"
|
||||
|
||||
# Export relevant variables
|
||||
export ROOT=
|
||||
export ROOTDELAY=
|
||||
export ROOTFLAGS=
|
||||
export ROOTFSTYPE=
|
||||
export IP=
|
||||
export BOOT=
|
||||
export BOOTIF=
|
||||
export UBIMTD=
|
||||
export break=
|
||||
export init=/sbin/init
|
||||
export quiet=n
|
||||
export readonly=y
|
||||
export rootmnt=/root
|
||||
export debug=
|
||||
export panic=
|
||||
export blacklist=
|
||||
export resume=
|
||||
export resume_offset=
|
||||
export recovery=
|
||||
export FLASH_KERNEL_SKIP=1
|
||||
|
||||
# mdadm needs hostname to be set. This has to be done before the udev rules are called!
|
||||
if [ -f "/etc/hostname" ]; then
|
||||
/bin/hostname -b -F /etc/hostname 2>&1 1>/dev/null
|
||||
fi
|
||||
|
||||
# Bring in the main config
|
||||
. /conf/initramfs.conf
|
||||
for conf in conf/conf.d/*; do
|
||||
[ -f ${conf} ] && . ${conf}
|
||||
done
|
||||
. /scripts/functions
|
||||
|
||||
# Parse command line options
|
||||
for x in $(cat /proc/cmdline); do
|
||||
case $x in
|
||||
init=*)
|
||||
init=${x#init=}
|
||||
;;
|
||||
root=*)
|
||||
ROOT=${x#root=}
|
||||
case $ROOT in
|
||||
LABEL=*)
|
||||
ROOT="${ROOT#LABEL=}"
|
||||
|
||||
# support any / in LABEL= path (escape to \x2f)
|
||||
case "${ROOT}" in
|
||||
*/*)
|
||||
if command -v sed >/dev/null 2>&1; then
|
||||
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
|
||||
else
|
||||
if [ "${ROOT}" != "${ROOT#/}" ]; then
|
||||
ROOT="\x2f${ROOT#/}"
|
||||
fi
|
||||
if [ "${ROOT}" != "${ROOT%/}" ]; then
|
||||
ROOT="${ROOT%/}\x2f"
|
||||
fi
|
||||
IFS='/'
|
||||
newroot=
|
||||
for s in $ROOT; do
|
||||
newroot="${newroot:+${newroot}\\x2f}${s}"
|
||||
done
|
||||
unset IFS
|
||||
ROOT="${newroot}"
|
||||
fi
|
||||
esac
|
||||
ROOT="/dev/disk/by-label/${ROOT}"
|
||||
;;
|
||||
UUID=*)
|
||||
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
|
||||
;;
|
||||
/dev/nfs)
|
||||
[ -z "${BOOT}" ] && BOOT=nfs
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
rootflags=*)
|
||||
ROOTFLAGS="-o ${x#rootflags=}"
|
||||
;;
|
||||
rootfstype=*)
|
||||
ROOTFSTYPE="${x#rootfstype=}"
|
||||
;;
|
||||
rootdelay=*)
|
||||
ROOTDELAY="${x#rootdelay=}"
|
||||
case ${ROOTDELAY} in
|
||||
*[![:digit:].]*)
|
||||
ROOTDELAY=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
resumedelay=*)
|
||||
RESUMEDELAY="${x#resumedelay=}"
|
||||
;;
|
||||
loop=*)
|
||||
LOOP="${x#loop=}"
|
||||
;;
|
||||
loopflags=*)
|
||||
LOOPFLAGS="-o ${x#loopflags=}"
|
||||
;;
|
||||
loopfstype=*)
|
||||
LOOPFSTYPE="${x#loopfstype=}"
|
||||
;;
|
||||
rootsubdir=*)
|
||||
ROOTSUBDIR="${x#rootsubdir=}"
|
||||
;;
|
||||
cryptopts=*)
|
||||
cryptopts="${x#cryptopts=}"
|
||||
;;
|
||||
nfsroot=*)
|
||||
NFSROOT="${x#nfsroot=}"
|
||||
;;
|
||||
netboot=*)
|
||||
NETBOOT="${x#netboot=}"
|
||||
;;
|
||||
ip=*)
|
||||
IP="${x#ip=}"
|
||||
;;
|
||||
boot=*)
|
||||
BOOT=${x#boot=}
|
||||
;;
|
||||
ubi.mtd=*)
|
||||
UBIMTD=${x#ubi.mtd=}
|
||||
;;
|
||||
resume=*)
|
||||
RESUME="${x#resume=}"
|
||||
;;
|
||||
resume_offset=*)
|
||||
resume_offset="${x#resume_offset=}"
|
||||
;;
|
||||
noresume)
|
||||
noresume=y
|
||||
;;
|
||||
panic=*)
|
||||
panic="${x#panic=}"
|
||||
case ${panic} in
|
||||
*[![:digit:].]*)
|
||||
panic=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
quiet)
|
||||
quiet=y
|
||||
;;
|
||||
ro)
|
||||
readonly=y
|
||||
;;
|
||||
rw)
|
||||
readonly=n
|
||||
;;
|
||||
debug)
|
||||
debug=y
|
||||
quiet=n
|
||||
exec >/run/initramfs/initramfs.debug 2>&1
|
||||
set -x
|
||||
;;
|
||||
debug=*)
|
||||
debug=y
|
||||
quiet=n
|
||||
set -x
|
||||
;;
|
||||
break=*)
|
||||
break=${x#break=}
|
||||
;;
|
||||
break)
|
||||
break=premount
|
||||
;;
|
||||
blacklist=*)
|
||||
blacklist=${x#blacklist=}
|
||||
;;
|
||||
netconsole=*)
|
||||
netconsole=${x#netconsole=}
|
||||
;;
|
||||
BOOTIF=*)
|
||||
BOOTIF=${x#BOOTIF=}
|
||||
;;
|
||||
hwaddr=*)
|
||||
BOOTIF=${x#BOOTIF=}
|
||||
;;
|
||||
recovery)
|
||||
recovery=y
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "${noresume}" ]; then
|
||||
export noresume
|
||||
unset resume
|
||||
else
|
||||
resume=${RESUME:-}
|
||||
fi
|
||||
|
||||
maybe_break top
|
||||
|
||||
# export BOOT variable value for compcache,
|
||||
# so we know if we run from casper
|
||||
export BOOT
|
||||
|
||||
# Don't do log messages here to avoid confusing graphical boots
|
||||
run_scripts /scripts/init-top
|
||||
|
||||
maybe_break modules
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Loading essential drivers"
|
||||
load_modules
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
[ -n "${netconsole}" ] && modprobe netconsole netconsole="${netconsole}"
|
||||
|
||||
maybe_break premount
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
|
||||
run_scripts /scripts/init-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
maybe_break mount
|
||||
log_begin_msg "Mounting root file system"
|
||||
. /scripts/${BOOT}
|
||||
parse_numeric ${ROOT}
|
||||
maybe_break mountroot
|
||||
mountroot
|
||||
log_end_msg
|
||||
|
||||
maybe_break bottom
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
|
||||
run_scripts /scripts/init-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# Preserve information on old systems without /run on the rootfs
|
||||
if [ -d ${rootmnt}/run ]; then
|
||||
mount -n -o move /run ${rootmnt}/run
|
||||
else
|
||||
# The initramfs udev database must be migrated:
|
||||
if [ -d /run/udev ] && [ ! -d /dev/.udev ]; then
|
||||
mv /run/udev /dev/.udev
|
||||
fi
|
||||
# The initramfs debug info must be migrated:
|
||||
if [ -d /run/initramfs ] && [ ! -d /dev/.initramfs ]; then
|
||||
mv /run/initramfs /dev/.initramfs
|
||||
fi
|
||||
umount /run
|
||||
fi
|
||||
|
||||
# Move virtual filesystems over to the real filesystem
|
||||
mount -n -o move /sys ${rootmnt}/sys
|
||||
mount -n -o move /proc ${rootmnt}/proc
|
||||
|
||||
validate_init() {
|
||||
checktarget="${1}"
|
||||
|
||||
# Work around absolute symlinks
|
||||
if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${checktarget}" ]; then
|
||||
case $(readlink "${rootmnt}${checktarget}") in /*)
|
||||
checktarget="$(chroot ${rootmnt} readlink ${checktarget})"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Make sure the specified init can be executed
|
||||
if [ ! -x "${rootmnt}${checktarget}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Upstart uses /etc/init as configuration directory :-/
|
||||
if [ -d "${rootmnt}${checktarget}" ]; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check init bootarg
|
||||
if [ -n "${init}" ]; then
|
||||
if ! validate_init "$init"; then
|
||||
echo "Target filesystem doesn't have requested ${init}."
|
||||
init=
|
||||
fi
|
||||
fi
|
||||
|
||||
# Common case: /sbin/init is present
|
||||
if [ ! -x "${rootmnt}/sbin/init" ]; then
|
||||
# ... if it's not available search for valid init
|
||||
if [ -z "${init}" ] ; then
|
||||
for inittest in /sbin/init /etc/init /bin/init /bin/sh; do
|
||||
if validate_init "${inittest}"; then
|
||||
init="$inittest"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# No init on rootmount
|
||||
if ! validate_init "${init}" ; then
|
||||
panic "No init found. Try passing init= bootarg."
|
||||
fi
|
||||
fi
|
||||
|
||||
maybe_break init
|
||||
|
||||
# don't leak too much of env - some init(8) don't clear it
|
||||
# (keep init, rootmnt)
|
||||
unset debug
|
||||
unset MODPROBE_OPTIONS
|
||||
unset DPKG_ARCH
|
||||
unset ROOTFLAGS
|
||||
unset ROOTFSTYPE
|
||||
unset ROOTDELAY
|
||||
unset ROOT
|
||||
unset IP
|
||||
unset BOOT
|
||||
unset BOOTIF
|
||||
unset UBIMTD
|
||||
unset blacklist
|
||||
unset break
|
||||
unset noresume
|
||||
unset panic
|
||||
unset quiet
|
||||
unset readonly
|
||||
unset resume
|
||||
unset resume_offset
|
||||
|
||||
# Chain to real filesystem
|
||||
exec run-init ${rootmnt} ${init} "$@" ${recovery:+--startup-event=recovery} <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1
|
||||
panic "Could not execute run-init."
|
||||
170
install_zip/prebuilt/multirom/ubuntu-init/local
Normal file
170
install_zip/prebuilt/multirom/ubuntu-init/local
Normal file
@@ -0,0 +1,170 @@
|
||||
# Local filesystem mounting -*- shell-script -*-
|
||||
|
||||
pre_mountroot()
|
||||
{
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
|
||||
run_scripts /scripts/local-top
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# Don't wait for a root device that doesn't have a corresponding
|
||||
# device in /dev (ie, mtd0)
|
||||
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
while [ -z "${FSTYPE}" ]; do
|
||||
FSTYPE=$(wait-for-root "${ROOT}" ${ROOTDELAY:-30})
|
||||
|
||||
# Load ubi with the correct MTD partition and return since
|
||||
# fstype doesn't work with a char device like ubi.
|
||||
if [ -n "$UBIMTD" ]; then
|
||||
modprobe ubi mtd=$UBIMTD
|
||||
return
|
||||
fi
|
||||
|
||||
# Run failure hooks, hoping one of them can fix up the system
|
||||
# and we can restart the wait loop. If they all fail, abort
|
||||
# and move on to the panic handler and shell.
|
||||
if [ -z "${FSTYPE}" ] && ! try_failure_hooks; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# We've given up, but we'll let the user fix matters if they can
|
||||
while [ -z "${FSTYPE}" -a ! -e "${ROOT}" ]; do
|
||||
# give hint about renamed root
|
||||
case "${ROOT}" in
|
||||
/dev/hd*)
|
||||
suffix="${ROOT#/dev/hd}"
|
||||
major="${suffix%[[:digit:]]}"
|
||||
major="${major%[[:digit:]]}"
|
||||
if [ -d "/sys/block/sd${major}" ]; then
|
||||
echo "WARNING bootdevice may be renamed. Try root=/dev/sd${suffix}"
|
||||
fi
|
||||
;;
|
||||
/dev/sd*)
|
||||
suffix="${ROOT#/dev/sd}"
|
||||
major="${suffix%[[:digit:]]}"
|
||||
major="${major%[[:digit:]]}"
|
||||
if [ -d "/sys/block/hd${major}" ]; then
|
||||
echo "WARNING bootdevice may be renamed. Try root=/dev/hd${suffix}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "Gave up waiting for root device. Common problems:"
|
||||
echo " - Boot args (cat /proc/cmdline)"
|
||||
echo " - Check rootdelay= (did the system wait long enough?)"
|
||||
echo " - Check root= (did the system wait for the right device?)"
|
||||
echo " - Missing modules (cat /proc/modules; ls /dev)"
|
||||
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
|
||||
done
|
||||
}
|
||||
|
||||
mountroot()
|
||||
{
|
||||
pre_mountroot
|
||||
|
||||
# Get the root filesystem type if not set
|
||||
if [ -z "${ROOTFSTYPE}" ]; then
|
||||
[ -n "${FSTYPE}" ] || FSTYPE=$(blkid -s TYPE -o value "${ROOT}")
|
||||
ROOTFSTYPE="${FSTYPE}"
|
||||
else
|
||||
FSTYPE=${ROOTFSTYPE}
|
||||
fi
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
|
||||
run_scripts /scripts/local-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
if [ "${readonly}" = "y" ] && \
|
||||
[ -z "$LOOP" ]; then
|
||||
roflag=-r
|
||||
else
|
||||
roflag=-w
|
||||
fi
|
||||
|
||||
# FIXME This has no error checking
|
||||
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
|
||||
|
||||
# FIXME This has no error checking
|
||||
# Mount root
|
||||
mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
|
||||
mountroot_status="$?"
|
||||
if [ "$LOOP" ]; then
|
||||
if [ "$mountroot_status" != 0 ]; then
|
||||
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
|
||||
panic "
|
||||
Could not mount the partition ${ROOT}.
|
||||
This could also happen if the file system is not clean because of an operating
|
||||
system crash, an interrupted boot process, an improper shutdown, or unplugging
|
||||
of a removable device without first unmounting or ejecting it. To fix this,
|
||||
simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
|
||||
gracefully shut down and reboot back into Windows. After this you should be
|
||||
able to reboot again and resume the installation.
|
||||
(filesystem = ${FSTYPE}, error code = $mountroot_status)
|
||||
"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p /host
|
||||
mount -o move ${rootmnt} /host
|
||||
|
||||
while [ ! -e "/host/${LOOP#/}" ]; do
|
||||
panic "ALERT! /host/${LOOP#/} does not exist. Dropping to a shell!"
|
||||
done
|
||||
|
||||
# Get the loop filesystem type if not set
|
||||
if [ -z "${LOOPFSTYPE}" ]; then
|
||||
eval $(fstype < "/host/${LOOP#/}")
|
||||
else
|
||||
FSTYPE="${LOOPFSTYPE}"
|
||||
fi
|
||||
if [ "$FSTYPE" = "unknown" ] && [ -x /sbin/blkid ]; then
|
||||
FSTYPE=$(/sbin/blkid -s TYPE -o value "/host/${LOOP#/}")
|
||||
[ -z "$FSTYPE" ] && FSTYPE="unknown"
|
||||
fi
|
||||
|
||||
if [ ${readonly} = y ]; then
|
||||
roflag=-r
|
||||
else
|
||||
roflag=-w
|
||||
fi
|
||||
|
||||
# FIXME This has no error checking
|
||||
modprobe loop
|
||||
modprobe ${FSTYPE}
|
||||
|
||||
# FIXME This has no error checking
|
||||
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "/host/${LOOP#/}" ${rootmnt}
|
||||
|
||||
if [ -d ${rootmnt}/host ]; then
|
||||
mount -o move /host ${rootmnt}/host
|
||||
fi
|
||||
elif [ "$ROOTSUBDIR" ]; then
|
||||
if [ "$mountroot_status" != 0 ]; then
|
||||
panic "
|
||||
Could not mount the partition ${ROOT}.
|
||||
This could also happen if the file system is not clean because of an operating
|
||||
system crash, an interrupted boot process, an improper shutdown, or unplugging
|
||||
of a removable device without first unmounting or ejecting it.
|
||||
(filesystem = ${FSTYPE}, error code = $mountroot_status)
|
||||
"
|
||||
fi
|
||||
|
||||
mkdir -p /host
|
||||
mount -o move ${rootmnt} /host
|
||||
|
||||
if [ ! -d "/host/$ROOTSUBDIR" ]; then
|
||||
panic "Failed to bind folder ${ROOTSUBDIR} as root: folder does not exist."
|
||||
fi
|
||||
|
||||
mount -o bind /host/$ROOTSUBDIR ${rootmnt}
|
||||
if [ -d ${rootmnt}/host ]; then
|
||||
mount -o move /host ${rootmnt}/host
|
||||
fi
|
||||
fi
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
|
||||
run_scripts /scripts/local-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
}
|
||||
356
install_zip/prebuilt/multirom/ubuntu-touch-init/init
Executable file
356
install_zip/prebuilt/multirom/ubuntu-touch-init/init
Executable file
@@ -0,0 +1,356 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -d /dev ] || mkdir -m 0755 /dev
|
||||
[ -d /root ] || mkdir -m 0700 /root
|
||||
[ -d /sys ] || mkdir /sys
|
||||
[ -d /proc ] || mkdir /proc
|
||||
[ -d /tmp ] || mkdir /tmp
|
||||
mkdir -p /var/lock
|
||||
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
|
||||
mount -t proc -o nodev,noexec,nosuid proc /proc
|
||||
# Some things don't work properly without /etc/mtab.
|
||||
ln -sf /proc/mounts /etc/mtab
|
||||
|
||||
grep -q '\<quiet\>' /proc/cmdline || echo "Loading, please wait..."
|
||||
|
||||
# Note that this only becomes /dev on the real filesystem if udev's scripts
|
||||
# are used; which they will be, but it's worth pointing out
|
||||
if ! mount -t devtmpfs -o mode=0755 udev /dev; then
|
||||
echo "W: devtmpfs not available, falling back to tmpfs for /dev"
|
||||
mount -t tmpfs -o mode=0755 udev /dev
|
||||
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
|
||||
[ -e /dev/null ] || mknod /dev/null c 1 3
|
||||
fi
|
||||
mkdir /dev/pts
|
||||
mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
|
||||
mount -t tmpfs -o "noexec,nosuid,size=10%,mode=0755" tmpfs /run
|
||||
mkdir /run/initramfs
|
||||
# compatibility symlink for the pre-oneiric locations
|
||||
ln -s /run/initramfs /dev/.initramfs
|
||||
|
||||
# Export the dpkg architecture
|
||||
export DPKG_ARCH=
|
||||
. /conf/arch.conf
|
||||
|
||||
# Set modprobe env
|
||||
export MODPROBE_OPTIONS="-qb"
|
||||
|
||||
# Export relevant variables
|
||||
export ROOT=
|
||||
export ROOTDELAY=
|
||||
export ROOTFLAGS=
|
||||
export ROOTFSTYPE=
|
||||
export IP=
|
||||
export BOOT=
|
||||
export BOOTIF=
|
||||
export UBIMTD=
|
||||
export break=
|
||||
export init=/sbin/init
|
||||
export quiet=n
|
||||
export readonly=y
|
||||
export rootmnt=/root
|
||||
export debug=
|
||||
export panic=
|
||||
export blacklist=
|
||||
export resume=
|
||||
export resume_offset=
|
||||
export recovery=
|
||||
|
||||
# mdadm needs hostname to be set. This has to be done before the udev rules are called!
|
||||
if [ -f "/etc/hostname" ]; then
|
||||
/bin/hostname -b -F /etc/hostname 2>&1 1>/dev/null
|
||||
fi
|
||||
|
||||
# Bring in the main config
|
||||
. /conf/initramfs.conf
|
||||
for conf in conf/conf.d/*; do
|
||||
[ -f ${conf} ] && . ${conf}
|
||||
done
|
||||
. /scripts/functions
|
||||
|
||||
# Parse command line options
|
||||
for x in $(cat /proc/cmdline); do
|
||||
case $x in
|
||||
init=*)
|
||||
init=${x#init=}
|
||||
;;
|
||||
root=*)
|
||||
ROOT=${x#root=}
|
||||
case $ROOT in
|
||||
LABEL=*)
|
||||
ROOT="${ROOT#LABEL=}"
|
||||
|
||||
# support any / in LABEL= path (escape to \x2f)
|
||||
case "${ROOT}" in
|
||||
*/*)
|
||||
if command -v sed >/dev/null 2>&1; then
|
||||
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
|
||||
else
|
||||
if [ "${ROOT}" != "${ROOT#/}" ]; then
|
||||
ROOT="\x2f${ROOT#/}"
|
||||
fi
|
||||
if [ "${ROOT}" != "${ROOT%/}" ]; then
|
||||
ROOT="${ROOT%/}\x2f"
|
||||
fi
|
||||
IFS='/'
|
||||
newroot=
|
||||
for s in $ROOT; do
|
||||
newroot="${newroot:+${newroot}\\x2f}${s}"
|
||||
done
|
||||
unset IFS
|
||||
ROOT="${newroot}"
|
||||
fi
|
||||
esac
|
||||
ROOT="/dev/disk/by-label/${ROOT}"
|
||||
;;
|
||||
UUID=*)
|
||||
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
|
||||
;;
|
||||
/dev/nfs)
|
||||
[ -z "${BOOT}" ] && BOOT=nfs
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
rootflags=*)
|
||||
ROOTFLAGS="-o ${x#rootflags=}"
|
||||
;;
|
||||
rootfstype=*)
|
||||
ROOTFSTYPE="${x#rootfstype=}"
|
||||
;;
|
||||
rootdelay=*)
|
||||
ROOTDELAY="${x#rootdelay=}"
|
||||
case ${ROOTDELAY} in
|
||||
*[![:digit:].]*)
|
||||
ROOTDELAY=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
resumedelay=*)
|
||||
RESUMEDELAY="${x#resumedelay=}"
|
||||
;;
|
||||
loop=*)
|
||||
LOOP="${x#loop=}"
|
||||
;;
|
||||
loopflags=*)
|
||||
LOOPFLAGS="-o ${x#loopflags=}"
|
||||
;;
|
||||
loopfstype=*)
|
||||
LOOPFSTYPE="${x#loopfstype=}"
|
||||
;;
|
||||
rootsubdir=*)
|
||||
ROOTSUBDIR="${x#rootsubdir=}"
|
||||
;;
|
||||
cryptopts=*)
|
||||
cryptopts="${x#cryptopts=}"
|
||||
;;
|
||||
nfsroot=*)
|
||||
NFSROOT="${x#nfsroot=}"
|
||||
;;
|
||||
netboot=*)
|
||||
NETBOOT="${x#netboot=}"
|
||||
;;
|
||||
ip=*)
|
||||
IP="${x#ip=}"
|
||||
;;
|
||||
boot=*)
|
||||
BOOT=${x#boot=}
|
||||
;;
|
||||
ubi.mtd=*)
|
||||
UBIMTD=${x#ubi.mtd=}
|
||||
;;
|
||||
resume=*)
|
||||
RESUME="${x#resume=}"
|
||||
;;
|
||||
resume_offset=*)
|
||||
resume_offset="${x#resume_offset=}"
|
||||
;;
|
||||
noresume)
|
||||
noresume=y
|
||||
;;
|
||||
panic=*)
|
||||
panic="${x#panic=}"
|
||||
case ${panic} in
|
||||
*[![:digit:].]*)
|
||||
panic=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
quiet)
|
||||
quiet=y
|
||||
;;
|
||||
ro)
|
||||
readonly=y
|
||||
;;
|
||||
rw)
|
||||
readonly=n
|
||||
;;
|
||||
debug)
|
||||
debug=y
|
||||
quiet=n
|
||||
exec >/run/initramfs/initramfs.debug 2>&1
|
||||
set -x
|
||||
;;
|
||||
debug=*)
|
||||
debug=y
|
||||
quiet=n
|
||||
set -x
|
||||
;;
|
||||
break=*)
|
||||
break=${x#break=}
|
||||
;;
|
||||
break)
|
||||
break=premount
|
||||
;;
|
||||
blacklist=*)
|
||||
blacklist=${x#blacklist=}
|
||||
;;
|
||||
netconsole=*)
|
||||
netconsole=${x#netconsole=}
|
||||
;;
|
||||
BOOTIF=*)
|
||||
BOOTIF=${x#BOOTIF=}
|
||||
;;
|
||||
hwaddr=*)
|
||||
BOOTIF=${x#BOOTIF=}
|
||||
;;
|
||||
recovery)
|
||||
recovery=y
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "${noresume}" ]; then
|
||||
export noresume
|
||||
unset resume
|
||||
else
|
||||
resume=${RESUME:-}
|
||||
fi
|
||||
|
||||
maybe_break top
|
||||
|
||||
# export BOOT variable value for compcache,
|
||||
# so we know if we run from casper
|
||||
export BOOT
|
||||
|
||||
# Don't do log messages here to avoid confusing graphical boots
|
||||
run_scripts /scripts/init-top
|
||||
|
||||
maybe_break modules
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Loading essential drivers"
|
||||
load_modules
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
[ -n "${netconsole}" ] && modprobe netconsole netconsole="${netconsole}"
|
||||
|
||||
maybe_break premount
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
|
||||
run_scripts /scripts/init-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
maybe_break mount
|
||||
log_begin_msg "Mounting root file system"
|
||||
. /scripts/${BOOT}
|
||||
parse_numeric ${ROOT}
|
||||
maybe_break mountroot
|
||||
mountroot
|
||||
log_end_msg
|
||||
|
||||
maybe_break bottom
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
|
||||
run_scripts /scripts/init-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# Preserve information on old systems without /run on the rootfs
|
||||
if [ -d ${rootmnt}/run ]; then
|
||||
mount -n -o move /run ${rootmnt}/run
|
||||
else
|
||||
# The initramfs udev database must be migrated:
|
||||
if [ -d /run/udev ] && [ ! -d /dev/.udev ]; then
|
||||
mv /run/udev /dev/.udev
|
||||
fi
|
||||
# The initramfs debug info must be migrated:
|
||||
if [ -d /run/initramfs ] && [ ! -d /dev/.initramfs ]; then
|
||||
mv /run/initramfs /dev/.initramfs
|
||||
fi
|
||||
umount /run
|
||||
fi
|
||||
|
||||
# Move virtual filesystems over to the real filesystem
|
||||
mount -n -o move /sys ${rootmnt}/sys
|
||||
mount -n -o move /proc ${rootmnt}/proc
|
||||
|
||||
validate_init() {
|
||||
checktarget="${1}"
|
||||
|
||||
# Work around absolute symlinks
|
||||
if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${checktarget}" ]; then
|
||||
case $(readlink "${rootmnt}${checktarget}") in /*)
|
||||
checktarget="$(chroot ${rootmnt} readlink ${checktarget})"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Make sure the specified init can be executed
|
||||
if [ ! -x "${rootmnt}${checktarget}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Upstart uses /etc/init as configuration directory :-/
|
||||
if [ -d "${rootmnt}${checktarget}" ]; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check init bootarg
|
||||
if [ -n "${init}" ]; then
|
||||
if ! validate_init "$init"; then
|
||||
echo "Target filesystem doesn't have requested ${init}."
|
||||
init=
|
||||
fi
|
||||
fi
|
||||
|
||||
# Common case: /sbin/init is present
|
||||
if [ ! -x "${rootmnt}/sbin/init" ]; then
|
||||
# ... if it's not available search for valid init
|
||||
if [ -z "${init}" ] ; then
|
||||
for inittest in /sbin/init /etc/init /bin/init /bin/sh; do
|
||||
if validate_init "${inittest}"; then
|
||||
init="$inittest"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# No init on rootmount
|
||||
if ! validate_init "${init}" ; then
|
||||
panic "No init found. Try passing init= bootarg."
|
||||
fi
|
||||
fi
|
||||
|
||||
maybe_break init
|
||||
|
||||
# don't leak too much of env - some init(8) don't clear it
|
||||
# (keep init, rootmnt)
|
||||
unset debug
|
||||
unset MODPROBE_OPTIONS
|
||||
unset DPKG_ARCH
|
||||
unset ROOTFLAGS
|
||||
unset ROOTFSTYPE
|
||||
unset ROOTDELAY
|
||||
unset ROOT
|
||||
unset IP
|
||||
unset BOOT
|
||||
unset BOOTIF
|
||||
unset UBIMTD
|
||||
unset blacklist
|
||||
unset break
|
||||
unset noresume
|
||||
unset panic
|
||||
unset quiet
|
||||
unset readonly
|
||||
unset resume
|
||||
unset resume_offset
|
||||
|
||||
# Chain to real filesystem
|
||||
exec run-init ${rootmnt} ${init} "$@" ${recovery:+--startup-event=recovery} <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1
|
||||
panic "Could not execute run-init."
|
||||
264
install_zip/prebuilt/multirom/ubuntu-touch-init/scripts/touch
Normal file
264
install_zip/prebuilt/multirom/ubuntu-touch-init/scripts/touch
Normal file
@@ -0,0 +1,264 @@
|
||||
# Local filesystem mounting -*- shell-script -*-
|
||||
|
||||
pre_mountroot()
|
||||
{
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
|
||||
run_scripts /scripts/local-top
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# Don't wait for a root device that doesn't have a corresponding
|
||||
# device in /dev (ie, mtd0)
|
||||
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
while [ -z "${FSTYPE}" ]; do
|
||||
FSTYPE=$(wait-for-root "${ROOT}" ${ROOTDELAY:-30})
|
||||
|
||||
# Load ubi with the correct MTD partition and return since
|
||||
# fstype doesn't work with a char device like ubi.
|
||||
if [ -n "$UBIMTD" ]; then
|
||||
modprobe ubi mtd=$UBIMTD
|
||||
return
|
||||
fi
|
||||
|
||||
# Run failure hooks, hoping one of them can fix up the system
|
||||
# and we can restart the wait loop. If they all fail, abort
|
||||
# and move on to the panic handler and shell.
|
||||
if [ -z "${FSTYPE}" ] && ! try_failure_hooks; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# We've given up, but we'll let the user fix matters if they can
|
||||
while [ -z "${FSTYPE}" -a ! -e "${ROOT}" ]; do
|
||||
# give hint about renamed root
|
||||
case "${ROOT}" in
|
||||
/dev/hd*)
|
||||
suffix="${ROOT#/dev/hd}"
|
||||
major="${suffix%[[:digit:]]}"
|
||||
major="${major%[[:digit:]]}"
|
||||
if [ -d "/sys/block/sd${major}" ]; then
|
||||
echo "WARNING bootdevice may be renamed. Try root=/dev/sd${suffix}"
|
||||
fi
|
||||
;;
|
||||
/dev/sd*)
|
||||
suffix="${ROOT#/dev/sd}"
|
||||
major="${suffix%[[:digit:]]}"
|
||||
major="${major%[[:digit:]]}"
|
||||
if [ -d "/sys/block/hd${major}" ]; then
|
||||
echo "WARNING bootdevice may be renamed. Try root=/dev/hd${suffix}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "Gave up waiting for root device. Common problems:"
|
||||
echo " - Boot args (cat /proc/cmdline)"
|
||||
echo " - Check rootdelay= (did the system wait long enough?)"
|
||||
echo " - Check root= (did the system wait for the right device?)"
|
||||
echo " - Missing modules (cat /proc/modules; ls /dev)"
|
||||
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
|
||||
done
|
||||
}
|
||||
|
||||
process_ubuntu()
|
||||
{
|
||||
mrom_dir=$1
|
||||
|
||||
if [ -e /tmpmnt/system.img ]; then
|
||||
# Prepare the root filesystem
|
||||
if [ -e /tmpmnt/.developer_mode ]; then
|
||||
echo "initrd: mounting system.img (developer mode)" >/dev/kmsg || true
|
||||
mount -o loop,rw /tmpmnt/system.img ${rootmnt}
|
||||
mountroot_status="$?"
|
||||
else
|
||||
echo "initrd: mounting system.img (user mode)" >/dev/kmsg || true
|
||||
mount -o loop,ro /tmpmnt/system.img ${rootmnt}
|
||||
mountroot_status="$?"
|
||||
fi
|
||||
mount --move /tmpmnt ${rootmnt}/data
|
||||
|
||||
# Create any missing persistent directory
|
||||
for dir in system-data system-data/dbus \
|
||||
system-data/network-manager/connections \
|
||||
system-data/network-manager/lib \
|
||||
system-data/log system-data/log/upstart userdata android-data; do
|
||||
mkdir -p ${rootmnt}/data/$dir
|
||||
done
|
||||
|
||||
# Move some data to persistant storage (first-boot)
|
||||
if [ ! -d ${rootmnt}/data/phablet ]; then
|
||||
cp -Ra ${rootmnt}/home/phablet ${rootmnt}/data/phablet
|
||||
fi
|
||||
|
||||
# Mount all the Android partitions
|
||||
mkdir -p ${rootmnt}/android/cache
|
||||
mkdir -p ${rootmnt}/android/system
|
||||
mount -o bind $mrom_dir/cache ${rootmnt}/android/cache
|
||||
mount -o loop,ro ${rootmnt}/var/lib/lxc/android/system.img ${rootmnt}/android/system
|
||||
|
||||
# Apply device-specific udev rules
|
||||
device=$(grep ^ro.product.device= ${rootmnt}/android/system/build.prop |sed -e 's/.*=//')
|
||||
if [ -n "$device" ]; then
|
||||
echo "initrd: identified device as $device" >/dev/kmsg || true
|
||||
mount --bind ${rootmnt}/usr/lib/lxc-android-config/70-$device.rules ${rootmnt}/lib/udev/rules.d/70-android.rules
|
||||
fi
|
||||
|
||||
# Bind-mount /lib/modules from Android
|
||||
[ -e /system/lib/modules ] && mount --bind /system/lib/modules /lib/modules
|
||||
|
||||
# Bind-mount the fstab
|
||||
mount --bind ${rootmnt}/usr/lib/lxc-android-config/image-fstab ${rootmnt}/etc/fstab
|
||||
elif [ -d /tmpmnt/ubuntu ]; then
|
||||
mount --bind /tmpmnt/ubuntu ${rootmnt}
|
||||
mountroot_status="$?"
|
||||
# Possibly a re-partitioned device
|
||||
else
|
||||
echo "initrd: Couldn't find a system partition." >/dev/kmsg || true
|
||||
panic "Couldn't find a system partition. Spawning adbd ..."
|
||||
fi
|
||||
}
|
||||
|
||||
mountroot()
|
||||
{
|
||||
pre_mountroot
|
||||
|
||||
# Make sure the device has been created by udev before we try to mount
|
||||
udevadm settle
|
||||
|
||||
# Get the root filesystem type if not set
|
||||
if [ -z "${ROOTFSTYPE}" ]; then
|
||||
[ -n "${FSTYPE}" ] || FSTYPE=$(blkid -s TYPE -o value "${ROOT}")
|
||||
ROOTFSTYPE="${FSTYPE}"
|
||||
else
|
||||
FSTYPE=${ROOTFSTYPE}
|
||||
fi
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
|
||||
run_scripts /scripts/local-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
if [ "${readonly}" = "y" ] && \
|
||||
[ -z "$LOOP" ]; then
|
||||
roflag=-r
|
||||
else
|
||||
roflag=-w
|
||||
fi
|
||||
|
||||
# FIXME This has no error checking
|
||||
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
|
||||
|
||||
# FIXME This has no error checking
|
||||
# Mount root
|
||||
mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
|
||||
mountroot_status="$?"
|
||||
if [ "$LOOP" ]; then
|
||||
if [ "$mountroot_status" != 0 ]; then
|
||||
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
|
||||
panic "
|
||||
Could not mount the partition ${ROOT}.
|
||||
This could also happen if the file system is not clean because of an operating
|
||||
system crash, an interrupted boot process, an improper shutdown, or unplugging
|
||||
of a removable device without first unmounting or ejecting it. To fix this,
|
||||
simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
|
||||
gracefully shut down and reboot back into Windows. After this you should be
|
||||
able to reboot again and resume the installation.
|
||||
(filesystem = ${FSTYPE}, error code = $mountroot_status)
|
||||
"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p /host
|
||||
mount -o move ${rootmnt} /host
|
||||
|
||||
if [ ! -d "/host/${LOOP}" ]; then
|
||||
panic "LOOP folder does not exit on the device, ${LOOP}"
|
||||
fi
|
||||
|
||||
# Get the loop filesystem type if not set
|
||||
if [ -z "${LOOPFSTYPE}" ]; then
|
||||
panic "LOOPFSTYPE was not set!"
|
||||
else
|
||||
FSTYPE="${LOOPFSTYPE}"
|
||||
fi
|
||||
|
||||
if [ "$FSTYPE" = "unknown" ]; then
|
||||
panic "LOOPFSTYPE was set to unknown!"
|
||||
fi
|
||||
|
||||
if [ ${readonly} = y ]; then
|
||||
roflag=-r
|
||||
else
|
||||
roflag=-w
|
||||
fi
|
||||
|
||||
# FIXME This has no error checking
|
||||
modprobe loop
|
||||
modprobe ${FSTYPE}
|
||||
|
||||
mkdir -p /tmpmnt
|
||||
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "/host/${LOOP}/data.img" /tmpmnt
|
||||
|
||||
echo "initrd: mounted all loops" >/dev/kmsg || true
|
||||
|
||||
process_ubuntu "/mrom_dir/"
|
||||
|
||||
echo "process_ubuntu complete" >/dev/kmsg || true
|
||||
|
||||
mkdir -p ${rootmnt}/host
|
||||
mount -o move /host ${rootmnt}/host
|
||||
|
||||
mkdir -p ${rootmnt}/mrom_dir/data
|
||||
mkdir -p ${rootmnt}/mrom_dir/system
|
||||
mkdir -p ${rootmnt}/mrom_dir/cache
|
||||
mkdir -p ${rootmnt}/data
|
||||
mkdir -p ${rootmnt}/system
|
||||
|
||||
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "${rootmnt}/host/${LOOP}/system.img" ${rootmnt}/mrom_dir/system
|
||||
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "${rootmnt}/host/${LOOP}/cache.img" ${rootmnt}/mrom_dir/cache
|
||||
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "${rootmnt}/host/${LOOP}/data.img" ${rootmnt}/mrom_dir/data
|
||||
mount -o bind ${rootmnt}/mrom_dir/system ${rootmnt}/system
|
||||
mount -o bind ${rootmnt}/mrom_dir/data ${rootmnt}/data
|
||||
elif [ "$ROOTSUBDIR" ]; then
|
||||
if [ "$mountroot_status" != 0 ]; then
|
||||
panic "
|
||||
Could not mount the partition ${ROOT}.
|
||||
This could also happen if the file system is not clean because of an operating
|
||||
system crash, an interrupted boot process, an improper shutdown, or unplugging
|
||||
of a removable device without first unmounting or ejecting it.
|
||||
(filesystem = ${FSTYPE}, error code = $mountroot_status)
|
||||
"
|
||||
fi
|
||||
|
||||
mkdir -p /host
|
||||
mount -o move ${rootmnt} /host
|
||||
|
||||
if [ ! -d "/host/$ROOTSUBDIR" ]; then
|
||||
panic "Failed to bind folder ${ROOTSUBDIR} as root: folder does not exist."
|
||||
fi
|
||||
|
||||
if [ ! -d "/host/$ROOTSUBDIR/data" ]; then
|
||||
panic "Failed to bind folder ${ROOTSUBDIR}/data: folder does not exist."
|
||||
fi
|
||||
|
||||
mkdir -p /tmpmnt
|
||||
mount -o bind "/host/$ROOTSUBDIR/data" /tmpmnt
|
||||
|
||||
process_ubuntu "/host/$ROOTSUBDIR/"
|
||||
|
||||
mkdir -p ${rootmnt}/host
|
||||
mount -o move /host ${rootmnt}/host
|
||||
|
||||
mrom_dir="${rootmnt}/host/$ROOTSUBDIR"
|
||||
|
||||
mkdir -p ${rootmnt}/system
|
||||
mkdir -p ${rootmnt}/data
|
||||
mkdir -p ${rootmnt}/mrom_dir
|
||||
mount -o bind ${mrom_dir}/system ${rootmnt}/system
|
||||
mount -o bind ${mrom_dir}/data ${rootmnt}/data
|
||||
mount -o bind ${mrom_dir} ${rootmnt}/mrom_dir
|
||||
fi
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
|
||||
run_scripts /scripts/local-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
}
|
||||
44
install_zip/prebuilt/scripts/extract_multirom.sh
Normal file
44
install_zip/prebuilt/scripts/extract_multirom.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/sbin/sh
|
||||
base=""
|
||||
if [ -d "/data/media/multirom" ] ; then
|
||||
base="/data/media/multirom"
|
||||
elif [ -d "/data/media/0/multirom" ] ; then
|
||||
base="/data/media/0/multirom"
|
||||
else
|
||||
if [ -d "/data/media/0" ] ; then
|
||||
base="/data/media/0/multirom"
|
||||
else
|
||||
base="/data/media/multirom"
|
||||
fi
|
||||
|
||||
mkdir "$base"
|
||||
chown root:root "$base"
|
||||
chmod 770 "$base"
|
||||
|
||||
mkdir "$base/roms"
|
||||
chown media_rw:media_rw "$base/roms"
|
||||
chmod 777 "$base/roms"
|
||||
|
||||
touch "$base/.nomedia"
|
||||
chown media_rw:media_rw "$base/.nomedia"
|
||||
|
||||
# remove internal ROM in order to regenerate boot.img
|
||||
rm -r "$base/roms/Internal"
|
||||
fi
|
||||
|
||||
rm "$base/boot.img-ubuntu"*
|
||||
cp -r /tmp/multirom/* "$base/"
|
||||
chmod 755 "$base/multirom"
|
||||
chmod 755 "$base/busybox"
|
||||
chmod 750 "$base/trampoline"
|
||||
chmod 755 "$base/kexec"
|
||||
chmod 755 "$base/ntfs-3g"
|
||||
chmod 755 "$base/ubuntu-init/init"
|
||||
chmod 644 "$base/ubuntu-init/local"
|
||||
chmod 755 "$base/ubuntu-touch-init/init"
|
||||
chmod 644 "$base/ubuntu-touch-init/scripts/touch"
|
||||
|
||||
# This makes does not allows access for media scanner on android, but
|
||||
# still is enough for ubuntu
|
||||
chmod 770 "$base"
|
||||
chown root:root "$base"
|
||||
80
install_zip/prebuilt/scripts/inject_boot.sh
Normal file
80
install_zip/prebuilt/scripts/inject_boot.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/sbin/sh
|
||||
BUSYBOX="/tmp/multirom/busybox"
|
||||
LZ4="/tmp/lz4"
|
||||
BOOT_DEV="$(cat /tmp/bootdev)"
|
||||
|
||||
CMPR_GZIP=0
|
||||
CMPR_LZ4=1
|
||||
|
||||
if [ ! -e "$BOOT_DEV" ]; then
|
||||
echo "BOOT_DEV \"$BOOT_DEV\" does not exist!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
dd if=$BOOT_DEV of=/tmp/boot.img
|
||||
/tmp/unpackbootimg -i /tmp/boot.img -o /tmp/
|
||||
if [ ! -f /tmp/boot.img-zImage ] ; then
|
||||
echo "Failed to extract boot.img"
|
||||
return 1
|
||||
fi
|
||||
|
||||
rm -r /tmp/boot
|
||||
mkdir /tmp/boot
|
||||
|
||||
cd /tmp/boot
|
||||
rd_cmpr=-1
|
||||
magic=$($BUSYBOX hexdump -n 4 -v -e '/1 "%02X"' "../boot.img-ramdisk.gz")
|
||||
case "$magic" in
|
||||
1F8B*) # GZIP
|
||||
$BUSYBOX gzip -d -c "../boot.img-ramdisk.gz" | $BUSYBOX cpio -i
|
||||
rd_cmpr=CMPR_GZIP;
|
||||
;;
|
||||
02214C18) # LZ4
|
||||
$LZ4 -d "../boot.img-ramdisk.gz" stdout | $BUSYBOX cpio -i
|
||||
rd_cmpr=CMPR_LZ4;
|
||||
;;
|
||||
*)
|
||||
echo "invalid ramdisk magic $magic"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ rd_cmpr == -1 ] || [ ! -f /tmp/boot/init ] ; then
|
||||
echo "Failed to extract ramdisk!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# copy trampoline
|
||||
if [ ! -e /tmp/boot/main_init ] ; then
|
||||
mv /tmp/boot/init /tmp/boot/main_init
|
||||
fi
|
||||
cp /tmp/multirom/trampoline /tmp/boot/init
|
||||
chmod 750 /tmp/boot/init
|
||||
|
||||
# crete ueventd symlink
|
||||
if [ -L /tmp/boot/sbin/ueventd ] ; then
|
||||
ln -sf ../main_init /tmp/boot/sbin/ueventd
|
||||
fi
|
||||
|
||||
# pack the image again
|
||||
cd /tmp/boot
|
||||
|
||||
case $rd_cmpr in
|
||||
CMPR_GZIP)
|
||||
find . | $BUSYBOX cpio -o -H newc | $BUSYBOX gzip > "../boot.img-ramdisk.gz"
|
||||
;;
|
||||
CMPR_LZ4)
|
||||
find . | $BUSYBOX cpio -o -H newc | $LZ4 stdin "../boot.img-ramdisk.gz"
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /tmp
|
||||
/tmp/mkbootimg --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz --cmdline "$(cat boot.img-cmdline)" --base $(cat boot.img-base) --output /tmp/newboot.img
|
||||
|
||||
if [ ! -e "/tmp/newboot.img" ] ; then
|
||||
echo "Failed to inject boot.img!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Writing new boot.img..."
|
||||
dd bs=4096 if=/tmp/newboot.img of=$BOOT_DEV
|
||||
return $?
|
||||
BIN
install_zip/prebuilt/scripts/lz4
Executable file
BIN
install_zip/prebuilt/scripts/lz4
Executable file
Binary file not shown.
BIN
install_zip/prebuilt/scripts/mkbootimg
Executable file
BIN
install_zip/prebuilt/scripts/mkbootimg
Executable file
Binary file not shown.
BIN
install_zip/prebuilt/scripts/unpackbootimg
Executable file
BIN
install_zip/prebuilt/scripts/unpackbootimg
Executable file
Binary file not shown.
@@ -1,8 +1,6 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
multirom_local_path := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
trampoline.c \
|
||||
devices.c \
|
||||
|
||||
Reference in New Issue
Block a user