| Author |
Message |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Sun 11 Dec 2011, 15:36 Post subject:
Subject description: building a new pet from /root/.packages file |
|
I refined newpet a bit to read the original pet.specs and make the duplicate without having to repeat the gui building process; also added a few features like searching for the correct name so it's not necessary to remember the exact title; also added cleanup, help menu, and Xdialog notice that the pet is in /tmp .
edit. Added option to update version, "newpet [package] [newname]"
edit2: Removed a tgz2pet related bug.
| Code: |
#!/bin/sh
## creates a new pet in /tmp of files listed in /root/.package
if [ ! "$1" -o "$1" == "-h" ]; then
echo 'USEAGE: newpet [package] [newname]
creates new pet in /tmp
add [newname] for updating version'
exit
fi
NAME="$(ls /root/.packages | grep -m1 -i "$1" | sed 's/.files//')"
if [ ! -f /root/.packages/${NAME}.files ]; then
echo "package doesn't exist"
exit
fi
[ -d /tmp/"$NAME" ] && rm -r /tmp/"$NAME"
mkdir /tmp/"$NAME"
for i in `cat /root/.packages/${NAME}.files`; do
echo "$i" >> /tmp/list
done
while read line; do
if [ -f $line ]; then
DIR="$(dirname ${line})"
[ -d /tmp/${NAME}${DIR} ] || mkdir -p /tmp/${NAME}${DIR}
cp -p "$line" /tmp/${NAME}${DIR}
fi
done </tmp/list
cat /root/.packages/user-installed-packages | grep -m1 "$NAME" >>/tmp/${NAME}/pet.specs
## Make pet
cd /tmp
## create new name (if $2 )
if [ "$2" ]; then
## edit pet.specs
SPECS="${NAME}/pet.specs"
sed -i "s/${NAME}.pet/${2}.pet/" ./"$SPECS"
newver="$(echo "$2" | tr -cd '0-9.')"
oldver="$(cat ${SPECS} | cut -d\| -f3)"
sed -i "s/|${oldver}|/|${newver}|/" ./"$SPECS"
field1="$(cat ${SPECS} | cut -d\| -f1)"
sed -i "s/${field1}/${2}/" ./"$SPECS"
NEWNAME="$2"
mv ./$NAME ./$NEWNAME
NAME="$NEWNAME"
fi
tar -czf ./${NAME}.tgz ./"$NAME"
tgz2pet ./${NAME}.tgz
if [ -f ${NAME}.pet ]; then
Xdialog --msgbox "${NAME}.pet created in /tmp" 5 35
fi
## Cleanup
[ -d /tmp/${NAME} ] && rm -r /tmp/${NAME}
[ -f /tmp/list ] && rm -r /tmp/list
|
Last edited by jpeps on Mon 12 Dec 2011, 01:50; edited 2 times in total
|
|
Back to top
|
|
 |
puppyluvr

Joined: 06 Jan 2008 Posts: 3052 Location: Chickasha Oklahoma
|
Posted: Sun 11 Dec 2011, 19:48 Post subject:
|
|
Hello,
@jpeps,
Yea, like that..
Your script is a bit above me, but if I omit the .files when I call it it works great.
As a test I pulled xfce4 back outta Lupen...
_________________ "Close the "Windows", and open your eyes, to a whole new world"
http://puppylinuxstuff.meownplanet.net/puppyluvr/
http://theplpd.webs.com/
Nothing but Puppy since 2.15CE...
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Sun 11 Dec 2011, 23:39 Post subject:
|
|
| puppyluvr wrote: |
Your script is a bit above me, but if I omit the .files when I call it it works great. |
Yeah..just put in the package name without any".files" extension. The first arg is just a search word anyway, so if you get close it should find the correct package.
example..to update:
"newpet traymanager TrayManager-4.6"
or just:
"newpet traymanager"
for a copy
I just edited it a bit to make the searches in pet.specs a little more specific; also, tgz2pet related bug for updating pets
|
|
Back to top
|
|
 |
RSH

Joined: 05 Sep 2011 Posts: 1564 Location: Germany
|
Posted: Mon 12 Dec 2011, 21:09 Post subject:
|
|
I really don't like using the terminal very much (except in programming processes) and so i did a little work on the first script of jpeps to use this one by a GUI or similar with right-click-action.
I have made a .pet for both of use. Both have language support for english and german.
http://murga-linux.com/puppy/viewtopic.php?t=74164
RSH
_________________ Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Tue 13 Dec 2011, 05:46 Post subject:
|
|
Here's one with a gtkdialog front-end. Select a package from the drop down menu, and then push the "make pet" button for a copy. If you enter a new name, it will make a new version. There's also a button for viewing the files for a selected package.
version 1.1 show only files in package
| Description |
|

Download |
| Filename |
gnewpet-1.1.pet |
| Filesize |
1.72 KB |
| Downloaded |
133 Time(s) |
| Description |
|
| Filesize |
13.62 KB |
| Viewed |
742 Time(s) |

