Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DBNAME="NIMHIX_ADMIN"
- DBHOST=localhost;
- DBUSER=xxxxx;
- DBPASS=xxxxx;
- DBTABLE=PAQUETES;
- LISTDIR=/home/xxxxx/nlista/lista/;
- for i in `ls $LISTDIR`
- do
- descline=`cat -n $LISTDIR$i | grep -i Description | awk '{print $1}'`
- taskline=`cat -n $LISTDIR$i | grep -i Task: | awk '{print $1}'`
- enddesc=$(echo $taskline-1 | bc)
- packname=` grep Package: $LISTDIR$i | awk '{ print $2 }' `
- version=` grep Version: $LISTDIR$i | awk '{ print $2 }' `
- maintainer=` grep ^Maintainer: $LISTDIR$i | cut -d : -f 2 `
- section=` grep Section: $LISTDIR$i | cut -d : -f 2 `
- priority=` grep Priority: $LISTDIR$i | cut -d : -f 2 `
- arch=`rgrep Filename: $LISTDIR$i | cut -d ' ' -f 2 | awk -F _ '{print $NF}' | cut -f 1 -d .`
- depends=`rgrep Depends: $LISTDIR$i | cut -d : -f 2 `;
- recommends=`rgrep Recommends: $LISTDIR$i | cut -d : -f 2 `;
- suggests=`rgrep Suggests: $LISTDIR$i | cut -d : -f 2 `;
- conflicts=`rgrep Conflicts: $LISTDIR$i | cut -d : -f 2 `;
- replaces=`rgrep Replaces: $LISTDIR$i | cut -d : -f 2 `;
- description=`sed -n "${descline},${enddesc}p" $LISTDIR$i|sed '/^Homepage:|Bugs:|Origin:|Supported:/d'|sed 's/,//g'|tr "'" " "`
- # description=`echo $description | tr "`" " " | tr "'" " " | tr "," " " `
- echo "INSERT INTO $DBTABLE ("PACKFN","MAINTAINER","SECTION","PRIORITY","PAQUETE","ARCHITECTURE","DEPENDS","RECOMMENDS","SUGGESTS","CONFLICTS","REPLACES","DESCRIPTION") \
- VALUES ('$packname-$version','$maintainer','$section','$priority','$packname','$arch','$depends','$recommends','$suggests','$conflicts','$replaces','$description');" \
- | mysql -uroot -pxxxx -h 192.168.10.44 $DBNAME
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement