The deb2pet() function fails with errors
Hi @sc0ttj,
After downloading a .deb package and attempting to convert it to a .pet package, it fails with the following error:
# pkg --deb2pet binutils_2.30-21ubuntu1~18.04.2_amd64.deb
cut: /var/packages/Packages-puppy-xenial64-official: No such file or directory
cut: /var/packages/Packages-puppy-tahr64-official: No such file or directory
Usage: pkg dir2pet DIR
Create a PET package from a directory.
DIR must be a valid directory containing a pet.specs
Here is valid /PKGNAME/pet.specs entry example:
pkgname-1.2.3|pkgname|1.2.3||Category|54kb||pkgname-1.2.3.pet|+dep1,+dep2|the description|ubuntu|bionic||
For an interactive way of creating a petspecs,
run the 'dir2pet' script.
After a bit of investigating, it seems that the problem is that when the binutils_2.30-21ubuntu1~18.04.2_amd64.deb package is unpacked, it does so in this way (i.e., directory structure):
binutils_2.30-21ubuntu1~18.04.2_amd64/binutils_2.30
(Similarly, the libpolkit-gobject-1-0_0.105-20ubuntu0.18.04.5_amd64.deb package unpacks as libpolkit-gobject-1-0_0.105-20ubuntu0.18.04.5_amd64/libpolkit-gobject-1-0_0.105
.)
Moreover, when the deb2pet() function calls the dir2pet() one, the FOLDR
and PKGNAME
variables are set as follow:
FOLDR=binutils_2.30-21ubuntu1~18.04.2_amd64
PKGNAME=binutils_2.30-21ubuntu1~18.04.2_amd64
[ -d "${FOLDR}/$PKGNAME" ] && dir2pet "${FOLDR}/$PKGNAME" || dir2pet "$PKGNAME"
As per the line above, when dir2pet() is called via dir2pet "$PKGNAME"
, it fails straight away because I believe that the directory check of the [ ! -d "$1" ] && print_usage dir2pet && exit 1
line requires a full path to the directory being checked.
However, even if I try to run it by providing the full path to the .deb file, it still fails.
# pkg --deb2pet `pwd`/binutils_2.30-21ubuntu1~18.04.2_amd64.deb
cut: /var/packages/Packages-puppy-xenial64-official: No such file or directory
cut: /var/packages/Packages-puppy-tahr64-official: No such file or directory
DEBUG: FOLDR=/root/Downloads/temp/binutils_2.30-21ubuntu1~18.04.2_amd64
PKGNAME=binutils_2.30-21ubuntu1~18.04.2_amd64
Usage: pkg dir2pet DIR
Create a PET package from a directory.
DIR must be a valid directory containing a pet.specs
Here is valid /PKGNAME/pet.specs entry example:
pkgname-1.2.3|pkgname|1.2.3||Category|54kb||pkgname-1.2.3.pet|+dep1,+dep2|the description|ubuntu|bionic||
For an interactive way of creating a petspecs,
run the 'dir2pet' script.
I think that this is because dir2pet "$PKGNAME"
still gets called because there is no
/root/Downloads/temp/binutils_2.30-21ubuntu1~18.04.2_amd64/binutils_2.30-21ubuntu1~18.04.2_amd64
directory that exists. :-(
However, if we do not assume that the PKGNAME
will be the same as the .deb file's name, I believe that this is an easy fix (as seen below.)
printf "DEBUG: FOLDR=%s\n" ${FOLDR}
FOLDR_FIRST5CHARS=`echo ${FOLDR:0:5}`
printf "DEBUG: FOLDR_FIRST5CHARS=%s\n" $FOLDR_FIRST5CHARS
PKGNAME_ALT=`find $CURDIR/$FOLDR -maxdepth 1 -type d -name "$FOLDR_FIRST5CHARS*" | awk -F"/" '(NR>1) {print $NF}'`
printf "DEBUG: PKGNAME_ALT=%s\n" $PKGNAME_ALT
[ -d "${CURDIR}/${FOLDR}/${PKGNAME_ALT}" ] && dir2pet "${CURDIR}/${FOLDR}/${PKGNAME_ALT}"
[ ! -f "$FOLDR.pet" ] && [ ! -f "${CURDIR}/${PKGNAME_ALT}.pet" ] && error "$FOLDR.deb NOT converted to PET package!"
In addition, I added the ${CURDIR} variable to ensure that we always have the full path. Then, when I test again, I get the desired result:
# pkg --deb2pet binutils_2.30-21ubuntu1~18.04.2_amd64.deb
cut: /var/packages/Packages-puppy-xenial64-official: No such file or directory
cut: /var/packages/Packages-puppy-tahr64-official: No such file or directory
DEBUG: FOLDR=binutils_2.30-21ubuntu1~18.04.2_amd64
DEBUG: FOLDR_FIRST5CHARS=binut
DEBUG: PKGNAME_ALT=binutils_2.30
Converting directory binutils_2.30 to .pet package.
Categories:
BuildingBlock, Desktop, System, Setup, Utility,
Filesystem, Graphic, Document, Business, Personal,
Network, Internet, Multimedia, Fun
Type one of the categories above, then hit ENTER: Personal
Add a short description, then hit ENTER: Test package
Add dependencies in this format: +libglib,+ffmpeg
Enter dependencies (if any), then hit ENTER:
cut: /var/packages/Packages-puppy-xenial64-official: No such file or directory
cut: /var/packages/Packages-puppy-tahr64-official: No such file or directory
cut: /var/packages/Packages-puppy-xenial64-official: No such file or directory
cut: /var/packages/Packages-puppy-tahr64-official: No such file or directory
Package binutils_2.30.pet created (1 MB)
The md5sum is: bd6fed82cc5b892c7c234831d44d640a.
Now that I finally have the converted binutils_2.30.pet file, I began wondering why those cut
-related No such file or directory messages were appearing. I had a bit of extra time and worked out what is happening. I have opened a separate issue, #95 (closed), where I detail this topic and the proposed fix for it.
Regards,
Bernard