|
Last edited by jpeps on Wed 14 Dec 2011, 05:50; edited 2 times in total
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Tue 13 Dec 2011, 05:55 Post subject:
|
|
Here's the code for the frontend:
| Code: |
#!/bin/sh
## gnewpet: frontend for newpet script. jpeters (jpeps) 12/13/11
#ver 1.1 12/14/11 show only files
n="0"
cd /root/.packages
for i in `ls | grep ".files" | sed 's/.files//'`; do
n="$((n+1))"
file[$n]="$i"
done
export NUM="$((n+1))"
function funcItemCreate() {
for ((i=1;i<"$NUM";i++)); do
echo '<item>'"${file[$i]}"'</item>'
done
}
Copy() {
newpet ${COMBOBOX} ${NewVersion}
}
export -f Copy
report() {
[ -f /tmp/list ] && rm /tmp/list
VAR=`cat /root/.packages/${COMBOBOX}.files`
for i in $VAR; do
[ -f "$i" ] && echo "$i" >>/tmp/list
done
Xdialog --stdout --no-cancel --editbox /tmp/list 18 70
rm /tmp/list
}
export -f report
GTKDIALOG=gtkdialog
export MAIN_DIALOG='
<window title="newpet">
<vbox>
<hbox>
<text>
<label>File List:</label>
</text>
<combobox>
<variable>COMBOBOX</variable>
'"$(funcItemCreate)"'
</combobox>
</hbox>
<hbox>
<text><label>New Version</label></text>
<entry tooltip-text="Leave blank for same version">
<variable>NewVersion</variable>
</entry>
</hbox>
<hbox>
<button ok></button>
<button cancel></button>
<button>
<label>Show Files</label>
<action>report</action>
</button>
<button>
<label>Make Pet</label>
<action>Copy</action>
</button>
</hbox>
</vbox>
</window>
'
$GTKDIALOG --program=MAIN_DIALOG
|
|
|
Back to top
|
|
 |
recobayu

Joined: 15 Sep 2010 Posts: 85 Location: indonesia
|
Posted: Thu 15 Dec 2011, 04:57 Post subject:
|
|
jpeps, thanks a lot. that is very interesting for me.
now, i have a question again.
if i have a text1 file that contain
| Code: |
first line of text1
second line of text1
thirth line of text1
fourth line of text1
fifth line of text1
|
and i have a text2 file that contain
| Code: |
line 1 of text2
line 2 of text2
line 3 of text2
line 4 of text2
line 5 of text2
|
how can the text1 file to be like this?
| Code: |
first line of text1
second line of text1
line 1 of text2
line 2 of text2
line 3 of text2
line 4 of text2
line 5 of text2
thirth line of text1
fourth line of text1
fifth line of text1
|
can i use sed or echo? or grep?
thanks.
|
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 832
|
Posted: Thu 15 Dec 2011, 11:58 Post subject:
|
|
| recobayu wrote: | jpeps, thanks a lot. that is very interesting for me.
now, i have a question again.
if i have a text1 file that contain
| Code: |
first line of text1
second line of text1
thirth line of text1
fourth line of text1
fifth line of text1
|
and i have a text2 file that contain
| Code: |
line 1 of text2
line 2 of text2
line 3 of text2
line 4 of text2
line 5 of text2
|
how can the text1 file to be like this?
| Code: |
first line of text1
second line of text1
line 1 of text2
line 2 of text2
line 3 of text2
line 4 of text2
line 5 of text2
thirth line of text1
fourth line of text1
fifth line of text1
|
can i use sed or echo? or grep?
thanks. |
recobayu,
Try this - | Code: | sed -i '/^second/ r text2.txt' text1.txt
|
Cheers,
s
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Fri 16 Dec 2011, 00:27 Post subject:
|
|
| seaside wrote: |
Try this - | Code: | sed -i '/^second/ r text2.txt' text1.txt
|
|
Another addition to my sed notes!
|
|
Back to top
|
|
 |
harii4

Joined: 30 Jan 2009 Posts: 443 Location: La Porte City, IA , U.S.A.
|
Posted: Sun 01 Jan 2012, 11:37 Post subject:
|
|
SOLVED - used an bad pet package - sorry
found out by more testing.
works great
----------------------------------------------------------
gnewpet not working in TXZ_pup?
i'm getting no files in the new pet - empty
The gnewpet gui - "show files" is empty as well.
might be an TXZ_pup thing?
Using straight DotPet - did not convert using pet2slack.
console:
| Code: | # gnewpet
cat: /root/.packages/user-installed-packages: No such file or directory
|
_________________ 3.01 Fat Free / Fire Hydrant featherweight/ TXZ_pup / 431JP2012
----------------------------------------------------------------------------------------
Peace and Justice are two sides of the same coin.
|
|
Back to top
|
|
 |
RSH

