casualsnek / waydroid_script

Python Script to add OpenGapps, Magisk, libhoudini translation library and libndk translation library to waydroid !
GNU General Public License v3.0
1.53k stars 147 forks source link

[enhancement] add an option to remove libndk/libhoudini #49

Open ghost opened 1 year ago

ghost commented 1 year ago

I accidently insatlled both libndk and libhoudini and now I can't run waydroid. It would be better in i could remove any of them through the script.

ayasa520 commented 1 year ago

https://github.com/ayasa520/waydroid_script/commit/fa8d6c23b03833fb58893c7637270d5c3568e1bf After further improvement, I will create PR

casualsnek commented 1 year ago

ayasa520@fa8d6c2 After further improvement, I will create PR

Maybe we could track the file during installation file and save them ? It will be easier to remove the file from package that got updated while the user had older installed ! Maintenance may also be easier as we won't have to make a list of files that got changed after a package update ! For clean uninstallation of houdini and other stuff using props, a unset_props method in general that takes each keys of app_props dict and does re.sub(f'^{prop_key}.*$', '', current_prop) would be enough too !

def unset_props(self):
    with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "r") as propfile:
        prop_content = propfile.read()
        for key in self.apply_props:
            prop_content = re.sub(f'^{key}.*$', '', prop_content) # We may need to save value if prop already existed during install and we have backup for it's key/value and set the second parameter of re.sub to "  f'{key}:{old_value}'  "
    with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "w") as propfile:
        propfile.write(prop_content)
ayasa520 commented 1 year ago

Maybe we could track the file during installation file and save them

If this saved file is accidentally deleted, the user will not be able to complete the uninstallation.

For clean uninstallation of houdini and other stuff using props, a unset_props method in general that takes each keys of app_props dict and does re.sub(f'^{prop_key}.*$', '', current_prop) would be enough too !

Yea, I did add this method. https://github.com/ayasa520/waydroid_script/blob/200e18bb0d03ce1cbdd88e9b28a95b8b2d526f80/stuffs/general.py#L74-L82

/system/etc/init/xxx.rc will still be executed after clearing the key-value pairs in prop file, so I think it's better to delete it completely