Difference between revisions of "Solution to App Catalog Installation Limit"

From WebOS Internals
Jump to navigation Jump to search
Line 16: Line 16:
  
 
<pre>
 
<pre>
 
 
 
#!/bin/sh
 
#!/bin/sh
  
 
# This code is open for re-use with no restrictions.  xorg
 
# This code is open for re-use with no restrictions.  xorg
  
# Usage: mvapp com.org.appname - mvapp app to destination
+
# Usage: mvapp link com.org.appname - mvapp app to destination and create link
# Usage: mvapp list - list all apps sorted by size
+
# Usage: mvapp unlink                - not implemented yet
 +
# Usage: mvapp list                 - list all apps sorted by size
  
APP=$1
+
COMMAND=$1
 +
APP=$2
 
# can change destination to anything you want, but use a leading . - props to emoney_33
 
# can change destination to anything you want, but use a leading . - props to emoney_33
 
DEST=/media/internal/.apps
 
DEST=/media/internal/.apps
 
ORG=/var/usr/palm/applications
 
ORG=/var/usr/palm/applications
  
cd $ORG
 
  
case $APP in
+
 
"")
+
#-------------------------------------------------------------------------#
  echo "Usage: mvapp com.org.appname - mvapp app to destination"
+
# function listapps - list the size of each app, sort showing largest last
  echo "Usage: mvapp list - list all apps sorted by size"
+
#-------------------------------------------------------------------------#
  exit 1
