shim builder (works on grunt)
This commit is contained in:
parent
692add0021
commit
01350f0001
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -6,6 +6,7 @@
|
||||
|
||||
// this setting isn't "unknown", its just for troubleshooting,
|
||||
// but it fixes the vscode.dev cursor on ChromeOS.
|
||||
"editor.disableMonospaceOptimizations": true
|
||||
"editor.disableMonospaceOptimizations": true,
|
||||
"makefile.configureOnOpen": false
|
||||
|
||||
}
|
23
Makefile
23
Makefile
@ -10,8 +10,14 @@ KVSFLIST := \
|
||||
src/KVS/hex_utils.c
|
||||
|
||||
TOOLS := \
|
||||
is_ti50
|
||||
|
||||
TOOL_SRC := \
|
||||
src/tools/is_ti50.c
|
||||
|
||||
TOOL_OBJS := $(patsubst src/tools/%.c,build/$(ARCH)/tools/%.o,$(TOOL_SRC))
|
||||
TOOL_BINS := $(patsubst %,build/$(ARCH)/tools/%,$(TOOLS))
|
||||
|
||||
CFLAGS := \
|
||||
-Iinclude \
|
||||
-g \
|
||||
@ -30,15 +36,24 @@ endif
|
||||
|
||||
TARGET = ${ARCH}-unknown-linux-${TOOLCHAIN}
|
||||
|
||||
all: clean build kvs kvg
|
||||
all: clean build kvs kvg tools
|
||||
|
||||
kvs: build build/$(ARCH)/bin/kvs
|
||||
kvg: build build/$(ARCH)/bin/kvg
|
||||
tools: build build/bin
|
||||
kvg-c: build build/$(ARCH)bin/kvg-c
|
||||
|
||||
tools: build $(TOOL_BINS)
|
||||
|
||||
build/$(ARCH)/tools/%: build/$(ARCH)/tools/%.o
|
||||
$(CC) $(LDFLAGS) -static -o $@ $<
|
||||
mv $@ build/$(ARCH)/bin/
|
||||
rm -rf build/$(ARCH)/tools
|
||||
|
||||
build/$(ARCH)/tools/%.o: src/tools/%.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
build:
|
||||
$(shell mkdir -p build/$(ARCH)/bin)
|
||||
mkdir -p build/$(ARCH)/bin
|
||||
mkdir -p build/$(ARCH)/tools
|
||||
|
||||
build/$(ARCH)/bin/kvs: src/KVS/main.c
|
||||
$(CC) $(KVSFLIST) -o build/$(ARCH)/bin/kvs $(CFLAGS)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
VERSION=1
|
||||
VERSION=2.0.0
|
||||
|
||||
HOST_ARCH=$(lscpu | grep Architecture | awk '{print $2}')
|
||||
if [ $HOST_ARCH == "x86_64" ]; then
|
||||
|
@ -155,8 +155,7 @@ create_stateful(){
|
||||
log "Creating KVS/Stateful Partition"
|
||||
local final_sector=$(get_final_sector "$LOOPDEV")
|
||||
local sector_size=$(get_sector_size "$LOOPDEV")
|
||||
# special UUID is from grunt shim, dunno if this is different on other shims
|
||||
"$CGPT" add "$LOOPDEV" -i 1 -b $((final_sector + 1)) -s $((STATE_SIZE / sector_size)) -t "9CC433E4-52DB-1F45-A951-316373C30605"
|
||||
"$CGPT" add "$LOOPDEV" -i 1 -b $((final_sector + 1)) -s $((STATE_SIZE / sector_size)) -t data
|
||||
partx -u -n 1 "$LOOPDEV"
|
||||
suppress mkfs.ext4 -F -L KVS "$LOOPDEV"p1
|
||||
safesync
|
||||
@ -168,7 +167,8 @@ inject_stateful(){
|
||||
echo "Mounting stateful.."
|
||||
mount "$LOOPDEV"p1 "$STATE_MNT"
|
||||
echo "Copying files.."
|
||||
cp -r $SCRIPT_DIR/stateful/* "$STATE_MNT"
|
||||
mkdir -p "${STATE_MNT}/dev_image/etc"
|
||||
touch "${STATE_MNT}/dev_image/etc/lsb-factory"
|
||||
umount "$STATE_MNT"
|
||||
}
|
||||
|
||||
@ -195,14 +195,42 @@ shrink_root() {
|
||||
partx -u -n 3 "$LOOPDEV"
|
||||
}
|
||||
|
||||
detect_arch() {
|
||||
MNT_ROOT=$(mktemp -d)
|
||||
mount -o ro "${LOOPDEV}p3" "$MNT_ROOT"
|
||||
|
||||
TARGET_ARCH=x86_64
|
||||
if [ -f "$MNT_ROOT/bin/bash" ]; then
|
||||
case "$(file -b "$MNT_ROOT/bin/bash" | awk -F ', ' '{print $2}' | tr '[:upper:]' '[:lower:]')" in
|
||||
# for now assume arm has aarch64 kernel
|
||||
# this only assumes since theres no armv7 (arm32) shims leaked
|
||||
*aarch64* | *armv8* | *arm*) TARGET_ARCH=aarch64 ;;
|
||||
esac
|
||||
fi
|
||||
echo "Detected architecture: $TARGET_ARCH"
|
||||
|
||||
umount "$MNT_ROOT"
|
||||
rmdir "$MNT_ROOT"
|
||||
}
|
||||
|
||||
inject_root(){
|
||||
log "Injecting ROOT-A Partition"
|
||||
detect_arch
|
||||
|
||||
echo "Mounting root.."
|
||||
suppress enable_rw_mount "$LOOPDEV"p3
|
||||
suppress mount "$LOOPDEV"p3 "$ROOT_MNT"
|
||||
echo "Copying files.."
|
||||
suppress cp -r "$SCRIPT_DIR"/root/* "$ROOT_MNT"
|
||||
cp -r "$SCRIPT_DIR/../build/$TARGET_ARCH/." "$ROOT_MNT"
|
||||
suppress cp -r "$SCRIPT_DIR/root/factory_install.sh" "$ROOT_MNT/usr/sbin/factory_install.sh"
|
||||
mkdir -p "$ROOT_MNT"/opt/kvs/bin
|
||||
mv "$ROOT_MNT"/bin/is_ti50 "$ROOT_MNT"/opt/kvs/bin/is_ti50
|
||||
echo 'export PATH=$PATH:/opt/kvs/bin' >> "$ROOT_MNT"/root/.bashrc
|
||||
|
||||
echo "Removing tcsd & trunksd.."
|
||||
rm -rf "$ROOT_MNT"/etc/init/tcsd.conf
|
||||
rm -rf "$ROOT_MNT"/etc/init/trunksd.conf
|
||||
|
||||
echo "$(date +'%m-%d-%Y %I:%M%p %Z')" > "$ROOT_MNT"/DATE_COMPILED
|
||||
suppress umount "$ROOT_MNT"
|
||||
}
|
||||
|
11
shim-builder/root/factory_install.sh
Executable file
11
shim-builder/root/factory_install.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
setterm -cursor on
|
||||
|
||||
chmod +rx /bin/kvs
|
||||
chmod +rx /bin/kvg
|
||||
|
||||
/bin/kvs
|
||||
|
||||
reboot now
|
||||
sleep 1d
|
Loading…
x
Reference in New Issue
Block a user