2023-09-06 16:47:42 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
WORKDIR=/home/.aliendalvik_systemimg_patch
|
|
|
|
TMPWORKDIR="$WORKDIR/tmp"
|
|
|
|
SQUASHFS_ROOT="$TMPWORKDIR/squashfs-root"
|
2023-09-06 17:18:35 +00:00
|
|
|
SYSTEM_IMG=/opt/alien/system.img
|
2023-09-06 16:47:42 +00:00
|
|
|
|
|
|
|
log() {
|
|
|
|
printf '%s\n' "$1" > /dev/stderr
|
|
|
|
}
|
|
|
|
|
2023-09-06 17:31:46 +00:00
|
|
|
install_deps() {
|
|
|
|
if ! rpm -q squashfs-tools > /dev/null; then
|
|
|
|
log "squashfs-tools package not found. Installing..."
|
|
|
|
pkcon -y install squashfs-tools
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
backup() {
|
|
|
|
orig_image="$WORKDIR/system.img.orig.$(date +%Y%m%dT%H%M%S)"
|
|
|
|
cp "$SYSTEM_IMG" "$orig_image"
|
|
|
|
log "Copying original image $SYSTEM_IMG to $orig_image"
|
|
|
|
}
|
|
|
|
|
2023-09-06 16:47:42 +00:00
|
|
|
extract_image() {
|
|
|
|
|
2023-09-06 17:31:46 +00:00
|
|
|
if [ ! -f "$orig_image" ]; then
|
|
|
|
log "$orig_image not found"
|
2023-09-06 16:47:42 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2023-09-06 17:18:35 +00:00
|
|
|
unsquashfs -dest "$SQUASHFS_ROOT/" "$SYSTEM_IMG"
|
2023-09-06 16:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_patch() {
|
2023-09-06 17:18:35 +00:00
|
|
|
cp nexus.xml "$SQUASHFS_ROOT/system/etc/sysconfig/nexus.xml"
|
|
|
|
cat system.prop >> "$SQUASHFS_ROOT/system/system_ext/build.prop"
|
2023-09-06 16:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_image() {
|
|
|
|
cp "$SYSTEM_IMG" "$TMPWORKDIR/system.img.backup"
|
|
|
|
mksquashfs "$SQUASHFS_ROOT" "$SYSTEM_IMG" -noappend -no-exports -no-duplicates -no-fragments
|
|
|
|
rm "$TMPWORKDIR/system.img.backup"
|
2023-09-06 17:18:35 +00:00
|
|
|
rm -r "$SQUASHFS_ROOT"
|
2023-09-06 16:47:42 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 17:18:35 +00:00
|
|
|
systemctl stop aliendalvik
|
2023-09-06 16:47:42 +00:00
|
|
|
|
|
|
|
mkdir -p "$WORKDIR"
|
|
|
|
mkdir -p "$TMPWORKDIR"
|
|
|
|
|
2023-09-06 17:31:46 +00:00
|
|
|
install_deps
|
|
|
|
backup
|
|
|
|
log "backup done"
|
2023-09-06 16:47:42 +00:00
|
|
|
extract_image
|
|
|
|
log "image was extracted"
|
|
|
|
log "install patch"
|
|
|
|
install_patch
|
|
|
|
log "build image"
|
|
|
|
build_image
|
|
|
|
log "image was built"
|
|
|
|
|
2023-09-06 17:18:35 +00:00
|
|
|
rmdir "$TMPWORKDIR"
|
2023-09-06 16:47:42 +00:00
|
|
|
|
|
|
|
exit 0
|