#!/bin/bash # Escrito por : Hamacker (sirhamacker@gmail.com) 2006-10-30 # Função : # Este script cria um .deb para um pacote já précompilado e nas # definicoes desse script o destino desse aplicativo será sempre # em /opt/nomedoprograma # se quiser '/usr/local' basta mudar 'PACKAGE_FOLDER' para : # PACKAGE_FOLDER=usr/local # apenas nao coloque barra no inicio do path # # se uma pasta for informada como parametro entao essa pasta será o # nosso pacote a ser criado. Essa pasta deverá ter a conotação : # nomedoprograma-versao # # Obs: Este script foi escrito com a ajuda deste link : # http://synthesize.us/HOWTO_make_a_deb_archive_without_dpkg # CURRENT=`pwd` # Informacoes peculiares sobre o pacote PACKAGE_NAME="tribaltrouble" PACKAGE_VERSION="1.0" PACKAGE_SECTION="X11/Games" PACKAGE_MAINTAINER="hamacker " SHORTCUT_CATEGORIES="Application;Game;" # pasta onde sera instalado PAGKAGE_FOLDER="opt" # nome da aplicacao APPLICATION_NAME="tribaltrouble" # nome do executavel (nao colocar barra no inicio) APLICATION_BIN="tribaltrouble" # nome do icone que sera utilizado (nao colocar barra no inicio) APPLICATION_ICON=$PAGKAGE_FOLDER/$PACKAGE_NAME/icon.png # descricao curta PACKAGE_DESCRIPTION="Ajude os Vinkings e os nativos em suas campanhas - jogo de estratégia RPG" # destino do pacote : BUILD_DESTINY=$CURRENT/build/$PAGKAGE_FOLDER/$PACKAGE_NAME/ ######################################### # leia-me que será criado para o pacote # ######################################### PACKAGE_README[1]="* The story so far..." PACKAGE_README[2]=" Once upon a time, a gang of Viking raiders got so drunk celebrating" PACKAGE_README[3]=" Their latest pillaging that they got lost on the high sea and stranded" PACKAGE_README[4]=" on a remote group of tropical islands. Here they chose to stay " PACKAGE_README[5]=" for a while, much to the annoyance of the local Natives..." PACKAGE_README[6]="* Userfriendly strategy game" PACKAGE_README[7]=" Tribal Trouble is a realtime strategy game designed to be easy to grasp," PACKAGE_README[8]=" yet difficult to master. While the game mechanics only take a few minutes" PACKAGE_README[9]=" to learn, it can still be quite a challenge to beat your opponents:" PACKAGE_README[10]=" To win, you are going to need some skills in planning strategies" PACKAGE_README[11]=" and utilizing the varying terrain for successful tactics." PACKAGE_README[12]="* Endless variation" PACKAGE_README[13]="New to the genre, Tribal Trouble offers full three dimensional computer generated" PACKAGE_README[14]=" maps with lots of adjustable parameters." PACKAGE_README[15]="Whether you choose to help out the Vikings or Natives, battle the computer" PACKAGE_README[16]=" or other players online, an almost endless supply of different" PACKAGE_README[17]="maps are waiting to be conquered." PACKAGE_README[18]="http://tribaltrouble.com/" #################################################################### # dentro de build/ recrio a estrutura que desejo ser instalada... # #################################################################### if [ -d "$CURRENT/build" ] ; then rm -fR $CURRENT/build fi mkdir -p $BUILD_DESTINY #################################################################### # ... e depois copio os arquivos para lá # #################################################################### cp -vR $CURRENT/* $BUILD_DESTINY/ # apagar eventuais .deb que tenham sido gerados antes rm -f $BUILD_DESTINY/*.deb # remover backups destes scripts rm -f $BUILD_DESTINY/*.sh~ ################################################# # Construção do pacote tambem deve ser removido # ################################################# rm -fR $BUILD_DESTINY/build #################################################################### # remover arquivos desnecessarios no pacote # #################################################################### rm -fR $BUILD_DESTINY/src rm -fR $BUILD_DESTINY/obj rm -f $BUILD_DESTINY/makefile* # entro dentro do diretorio de construcao, e crio uma pasta doc mkdir -p $CURRENT/build/etc mkdir -p $CURRENT/build/opt mkdir -p $CURRENT/build/usr/share/doc/$PACKAGE_NAME ############################## # Escrever um arquivo README # ############################## rm -f $CURRENT/build/usr/share/doc/$PACKAGE_NAME/README touch $CURRENT/build/usr/share/doc/$PACKAGE_NAME/README for linha_readme in "${PACKAGE_README[@]}"; do echo $linha_readme >>$CURRENT/build/usr/share/doc/$PACKAGE_NAME/README done ##################### # criando um atalho # ##################### mkdir -p $CURRENT/build/usr/share/applications cat > $CURRENT/build/usr/share/applications/$PACKAGE_NAME.desktop < $CURRENT/build/usr/bin/$PACKAGE_NAME.sh <$CURRENT/build/control echo "Version: $PACKAGE_VERSION">>$CURRENT/build/control echo "Section: $PACKAGE_SECTION">>$CURRENT/build/control echo "Priority: optional">>$CURRENT/build/control echo "Architecture: all">>$CURRENT/build/control echo "Installed-Size: `du -ks usr|cut -f 1`">>$CURRENT/build/control echo "Replaces: $PACKAGE_NAME">>$CURRENT/build/control echo "Provides: $PACKAGE_NAME">>$CURRENT/build/control echo "Maintainer: $PACKAGE_MAINTAINER">>$CURRENT/build/control echo "Description: $PACKAGE_DESCRIPTION">>$CURRENT/build/control for linha_long_desc in "${PACKAGE_README[@]}"; do echo " $linha_long_desc" >>$CURRENT/build/control done ############################################################################ # Setting this environment variable fixes Apple's modified GNU tar so that # # it won't make dot-underscore AppleDouble files. Google it for details... # ############################################################################ #export COPY_EXTENDED_ATTRIBUTES_DISABLE=1 ######################## # Acertando permissoes # ######################## find $CURRENT/build -type d -exec chmod 777 {} \; chown nobody.users -R $CURRENT/build #################################################### # Posicionando-se sob o diretorio a ser empacotado # #################################################### cd $CURRENT/build ############################################### # criar arquivo de dados em formato tarball # # neste exemplo, apenas pastas usr, opt e etc # # podem ser instaladas # ############################################### tar czvf data.tar.gz usr/ opt/ etc/ # criar arquivo de controle em formato tarball tar czvf control.tar.gz control # criar o arquivo debian-binary echo "2.0" >$CURRENT/build/debian-binary # create the ar (deb) archive cd $CURRENT ar -r ../$PACKAGE_NAME-$PACKAGE_VERSION.deb \ $CURRENT/build/debian-binary \ $CURRENT/build/control.tar.gz \ $CURRENT/build/data.tar.gz if [ $? -ne 0 ] ; then echo "ops! falhou a criação do pacote $CURRENT/$PACKAGE_NAME-$PACKAGE_VERSION.deb !" exit; else echo "[sucesso] Pacote criado com sucesso." echo "Para instalar :" echo " sudo dpkg -i ../$PACKAGE_NAME-$PACKAGE_VERSION.deb" echo "Para remover :" echo " sudo apt-get -y --purge remove $PACKAGE_NAME" fi echo "fim." # remover os tarballs temporarios rm $CURRENT/build/data.tar.gz $CURRENT/build/control.tar.gz # retornar ao diretorio inicial cd $CURRENT