Skip to content

Commit

Permalink
add uninstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown321 committed Dec 28, 2024
1 parent d94cf4d commit b74ed9e
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ src/Version.h
LICENSE_3rdparty
core..*
hdumpstate*
release/
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,33 @@ nw-installer/installer/userdata.tar: LICENSE_3rdparty qr.bmp
server:
$(MAKE) -C server

uninstaller:
$(MAKE) -C nw-installer prepare
cat LICENSE LICENSE_3rdparty > nw-installer/installer/windows/LICENSE.txt.user
tar -C uninstaller -cf nw-installer/installer/userdata.tar \
run.sh

release-clean:
$(MAKE) -C nw-installer OUTFILE=$(PRODUCT).exe APPNAME=$(PRODUCT) clean
-rm -rf release

release: release-clean build-arm server cassetteunpacker/res nw-installer/installer/userdata.tar
$(MAKE) -C nw-installer OUTFILE=$(PRODUCT).exe APPNAME=$(PRODUCT)
mkdir -p release/installer/
cd nw-installer/installer/stock/ && tar -czvf stock.tar.gz NW_WM_FW.UPG
cd nw-installer/installer/walkmanOne/ && tar -czvf walkmanOne.tar.gz NW_WM_FW.UPG
mv nw-installer/installer/walkmanOne/walkmanOne.tar.gz release/installer
mv nw-installer/installer/stock/stock.tar.gz release/installer
mv nw-installer/installer/windows/${PRODUCT}.exe release/installer
$(MAKE) -C nw-installer OUTFILE=$(PRODUCT).uninstaller.exe APPNAME=$(PRODUCT)-uninstaller clean
$(MAKE) uninstaller
$(MAKE) -C nw-installer OUTFILE=$(PRODUCT).uninstaller.exe APPNAME=$(PRODUCT)-uninstaller build
mkdir -p release/uninstaller
cd nw-installer/installer/stock/ && tar -czvf stock.uninstaller.tar.gz NW_WM_FW.UPG
cd nw-installer/installer/walkmanOne/ && tar -czvf walkmanOne.uninstaller.tar.gz NW_WM_FW.UPG
mv nw-installer/installer/walkmanOne/walkmanOne.uninstaller.tar.gz release/uninstaller
mv nw-installer/installer/stock/stock.uninstaller.tar.gz release/uninstaller
mv nw-installer/installer/windows/${PRODUCT}.uninstaller.exe release/uninstaller

# see also: `perf record` && `perf report`
profile:
Expand Down Expand Up @@ -150,4 +170,4 @@ qr.bmp:
@convert qr.png -type palette qr.bmp
@rm qr.png

.PHONY: build build-arm docker push profile profile-arm valgrind deps release release-clean LICENSE_3rdparty server
.PHONY: build build-arm docker push profile profile-arm valgrind deps release release-clean LICENSE_3rdparty server uninstaller
14 changes: 14 additions & 0 deletions installer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ install() {
busybox chown -h ${user}:${group} /system/vendor/sony/lib/libprotobuf.so.32

log "installing server"
test -f /system/vendor/sony/plugins/platforms/libqeglfs.so_vendor
if test $? -ne 0; then
# make sure this file is from SONY (not linked to libprotobuf)
busybox grep -q protobuf /system/vendor/sony/plugins/platforms/libqeglfs.so
if test $? -eq 1; then
log "backing up libqeglfs"
busybox cp -p /system/vendor/sony/plugins/platforms/libqeglfs.so /system/vendor/sony/plugins/platforms/libqeglfs.so_vendor
else
log "libqeglfs is linked to libprotobuf, not backing up"
fi
else
log "libqeglfs backup already exists"
fi

cp libqeglfs.so /system/vendor/sony/plugins/platforms/
chown root:shell /system/vendor/sony/plugins/platforms/libqeglfs.so
chmod 0755 /system/vendor/sony/plugins/platforms/libqeglfs.so
Expand Down
69 changes: 69 additions & 0 deletions uninstaller/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/sh
VENDOR=/system/vendor/unknown321/
BINARY=wampy
user=system
group=system

log()
{
oldIFS=$IFS
IFS="
"
for line in $(echo "${1}"); do
echo "$(date) ${line}" >> $LOG_FILE
done
IFS=$oldIFS
}

uninstall() {
log "removing ${BINARY}"
busybox rm -f ${VENDOR}/bin/${BINARY}

log "uninstalling ${BINARY} service"
grep -q "init.${BINARY}.rc" "${INITRD_UNPACKED}/init.rc"
if test $? -eq 0; then
log "removing service"
busybox sed -i "/import init.${BINARY}.rc/d" ${INITRD_UNPACKED}/init.rc
fi
busybox rm -f ${INITRD_UNPACKED}/init.${BINARY}.rc

log "removing libraries"
busybox rm -f ${VENDOR}/lib/libMagick++-7.Q8HDRI.so
busybox rm -f ${VENDOR}/lib/libMagickCore-7.Q8HDRI.so
busybox rm -f ${VENDOR}/lib/libMagickWand-7.Q8HDRI.so

busybox rm -f ${VENDOR}/lib/libjpeg.so.62.4.0
busybox rm -f ${VENDOR}/lib/libjpeg.so.62

log "uninstalling server"
busybox test -f /system/vendor/sony/plugins/platforms/libqeglfs.so_vendor
if busybox test $? -eq 0; then
# make sure backup is from SONY (not linked to libprotobuf)
busybox grep -q protobuf /system/vendor/sony/plugins/platforms/libqeglfs.so_vendor
if busybox test $? -eq 1; then
log "restoring libqeglfs from backup"
busybox cp -f /system/vendor/sony/plugins/platforms/libqeglfs.so_vendor /system/vendor/sony/plugins/platforms/libqeglfs.so
chown root:shell /system/vendor/sony/plugins/platforms/libqeglfs.so
chmod 0755 /system/vendor/sony/plugins/platforms/libqeglfs.so

log "removing protobuf lib"
busybox rm -f ${VENDOR}/lib/libprotobuf.so.32.0.12
busybox rm -f ${VENDOR}/lib/libprotobuf.so.32
busybox rm -f /system/vendor/sony/lib/libprotobuf.so.32
else
log "backup file is linked to libprotobuf, not restoring"
fi
else
log "no valid libqeglfs backup found, leaving as is"
fi

log "removing skins, licenses, qr code"
busybox rm -rf ${VENDOR}/usr/share/${BINARY}/
}

mount -t ext4 -o rw /emmc@android /system

uninstall

sync
umount /system

0 comments on commit b74ed9e

Please sign in to comment.