maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Download apps to harddrive (https://talk.maemo.org/showthread.php?t=59228)

linuxeventually 2010-08-02 05:14

Re: Download apps to harddrive
 
1 Attachment(s)
EDIT: FIXED. Current version is 0.7 (Changelog: line 13 had a hardcode for sda2 and line 10 wasn't copying correctly so I split it)

Yeah the first line of the script lets you easily change the location of the SD card. Well the physical location of the partitions is usually very handy but in this case you need the mount point. Something like changing sdhc="/media/mmc1" to sdhc="/media/mmc2" would do the trick.

Don't worry finding the mountpoint is easy.
Code:

$ partmount() { df -h | grep /dev/$1 | awk '{ print $6}'; }
$ partmount mmcblk1p1

The output is the mount point for your microsd card. It should be /media/mmc2 or thereabouts.

Or you could just use the modified script (defaults to wherever /dev/mmcblk1p1 is mounted but prompts anyway, you can just hit enter):
Code:

#!/bin/bash
##########################################
# savedebz by Linux Eventually ver 0.7 ###
##########################################
# SD card install location
unset sdhc
unset partition
##sdhc="/media/mmc1"
read -p "Which partition on the SD \
card (default: mmcblk1p1)?: " partition;
sdhc=`df -h | grep /dev/$partition | awk '{ print $6 }'`;

if [ -z "$partition" ];
then sdhc=`df -h | grep /dev/mmcblk1p1 | awk '{ print $6 }'`;
fi
sdmount=`echo $sdhc`
mountmsg=`echo "Mountpoint:"`
sdmsg=`echo $mountmsg $sdmount`
echo  $sdmsg

# Install packages back to Nokia Internet Tablet
if [ "$1" = "install" ];
then echo "Install packages from SD card to NXx0?";
read -p "Are you sure? (y/n): " confirminstall
fi
  if [ "$confirminstall" = "y" ]; then
  echo "Installing ... (this will take awhile)"
  debzinstall() { alldebz=`cat $sdhc/installdebz`; apt-get -o dir::cache=$sdhc/debz install $alldebz; }
  debzinstall
  echo "debz installation complete"
  exit 0
    else if [ "$confirminstall" = "n" ]; then
    echo "Installation not selected. Exiting."; exit 0
      else if [ ! -z "$confirminstall" ]; then echo "Invalid selection"; exit 0
    fi
  fi
fi

# If invalid parameter then quit
if [ ! -z "$1" ];
then echo "ERROR Invalid parameter"
echo "Valid options are none or install"
exit 0
fi

# Ask user to execute script
if [ -z "$1" ]; then
echo "Download packages to SD card?";
read -p "Are you sure? (y/n): " confirmbackup
  if [ "$confirmbackup" = "y" ]; then
  echo "Installing ... (this will take awhile)"
    else if [ "$confirmbackup" = "n" ]; then
    echo "Download not selected. Exiting."; exit 0
  else echo "Invalid selection"; exit 0
  fi
fi
fi

# Create directory on SD card
if [ ! -d "$sdhc/debz/archives" ];
then
mkdir $sdhc/debz{,/archives}
cp -r /var/cache/apt/archives/partial/ $sdhc/debz/archives/
fi

# Save list of installed packages
dpkg -l | grep ii | awk '{ print $2 }' > $sdhc/alldebz;

# Save list of packages on SD
ls $sdhc/debz/archives/ | awk 'BEGIN{FS="_"};{print$1}' > $sdhc/debzsd;

# Compare files (to save bandwidth)
cd $sdhc
###########
## pdiff ##
###########
perl <<'EOF'
$output = newdebz;
chomp($output);
open a, "<alldebz";
open b, "<debzsd";
local $/;
my @a = split /\n/, <a>;
my @b = split /\n/, <b>;
my %b = map { $_ => 1 } @b; # Make hash of B
my @res = grep { !defined $b{$_} } @a; # Everything in A not in B
open myoutput, ">$output";
select myoutput;
print join "\n", @res;
print "\n";
EOF
###########

# Convert line breaks to spaces
foobar=`cat $sdhc/newdebz`; echo $foobar > $sdhc/installdebz
pkgz=`cat $sdhc/installdebz`

# Re-download packages and save them to SD card
apt-get -o dir::cache=$sdhc/debz --reinstall -d install $pkgz

echo "Finished."

Again run this as root.

linuxeventually 2010-08-02 10:38

[ANNOUNCE] SaveDEBz
 
Current version is 0.9
* Now available in extras-devel (Fremantle, Diablo, Chinook)! :D

The savedebz script has no major bugs that I am aware of. Need to do a real-world test tomorrow.

Introducing zsavedebz, utilizing a simple zenity GUI it has the same functionality as savedebz.

zsavedebz has a couple minor bugs that I'll fix tomorrow.
* Zenity window sizes are too small
* Need to grep -v the virtual mountpoints from the dialog

TODO LIST:
* Better documentation
* Better description
* Icon and/or .desktop file(s) for zsavedebz
* Add check for root to both scripts using UID

After that, I'll check things over a few times (and get testers?) then I'll promote to extras.

USAGE:
Backup/Download
Code:

$ sudo savedebz
Follow directions from there

Restore/Install
Code:

$ sudo savedebz install
----------

Backup/Download
Code:

$ sudo zsavedebz
Follow popup questions and alerts

Restore/install
Code:

$ sudo zsavedebz install
It should install and work on any Debian-based system (of any arch), I'll test it with Ubuntu tomorrow.

Coffee 2010-08-03 05:22

Re: Download apps to harddrive
 
Linuxeventually,
I tried it mate and still got an error, something about not being able to create the folder and access the card. That said, I do have items on my card in the location, files I think. Something like newdebz, all debz etc. I ran the mounting code and returned "media/mmc1"
Q. Do I run this before I start downloading or after, silly question I am sure and expect after though just checking.

Stephen

Coffee 2010-08-03 05:23

Re: Download apps to harddrive
 
I created the folders myself and then ran it and still didn't work correctly.
Got the whole, installing, reading packages list, building dependency tree, stat info, then....
E: Handler silently failed
Finished.

I don't know why, in xterm I couldn't mkdir /media/mmc1/debz
though in file explorer I could create a folder. Anyway, just my feedback. I will flash it now and then try again.

linuxeventually 2010-08-03 10:29

Re: Download apps to harddrive
 
Yeah sorry, hold on. I didn't get to work on it today and I tested it on a clean install and the script is borked. Not sure if it's the lack of BASH or if it's something I changed. Working on it now =\

0.9 is not stable. Sorry. Unforseen bugs

Coffee 2010-08-03 21:58

Re: Download apps to harddrive
 
Not a problem mate nor a rush, most thank full you are even doing this.

linuxeventually 2010-08-03 22:10

Re: Download apps to harddrive
 
Yeah well it's something that has bothered my for a long time.

I always just figured there was a tool that already exists but the closest that I've seen is apt-cd and every time that I have used it, it didn't restored properly.

I was doing the majority of my testing in Scratchbox so I didn't notice some major issues that come up on the device. For instance the big issue right now is that because I have it "installing" (in order to download I have to tell it to reinstall the packages) ALL the packages on the system that includes packages that shipped with the firmware. Attempting to re-download those results in several conflicts and dependencies errors that I am unable to force and results in crashing the script. It seems my best bet in resolving that issue is to find a list of all stock packages and exclude them from the script.

More personal things came up last night so I didn't progress far but I definitely want to get this stable soon.

Coffee 2010-08-03 22:18

Re: Download apps to harddrive
 
Not having any idea at all, can it be done from another angle?
I noticed when I backup after install and setup done, the back up contains a list inside a zip in the location the backups are stored. Whilst it doesn't store a copy of the actual files required, it does a list. However it does it, it reads the list reads the list and then downloads them from repo's. Are we able to use the list, to download them and redirect those saved deb files to a folder and prevent from install. Then just need to know how to install those deb's that we have. I am sure this is pretty much what you are doing though can we use the backups list, does it make things any simpler?

linuxeventually 2010-08-03 23:28

Re: Download apps to harddrive
 
If you have a backup list that you'd like to send to me then I could implement that. I don't recall such a feature on the N810 but maybe I just wasn't looking in the right place.

But yeah all the script does right now is:
1. Ask dpkg to generate a list of installed packages and save that list to SD
2. Generate a list of packages stored on the SD (if any)
3. Download the installed package minus the ones already saved to SD (if any)

1. Download packages found on the SD card

I need to make it much smarter clearly as it fails pretty easily. But by having a proper list of what to download and what shouldn't be downloaded (installed by default) should eliminate the errors.

I came across Rob1n's package sources script which may help. This little endeavour is going to need to grow to get this properly done.

TO DO LIST
* Fix the depends bug
* Implement Rob1n's script as a possible solution or feature
* Implement a search for saved .debs anywhere in the home directory
* Implement better checking
* Implement not reinstalling any packages when restoring.
* More redundant checks, less redundant downloads

If anyone has any pointers, like for instance the URL of the page that has all the stock packages mirrored (I lost the link) please reply.

couldvbb 2010-08-03 23:48

Re: Download apps to harddrive
 
firefox ->/home/user/MyDocs/.documents

system->
/var/tmp (.install )
/home/user/MyDocs/.apt-archive-cache(.deb)
but Automatically cleared after installation
so Must download it before,Immediately extracted


All times are GMT. The time now is 11:56.

vBulletin® Version 3.8.8