home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / utilities-general / rpm2targz.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2001-04-02  |  2KB  |  52 lines

  1. #!/bin/sh
  2. # Copyright 1997, 1998 Patrick Volkerding, Moorhead, Minnesota USA
  3. # All rights reserved.
  4. #
  5. # Redistribution and use of this script, with or without modification, is
  6. # permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. #
  11. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  14. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  17. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  18. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  19. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  20. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. #
  22.  
  23. if [ "$TMPDIR" = "" ]; then
  24.   TMPDIR=/tmp
  25. fi
  26. if [ "$1" = "" ]; then
  27.   echo "rpm2targz:  Converts RPM format to standard GNU tar + GNU zip format."
  28.   echo "            (view converted packages with \"less\", install and remove"
  29.   echo "            with \"installpkg\", \"removepkg\", \"pkgtool\", or manually"
  30.   echo "            with \"tar\")"
  31.   echo
  32.   echo "Usage:      rpm2targz <file.rpm>"
  33.   echo "            (Outputs \"file.tar.gz\")"
  34.   exit 1;
  35. fi
  36. for i in $* ; do
  37.   if [ ! "$1" = "$*" ]; then
  38.     echo "Processing file: $i"
  39.   fi
  40.   rm -rf $TMPDIR/rpm2targz$$ # clear the way, just in case of mischief
  41.   mkdir $TMPDIR/rpm2targz$$
  42.   ofn=`basename $i .rpm`.cpio
  43.   dd ibs=`rpmoffset < $i` skip=1 if=$i 2> /dev/null | gzip -dc > $TMPDIR/rpm2targz$$/$ofn
  44.   ( cd $TMPDIR/rpm2targz$$
  45.     cpio --extract --preserve-modification-time --make-directories < $ofn 1> /dev/null 2> /dev/null
  46.     rm -f $ofn
  47.     find . -type d -perm 700 -exec chmod 755 {} \;
  48.     tar czf - . ) > `basename $i .rpm`.tar.gz      
  49.   ( cd $TMPDIR ; rm -rf rpm2targz$$ )
  50. done
  51.  
  52.