dir2pet without gui? [SOLVED]

Booting, installing, newbie
Post Reply
Message
Author
slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

dir2pet without gui? [SOLVED]

#1 Post by slavvo67 »

Let's say I have a directory containing 20 sub-directories that I wish to package individually as .pet files. I understand the GUI in dir2pet makes you add the version # of the application but is there a more streamlined script to do so?
Last edited by slavvo67 on Sun 16 Jul 2017, 18:36, edited 1 time in total.

stemsee

#2 Post by stemsee »

Code: Select all

for dir in `ls appdirs/*`
do
makepet $dir
done
my apptree cold be adapted

Code: Select all

#!/bin/sh
# apptree copyright (c) 2015 Marcos M Contant
# 
if [ ! -z "$2" ]; then
	nm="$2"
else
	. /tmp/name
fi
while read line
do
lined=`echo $line | rev | cut -f2,3,4,5,6,7,8,9,10,11,12,13,14 -d '/' | rev`
mkdir -p $HOME/"$nm"/"$lined"
cp -f $line $HOME/"$nm"/"$lined"/
done < "$1"
rox $HOME/"$nm" &

choice=`yad --geometry=400 --text "Make an sfs or pet? or both? Enter: 'sfs', 'pet' or 'both'"  --entry`
name=`yad --geometry=250 --title "Rename $nm dir to:" --entry`
if [ ! -z "$name" ]; then
	rename "$nm" "$name" $HOME/"$nm"
	nm="$name"
fi
case $choice in
	sfs) mksquashfs $HOME/"$nm" $HOME/"$nm".sfs -comp xz | yad --title "Mksquashfs" --progress --pulsate
	rox $HOME;;
	pet) exec makepet $HOME/"$nm"
	rox $HOME;;
	both) mksquashfs $HOME/"$nm" $HOME/"$nm".sfs -comp xz | yad  --title "Mksquashfs" --progress --pulsate
			exec makepet $HOME/"$nm"
			rox $HOME;;
	*) exec "$0";;
esac
deldir=`yad --geometry=250 --title "Remove /root/'$nm' dir? y or n" --entry`
case $deldir in
	y) rm -rf $HOME/"$nm" | yad --title "Removing '$nm'" --progress --pulsate;;
	n) exit 0;;
	*) exit 1;;
esac
exit 0
#############finished##############
Last edited by stemsee on Mon 17 Jul 2017, 14:55, edited 1 time in total.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#3 Post by slavvo67 »

Hi Stemsee:

I appreciate your response and, as usual, I wasn't clear enough. So, you get those 4 or so questions when packaging the pet. That's fine for 1 or 2 pets but when you have 20 or so subdirectories, it's annoying and redundant. Now, I understand the normal need to add the version number of Firefox, for example. I'm doing something a little different here.... (Hmm, I wonder if there's a way to grep that version and pass it to the package name)....

I'm basically taking everything located in /root/.packages/builtin_files and rebuilding them back into pets (basically reverse engineering a puppy, no?). I already completed the first step of creating sub directories in my chosen directory /root/NEWPET and now I'm basically repacking each directory as a version 1.0 to put into Woof and recreate.

Why? Because certain distros no longer have their packages available. For example, Quirky Unicorn which, aside from the name, is probably my favorite 32bit Quirky.

Here's my 2nd part hack:

cd /
cd /root/NEWPET
for file in *; do
echo "Creating package..."
tar -zcvf $file-1.0.tar.gz $file
sync
TARBALL="$file-1.0.tar.gz"
echo
echo "File $file.tar.gz created. Now converting to .pet..."
FULLSIZE="`stat --format=%s ${TARBALL}`"
MD5SUM="`md5sum $TARBALL | cut -f 1 -d ' '`"
echo -n "$MD5SUM" >> $TARBALL
sync
mv -f $TARBALL $file-1.0.pet
sync
echo
echo "$file.pet has been created. Finished."
echo
echo "If you look in /root/NEWPET you will see the new file."
echo
echo "dir2pet exited."
done
Last edited by slavvo67 on Sat 11 Mar 2017, 23:48, edited 1 time in total.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#4 Post by slavvo67 »

Here's my first to take the original build files:

#!/bin/bash

cd /
mkdir "/root/NEWPET"
cd /root/.packages/builtin_files

find . | while read file; do
file1="/root/.packages/builtin_files/$file"
## filename extracts only the file name and extension from the full directory
filename=$(basename "$file1")
filename2="${filename%.*}"
mkdir "/root/NEWPET/$filename2"
built1=`echo "$file1" | awk -F "/" '{print $4}'`
if [[ "$built1" = "builtin_files" ]]; then
while IFS='' read -r line || [[ -n "$line" ]]; do
last1=`echo "${line: -1}"`
first1=`echo "${line:0:1}"`
echo "$first1" >>/root/FIRST1
echo "$last1" >>/root/FIRST1
if [[ "$first1" = "/" ]]; then
directory1="$line"
mkdir "/root/NEWPET/$filename2/$directory1"
fi
if [[ "first1" != "/" ]]; then
line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//')"
echo "$directory1">/root/DIRECTORY1.txt
echo "$line2">/root/LINE2.txt
cp "$directory1/$line2" "/root/NEWPET/$filename2$directory1/$line2"
fi
done < "$file1"
else
while IFS='' read -r line || [[ -n "$line" ]]; do
last1=`echo "${line: -1}"`
first1=`echo "${line:0:1}"`
if [[ "$last1" = "/" ]]; then
mkdir "/root/NEWPET/$filename2/$line"
else
cp "$line" "/root/NEWPET/$filename2/$line"
fi
done < "$file1"
fi
done
yad --text="Should be done. Look in /root/NEWPET/for your package"

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#5 Post by Geoffrey »

Gnewpet - makes pets from installed packages
http://murga-linux.com/puppy/viewtopic. ... 673#598673
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#6 Post by wow »

Let's say I have a directory containing 20 sub-directories that I wish to package individually as .pet files.
If you have a .desktop file or a simple pet.spec or don't care about package description for ppm, you can try something like this:

Code: Select all

for i in * ; do [ -d $i ] && tar -zcf $i.tar.gz $i && tgz2pet $i.tar.gz ; done
[url=http://www.puppylinux.com][img]http://i.imgur.com/M4OyHe1.gif[/img][/url]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#7 Post by slavvo67 »

Hi Geoffrey: Gnewpet is good but it has the gui and only packages one pet at a time. Otherwise, it would be a great option.

Hi Wow: I will need to try your script. I actually solved with the longer script(s) above but yours is much shorter and may work better.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#8 Post by slavvo67 »

Hi all:

I noticed that my scripts didn't take into account the petspec file that Woof requires. I amended one of the scripts to create that file so now I'm solved for sure. Not going to post a bunch of script here but if someone is interested, you can PM for it.

Best,

Slavvo67

belham2
Posts: 1715
Joined: Mon 15 Aug 2016, 22:47

#9 Post by belham2 »

slavvo67 wrote:Hi all:

I noticed that my scripts didn't take into account the petspec file that Woof requires. I amended one of the scripts to create that file so now I'm solved for sure. Not going to post a bunch of script here but if someone is interested, you can PM for it.

Best,

Slavvo67

Hi Slavvo67,

Posted this just now, it kind of relates to your thread here:

http://www.murga-linux.com/puppy/viewtopic.php?t=109975

Why do we (or any user) need to carry the absurdly large .packages folder in /root when we have all these script developments (by the way, sure wish you'd post what you finished-found out here, be nice for us/others to see and maybe use---forum PM-ing scripts is NOT the recommended method for disseminating anything on murga). Anyhow, what you did, getting rid of those redundant 4 questions, sounds great. :wink:

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#10 Post by 01micko »

Code: Select all

# dir2pet -h

Usage: dir2pet [option]... [<name-of-dir>]

Create a compressed file containing the content of a directory

Options:
  -h, --help			   show this help
  -C, --change-compression-default Change the default compression
				   (gz or xz, currently xz)

--------------------------------------------------------------------

Basic:
  <name-of-dir>	the directory, not path, to be packaged.
		THIS IS THE PACKAGE.
		(Omit if specified with -p option)

  EXAMPLE:
    # dir2pet my_fun_game-0.1-i486

--------------------------------------------------------------------

Advanced:
  -s		   skip all questions - for package build scripts
  -p=<name-of-dir> directory to be packaged. THIS IS THE PACKAGE.

The following options are only useful with the "-s" option.
For best results, use as many as possible:

Compression: (use only one, default if none chosen is "xz")
  -x	use xz (high) compression
  -g	use gz (low) compression

Non-compulsory:
  -w="<description>" quoted description of the application
  -d=<+deps>	     comma-delimited dependencies, with prepended
		     "+" sign
  -c=<Category>	     category of application, for package manager -
		     allowed categories:
			BuildingBlock (default)
			Desktop
			System
			Setup
			Utility
			Filesystem
			Graphic
			Document
			Business
			Personal
			Network
			Internet
			Multimedia
			Fun

  EXAMPLE
    # dir2pet -x -s -w="fun game" -d=+gtk+,+ffmpeg,+cairo -p=my_fun_game-0.1-i486
This has been in woof-ce for over 3 years.
Puppy Linux Blog - contact me for access

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#11 Post by slavvo67 »

Thanks, 01micko. I note, dir2pet in Quirky does not have the -h option so I was dealing with a slightly different doggie. Might want to let BK know though I'm not sure if he branched the dir2pet differently in Quirky.

Sadly, I put quite a bit of time in hacking dir2pet and petspec in order to reverse out the /root/.packages directory. Anyway, it's a very specific request and probably not useful to most.

I'll grab the woof-CE dir2pet and maybe try to incorporate your version into a Quirk-en-Stein. Maybe, that's what BarryK's Easy is supposed to be...

Anyway, thanks for your help!!

Slavvo67

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#12 Post by slavvo67 »

Just an update, my scripts work but do not import properly into Woof. Figuring it out.....

Slavo67

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#13 Post by slavvo67 »

01micko:

Has the dir2pet sciript without GUI been working for 3 years?

The script below creates a pet but the pet will not extract when clicked on....

dir2pet -x -s -p=$petname

So currently I have to extract the package manually and repackage as pet for it to work. Mind you, this is in Quirky but should be just about the same.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#14 Post by slavvo67 »

Sorry, Mick -- I answered my own question:

It needs the w= or it won't package correctly...

dir2pet -g -s -w="$name111" -p=$name111

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#15 Post by slavvo67 »

To correct my previous post, the -g instead of the -x made the difference.

Post Reply