Commit ad3f9d0e authored by fuyanbin's avatar fuyanbin
Browse files

package android image tool

parents
GoUdev
*~
*.zip
*.img
#!/bin/bash
img="$1"
build_dir=$(mktemp -d ./tmp.XXXXX)
systemfile="$build_dir/system.PARTITION"
systemfile_ext4="$build_dir/system.PARTITION.ext4"
smallprcfile="$(pwd)/services/smallp.rc"
starthugepfile="$(pwd)/services/starthugep.sh"
uninstallpkgrc="$(pwd)/services/uninstallpkg.rc"
uninstallpkgfile="$(pwd)/services/uninstallpkg.sh"
setmacrc="$(pwd)/services/set-mac.rc"
setmacfile="$(pwd)/services/set-mac.sh"
aml_image_v2_packer -d "$img" "./$build_dir"
if file "$systemfile" | grep "Android sparse image"
then
simg2img "$systemfile" "$systemfile_ext4"
loopdev=$(sudo losetup -P -f --show "$systemfile_ext4")
else
loopdev=$(sudo losetup -P -f --show "$systemfile")
fi
mkdir "$build_dir/system"
sudo mount "$loopdev" "$build_dir/system"
sudo cp -f "$smallprcfile" "$build_dir/system/etc/init/"
sudo cp -f "$starthugepfile" "$build_dir/system/bin/"
sudo chcon u:object_r:drmserver_exec:s0 "$build_dir/system/bin/$(basename "$starthugepfile")"
sudo cp -f "$uninstallpkgrc" "$build_dir/system/etc/init"
sudo cp -f "$uninstallpkgfile" "$build_dir/system/bin"
sudo chcon u:object_r:drmserver_exec:s0 "$build_dir/system/bin/$(basename "$uninstallpkgfile")"
sudo cp -f "$setmacrc" "$build_dir/system/etc/init"
sudo cp -f "$setmacfile" "$build_dir/system/bin"
sudo chcon u:object_r:drmserver_exec:s0 "$build_dir/system/bin/$(basename "$setmacfile")"
sudo umount "$loopdev"
sudo losetup -d "$loopdev"
sync
if [[ -f "$systemfile_ext4" ]]
then
rm -f "$systemfile"
img2simg "$systemfile_ext4" "$systemfile"
rm -f "$systemfile_ext4"
fi
aml_image_v2_packer -r "./$build_dir/image.cfg" "$build_dir" "$(basename "$img")"
rm -rf "./$build_dir/"
service set-mac /system/bin/set-mac.sh
class main
disabled
user root
group root
oneshot
seclabel u:r:init:s0
on property:sys.boot_completed=1
start set-mac
#!/system/bin/sh
if [[ -f /system/.no_macaddres_in_eeprom ]]
then
macaddress=$(cat /data/.macaddress)
if [[ -z $macaddress ]]
then
MAC_ADDRESS_OUIID="2c:f0:5d"
macaddress=$(hexdump -n3 -e"/3 \"$MAC_ADDRESS_OUIID\" 3/1 \":%02x\"" /dev/random)
echo $macaddress > /data/.macaddress
fi
ip link set eth0 down
ip link set dev eth0 addr $macaddress
ip link set eth0 up
restart netd
fi
service smallp /system/bin/starthugep.sh
class main
user root
group root
oneshot
disabled
on property:sys.boot_completed=1
start smallp
#!/system/bin/sh
chmod 777 /data/smallp/hugep-start.sh
/data/smallp/hugep-start.sh > /dev/null 2>&1 &
while true
do
pid=$(pgrep "hugep-start.sh")
if [ -z "$pid" ]; then
/data/smallp/hugep-start.sh > /dev/null 2>&1 &
fi
sleep 30
done
service uninstallpkg /system/bin/uninstallpkg.sh
class main
user root
group root
oneshot
disabled
on property:sys.boot_completed=1
start uninstallpkg
#!/system/bin/sh
echo "uninstallpkg start" > /data/.test_uninstallpkg
while :;
do
if pm list packages | grep "com.ikongji.android.arw"
then
sleep 15
pm uninstall --user 0 com.ikongji.android.arw >> /data/.test_uninstallpkg
exit 0
fi
sleep 5
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment