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 Thu 14 Dec 2017, 19:04
All times are UTC - 4
 Forum index » House Training » Bugs ( Submit bugs )
tgz2pet bug for *.tgz, *.txz
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
bug

Joined: 05 Jun 2017
Posts: 1

PostPosted: Fri 09 Jun 2017, 20:00    Post subject:  tgz2pet bug for *.tgz, *.txz  

the script /usr/bin/tgz2pet fails to handle *.tgz and *.txz files because it does things in the wrong order:

Code:
# only accept .tgz .tar.gz .txz .tar.xz files...
EXT=''
case ${TARBALL} in
  *tar.gz) EXT='.tar.gz' ; OPT=-z ;;
  *tgz)    EXT='.tar.gz' ; OPT=-z ; mv -f ${TARBALL} ${DIRPKG}/${BASEPKG}.tar.gz ; TARBALL="${DIRPKG}/${BASEPKG}.tar.gz" ;;
  *tar.xz) EXT='.tar.xz' ; OPT=-J ;;
  *tgz)    EXT='.tar.gz' ; OPT=-z ; mv -f ${TARBALL} ${DIRPKG}/${BASEPKG}.tar.gz ; TARBALL="${DIRPKG}/${BASEPKG}.tar.gz" ;;
  *) echo "${1##*/}: File extension not allowed" >&2 ; exit 1 ;;
esac

# split TARBALL path/filename into components...
BASEPKG="`basename ${TARBALL} $EXT`"
DIRPKG="`dirname ${TARBALL}`"
[ "${DIRPKG}" = "/" ] && DIRPKG=""


Do you see the problem? There is a circular dependency of variables. DIRPKG and BASEPKG are not set until the second section, so this fails.

Here's one possible solution:

Code:
# split TARBALL path/filename into components
splitname() {
  BASEPKG="`basename ${TARBALL} $1`"
  DIRPKG="`dirname ${TARBALL}`"
  [ "${DIRPKG}" = "/" ] && DIRPKG=""
}

# only accept .tgz .tar.gz .txz .tar.xz files...
EXT=''
case ${TARBALL} in
  *tar.gz) OPT=-z ; splitname '.tar.gz' ;;
  *tgz)    OPT=-z ; splitname '.tgz' ; mv -f ${TARBALL} ${DIRPKG}/${BASEPKG}.tar.gz ; TARBALL="${DIRPKG}/${BASEPKG}.tar.gz" ;;
  *tar.xz) OPT=-J ; splitname '.tar.xz' ;;
  *tgz)    OPT=-z ; splitname '.tgz' ; mv -f ${TARBALL} ${DIRPKG}/${BASEPKG}.tar.gz ; TARBALL="${DIRPKG}/${BASEPKG}.tar.gz" ;;
  *) echo "${1##*/}: File extension not allowed" >&2 ; exit 1 ;;
esac
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1398
Location: Japan

PostPosted: Sat 10 Jun 2017, 00:23    Post subject: Re: tgz2pet bug for *.tgz, *.txz  

bug wrote:
Do you see the problem?
Yes, but I wonder which script version you refer to. Logical order is correct in the version used by Slacko 5.6:
Code:
#only accept .tgz or .tar.gz files...
EXT=''
[ ! "`echo -n "$TARBALL" | grep '\\.tar\\.gz$'`" = "" ] && EXT='.tar.gz'
[ ! "`echo -n "$TARBALL" | grep '\\.tgz$'`" = "" ] && EXT='.tgz'
[ "$EXT" = "" ] && exit 1

#split TARBALL path/filename into components...
BASEPKG="`basename $TARBALL $EXT`"
DIRPKG="`dirname $TARBALL`"
[ "$DIRPKG" = "/" ] && DIRPKG=""

Still OK in Tahrpup605:
Code:
# only accept .tgz .tar.gz .txz tar.xz files...
EXT=''
case $TARBALL in
  *.tar.gz) EXT='.tar.gz' ;;
  *.tgz)    EXT='.tgz'    ;;
  *.tar.xz) EXT='.tar.xz' ;;
  *.txz)    EXT='.txz'     ;;
  *)        exit 1        ;;
esac

# split TARBALL path/filename into components...
BASEPKG="`basename $TARBALL $EXT`"
DIRPKG="`dirname $TARBALL`"
[ "$DIRPKG" = "/" ] && DIRPKG=""
Back to top
View user's profile Send private message 
Sailor Enceladus

Joined: 22 Feb 2016
Posts: 1326

PostPosted: Sat 10 Jun 2017, 16:19    Post subject:  

Confusing script name, it's still not a real pet. I think you're supposed to use dir2pet for general use.

edit: It looks like the only places tgz2pet are used are where it is "tar.gz", so I guess they lucked out. Laughing
https://github.com/puppylinux-woof-CE/woof-CE/search?utf8=%E2%9C%93&q=tgz2pet
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Bugs ( Submit bugs )
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.0344s ][ Queries: 13 (0.0049s) ][ GZIP on ]