tazpkg rev 264

Add tazpkg convert rpm
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 25 18:20:19 2009 +0200 (2009-05-25)
parents eff911177314
children 0e1230d720bb
files tazpkg
line diff
     1.1 --- a/tazpkg	Mon May 25 17:31:35 2009 +0200
     1.2 +++ b/tazpkg	Mon May 25 18:20:19 2009 +0200
     1.3 @@ -120,7 +120,7 @@
     1.4    clean-cache      Clean all packages downloaded in cache directory.
     1.5    depends          Display dependencies tree.
     1.6    rdepends         Display reverse dependencies tree.
     1.7 -  convert          convert a debian package to a slitaz package (.tazpkg)
     1.8 +  convert          convert a debian or rpm package to a slitaz package (.tazpkg)
     1.9    link             link a package from another slitaz installation
    1.10    setup-mirror     Change the mirror url configuration.
    1.11    list-undigest    List undigest mirrors.
    1.12 @@ -927,6 +927,52 @@
    1.13  	rm -rf $TMP_DIR
    1.14  }
    1.15  
    1.16 +# convert a .rpm package to .tazpkg
    1.17 +convert_rpm()
    1.18 +{
    1.19 +	mkdir -p $TMP_DIR
    1.20 +	cp $PACKAGE_FILE $TMP_DIR
    1.21 +	PACKAGE_FILE=$TMP_DIR/$(basename $PACKAGE_FILE)
    1.22 +	rpm -qip $PACKAGE_FILE | awk -v pkg=$PACKAGE_FILE '
    1.23 +BEGIN {
    1.24 +	goturl=0;
    1.25 +	printf "# Taz package receipt.\n";
    1.26 +	printf "# generated by tazpkg from rpm package %s\n",pkg;
    1.27 +}
    1.28 +{
    1.29 +	if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; }
    1.30 +	if (/^Version/) printf "VERSION=\"%s-",$3;
    1.31 +	if (/^Release/) printf "%s\"\n",$3;
    1.32 +	if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15);
    1.33 +	if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; }
    1.34 +}
    1.35 +END {
    1.36 +	if (goturl == 0) 
    1.37 +		printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name;
    1.38 +	printf "CATEGORY=\"misc\"\n";
    1.39 +	printf "MAINTAINER=\"nobody@slitaz.org\"\n";
    1.40 +}
    1.41 +' > $TMP_DIR/receipt
    1.42 +	. $TMP_DIR/receipt
    1.43 +	file=$PACKAGE-$VERSION
    1.44 +	mkdir -p $TMP_DIR/$file/fs/
    1.45 +	mv $TMP_DIR/receipt $TMP_DIR/$file
    1.46 +	rpm -qip $PACKAGE_FILE | awk '
    1.47 +DEGIN { show=0 }
    1.48 +{ 
    1.49 +  if (show) print;
    1.50 +  if (/^Description/) show=1;
    1.51 +}
    1.52 +' > $TMP_DIR/$file/description.txt
    1.53 +	cd $TMP_DIR/$file/fs/
    1.54 +	rpm2cpio $PACKAGE_FILE | cpio -idm
    1.55 +	cd ../..
    1.56 +	tazpkg pack $file
    1.57 +	mv $file.tazpkg $TOP_DIR
    1.58 +	cd $TOP_DIR
    1.59 +	rm -rf $TMP_DIR
    1.60 +}
    1.61 +
    1.62  ###################
    1.63  # Tazpkg commands #
    1.64  ###################
    1.65 @@ -2229,6 +2275,8 @@
    1.66  		case "$PACKAGE_FILE" in
    1.67  		*.deb|*.udeb)
    1.68  			convert_deb;;
    1.69 +		*.rpm)
    1.70 +			convert_rpm;;
    1.71  		*)
    1.72  			echo "Unsupported format";;
    1.73  		esac