Aconselho a tirar esses caracteres de escape, nem todos os
terminais/shells suportam isso, o que pode ser um problema se a tua
idéia é distribuir esses scripts algum dia.

No configure, nem todos os programas suportam "--enable-gcc", de fato,
boa parte vai abortar a execução por não ser uma opção reconhecida. E
tu define CFLAGS duas vezes, esqueceu o XX na segunda (CXXFLAGS).

Eu não gosto muito desse CWD=$(pwd), com CWD=$( cd $(basename $0);
pwd) ele é definido como o diretório corrente do script sempre e eu
não preciso entrar no diretório p/ chamar um slackbuild.

Eu costumo adicionar uma opçao "--cleanup" aos scripts, que limpa os
diretórios temporários automagicamente ao fim da execução, acho um
saco ter que limpar o lixo manualmente depois.

Sobre usar o set -e ao invés de || exit 1, isso é uma opção pessoal.
Com || exit 1 tu define explicitamente as partes criticas do código e
ignora "pequenos" problemas como tentar copiar um arquivo de
documentação que não existe. Particularmente, eu prefiro usar um set
-e e explicitar onde erros são "tolerados" com um || true para não
matar o script.


On Tue, Jan 5, 2010 at 11:06 PM, Leonardo <[email protected]> wrote:
> larga um set -e no começo do script e remova os || exit 1. com set -e
> o script é instruído a parar em caso de processos que saiam com erro.
>
> veja o template do slackbuild.org[1], é relativamente bem comentado.
>
>
> [1]http://slackbuilds.org/template.SlackBuild
>
> 2010/1/5 Elton <[email protected]>:
>> Boa noite, lendo no site do SlackBuild, vendo alguns do Alien Bob e
>> alguns do site Slacky, resolvi iniciar os meus estudos com o
>> SlackBuild, fiz um modelo para instalar no Slackware 13 64 bits e fui
>> adaptando para cada programa ou biblioteca, o primeiro que eu fiz é
>> para o tls, ainda não instalei, gostaria que vocês olhassem e se
>> possível, indicar possíveis erros que eu possa estar comentendo. Desde
>> já agradecido. O script estar a seguir:
>>
>> #############################################################################
>> #!/bin/sh -e
>>
>> # Slackware Slackbuild script
>> # By:           Elton <[email protected]>
>> # For:          tls
>> # description:  An OpenSSL TCL extension
>> # URL:          http://tls.sourceforge.net/
>> # Need:         tcl 8.3.2+
>>
>> # Set initial variables:
>> PRGNAM=tls
>> VERSION=1.6
>> ARCH=${ARCH:-x86_64}
>> BUILD=${BUILD:-1}
>> TAG=${TAG:-gp}
>>
>> # Place to build (TMP) package (PKG) and output (OUTPUT) the program:
>> CWD=$(pwd)
>> TMP=${TMP:-/tmp/txz}
>> PKG="$TMP/pkg-$PRGNAM"
>> OUTPUT=${OUTPUT:-/tmp}
>>
>> # the architecture on which you want to build your package
>> if [ "$ARCH" = "i486" ]; then
>>  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
>>  LIBDIRSUFFIX=""
>> elif [ "$ARCH" = "x86_64" ]; then
>>  SLKCFLAGS="-O2 -fPIC"
>>  LIBDIRSUFFIX="64"
>> fi
>>
>> # Delete the leftover directories if they exist (due to a previous
>> build)
>> # and (re)create the packaging directory
>> rm -rf $PKG
>> mkdir -p $TMP $PKG $OUTPUT
>> rm -rf $TMP/$PRGNAM$VERSION
>>
>> # Change to the TMP directory
>> cd $TMP || exit 1
>>
>> # Extract the application source in TMP
>> # tar.gz
>> tar -zxvf $CWD/$PRGNAM$VERSION-src.tar.gz || exit 1
>>
>> echo -e "\E[0;32m+----------------------------+\E[0;0m"
>> echo -e "\E[0;32m| Start SlackBuild $NAME-$VERSION |\E[0;0m"
>> echo -e "\E[0;32m+----------------------------+\E[0;0m"
>>
>> # Change to the application source directory
>> cd $PRGNAM$VERSION || exit 1
>>
>> # Change ownership and permissions if necessary
>> chown -R root:root .
>> find . -perm 777 -exec chmod 755 {} \;
>> find . -perm 775 -exec chmod 755 {} \;
>> find . -perm 555 -exec chmod 755 {} \;
>> find . -perm 666 -exec chmod 644 {} \;
>> find . -perm 664 -exec chmod 644 {} \;
>> find . -perm 444 -exec chmod 644 {} \;
>>
>> # Set configure options
>> CFLAGS="$SLKCFLAGS" \
>> CFLAGS="$SLKCFLAGS" \
>> ./configure \
>>  --prefix=/usr \
>>  --libdir=/usr/lib${LIBDIRSUFFIX} \
>>  --localstatedir=/var \
>>  --sysconfdir=/etc \
>>  --with-ssl-dir=/usr \
>>  --enable-gcc \
>>  $ARCH-slackware-linux \
>>  2>&1 | tee $OUTPUT/configure-${PRGNAM}.log || exit 1
>>
>> # compile the source, but exit if anything goes wrong
>> make || exit 1
>>
>> # Install everything into the package directory, but exit if anything
>> goes wrong
>> make install DESTDIR=$PKG || exit 1
>>
>> # Create a directory for documentation
>> mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
>>
>> # Copy documentation to the docs directory and fix permissions
>> cp -a ChangeLog README.txt license.terms tls.htm \
>>  $PKG/usr/doc/$PRGNAM-$VERSION
>> cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/
>> $PRGNAM.SlackBuild
>> find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 644 {} \;
>>
>> # Create the ./install directory and copy the slack-desc into it
>> mkdir -p $PKG/install
>> cat $CWD/slack-desc > $PKG/install/slack-desc
>>
>> # Strip some libraries and binaries
>> cd $PKG
>> find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : |
>> xargs strip --strip-unneeded 2> /dev/null
>> find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d :
>> | xargs strip --strip-unneeded 2> /dev/null
>> find . | xargs file | grep "current ar archive" | cut -f 1 -d : |
>> xargs strip -g 2> /dev/null
>>
>> # Build the package
>> cd $PKG
>> /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$
>> {PKGTYPE:-txz}
>>
>> # End
>>
>> --
>> GUS-BR - Grupo de Usuários de Slackware Brasil
>> http://www.slackwarebrasil.org/
>> http://groups.google.com/group/slack-users-br
>>
>> Antes de perguntar:
>> http://www.istf.com.br/perguntas/
>>
>> Para sair da lista envie um e-mail para:
>> [email protected]
>>
>
> --
> GUS-BR - Grupo de Usuários de Slackware Brasil
> http://www.slackwarebrasil.org/
> http://groups.google.com/group/slack-users-br
>
> Antes de perguntar:
> http://www.istf.com.br/perguntas/
>
> Para sair da lista envie um e-mail para:
> [email protected]
>
-- 
GUS-BR - Grupo de Usuários de Slackware Brasil
http://www.slackwarebrasil.org/
http://groups.google.com/group/slack-users-br

Antes de perguntar:
http://www.istf.com.br/perguntas/

Para sair da lista envie um e-mail para:
[email protected]

Responder a