lentamente continuo avanzando con sumpack esto parece tonto, pero es util es un script , bajo el nombre de upackname que separa nombres de paquetes en sus partes (para lo que hago necesito solo dos: nombre y version, pero no es dificil separar mas en este contexto: release, etc) si alguien conoce algo mejor, sacarle errores, o como mejorarlo o darle mas capacidades, gracias #!/bin/bash version(){ cat <<EOF upackname $PROG_VERSION Copyright (C) 2010 Diego Saravia <[email protected]> License: $PROG_LICENCE <http://gnu.org/licenses/gpl.html> EOF } help(){ cat <<EOF upackname PACKAGE Splits package string in name, version and extension EOF } usage(){ cat <<EOF Usage: upackname PACKAGE EOF } extsep(){ for ext in $2 ; do rext=`echo $ext | sed 's|\.|\\\.|' ` first=`echo $1 | sed "s/\.$rext\$//"` if test "x$first" != "x$1"; then PACKEXT=$ext PACKTYPE=$3 PACKNOEXT=$first break fi done } PROG_VERSION=0.1 PROG_LICENCE="AGPLv3+: GNU AGPL version 3 or later" while test $# -gt 0 ; do case "$1" in -h|--help) help ;; -v|-V|--version) version ;; -u|--usage) usage ;; *) FILES=$@ break ;; esac shift done if test x"$1" = x ; then usage exit fi PACK=$1 #PACKSTRING=`basename $PACK` PACKSTRING=`echo $PACK | awk -F/ '{print $NF}'` PACKDIRPRE=${PACK%${PACKSTRING}} # en dos pasos por si no tiene / if test x"$PACKDIRPRE" = x/ ; then PACKDIR=/ else PACKDIR=${PACKDIRPRE%/} fi # 4 kind: file list (lf), metapacks (ebuild ubuild suma), binary packs, source packs METAEXT="ebuild ubuild summa" LISTEXT="lf" #KNOWN: BINPKGEXT="tgz tbz2 deb rpm" #SEE: PKGEXT="tar.gz tgz tar.bz tar.bz2 tbz tbz2 ZIP sip jar gz Z z bz2 bz 7Z 7z RAR rar LHa LHA lha lzh a deb lzma xz rpm" PACKTYPE=0 # EXIST EXTENSION PACKEXT="" # packtype PACKNAMEVERS=$PACKSTRING ########################################3 test sobre archivos reales, ver que pasa si no se quiere esto # o sea proveer # basename? extsep $PACKSTRING "$BINPKGEXT" BINPKGEXT if test x"$PACKEXT" = x ; then extsep $PACKSTRING "$LISTEXT" LISTEXT fi if test x"$PACKEXT" = x ; then PACKEXT=`echo $PACKSTRING | awk -F. '{print $NF}'` PACKNOEXT=${PACKSTRING%.${PACKEXT}} PACKTYPE=UNKNOWNEXT fi if test x"$PACKEXT" = x ; then PACKNOEXT=$PACKSTRING PACKTYPE=NOEXT fi case $PACKEXT in ebuild|ubuild|tbz2) #http://distfiles.gentoo.org/distfiles/pms-3.pdf `echo $PACKNOEXT | sed -e 's/\(.*\)-\([[:digit:]]\+\(\.[[:digit:]]\+\)*\+[a-z]\?\(_\(alpha\|beta\|pre\|rc\|p\)[[:digit:]]*\)*\(-r[[:digit:]]\+\)\?\)$/export PACKNAME=\1 PACKVERSION=\2/'` #PACKNAME=sed -e 's/(.*\)\(-[[:digit:]]\+\(\.[[:digit:]]\+\)*\+[a-z]\?\(_\(alpha\|beta\|pre\|rc\|p\)[[:digit:]]*\)*\(-r[[:digit:]]\+\)\?\)$//'` #PACKVERSION=`echo $PACK|cut -d- -f2-` #if test x"$PACKVERSION" = x"$PACKNAME" ; then # esto es raro, # PACKVERSION='' # # que el cut ponga el primer campo si no hay segundo ver # #PACKVERSION=0 # fi #sed 's/-[0-9]\{1,\}.*$//' ;; rpm) PACKNAME=`echo $PACKNOEXT |sed 's/-[^-]*-[^-]*$//'` PACKVERSIONPRE=${PACKNOEXT#${PACKNAME}} # primero el nombre por si es todo PACKVERSION=${PACKVERSIONPRE#-} # `echo $PACKNOEXT | sed -e 's/\([a-zA-Z0-9_\-\+]*\)-\([a-zA-Z0-9_\.]*\)-\([a-zA-Z0-9_\.]*\)\.\(noarch\|src\|noarch\|i386\|i686\|athlon\|ppc\|x86_64\)$/export PACKNAME\="\1" PACKVERSION\="\2-\3.\4" PACKOV\="\2" PACKRV\="\3" PACKARCH\="\4"/'` #older systems do not have arch part, see # my $name = $1; # my $version = $2; # my $release = $3; # my $arch = $4; #$ rpm -qp --qf '%{NAME}' some.rpm #rpm -qa|sed 's/-[^-]*-[^-]*$//' #RPM <name>-<version>-<release>.<architecture>.rpm nano-0.98-2.i386.rpm libgnomeuimm-2.0-2.0.0-3.src.rpm #A package label is contained within the file and does not necessarily #need to match the name of the file. #Additionally, libraries are distributed in two separate packages for #each version. One contains the precompiled code, while the second one #contains the development files such as headers, static library files, #etc. for the library in question. Those packages have "-devel" appended to their name field. Users need to carefully check so that #the version of the development package matches that of the binary #package, otherwise the library may not work very well. ;; deb) #DEB <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb PACKNAME=`echo $PACKNOEXT | awk -F_ '{print $1}'` PACKVERSIONPRE=${PACKNOEXT#${PACKNAME}} # en dos pasos por si el nombre debian esta mal y no usa _ PACKVERSION=${PACKVERSIONPRE#_} #\([a-z][a-z0-9\+\-\.]+\)_\([a-zA-Z0-9_\.]*\)-\([0-9a-zA-Z\+\.\~]+\)_\(noarch\|src\|noarch\|i386\|i686\|athlon\|ppc\|x86_64\) #The name of the package itself (not the filename, just the name of the package) can contain lowercase letters, numbers, and the "-" and "+" characters. #debian_revision #This part of the version number specifies the version of the Debian package based on the upstream version. #It may contain only alphanumerics and the characters + . ~ (plus, full stop, tilde) and is compared in the same way as the upstream_version is. #It is optional; if it isn't present then the upstream_version may not contain a hyphen. #This format represents the case where a piece of software was written specifically to be turned into a Debian package, #and so there is only one "debianisation" of it and therefore no revision indication is required. #It is conventional to restart the debian_revision at 1 each time the upstream_version is increased. #The package management system will break the version number apart at the last hyphen in the string #(if there is one) to determine the upstream_version and debian_revision. The absence of a debian_revision is equivalent to a debian_revision of 0 #The VVV component is the version number specified by the upstream #developer. There are no standards in place here, so the version number #may have formats as different as "19990513" and "1.3.8pre1". #The RRR component is the Debian revision number, and is specified by #the Debian developer (or an individual user if he chooses to build the #package himself). This number corresponds to the revision level of the #Debian package, thus, a new revision level usually signifies changes #in the Debian Makefile (debian/rules), the Debian control file #(debian/control), the installation or removal scripts (debian/p*), or #in the configuration files used with the package. #The AAA component identifies the processor for which the package was #built. This is commonly i386, which refers to chips compatible to #Intel's 386 or later versions. For other possibilities review Debian's #FTP directory structure at What are all those directories at the #Debian FTP archives?, Section 6.7. For details, see the description of #"Debian architecture" in the manual page dpkg-architecture(1). #noarch i386 i686 athlon ppc src x86_64 #i386 ia64 alpha amd64 armeb arm hppa m32r m68k mips mipsel powerpc ppc64 s390 s390x sh3 sh3eb sh4 sh4eb sparc darwin-i386 darwin-ia64 darwin-alpha darwin-amd64 darwin-armeb darwin-arm darwin-hppa darwin-m32r darwin-m68k darwin-mips darwin-mipsel darwin-powerpc darwin-ppc64 darwin-s390 darwin-s390x darwin-sh3 darwin-sh3eb darwin-sh4 darwin-sh4eb darwin-sparc freebsd-i386 freebsd-ia64 freebsd-alpha freebsd-amd64 freebsd-armeb freebsd-arm freebsd-hppa freebsd-m32r freebsd-m68k freebsd-mips freebsd-mipsel freebsd-powerpc freebsd-ppc64 freebsd-s390 freebsd-s390x freebsd-sh3 freebsd-sh3eb freebsd-sh4 freebsd-sh4eb freebsd-sparc kfreebsd-i386 kfreebsd-ia64 kfreebsd-alpha kfreebsd-amd64 kfreebsd-armeb kfreebsd-arm kfreebsd-hppa kfreebsd-m32r kfreebsd-m68k kfreebsd-mips kfreebsd-mipsel kfreebsd-powerpc kfreebsd-ppc64 kfreebsd-s390 kfreebsd-s390x kfreebsd-sh3 kfreebsd-sh3eb kfreebsd-sh4 kfreebsd-sh4eb kfreebsd-sparc knetbsd-i386 knetbsd-ia64 knetbsd-alpha knetbsd-amd64 knetbsd-armeb knetbsd-arm knetbsd-hppa knetbsd-m32r knetbsd-m68k knetbsd-mips knetbsd-mipsel knetbsd-powerpc knetbsd-ppc64 knetbsd-s390 knetbsd-s390x knetbsd-sh3 knetbsd-sh3eb knetbsd-sh4 knetbsd-sh4eb knetbsd-sparc netbsd-i386 netbsd-ia64 netbsd-alpha netbsd-amd64 netbsd-armeb netbsd-arm netbsd-hppa netbsd-m32r netbsd-m68k netbsd-mips netbsd-mipsel netbsd-powerpc netbsd-ppc64 netbsd-s390 netbsd-s390x netbsd-sh3 netbsd-sh3eb netbsd-sh4 netbsd-sh4eb netbsd-sparc openbsd-i386 openbsd-ia64 openbsd-alpha openbsd-amd64 openbsd-armeb openbsd-arm openbsd-hppa openbsd-m32r openbsd-m68k openbsd-mips openbsd-mipsel openbsd-powerpc openbsd-ppc64 openbsd-s390 openbsd-s390x openbsd-sh3 openbsd-sh3eb openbsd-sh4 openbsd-sh4eb openbsd-sparc hurd-i386 hurd-ia64 hurd-alpha hurd-amd64 hurd-armeb hurd-arm hurd-hppa hurd-m32r hurd-m68k hurd-mips hurd-mipsel hurd-powerpc hurd-ppc64 hurd-s390 hurd-s390x hurd-sh3 hurd-sh3eb hurd-sh4 hurd-sh4eb hurd-sparc ;; ;; esac if test x"$PACKNAME" = x"$PACKNOEXT" ; then PACKVERSION=`echo $PACKNOEXT | awk -F- '{print $NF}'` if test x"$PACKVERSION" = x"$PACKNOEXT" ; then PACKVERSION='' fi PACKNAMEPRE=${PACKNOEXT%${PACKVERSION}} # en dos pasos por si no tiene - PACKNAME=${PACKNAMEPRE%-} fi if test x"$PACKNAME" = x"$PACKNOEXT" ; then PACKVERSION=`echo $PACKNOEXT | awk -F_ '{print $NF}'` if test x"$PACKVERSION" = x"$PACKNOEXT" ; then PACKVERSION='' fi PACKNAMEPRE=${PACKNOEXT%${PACKVERSION}} # en dos pasos por si no tiene - PACKNAME=${PACKNAMEPRE%_} fi echo "PACKSTRING='$PACKSTRING'" echo "PACKDIR='$PACKDIR'" echo "PACKNAME='$PACKNAME'" echo "PACKVERSION='$PACKVERSION'" #version and release # no: si no hay version , version debe ser 0 echo "PACKEXT='$PACKEXT'" echo "PACKTYPE='$PACKTYPE'" echo "PACKCOMPLETENAME='$PACKNOEXT'" # without extension SLASH=- if test x"$PACKVERSION" = x ; then SLASH='' fi echo "PACKCOMPLETENORMALIZEDNAME='$PACKNAME$SLASH$PACKVERSION'" # without extension -- Diego Saravia [email protected] NO FUNCIONA->[email protected]