# HG changeset patch # User Pascal Bellard # Date 1243268419 -7200 # Node ID f91e0e647f540b9976a5ec31982f3cd1bdfd1f40 # Parent eff9111773144dc42bb0330efd351cbf767c9cd7 Add tazpkg convert rpm diff -r eff911177314 -r f91e0e647f54 tazpkg --- a/tazpkg Mon May 25 17:31:35 2009 +0200 +++ b/tazpkg Mon May 25 18:20:19 2009 +0200 @@ -120,7 +120,7 @@ clean-cache Clean all packages downloaded in cache directory. depends Display dependencies tree. rdepends Display reverse dependencies tree. - convert convert a debian package to a slitaz package (.tazpkg) + convert convert a debian or rpm package to a slitaz package (.tazpkg) link link a package from another slitaz installation setup-mirror Change the mirror url configuration. list-undigest List undigest mirrors. @@ -927,6 +927,52 @@ rm -rf $TMP_DIR } +# convert a .rpm package to .tazpkg +convert_rpm() +{ + mkdir -p $TMP_DIR + cp $PACKAGE_FILE $TMP_DIR + PACKAGE_FILE=$TMP_DIR/$(basename $PACKAGE_FILE) + rpm -qip $PACKAGE_FILE | awk -v pkg=$PACKAGE_FILE ' +BEGIN { + goturl=0; + printf "# Taz package receipt.\n"; + printf "# generated by tazpkg from rpm package %s\n",pkg; +} +{ + if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; } + if (/^Version/) printf "VERSION=\"%s-",$3; + if (/^Release/) printf "%s\"\n",$3; + if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15); + if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; } +} +END { + if (goturl == 0) + printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name; + printf "CATEGORY=\"misc\"\n"; + printf "MAINTAINER=\"nobody@slitaz.org\"\n"; +} +' > $TMP_DIR/receipt + . $TMP_DIR/receipt + file=$PACKAGE-$VERSION + mkdir -p $TMP_DIR/$file/fs/ + mv $TMP_DIR/receipt $TMP_DIR/$file + rpm -qip $PACKAGE_FILE | awk ' +DEGIN { show=0 } +{ + if (show) print; + if (/^Description/) show=1; +} +' > $TMP_DIR/$file/description.txt + cd $TMP_DIR/$file/fs/ + rpm2cpio $PACKAGE_FILE | cpio -idm + cd ../.. + tazpkg pack $file + mv $file.tazpkg $TOP_DIR + cd $TOP_DIR + rm -rf $TMP_DIR +} + ################### # Tazpkg commands # ################### @@ -2229,6 +2275,8 @@ case "$PACKAGE_FILE" in *.deb|*.udeb) convert_deb;; + *.rpm) + convert_rpm;; *) echo "Unsupported format";; esac