Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 17 Jun 2018, 20:46
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Copy package to non-mounted save file
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 1066

PostPosted: Tue 22 May 2018, 23:30    Post subject:  Copy package to non-mounted save file  

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:

.../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:

bash CpyPkg icu


and watch the magic happen.
Code:

#!/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:

done <$PACKAGE/files.list


to

Code:

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:

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.
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1066

PostPosted: Thu 24 May 2018, 00:58    Post subject:  

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

Code:

#!/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.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12312
Location: Gatineau (Qc), Canada

PostPosted: Thu 24 May 2018, 15:43    Post subject:  

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 Wink. Does
not change a thing.

Sorry for ruffled feathers and that sort of thing!

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1066

PostPosted: Thu 24 May 2018, 21:17    Post subject:  

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.

Quote:

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.

Quote:
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?

Quote:
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.


Quote:
Why use /var? You could just as well use the /schmurf directory Wink. 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.

Quote:
Sorry for ruffled feathers and that sort of thing!


No wories. Someone else may have the same questions.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0436s ][ Queries: 13 (0.0054s) ][ GZIP on ]