home *** CD-ROM | disk | FTP | other *** search
/ host-198-236-40-254.wlwv.k12.or.us / host-198-236-40-254.wlwv.k12.or.us.tar / host-198-236-40-254.wlwv.k12.or.us / tsu / BareMetalInstall.iso / tools / deb2mo next >
Text File  |  2012-12-18  |  1KB  |  52 lines

  1. #!/bin/bash
  2. # convert Debian/Ubuntu's DEB package into .MO compressed file
  3. # which can be used as a LiveCD module
  4. #
  5. # Author: Tomas M. <http://www.linux-live.org>
  6. #         Peter Chabada <http://chabada.sk>
  7. #
  8.  
  9. if [ "$1" = "" ]; then
  10.    echo "Convert Debian/Ubuntu's DEB package into .MO compressed module"
  11.    echo "usage: $0 source_filename.deb [output_file.mo]"
  12.    exit 1
  13. fi
  14.  
  15. if ! which dpkg > /dev/null; then
  16.    echo "Error: dpkg is not installed!"
  17.    echo "You must have dpkg installed to unpack DEB package."
  18.    exit 1
  19. fi
  20.  
  21. PATH=.:$(dirname $0):/usr/lib:$PATH
  22. . liblinuxlive || exit 1
  23.  
  24. TMPDIR=/tmp/deb2mo_$$
  25. TMPDIRCONTR=/tmp/deb2mo_contr_$$
  26.  
  27. rm -Rf $TMPDIR
  28. rm -Rf $TMPDIRCONTR
  29.  
  30. dpkg --extract $1 $TMPDIR
  31. if [ $? != 0 ]; then echo "error unpacking package"; exit; fi
  32.  
  33. dpkg --control $1 $TMPDIRCONTR
  34. if [ $? != 0 ]; then echo "error unpacking package control files"; exit; fi
  35.  
  36. echo >> $TMPDIRCONTR/control
  37.  
  38. PACKAGE=`dpkg --field $1 package`
  39.  
  40. mkdir -p $TMPDIR/var/lib/dpkg/info
  41. for FILE in $TMPDIRCONTR/*; do
  42.    cp $FILE $TMPDIR/var/lib/dpkg/info/$PACKAGE.`basename $FILE`
  43. done
  44.  
  45. PACKAGE=$PACKAGE.mo
  46. if [ ! "$2" = "" ]; then PACKAGE=$2; fi
  47. create_module $TMPDIR "$PACKAGE"
  48. if [ $? != 0 ]; then echo "error building compressed image"; exit; fi
  49.  
  50. rm -Rf $TMPDIR
  51. rm -Rf $TMPDIRCONTR
  52.