+
listapps () {
  ;;
 
"list")
 
  # list app directory with size, props to daventx
 
 
   du -s $ORG/* | sort -n
 
   du -s $ORG/* | sort -n
 
   exit 0
 
   exit 0
  ;;
+
}  # end of listapps function
esac
+
 
 +
 
 +
#-------------------------------------------------------------------------#
 +
# function linkapp - move the app to destination and create symbolic link
 +
#-------------------------------------------------------------------------#
 +
linkapp () {
 +
 
 +
cd $ORG
  
if [ -d $DEST ]
+
if [ ! -d $DEST ]
then
+
then
  echo "Destination directory exists..."
+
      mkdir $DEST
else
+
fi
  mkdir $DEST
 
fi
 
  
if [ -h $APP ]
+
if [ -h $ORG/$APP ]
then
+
then
  echo "Link already exists for... ${APP}"
+
      echo "Link already exists for... ${APP}"
  exit 10
+
      exit 1
fi
+
fi
  
if [ -d $APP ]
+
if [ -d $ORG/$APP ]
then
+
then
  echo "Moving $APP to $DEST..."
+
  echo "Moving $APP to $DEST..."
else
+
else
  echo "Not a valid application directory."
+
  echo "Not a valid application directory."
  echo "Usage: mvapp com.org.appname "
+
  echo "Usage: mvapp link com.org.appname "
  echo "Usage: mvapp list"
+
  echo "Usage: mvapp list"
  exit 11
+
  exit 2
fi
+
fi
  
mount -o remount,rw /
+
mount -o remount,rw /
  
cd $ORG
+
cd $ORG
echo "Size of $ORG before move... "
+
echo "Size of $ORG before move... "
du -sh .
+
du -sh .
  
# move over to USB drive
+
# move over to USB drive
cp -r  $ORG/$APP $DEST
+
cp -r  $ORG/$APP $DEST
if [ $? != 0 ]
+
if [ $? != 0 ]
then
+
then
 
   echo "Copy failed. Leaving app in $ORG."
 
   echo "Copy failed. Leaving app in $ORG."
   exit 12
+
   exit 3
fi
+
fi
  
rm -r $ORG/$APP
+
rm -r $ORG/$APP
if [ $? != 0 ]
+
if [ $? != 0 ]
then
+
then
 
   echo "Remove failed. Leaving app in $ORG."
 
   echo "Remove failed. Leaving app in $ORG."
 
   rm -r $DEST/$APP
 
   rm -r $DEST/$APP
   exit 13
+
   exit 4
fi
+
fi
 +
 
 +
# create the symbolic link
 +
ln -s $DEST/$APP $ORG/$APP
 +
 
 +
# rescan luna in case it's needed
 +
luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1
 +
 
 +
echo "$APP moved and linked."
 +
echo "Size of $ORG after move... "
 +
du -sh .
 +
}
 +
# end of linkapp function
 +
 
  
# create the symbolic link
+
#-------------------------------------------------------------------------#
ln -s $DEST/$APP $ORG/$APP
+
# function unlinkapp -  not implemented yet
 +
#-------------------------------------------------------------------------#
 +
unlinkapp () {
 +
echo "Not implemented yet."
 +
}
  
  
# rescan luna in case it's needed
+
#-------------------------------------------------------------------------#
luna-send -n 1 palm://com.palm.applicationManager/rescan {}  >/dev/null 2>&1
+
# Script Begins Here
 +
#-------------------------------------------------------------------------#
  
echo "$APP moved and linked."
+
case $COMMAND in
echo "Size of $ORG after move... "
+
"list")
du -sh .
+
  listapps
 +
  ;;
 +
"link")
 +
  linkapp
 +
  ;;
 +
"unlink")
 +
  unlinkapp
 +
  ;;
 +
*)
 +
  echo "Usage: mvapp link com.org.appname  - move app and link to destination"
 +
  echo "Usage: mvapp unlink com.org.appname - not implemented yet"
 +
  echo "Usage: mvapp list                  - list all apps sorted by size"
 +
  exit 1
 +
  ;;
 +
esac
  
exit 0
 
  
 
</pre>
 
</pre>

Revision as of 19:48, 2 October 2009

Based on rwhitby's findings that temporarily moving /var/usr/palm/applications will allow installing apps from the App Catalog, here's a permanent way to keep the apps on (much larger) /media/internal by using links. This will permanently save space on /var.

It's unfortunate that Palm has not resolved the issue in the 1.2 update. This is a workaround that could work long term, also saving space on /var, but this needs support by the homebrew community to add in the homebrew installer apps.

Overview

This solution involves creating a (hidden) directory in the /media/internal area, moving selected applications to the newly created directory, and then creating a symbolic link in the /var/usr/palm/applications directory pointing to the new location. This frees up the disk space from the relatively limited /var volume to the larger /media/internal. The included script (which must be created) will move the files and create the appropriate link. It will also provide information on the size of the applications stored in the /var/usr/palm/applications directory.

Solution (symbolic link method)

- create a script to move apps to new home and create link

mount -o remount,rw /

vi /usr/bin/mvapp


#!/bin/sh

# This code is open for re-use with no restrictions.  xorg

# Usage: mvapp link com.org.appname  - mvapp app to destination and create link
# Usage: mvapp unlink                - not implemented yet
# Usage: mvapp list                  - list all apps sorted by size

COMMAND=$1
APP=$2
# can change destination to anything you want, but use a leading . - props to emoney_33
DEST=/media/internal/.apps
ORG=/var/usr/palm/applications



#-------------------------------------------------------------------------#
# function listapps - list the size of each app, sort showing largest last
#-------------------------------------------------------------------------#
listapps () {
   du -s $ORG/* | sort -n
   exit 0
}  # end of listapps function


#-------------------------------------------------------------------------#
# function linkapp - move the app to destination and create symbolic link
#-------------------------------------------------------------------------#
linkapp () {

 cd $ORG

 if [ ! -d $DEST ]
 then
      mkdir $DEST
 fi

 if [ -h $ORG/$APP ]
 then
      echo "Link already exists for... ${APP}"
      exit 1
 fi

 if [ -d $ORG/$APP ]
 then
   echo "Moving $APP to $DEST..."
 else
   echo "Not a valid application directory."
   echo "Usage: mvapp link com.org.appname "
   echo "Usage: mvapp list"
   exit 2
 fi

 mount -o remount,rw /

 cd $ORG
 echo "Size of $ORG before move... "
 du -sh .

 # move over to USB drive
 cp -r  $ORG/$APP $DEST
 if [ $? != 0 ]
 then
  echo "Copy failed. Leaving app in $ORG."
  exit 3
 fi

 rm -r $ORG/$APP
 if [ $? != 0 ]
 then
  echo "Remove failed. Leaving app in $ORG."
  rm -r $DEST/$APP
  exit 4
 fi

 # create the symbolic link
 ln -s $DEST/$APP $ORG/$APP

 # rescan luna in case it's needed
 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1

 echo "$APP moved and linked."
 echo "Size of $ORG after move... "
 du -sh .
}
# end of linkapp function


#-------------------------------------------------------------------------#
# function unlinkapp -  not implemented yet
#-------------------------------------------------------------------------#
unlinkapp () {
 echo "Not implemented yet."
}


#-------------------------------------------------------------------------#
# Script Begins Here
#-------------------------------------------------------------------------#

case $COMMAND in
"list")
   listapps
   ;;
"link")
   linkapp
   ;;
"unlink")
   unlinkapp
   ;;
*)
   echo "Usage: mvapp link com.org.appname   - move app and link to destination"
   echo "Usage: mvapp unlink com.org.appname - not implemented yet"
   echo "Usage: mvapp list                   - list all apps sorted by size"
   exit 1
   ;;
esac




chmod 777 /usr/bin/mvapp

To use, find the largest apps in /var/usr/palm/applications...

mvapp list

It shows the largest apps last... IE....
8352 com.apnews.webos
8512 com.fandango.app.fandango
8672 com.palm.app.musicplayerremix
10304 com.shortcovers.palm.pre
10432 com.fusioncreativestudios.deadman
10656 com.ulocate.app.where
To move com.ulocate.app.where, use the script...

mvapp com.ulocate.app.where

It should now work in the new location thanks to the link. Test each app to make sure it works before doing another. I don't recommend looping the script to do every app in the dir or to link the entire app dir. File attributes are lost on the move, which some apps may need. You need to test each app after a move.

Contingency Plan

If you have issues with an app, remove it completely and reinstall through the respective app catalog or homebrew installer app.

Proposal

Would like to propose that PreWare, WebOS Quick Install and other Pre installer apps provide an option to move any app in /var to the /media fs and create a link per the code above. Also provide option to move back. Could make a backup retaining file attributes using tar and restore that way.

Risks, Issues, Dependencies

- File attributes of linux fs are not copied over to fat fs. May not work with apps that rely on file attributes.

- Jason Robitaille has indicated that a future version of WebOS Quick Install will include a routine to resize the /var partition. He has also indicated that doing so will wipe the /media/internal area, so any applications stored there would need to be backed up first. It might be good to be able to reverse the process of this soulution. This could be done either by adding to this mvapp script, or cerating a new one.

Discuss

Discuss in the Discussion tab or PreCentral...

http://forums.precentral.net/web-os-development/205649-resolution-app-catalog-install-limit-proposal.html