Last active
February 9, 2025 14:53
-
-
Save griffi-gh/92c7aee52ccdee9dcf408d1fcb056294 to your computer and use it in GitHub Desktop.
galaxy-watch-app-dump.nu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nu | |
let sdb = $"($env.HOME)/tizen-studio/tools/sdb" | |
def sdb-is-connected [] { | |
(^$sdb shell whoami) | str contains "owner" | |
} | |
def sdb-list-apps [] { | |
(^$sdb shell ls /opt/usr/globalapps -1) | lines | |
} | |
def sdb-pull [path: string, dest: string] { | |
(^$sdb pull $path $dest) | |
} | |
def main [] { | |
echo "Usage: backup_app.nu [list|dump <app>]" | |
} | |
def "main dump" [ | |
app: string, | |
--tpk | |
] { | |
if not (sdb-is-connected) { | |
echo "Not connected to device" | |
exit | |
} | |
echo "Dumping $app" | |
mkdir $app | |
cd $app | |
# Some apps are seemingly installed in different directories? | |
# "Normal" apps have copies in app_global, system apps are seemingly only available in app_usr/app_owner??? | |
# we only care about the globalapps directory for now | |
# let app_owner = $"/opt/usr/home/owner/apps_rw/($app)" | |
# let app_usr = $"/opt/usr/apps/($app)" | |
let app_global = $"/opt/usr/globalapps/($app)" | |
sdb-pull $app_global . | |
if ($tpk) { | |
echo "Creating TPK" | |
let zip_name = $"./../($app).tpk" | |
^zip -r $zip_name ./* | |
cd .. | |
rm -r $app | |
} else { | |
cd .. | |
} | |
echo "Done" | |
} | |
def "main list" [] { | |
if not (sdb-is-connected) { | |
echo "Not connected to device" | |
exit | |
} | |
echo (sdb-list-apps) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment