Skip to content

Instantly share code, notes, and snippets.

@griffi-gh
Created September 9, 2024 13:35
Show Gist options
  • Save griffi-gh/92c7aee52ccdee9dcf408d1fcb056294 to your computer and use it in GitHub Desktop.
Save griffi-gh/92c7aee52ccdee9dcf408d1fcb056294 to your computer and use it in GitHub Desktop.
galaxy-watch-app-dump.nu
#!/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/apps) | 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