Joined: 05 Sep 2011 Posts: 1564 Location: Germany
|
Posted: Wed 11 Jan 2012, 23:25 Post subject:
|
|
Hi,
i have found out, that the scripts here posted don't bring you the installed .pet back as it has been installed.
Every symbolic link comes back as a real file. Though the created .pet may mostly work - they are just a little bigger as the installed one (the more links the more real files will be written instead of the links)
BUT, no problem after all: it is easy to fix!
Just change "cp -p "$line" /tmp/${NAME}${DIR}" to this: "cp -p -P "$line" /tmp/${NAME}${DIR}".
-P says "don't follow symbolic links". So symbolic links will be re-copied as symbolic links inside the .pet.
RSH
_________________ Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Fri 13 Jan 2012, 02:30 Post subject:
|
|
Thanks RSH. Bug corrected. I also have a checkbox to leave the copied directory in /tmp for other possible file additions/deletions. As before, for a straight copy leave the new version entry blank.
| Description |
|
| Filesize |
12.75 KB |
| Viewed |
550 Time(s) |

|
| Description |
|

Download |
| Filename |
gnewpet-2.1.pet |
| Filesize |
1.93 KB |
| Downloaded |
146 Time(s) |
|
|
Back to top
|
|
 |
RSH

Joined: 05 Sep 2011 Posts: 1564 Location: Germany
|
Posted: Fri 13 Jan 2012, 09:29 Post subject:
|
|
| jpeps wrote: | Here's the code for the frontend:
Code:
#!/bin/sh
## gnewpet: frontend for newpet script. jpeters (jpeps) 12/13/11
#ver 1.1 12/14/11 show only files
n="0"
cd /root/.packages
for i in `ls | grep ".files" | sed 's/.files//'`; do
n="$((n+1))"
file[$n]="$i"
done
export NUM="$((n+1))"
function funcItemCreate() {
for ((i=1;i<"$NUM";i++)); do
echo '<item>'"${file[$i]}"'</item>'
done
}
Copy() {
newpet ${COMBOBOX} ${NewVersion}
}
export -f Copy
report() {
[ -f /tmp/list ] && rm /tmp/list
VAR=`cat /root/.packages/${COMBOBOX}.files`
for i in $VAR; do
[ -f "$i" ] && echo "$i" >>/tmp/list
done
Xdialog --stdout --no-cancel --editbox /tmp/list 18 70
rm /tmp/list
}
export -f report
GTKDIALOG=gtkdialog
export MAIN_DIALOG='
<window title="newpet">
<vbox>
<hbox>
<text>
<label>File List:</label>
</text>
<combobox>
<variable>COMBOBOX</variable>
'"$(funcItemCreate)"'
</combobox>
</hbox>
<hbox>
<text><label>New Version</label></text>
<entry tooltip-text="Leave blank for same version">
<variable>NewVersion</variable>
</entry>
</hbox>
<hbox>
<button ok></button>
<button cancel></button>
<button>
<label>Show Files</label>
<action>report</action>
</button>
<button>
<label>Make Pet</label>
<action>Copy</action>
</button>
</hbox>
</vbox>
</window>
'
$GTKDIALOG --program=MAIN_DIALOG |
Hi jpeps.
This gui is more comfortable as the one i did made using your first script. My suggestion is:
what must changed or added in the gui to get the same list but with checkboxes to select several (is this right for 'more than 1?) files to rebuild?
I think than you would have one of the most useful and ultimate tool - not only to "cannibalize" the work of others but also to get pets, that somehow get lost, out of iso files.
And at least: it would be exactly (just modified, that's actually mostly all what i am able to do) what i need on a work not only useful for my LazY Puppy but also useful to promote and support puppy in principle.
I know it has to be done some work on the backend, but therefor (my work) i do need only the gui code.
Thank you in advance for your excellent code.
RSH
_________________ Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Fri 13 Jan 2012, 13:13 Post subject:
|
|
| RSH wrote: |
what must changed or added in the gui to get the same list but with checkboxes to select several (is this right for 'more than 1?) files to rebuild?
|
You could of course do that, but why not build them one at a time? It seems much simpler and easier to control, especially when you want to rename versions.
To do a list, it would be trivial to just add a loop.
|
|
Back to top
|
|
 |
RSH

Joined: 05 Sep 2011 Posts: 1564 Location: Germany
|
Posted: Fri 13 Jan 2012, 14:22 Post subject:
|
|
| RSH wrote: | | ...i do need only the gui code. |
I meant: i am not interested in the backend and/or to build tons of files out of an iso at a time.
The issue is following:
1. Reading a directory
- while reading creating list (.txt file) and writing names of found files into this list file
2. Read the list file and show completely in a GUI to select or deselect items of list (incl. all/none - button)
3. Save list.
4. Read list and create symbolic links of only the enabled listed files.
I can do 1., 3. and 4.
I can do 2. only using geany, want to do it in a GUI - more comfortable when using all/none button/s and then select or deselect some. To use the list in your gui without changes would mean to click to open list, scroll to the item and click it. Makes two clicks at one item. If there are 200 files listed and i want to use only 3 of them i would have to click 2x197 clicks to get all edited - so, no GUI comfort. (similar is geany using keyboard)
How can i create an gtkdialog item, that is a scroll-able list like yours, but already opened and just adding a checkbox to every item?
RSH
_________________ Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
|
|
Back to top
|
|
 |
|