#!/bin/sh # # mksrpmtree.sh - Criação de uma estrutura para geração de um RPM # # Copyright (c) 2004 by Mauricio Teixeira # All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #-------------------------------------------------------------------------- # # Baixa um arquivo SRPM (ou utiliza um especificado) e cria a estrutura # necessária para a compilação de um novo pacote no diretório local. # if [ -z $1 ]; then echo "$(basename $0) " echo echo "Onde pode ser uma URL ou um arquivo local." exit fi if [ -z "$(echo $1 | egrep "(http|HTTP|ftp|FTP)://")" ]; then if [ -z "$(echo $1 | egrep "(src.rpm|SRC.RPM)$")" ]; then echo "$1: nome não parece ser um SRPM válido!" exit fi if ! [ -f $1 ]; then echo "$1: arquivo não encontrado!" exit fi filename=$(pwd)/$1 else filename=$(echo $1 | awk -F/ '{print $NF}') rm -f $TMP/$filename wget -P $TMP $1 if [ $? -gt 0 ]; then echo "Erro executando wget!" exit fi filename=$TMP/$filename fi pkgname=$(rpm -qp --queryformat "%{name}" $filename) mkdir -p $pkgname/{SPECS,SOURCES} if [ $? -gt 0 ]; then echo "Erro criando estrutura de diretórios!" exit fi cd $pkgname rpm2cpio $filename | cpio -idv if [ $? -gt 0 ]; then echo "Erro extraindo arquivos!" exit fi mv $pkgname.spec SPECS filelist=$(rpm2cpio $filename | cpio -it | grep -v $pkgname.spec) for fn in $filelist; do mv $fn SOURCES done if [ "$(echo $1 | egrep "(http|HTTP|ftp|FTP)://")" ]; then rm -f $filename fi tree