#!/bin/bash PACKAGE_SOURCE="" PACKAGE_BINARY="" SOURCE_FOLDER="" #DESTINATION_FOLDER="" DEBIAN_TPL="/usr/share/dg/debian.tpl" _usage() { echo "[USAGE]: " echo "Execute dg from root folder for package" echo "dg PACKAGE_SOURCE PACKAGE_BINARY [SOURCE_FOLDER]" echo "" exit 1 } _check_parameters() { echo "Comprobando el directorio fuente" [ -d "$SOURCE_FOLDER" ] || _usage } _replace_vars() { for f in $(ls -1 debian/* ); do echo "" echo "Procesando $f" # Cambia el nombre del source echo "Cambia el nombre del source en $f" sed -i "s%_@_PACKAGE_SOURCE_@_%$PACKAGE_SOURCE%g" "$f" # Cambia el nombre del binario echo "Cambia el nombre del binario en $f" sed -i "s%_@_PACKAGE_BINARY_@_%$PACKAGE_BINARY%g" "$f" # Cambiamos Developer echo "Cambiamos Developer" sed -i "s%_@_DEBFULLNAME_@_%$DEBFULLNAME%g" "$f" sed -i "s%_@_DEBEMAIL_@_%$DEBEMAIL%g" "$f" # Cambiamos el nombre de la plantilla echo "Cambiando el nombre de la plantilla" FINAL_NAME="$(basename $f .tpl)" mv "$f" "debian/$FINAL_NAME" sleep 0.5 done } _replenish_debian() { echo "Reabasteciendo directorio debian" echo "¿Existe debian? .. lo creo." [ -d debian ] || mkdir debian echo "Copiando ficheros" cp -rf "$DEBIAN_TPL"/* debian/ } _building_installation_tree() { echo "" echo "" echo "" echo "Construyendo el arbol de instalacion" #mkdir -p "install.$PACKAGE_BINARY" cp -rf "$SOURCE_FOLDER" "install.$PACKAGE_BINARY" echo "install.$PACKAGE_BINARY/* /" >> "debian/$PACKAGE_BINARY.install" } # Main if [ $# -eq 0 ] ; then _usage fi # Asigna valores de los parametros PACKAGE_SOURCE="$1" PACKAGE_BINARY="$2" if [ -n "$3" ] ; then $SOURCE_FOLDER="$3" _building_installation_tree fi #_check_parameters _replenish_debian _replace_vars exit 0