Copy package to non-mounted save file

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

Copy package to non-mounted save file

#1 Post by s243a »

Here's a simple script that I made to copy an installed package to a non mounted save folder.

The example is for TazPup but I also discuss the modifications for a standard puppy.

The use case is that something isn't working correctly with your current save file and you want to fix it by adding missing packages.

What you do is you open a clean instance of puppy, install the package and then copy the missing package over. The script handles the latter part.

Now assuming that you are running puppy from an instance with the missing package installed, simply go to any directory withing the save folder, and then run the script. For instance, say I'm in the path

Code: Select all

.../tazsave/var/lib/tazpkg/installed
and this scipt is called CpyPkg and it resides either in this same folder or somewhere in the executable search path. Also assume that my list of files resides in ./icu/files.list. Then simply type

Code: Select all

bash CpyPkg icu


and watch the magic happen.

Code: Select all

#!/bin/bash

THIS_DIR=$PWD
cd $THIS_DIR
PACKAGE=$1
ROOT="${THIS_DIR%%/tazpupsave/*}/tazpupsave"
while read line; do
  DIR=$(dirname "$line")
  mkdir -p "$ROOT$DIR"
  cp -a -u "$line" "$ROOT$line" 
done <$PACKAGE/files.list
Note that for puppy in my script change

Code: Select all

done <$PACKAGE/files.list
to

Code: Select all

done <$PACKAGE
and specify the path to the list of packages. Usually in ~/.packages/pkgname

so if one was installing the package icu into the non mounted folder the command would look something like this on tarpup.

Code: Select all

bash CpyPkg .../tahrsave/root/.packages/icu


As a final note that the script only copies over the files in the package. The list of files to copy must first be manually copied to the save folder.

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#2 Post by s243a »

Here's an example about how one might modify the script to copy multiple packages:

Code: Select all

#!/bin/bash

#THIS_DIR=$PWD
#ROOT="${THIS_DIR%%/tazpupsave/*}/tazpupsave"
ROOT=/mnt/home/tazpupsave

#cd $THIS_DIR

PACKAGES=(
'/var/lib/tazpkg/installed/linux-libre-squashfs' 
'/var/lib/tazpkg/installed/linux-squashfs' 
'/var/lib/tazpkg/installed/xchat'
'/var/lib/tazpkg/installed/xchat-plugin'
'/var/lib/tazpkg/installed/audacious-dev'
'/var/lib/tazpkg/installed/xorg-dev'
) 

copyPackage(){
    PACKAGE=$1
    if [ -n "$2" ]; then
      aRoot="$2"
    else
      aROOT="$ROOT"
    fi
    while read line; do
      DIR=$(dirname "$line")
      mkdir -p "$aROOT$DIR"
      cp -a -u "$line" "$aROOT$line"
    done <$PACKAGE/files.list 
}
for PACKAGE in "${PACKAGES[@]}"; do
  copyPackage "$PACKAGE"
done
The above was written for TazPup, modifications for a standard puppy discussed above.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hi, s243a

Euh... Sorry for the dumb question, but...
how can you copy anything to something that does not exist?...

Because, if a dir. is not mounted, it is not anywhere in the hierarchy...

Well, if you created say, sdc1, in the /mnt hierarchy it exists, and you
can copy to it. BUT, it copies in your save file. And later, when you will
actually mount /dev/sdc1 to /mnt/sdc1, this operation will obscure what
you have copied previously.

Also, are you using a save file (3rd line of your post) or a save folder (1st
line of your post)? That's not clear.

If you are copying to a pupsave folder, that is possible, you do not have
to mount it to copy to it. It is there, it is simply not "in operational mode",
so to speak. But anything you try to copy to an unmounted pupsave file
will just bounce off.

I wish that your script works, I really do. But I do not see it as it stands.
Why use /var? You could just as well use the /schmurf directory ;). Does
not change a thing.

Sorry for ruffled feathers and that sort of thing!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#4 Post by s243a »

musher0 wrote:Hi, s243a

Euh... Sorry for the dumb question, but...
how can you copy anything to something that does not exist?...
Sory bad choice of words. I meant not mounted as one of the layers of the layered file system, so that the running puppy does not depend on its contents for operation.
Also, are you using a save file (3rd line of your post) or a save folder (1st
line of your post)? That's not clear.
I think it works either way as long as the save file is mounted with read write access.
If you are copying to a pupsave folder, that is possible, you do not have
to mount it to copy to it. It is there, it is simply not "in operational mode",
Yes maybe as some kind of direct disc access but this is termonology and I am not an expert in this termonology. I noticed in TazPup running under Tux the path was shown by a uuid so maybe it was doing this?
I wish that your script works, I really do. But I do not see it as it stands.
Well first we must decide what it is supposed to do before we can agree if it works. It served the purpose for me that I wrote it for but I guess I wasn't clear about the purpose.

Why use /var? You could just as well use the /schmurf directory ;). Does
not change a thing.
because this is where TazPup stores info about packages. The equivalent in a standard puppy would be /root/.packages

I chose to first copy over the info about the packages because at the time it ment a shorter path that I had to type to where the list of files is located. The working directory was in the save file so that I could deduce the root of the save file from the path of the current working direcory. Again this was so that I could type less or at least read shorter paths.
Sorry for ruffled feathers and that sort of thing!
No wories. Someone else may have the same questions.

Post Reply