Repository 32bit  Forum
Repository 64bit  Wiki

Slackbuild Maker - Utility per creare Slackbuilds

Forum dedicato alla programmazione.

Moderatore: Staff

Regole del forum
1) Citare in modo preciso il linguaggio di programmazione usato.
2) Se possibile portare un esempio del risultato atteso.
3) Leggere attentamente le risposte ricevute.
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.

La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.

Slackbuild Maker - Utility per creare Slackbuilds

Messaggioda Blallo » lun mag 09, 2011 5:44

Visto che stanotte non avevo un piffero a cui pensare, e il sonno era questo sconosciuto
Ho buttato giù questa ciofeca, che a quanto pare, funziona
Ovviamente è scritto maluccio (è di getto), sicuramente migliorabile sia funzionalmente che esteticamente
Lo script si occupa sia dello SB, sia dello slack-desc che del doinst.sh
e li posiziona già nel ramo di directories $NAME/$VERSION/src
cotti e mangiati (cit) per essere lanciati
(lo slack-desc viene creato con lo script presente nel wiki)

https://github.com/jpage89/SlackBuild_Maker

Testate testate! \:D/
Ultima modifica di Blallo il ven nov 18, 2011 17:55, modificato 5 volte in totale.
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » mer mag 11, 2011 0:46

Nuova versione, se a qualcuno interessa ;)
E' essenzialmente una release "estetica", ma ho corretto un baco e ho iniziato l'implementazione di qualcosa

Codice: Seleziona tutto
#!/bin/sh

# Slackbuild Creator v 0.2

# Written by Savino Pio Liguori aka jimmy_page_89
# Contact: jimmy_page_89 AT hotmail DOT it

# This script create a Slackbuild, following the standards of the
# Slacky.eu community ( http:www.slacky.eu )

# Actual standard: 13.37

# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

WORKDIR=${$WORKDIR:-$HOME}
FAVEDITOR=${$FAVEDITOR:-vim}
SLACKYSTD=${$SLACKYSTD:-YES}

set -e

# Defining functions

_print_slackbuild()
{
# Creating slacky tree
mkdir -p $WORKDIR/$NAME/$VER/src

cat > $WORKDIR/$NAME/$VER/src/$NAME.SlackBuild << EOF
#!/bin/sh

# Heavily based on the Slackware 13.37 SlackBuild (v1)

# Written by $AUTH ( $AUTHMAIL )
# Last build from $BUILDER ( $BUILDMAIL )

# Slackware build script for $NAME
# Official Site: $SITE

# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

set -e

PKGNAME=$NAME
VERSION=\${VERSION:-$VER}
BUILD=\${BUILD:-$BUILD}
TAG=\${TAG:-sl}
ARCH=\${ARCH:-$ARCH}

SOURCE="$SRC"
TAR=$TAR
DIR=$DIR

# If EULA
if [ -e EULA.TXT ];then
  more EULA.TXT
  echo "Do you accept terms? (yes/[no])"
  read ACCEPT
  if [ "\$ACCEPT" != "yes" ];then
    echo; echo "SlackBuild Aborted!!"
    exit 1
  fi
fi

# Does not touch following if not needed
CWD=\$(pwd)
TMP=\${TMP:-/tmp/buildpkgs/\$PKGNAME}
PKG=\$TMP/package-\$PKGNAME
OUTPUT=\${OUTPUT:-\$CWD}
TAR=\${TAR:-\$(basename \$SOURCE)}
DIR=\${DIR:-\$(echo "\$TAR"|sed -r 's/(\.tar|)(.gz|.bz2|)$//')}

if [ ! -e \$CWD/\$TAR ];then
  wget \$SOURCE
fi

CHOST="i486"
if [ "\$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
  CHOST="x86_64"
fi

rm -rf \$TMP
mkdir -p \$TMP \$PKG \$OUTPUT
cd \$TMP
tar xvf \$CWD/\$TAR
cd \$DIR

$PATCH

chown -R root:root .
chmod -R u+w,go+r-w,a-s .

$MAKE

$SPECIAL

mkdir -p \$PKG/usr/doc/\$PKGNAME-\$VERSION
cp -r \\
  $DOC \\
  \$PKG/usr/doc/\$PKGNAME-\$VERSION

cat \$CWD/\$PKGNAME.SlackBuild > \$PKG/usr/doc/\$PKGNAME-\$VERSION/\$PKGNAME.SlackBuild
cat \$CWD/slack-desc > \$PKG/usr/doc/\$PKGNAME-\$VERSION/slack-desc

if [ -d \$PKG/usr/man ]; then
    ( cd \$PKG/usr/man
      find . -type f -exec gzip -9 {} \;
      for i in \$( find . -type l ) ; do ln -s \$( readlink \$i ).gz \$i.gz ; rm \$i ; done
    )
fi

( cd \$PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
  find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
)

mkdir -p \$PKG/install
cat \$CWD/slack-desc > \$PKG/install/slack-desc
[ -e \$CWD/doinst.sh ] && cat \$CWD/doinst.sh > \$PKG/install/doinst.sh

cd \$PKG
chown -R root:root \$PKG

if [ -x "\$(which requiredbuilder 2>/dev/null)" ];then
  requiredbuilder -y -v -s $SHAREBIN \$CWD \$PKG
fi

/sbin/makepkg -l y -c n \$OUTPUT/\$PKGNAME-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-txz}

if [ "\$1" = "--cleanup" ]; then
  rm -rf \$TMP
fi
EOF
}

_print_std_doinst()
{
cat > $WORKDIR/$NAME/$VER/src/doinst.sh << EOF
config() {
  NEW="\$1"
  OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r \$OLD ]; then
    mv \$NEW \$OLD
  elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
    # toss the redundant copy
    rm \$NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}
#if [ -e etc/rc.d/rc.script ]; then
#  cp -a etc/rc.d/rc.script etc/rc.d/rc.script.new.incoming
#  cat etc/rc.d/rc.script.new > etc/rc.d/rc.script.new.incoming
#  mv etc/rc.d/rc.script.new.incoming etc/rc.d/rc.script.new
#fi
#config etc/rc.d/rc.script.new
#config etc/configfile.new
EOF

$FAVEDITOR $WORKDIR/$NAME/$VER/src/doinst.sh

}

_print_slackdesc()
{
# This script was "inspired" from the original slack-desc script
# by naitso. You can find the original at this page:
# http://www.slacky.eu/wikislack/index.php?title=Crea_file_slack-desc

  local COUNT=0
  local R0
  local R1
  local R2

# Set file name
  local FILE=$WORKDIR/$NAME/$VER/src/slack-desc

  clear

# Check if slack-desc alredy exist in your work directory
  if [ -e $FILE ]; then
    while [ $COUNT == 0 ]; do
      clear
      echo "slack-desc on $WORKDIR alredy exist! Overwrite?"
      echo "Type Y/N or Q to quit"
      read R0
      case "$R0" in
        n | N )
     echo "This slack-desc become slack-desc.new"
     FILE=$FILE.new
     COUNT=1
     ;;
   y | Y )
     rm $WORKDIR/$FILE || exit 2
     COUNT=1
     ;;
   q | Q )
     echo "Quit"
     exit 0
     ;;
   * ) clear
     echo "Please enter only Y, N or Q to quit"
     sleep 2
   esac
    done
fi

# First question
  echo ""
  echo "Write a very short package's description and press ENTER"
  echo "(ex: Free FTP client)"
  echo ""
  read R1

# Second question
  echo ""
  echo "Write a package description and press ENTER"
  echo "(ascii only no fancy character: a-z and - or _)"
  echo ""
  read R2

#build slack-desc
  local NUM=0
  local SPACE=$(echo "$NAME" | sed -e "s/./ /g")
  local RULER="|----handy-ruler----"
  local N_RULER=$(echo -n "$RULER" | wc -m)
  local CHA=$(echo -n "$NAME" | wc -m)

# Set the max row for description
  local MAX_ROW=7

# limit the columns
  local COL=$[77-$CHA]
  if [ $CHA -gt "40" ]; then
    echo "Name too long, please change it"
    exit 1
  fi

  while [ $N_RULER -lt $[$COL+1] ]; do
    LINE=$LINE$(echo -n "-")
    N_RULER=$[N_RULER+1]
  done

# Slack-desc header   

cat > $FILE << EOF
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also customary
# to leave one space after the ':'.

$SPACE$RULER$LINE|
EOF

# limit description for slack-desc
  local ROW=$(echo $R2 | fmt -w $COL | sed -e "s/^/$NAME: &/ " | wc -l)
  if [ $ROW -ge "$MAX_ROW" ]; then
    ROW=$MAX_ROW
  fi
  local MAX=$[$MAX_ROW-$ROW]

# Adding package-name and short description to file, (all in one line)
  echo "$NAME ($R1)" | fmt -w $COL | sed -n -e "1,1s/^/$NAME: &/p " >> $FILE

# Adding a empty row
  echo $NAME: >> $FILE

# Adding the description in max 7 rows
  echo $R2 | fmt -w $COL | sed -n -e "1,7s/^/$NAME: &/p " >> $FILE

# Adding a empty row before homepage
  echo $NAME: >> $FILE

# If the rows are minus than 11, add the remaining (empty)
  while [ $NUM -lt $MAX ]; do
    echo "$NAME:" >> $FILE
      NUM=$[NUM+1]
  done
}

_download()
{
  local URL

  read -p "Insert your URL: " URL
  wget $URL
  mv $(basename $URL) $WORKDIR/$NAME/$VER/src/
}

_define_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Package name: " NAME
    read -p "$NAME - OK, No(n)" END
    if [ -z "$NAME" ]; then
      echo "Empty name!"
      END=n
    fi
  done
}

_define_official_site()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Official site: " SITE
    read -p "$SITE - OK, No(n)" END
    if [ -z "$SITE" ]; then
      echo "Empty site!"
      END=n
    fi
  done
}

_define_author()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Author: " AUTH
    read -p "Contact: " AUTHMAIL
    read -p "$AUTH ( $AUTHMAIL ) - OK, No(n)" END
    if [ -z "$AUTH" -o -z "$AUTHMAIL" ]; then
      if [ "$END" != "n" ]; then
        echo "Empty tags!"
        END=n
      fi
    fi
  done
}

_define_builder()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Last builder: " BUILDER
    read -p "Contact: " BUILDMAIL
    read -p "$BUILDER ( $BUILDMAIL ) - OK, No(n)" END
    if [ -z "$BUILDER" -o -z "$BUILDMAIL" ]; then
      if [ "$END" != "n" ]; then
        echo "Empty tags!"
        END=n
      fi
    fi
  done
}

_define_version()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Package version: " VER
    read -p "$VER - OK, No(n)" END
   
    if [ -z "$VER" ]; then
      echo "Empty tag!"
      END=n
   
    fi
  done
}

_set_build()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Package build (Enter if 1) :" BUILD

    if [ -z "$BUILD" ]; then
      BUILD=1
    fi

    read -p "$BUILD - OK, No(n)" END
  done
}

_define_arch()
{
  local END=n

  while [ "$END" = "n" ]; do
    echo "Please select architecture:"
    echo "  1) i486"
    echo "  2) i686"
    echo "  3) x86_64"
    echo "  4) noarch"
    echo "  5) host (same as uname -m): "
    read ARCH
   
    if [ "$ARCH" = "1" ]; then
      ARCH="i486"
    elif [ "$ARCH" = "2" ]; then
      ARCH="i686"
    elif [ "$ARCH" = "3" ]; then
      ARCH="x86_64"
    elif [ "$ARCH" = "4" ]; then
      ARCH="noarch"
    elif [ "$ARCH" = "5" ]; then
      ARCH=$(uname -m)
    else
      echo "Wrong option!"
      ARCH=""
    fi

    if [ ! -z "$ARCH" ]; then
      read -p "$ARCH - OK, No(n)" END
    fi
  done
}

_define_source_url()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Source URL (Press Enter if not): " SRC
    echo "$SRC"
    read -p "OK, No(n)" END
  done   
 
  if [ ! -z "$SRC" ]; then 
    SRC=$(echo $SRC | sed -e 's/'$VER'/$VERSION/') # Change the number version with the tag $VERSION
 
# -e 's/'$NAME'/$PKGNAME/' COME FUNZIONARE?
  fi
}

_set_tarball_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Tarball name (if not standard): " TAR
    if [ ! -z "$TAR" ]; then
      read -p "$TAR -OK, No(n)" END
    else
      END=""
    fi
  done

  if [ ! -z "$TAR" ]; then
    TAR=$(echo $TAR | sed -e 's/'$NAME'/$PKGNAME/' \
                          -e 's/'$VER'/$VERSION/')    # DA TESTARE
  fi
}

_set_dir_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Source directory (if not standard): " DIR
    if [ ! -z "$DIR" ]; then
      read -p "$DIR - OK, No(n)" END
    else
      END=""
    fi
  done
}

_write_patch()
{
  local END=n

  if [ -e "$WORKDIR/patch.tmp" ]; then
    rm $WORKDIR/patch.tmp
  fi
 
  while [ "$END" = "n" ]; do
    echo "Patch section"
    echo "Now this script is going to open $FAVEDITOR where"
    echo "you have to write the entire command of the patch(es)."
    echo "Simply don't save if there aren't patches."
    echo "(Don't forget the CWD variable!)"
    read

    $FAVEDITOR $WORKDIR/patch.tmp
    if [ -e "$WORKDIR/patch.tmp" ]; then
      PATCH=$(cat $WORKDIR/patch.tmp)
      echo "$PATCH"
      read -p "OK, No(n)" END
    else
      END=""
    fi
  done

  if [ -e "$WORKDIR/patch.tmp" ]; then
    rm $WORKDIR/patch.tmp
  fi
}

_set_build_type()
{
  local END=n
  local BUTYPE

  while [ "$END" = "n" ]; do
    echo "What type of build have this package?"
    echo "  1) configure"
    echo "  2) cmake"
    echo "  3) python"
    echo "  *) custom"
    read BUTYPE

    case "$BUTYPE" in
      1)
        _std_conf
        ;;
      2)
        _cmake_conf
        ;;
      3)
        _py_conf
        ;;
      *)
        $FAVEDITOR $WORKDIR/build.tmp
    esac

    MAKE=`cat $WORKDIR/build.tmp`
    echo ""
    read -p "It's all ok? OK, No(n)" END
    rm $WORKDIR/build.tmp
  done
}
_write_special_op()
{
  local END=n

  if [ -e "$WORKDIR/special.tmp" ]; then
    rm $CWD/special.tmp
  fi

  while [ "$END" = "n" ]; do
    echo "Special operations section"
    echo "Now this script is going to open $FAVEDITOR where"
    echo "you have to write special operations."
    echo "Simply don't save if there isn't nothing to do."
    read

    $FAVEDITOR $WORKDIR/special.tmp
    if [ -e "$WORKDIR/special.tmp" ]; then
      SPECIAL=$(cat $WORKDIR/special.tmp)
      echo "$SPECIAL"
      read -p "OK, No(n)" END
    else
      END=""
    fi
  done

  if [ -e "$WORKDIR/special.tmp" ]; then
    rm $WORKDIR/special.tmp
  fi
}

_select_docs()
{
  local END=n
 
  while [ "$END" = "n" ]; do
    read -p "Insert documentation file names: " DOC
    if [ -z "$DOC" ]; then
      echo "Empty tag!"
    else
     read -p "$DOC - OK, No(n)" END
    fi
  done
}

_sharebin()
{
  local END=n

  while [ "$END" = "n" ]; do
    read -p "Do you have some binaries in /usr/share? ok(y), NO " SHAREBIN
    if [ -z "$SHAREBIN" ]; then
      read -p "There aren't. OK, No(n)" END
    else
      read -p "There are. OK, No(n)" END
      SHAREBIN="-c -b"
    fi
  done
}

_std_conf()
{
cat > $WORKDIR/build.tmp << EOF
CFLAGS="\$SLKCFLAGS" \\
CXXFLAGS="\$SLKCFLAGS" \\
./configure \\
  --prefix=/usr \\
  --libdir=/usr/lib\$LIBDIRSUFFIX \\
  --sysconfdir=/etc \\
  --localstatedir=/var \\
  --mandir=/usr/man \\
  --build=\$CHOST-slackware-linux
make
make install DESTDIR=\$PKG
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}

_cmake_conf()
{
cat > $WORKDIR/build.tmp << EOF
( mkdir -p build
  cd build
  cmake .. \
    -DCMAKE_C_FLAGS:STRING="\$SLKCFLAGS" \\
    -DCMAKE_CXX_FLAGS:STRING="\$SLKCFLAGS" \\
    -DCMAKE_INSTALL_PREFIX=/usr \\
    -DMAN_INSTALL_DIR=/usr/man \\
    -DSYSCONF_INSTALL_DIR=/etc \\
    -DLIB_SUFFIX=\${LIBDIRSUFFIX}
  make
  make install DESTDIR=\$PKG
)
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}

_py_conf()
{
cat > $WORKDIR/build.tmp << EOF
python setup.py install --root=\$PKG
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}



_slack_desc()
{
  local DSK

  echo "What do you want to do with slack-desc?"
  echo "  1) Create"
  echo "  2) Download"
  echo "  *) I do not want it, i'm a Pidgey"
  read DSK

  case "$DSK" in
    1)
      _print_slackdesc
      ;;
    2)
      _down_files
      ;;
    *)
      echo "Please supports fat pidgeons."
      ;;
  esac
}

_doinst()
{
  local OPT

  clear
 
  echo "What do you want to do with doinst.sh?"
  echo "  1) Create"
  echo "  2) Create from Slacky Standard"
  echo "  3) Download"
  echo "  *) I don't need it."
  read OPT
 
  case "$OPT" in
    1)
      $FAVEDITOR $WORKDIR/$NAME/$VERSION/src/doinst.sh
      ;;
    2)
      _print_std_doinst
      ;;
    3)
      _download
      ;;
    *)
      echo "KTHXBAI"
      ;;
  esac
}



# Now the real script starts

echo "SlackBuild Creator"

# Package name
_define_name

 # Official site
_define_official_site

# Author
_define_author

# Packager
_define_builder

# Version
_define_version

# Number of build
_set_build

# Architecture
_define_arch

# Source URL
_define_source_url

# Tarball name
_define_tarball_name

# Sources dir
_set_dir_name

# Patches
_write_patch

# Configure, cmake or other?
_set_build_type

# Special operations
_write_special_op

# Documentation
_select_docs

# Binaries in /usr/share
_sharebin

# Now let's go!!!

echo "Ok, all data insert. Press Enter to create $NAME.Slackbuild in $WORKDIR/$NAME/$VER/src"
read

_print_slackbuild # print..print...print..

_doinst # doinst.sh

_slack_desc # Slack-desc choises

echo "Ok, that's all folks. Thanks a lot for using Slackbuild Creator! ^TM"

exit 0


Codice: Seleziona tutto
CHANGELOG

0.2
 - Changed default workdir
   * Now is set to $HOME by default

 - Fixed global variables
   * Now you can determine they externally

 - Inverted _build_type() and _special()

 - Added SLACKYSTD
   * Set NO if you don't want Slacky.eu standard
     (WARNING: not implemented yet)

 - In function _std_doinst()
   * Renamed in _print_std_doinst

 - In function _down_files()
   * Renamed in _download (c'est plus facile)
   * Fixed "mv" section to move every file you want

 - In function _name()
   * Renamed in _define_name()

 - In function _official()
   * Renamed in _define_official_site()

 - In function _auth()
   * Renamed in _define_author()

 - In function _builder()
   * Renamed in _define_builder()

 - In function _arch()
   * Renamed in _define_arch()

 - In function _source()
   * Renamed in _define_source_url()

 - In function _tarball()
   * Renamed in _set_tarball_name()

 - In function _dir()
   * Renamed in _set_dir_name()

 - In function _patch()
   * Renamed in _write_patch()
   * Fix "rm" section

 - In function _build_type()
   * Renamed in _set_build_type()

 - In function _special()
   * Renamed in _write_special_op()

 - In function _doc()
   * Renamed in _select_docs
 -
   
0.1
 - First release
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda brainvision » mer mag 11, 2011 0:58

Codice: Seleziona tutto
# Slacky.eu community ( http://www.slacky.eu )
Avatar utente
brainvision
Packager
Packager
 
Messaggi: 756
Iscritto il: ven dic 26, 2008 18:23
Località: bologna (bo)
Nome Cognome: Leonardo Totaro
Slackware: x86_64-current
Kernel: 3.7.1
Desktop: xfce 4.10

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » mer mag 11, 2011 4:12

NUOVA VERSIONE!

Testata più e più volte, funziona perfettamente

Lasciatemi un po' di feedback su [-o<
Codice: Seleziona tutto
#!/bin/sh

# Slackbuild Creator v 0.3

# Written by Savino Pio Liguori aka jimmy_page_89
# Contact: jimmy_page_89 AT hotmail DOT it

# This script create a Slackbuild, following the standards of the
# Slacky.eu community ( http://www.slacky.eu )

# Actual standard: 13.37

# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

WORKDIR=${WORKDIR:-$HOME}
FAVEDITOR=${FAVEDITOR:-vim}
# Set NO if you don't want to use Slacky.eu standard (At now only output directory tree)
SLACKYSTD=${SLACKYSTD:-YES}

set -e

# Defining commands "prototypes" (don't touch this)
COMMANDS="_intro
_define_name
_define_official_site
_define_author
_define_builder
_define_version
_set_build 
_define_arch
_define_source_url
_set_tarball_name
_set_dir_name
_write_patch
_set_build_type
_write_special_op
_select_docs
_sharebin
_print_slackbuild
_slack_desc
_doinst
_outro"

# Defining functions

_set_tree()
{
# This section set AUTOMATICALLY where you want
# to put all your work.
#Don't edit this part!!!

  if [ -d $WORKDIR/$NAME ]; then
    rm -rf $WORKDIR/$NAME
  fi
 
  if [ "$SLACKYSTD" = "YES" ]; then
    mkdir -p $WORKDIR/$NAME/$VER/src
    EXPDIR=$WORKDIR/$NAME/$VER/src
  else
    EXPDIR=$WORKDIR
  fi
}

_print_slackbuild()
{
  _set_tree
 
  _clscr
 
  echo "Ok, all data insert."
  echo ""
  echo "Press Enter to create $NAME.Slackbuild in $EXPDIR"
  echo ""
  read

cat > $EXPDIR/$NAME.SlackBuild << EOF
#!/bin/sh

# Heavily based on the Slackware 13.37 SlackBuild (v1)

# Written by $AUTH ( $AUTHMAIL )
# Last build from $BUILDER ( $BUILDMAIL )

# Slackware build script for $NAME
# Official Site: $SITE

# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

set -e

PKGNAME=$NAME
VERSION=\${VERSION:-$VER}
BUILD=\${BUILD:-$BUILD}
TAG=\${TAG:-sl}
ARCH=\${ARCH:-$ARCH}

SOURCE="$SRC"
TAR=$TAR
DIR=$DIR

# If EULA
if [ -e EULA.TXT ];then
  more EULA.TXT
  echo "Do you accept terms? (yes/[no])"
  read ACCEPT
  if [ "\$ACCEPT" != "yes" ];then
    echo; echo "SlackBuild Aborted!!"
    exit 1
  fi
fi

# Does not touch following if not needed
CWD=\$(pwd)
TMP=\${TMP:-/tmp/buildpkgs/\$PKGNAME}
PKG=\$TMP/package-\$PKGNAME
OUTPUT=\${OUTPUT:-\$CWD}
TAR=\${TAR:-\$(basename \$SOURCE)}
DIR=\${DIR:-\$(echo "\$TAR"|sed -r 's/(\.tar|)(.gz|.bz2|)$//')}

if [ ! -e \$CWD/\$TAR ];then
  wget \$SOURCE
fi

CHOST="i486"
if [ "\$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "\$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
  CHOST="x86_64"
fi

rm -rf \$TMP
mkdir -p \$TMP \$PKG \$OUTPUT
cd \$TMP
tar xvf \$CWD/\$TAR
cd \$DIR

$PATCH

chown -R root:root .
chmod -R u+w,go+r-w,a-s .

$MAKE

$SPECIAL

mkdir -p \$PKG/usr/doc/\$PKGNAME-\$VERSION
cp -r \\
  $DOC \\
  \$PKG/usr/doc/\$PKGNAME-\$VERSION

cat \$CWD/\$PKGNAME.SlackBuild > \$PKG/usr/doc/\$PKGNAME-\$VERSION/\$PKGNAME.SlackBuild
cat \$CWD/slack-desc > \$PKG/usr/doc/\$PKGNAME-\$VERSION/slack-desc

if [ -d \$PKG/usr/man ]; then
    ( cd \$PKG/usr/man
      find . -type f -exec gzip -9 {} \;
      for i in \$( find . -type l ) ; do ln -s \$( readlink \$i ).gz \$i.gz ; rm \$i ; done
    )
fi

( cd \$PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
  find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
)

mkdir -p \$PKG/install
cat \$CWD/slack-desc > \$PKG/install/slack-desc
[ -e \$CWD/doinst.sh ] && cat \$CWD/doinst.sh > \$PKG/install/doinst.sh

cd \$PKG
chown -R root:root \$PKG

if [ -x "\$(which requiredbuilder 2>/dev/null)" ];then
  requiredbuilder -y -v -s $SHAREBIN \$CWD \$PKG
fi

/sbin/makepkg -l y -c n \$OUTPUT/\$PKGNAME-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-txz}

if [ "\$1" = "--cleanup" ]; then
  rm -rf \$TMP
fi
EOF
}

_print_std_doinst()
{
cat > $EXPDIR/doinst.sh << EOF
config() {
  NEW="\$1"
  OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r \$OLD ]; then
    mv \$NEW \$OLD
  elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
    # toss the redundant copy
    rm \$NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}
#if [ -e etc/rc.d/rc.script ]; then
#  cp -a etc/rc.d/rc.script etc/rc.d/rc.script.new.incoming
#  cat etc/rc.d/rc.script.new > etc/rc.d/rc.script.new.incoming
#  mv etc/rc.d/rc.script.new.incoming etc/rc.d/rc.script.new
#fi
#config etc/rc.d/rc.script.new
#config etc/configfile.new
EOF

$FAVEDITOR $EXPDIR/doinst.sh

}

_print_slackdesc()
{
# This script was "inspired" from the original slack-desc script
# by naitso. You can find the original at this page:
# http://www.slacky.eu/wikislack/index.php?title=Crea_file_slack-desc

  local COUNT=0
  local R0
  local R1
  local R2
  local R3

  if [ -e $EXPDIR/slack-desc ]; then
    rm $EXPDIR/slack-desc
  fi

# First question
  _clscr
  echo "Write a very short package's description and press ENTER"
  echo "(ex: Free FTP client)"
  echo ""
  read R1

# Second question
  _clscr
  echo "Write a package description and press ENTER"
  echo "(ascii only no fancy character: a-z and - or _)"
  echo ""
  read R2

# Third question, only if you are NOT using Slacky.eu standard
  if [ "$SLACKYSTD" = "NO" ]; then
    _clscr
    echo "Write package's homepage and press ENTER"
    echo "(ex:http://www.example.org)"
    echo ""
    read R3
  fi

# Build slack-desc
  local NUM=0
  local SPACE=$(echo "$NAME" | sed -e "s/./ /g")
  local RULER="|----handy-ruler----"
  local N_RULER=$(echo -n "$RULER" | wc -m)
  local CHA=$(echo -n "$NAME" | wc -m)

# Set the max row for description
  local MAX_ROW=9

# Limit the columns
  local COL=$[77-$CHA]
 
  if [ $CHA -gt "40" ]; then
    echo "Name too long, please change it"
    exit 1
  fi

  while [ $N_RULER -lt $[$COL+1] ]; do
    local LINE=$LINE$(echo -n "-")
    N_RULER=$[N_RULER+1]
  done
 
# Slack-desc header   

cat > $EXPDIR/slack-desc << EOF
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also customary
# to leave one space after the ':'.

$SPACE$RULER$LINE|
EOF

# limit description for slack-desc
  local ROW=$(echo $R2 | fmt -w $COL | sed -e "s/^/$NAME: &/ " | wc -l)
 
  if [ $ROW -ge "$MAX_ROW" ]; then
    ROW=$MAX_ROW
  fi
 
  local MAX=$[$MAX_ROW-$ROW]

# Adding package-name and short description to file, (all in one line)
  echo "$NAME ($R1)" | fmt -w $COL | sed -n -e "1,1s/^/$NAME: &/p " >> $EXPDIR/slack-desc

# Adding a empty row
  echo $NAME: >> $EXPDIR/slack-desc

# Adding the description in max 7 rows
  echo $R2 | fmt -w $COL | sed -n -e "1,7s/^/$NAME: &/p " >> $EXPDIR/slack-desc

  if [ "$SLACKYSTD" = "NO" ]; then
# Adding a empty row before homepage
    echo $NAME: >> $EXPDIR/slack-desc
# Adding homepage
    echo "$NAME: ($R3)" >> $EXPDIR/slack-desc
  fi
# If the rows are minus than 11, add the remaining (empty)
while [ $NUM -lt $MAX ]; do
   echo "$NAME:" >> $EXPDIR/slack-desc
   NUM=$[NUM+1]
done
}

_download()
{
  _clscr
  local URL

  read -p "Insert your URL: " URL
  wget $URL -O $EXPDIR/$(basename $URL)
}

_define_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Package name: " NAME
    echo ""
   
    if [ -z "$NAME" ]; then
      echo "Empty tag. Please rewrite."
      read
    else
      echo "$NAME"
      echo ""
      read -p "OK, No(n) " END
    fi
  done
}

_define_official_site()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Official site: " SITE
    echo ""
   
    if [ -z "$SITE" ]; then
      echo "Empty tag. Please rewrite."
      read
    else
      echo "$SITE"
      echo ""
      read -p "OK, No(n)" END
    fi
  done
}

_define_author()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Author: " AUTH
    echo ""
    read -p "Contact: " AUTHMAIL
    echo ""
   
    if [ -z "$AUTH" -o -z "$AUTHMAIL" ]; then
      echo "Empty tag(s). Please rewrite."
      read
    else
      echo "$AUTH ( $AUTHMAIL )"
      echo ""
      read -p "OK, No(n)" END     
    fi
  done
}

_define_builder()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Last builder: " BUILDER
    echo ""
    read -p "Contact: " BUILDMAIL
    echo ""
   
    if [ -z "$BUILDER" -o -z "$BUILDMAIL" ]; then
      echo "Empty tag(s). Please rewrite."
      read
    else
      echo "$BUILDER ( $BUILDMAIL )"
      echo ""
      read -p "OK, No(n)" END
    fi
  done
}

_define_version()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Package version: " VER
    echo ""
   
    if [ -z "$VER" ]; then
      echo "Empty tag. Please rewrite."
      read
    else
      echo "$VER"
      echo ""
      read -p "OK, No(n)" END
    fi
  done
}

_set_build()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Package build (Enter if 1) :" BUILD
    echo ""

    if [ -z "$BUILD" ]; then
      BUILD=1
    fi
   
    echo "$BUILD"
    echo ""
    read -p "OK, No(n)" END
  done
}

_define_arch()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    echo "Please select architecture:"
    echo "  1) i486"
    echo "  2) i686"
    echo "  3) x86_64"
    echo "  4) noarch"
    echo "  5) host (same as uname -m): "
    echo ""
    read ARCH
    echo ""
   
    if [ "$ARCH" = "1" ]; then
      ARCH="i486"
    elif [ "$ARCH" = "2" ]; then
      ARCH="i686"
    elif [ "$ARCH" = "3" ]; then
      ARCH="x86_64"
    elif [ "$ARCH" = "4" ]; then
      ARCH="noarch"
    elif [ "$ARCH" = "5" ]; then
      ARCH=$(uname -m)
    else
      echo "Wrong option!"
      echo "Please rewrite"
      ARCH=""
      read
    fi

    if [ ! -z "$ARCH" ]; then
      echo "$ARCH"
      echo ""
      read -p "OK, No(n)" END
    fi
  done
}

_define_source_url()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Source URL (Press Enter if not): " SRC
    echo ""
   
    if [ -z "$SRC" ]; then
      echo "No download link"
    else
      echo "$SRC"
    fi
   
    echo ""
    read -p "OK, No(n)" END
  done   
 
  if [ ! -z "$SRC" ]; then 
    # Change the number version with the tag $VERSION
    SRC=$(echo $SRC | sed -e 's/'$VER'/$VERSION/')
  fi
}

_set_tarball_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Tarball name (if not standard): " TAR
    echo ""
    if [ -z "$TAR" ]; then
     END=""
    else
      echo "$TAR"
      echo ""
      read -p "OK, No(n)" END
    fi
  done

  if [ ! -z "$TAR" ]; then
    TAR=$(echo $TAR | sed -e 's/'$NAME'/$PKGNAME/' \
                          -e 's/'$VER'/$VERSION/')
  fi
}

_set_dir_name()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Source directory (if not standard): " DIR
    echo ""
   
    if [ -z "$DIR" ]; then
      END=""
    else 
      echo "$DIR"
      echo ""
      read -p "OK, No(n)" END
    fi
   
  if [ ! -z "$DIR" ]; then
    DIR=$(echo $DIR | sed -e 's/'$NAME'/$PKGNAME/' \
                          -e 's/'$VER'/$VERSION/')
  fi
  done
}

_write_patch()
{
  local END=n

  if [ -e "$WORKDIR/patch.tmp" ]; then
    rm $WORKDIR/patch.tmp
  fi
 
  while [ "$END" = "n" ]; do
    _clscr
    echo "Patch section"
    echo "Now this script is going to open $FAVEDITOR where"
    echo "you have to write the entire command of the patch(es)."
    echo "Simply don't save if there aren't patches."
    echo "(Don't forget the CWD variable!)"
    echo ""
    read

   clear
   
    $FAVEDITOR $EXPDIR/patch.tmp
   
    _clscr
   
    if [ -e "$WORKDIR/patch.tmp" ]; then
      PATCH=$(cat $WORKDIR/patch.tmp)
      echo "$PATCH"
    fi
   
    if [ ! -e "$WORKDIR/patch.tmp" -o -z "$PATCH" ]; then
      echo "Nothing to patch"
    fi
     
    echo ""
    read -p "OK, No(n)" END
   
  done

  if [ -e "$WORKDIR/patch.tmp" ]; then
    rm $WORKDIR/patch.tmp
  fi
}

_set_build_type()
{
  local END=n
  local BUTYPE
 
  if [ -e $WORKDIR/build.tmp ]; then
    rm $WORKDIR/build.tmp
  fi

  while [ "$END" = "n" ]; do
    _clscr
    echo "What type of build have this package?"
    echo "  1) configure (DEFAULT)"
    echo "  2) cmake"
    echo "  3) python"
    echo "  4) custom"
    echo ""
    read BUTYPE

   if [ -z "$BUTYPE" ]; then
     BUTYPE=1
   fi
   
   clear
   
    case "$BUTYPE" in
      1)
        _std_conf
        ;;
      2)
        _cmake_conf
        ;;
      3)
        _py_conf
        ;;
      4)
        $FAVEDITOR $WORKDIR/build.tmp
    esac
   
   _clscr
   
   if [ -e $WORKDIR/build.tmp ]; then
      MAKE=$(cat $WORKDIR/build.tmp)
      echo "$MAKE"
      echo ""
    fi
     
    if [ ! -e "$WORKDIR/build.tmp" -o -z "$MAKE" ]; then
      echo ""
      echo "File not present. Please rewrite"
    else
      read -p "It's all ok? OK, No(n)" END     
    fi
 
    if [ -e $WORKDIR/build.tmp ]; then
      rm $WORKDIR/build.tmp
    fi
  done
}

_write_special_op()
{
  local END=n

  if [ -e "$WORKDIR/special.tmp" ]; then
    rm $WORKDIR/special.tmp
  fi

  while [ "$END" = "n" ]; do
    _clscr
    echo ""
    echo "Special operations section"
    echo "Now this script is going to open $FAVEDITOR where"
    echo "you have to write special operations."
    echo "Simply don't save if there isn't nothing to do."
    echo ""
    read

    clear
   
    $FAVEDITOR $WORKDIR/special.tmp
   
    _clscr
    if [ -e "$WORKDIR/special.tmp" ]; then
      SPECIAL=$(cat $WORKDIR/special.tmp)
      echo "$SPECIAL"
    fi
   
    if [ ! -e "$WORKDIR/special.tmp" -o -z "$SPECIAL" ]; then
      echo "Nothing to insert?"
    fi
   
    echo ""
    read -p "OK, No(n)" END
  done

  if [ -e "$WORKDIR/special.tmp" ]; then
    rm $WORKDIR/special.tmp
  fi
}

_select_docs()
{
  local END=n
 
  while [ "$END" = "n" ]; do
    _clscr
    read -p "Insert documentation file names: " DOC
    echo ""
   
    if [ -z "$DOC" ]; then
      echo "Empty tag. Please rewrite."
      read
    else
      echo "$DOC"
      echo ""
      read -p "OK, No(n)" END
    fi   
  done
}

_sharebin()
{
  local END=n

  while [ "$END" = "n" ]; do
    _clscr
    read -p "Do you have some binaries in /usr/share? ok(y), NO " SHAREBIN
    echo ""
   
    if [ -z "$SHAREBIN" ]; then
      echo "Nothing in /usr/share"
    else
      echo "Nothing in /usr/share"
      SHAREBIN="-c -b"
    fi

    echo ""
    read -p "OK, No(n)" END   
  done
}

_std_conf()
{
cat > $WORKDIR/build.tmp << EOF
CFLAGS="\$SLKCFLAGS" \\
CXXFLAGS="\$SLKCFLAGS" \\
./configure \\
  --prefix=/usr \\
  --libdir=/usr/lib\$LIBDIRSUFFIX \\
  --sysconfdir=/etc \\
  --localstatedir=/var \\
  --mandir=/usr/man \\
  --build=\$CHOST-slackware-linux
make
make install DESTDIR=\$PKG
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}

_cmake_conf()
{
cat > $WORKDIR/build.tmp << EOF
( mkdir -p build
  cd build
  cmake .. \
    -DCMAKE_C_FLAGS:STRING="\$SLKCFLAGS" \\
    -DCMAKE_CXX_FLAGS:STRING="\$SLKCFLAGS" \\
    -DCMAKE_INSTALL_PREFIX=/usr \\
    -DMAN_INSTALL_DIR=/usr/man \\
    -DSYSCONF_INSTALL_DIR=/etc \\
    -DLIB_SUFFIX=\${LIBDIRSUFFIX}
  make
  make install DESTDIR=\$PKG
)
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}

_py_conf()
{
cat > $WORKDIR/build.tmp << EOF
python setup.py install --root=\$PKG
EOF

  $FAVEDITOR $WORKDIR/build.tmp
}

_slack_desc()
{
  local OPT
 
  _clscr
 
  echo "What do you want to do with slack-desc?"
  echo "  1) Create (DEFAULT)"
  echo "  2) Download"
  echo "  3) I do not want it"
  echo ""
  read OPT
 
  if [ -z "$OPT" ]; then
    OPT=1
  fi

  case "$OPT" in
    1)
      _print_slackdesc
      ;;
    2)
      _download
      ;;
    3)
     clear
      echo ""
      echo "Please supports fat pidgeons."
      echo ""
      read
      ;;
  esac
}

_doinst()
{
  local OPT
 
  _clscr
 
  echo "What do you want to do with doinst.sh?"
  echo "  1) Create from Slacky Standard (DEFAULT)"
  echo "  2) Create from scratch"
  echo "  3) Download"
  echo "  4) I don't need it."
  echo ""
  read OPT
 
  if [ -z "$OPT" ]; then
    OPT=1
  fi
 
  case "$OPT" in
    1)
      _print_std_doinst
      ;;     
    2)
      $FAVEDITOR $EXPDIR/doinst.sh
      ;;
    3)
      _download
      ;;
    4)
      clear
      echo ""
      echo "Please supports fat pidgeons."
      echo ""
      read
      ;;
  esac
}

_intro()
{
  _clscr
  echo "Press ENTER to start"
  echo ""
  read
}

_outro()
{
  _clscr
  echo "Ok, that's all folks. Thanks a lot for using Slackbuild Creator! ^TM"
  read
}

_clscr()
{
  clear
  echo ""
  echo "####################################################"
  echo "#                                                  #"
  echo "#                SlackBuild Creator                #"
  echo "#                 by jimmy_page_89                 #"
  echo "#                                                  #"
  echo "####################################################"
  echo ""
}

# Now the real script starts. Radically simple!

for i in $COMMANDS; do
  $i
done

exit 0


Codice: Seleziona tutto
CHANGELOG

0.3
 - Correct script header (thanks to brainvision)
 
 - General fixed output
   * Now is so coooool
 
 - Inverted _doinst() and _slack_desc
 
 - Changed command execution
   * introduced COMMANDS
 
 - Added _intro() and _outro() functions
 
 - Added EXPDIR
   * Set where you want to put slackbuilds
 
 - In function _print_slackdesc()
   * Removed clear
   * Removed check of existing files, now it remove by default
   * Main bugs fixed
   * Removed variable FILE
   * Fixed some local variables
   * Added non-Slacky-standard support
   * WARNING: consider ALL in TESTING
 
 - In function _slack_desc()
   * Set option 1 as default
   * Set 3 to option NOT
   * Changed variable DSK in OPT
 
 - In function _doinst()
   * Set option 1 as Slacky standard and made as default.
   * Set option 2 to desc from scratch
   * Set option 4 to NOT
   
 - In function _download()
   * Added EXPDIR
   
 - In function _set_tarball_name()
   * Out of testing the "sed" part
 
 - In function _set_dir_name()
   * Added "sed" correction part
 
 - In function _set_build_type()
   * Add first control, removing build.tmp if exists (TESTING)
   * Set "configure" as default
   
 - In function _write_special_op()
   * Fixed first removing operation
   
 - In function _set_build_type()
   * Added second "if exists" control
   
 - In function _write_special_op()
   * Fixed control, file may not exists and you don't want it
 
 - In function _print-slackbuild()
   * moved _set_tree() inside
   
 - Added some comments


0.2
 - Changed default workdir
   * Now is set to $HOME by default

 - Fixed global variables
   * Now you can determine they externally

 - Inverted _build_type() and _special()

 - Added SLACKYSTD
   * Set NO if you don't want Slacky.eu standard
     (WARNING: not implemented yet)

 - In function _std_doinst()
   * Renamed in _print_std_doinst

 - In function _down_files()
   * Renamed in _download (c'est plus facile)
   * Fixed "mv" section to move every file you want

 - In function _name()
   * Renamed in _define_name()

 - In function _official()
   * Renamed in _define_official_site()

 - In function _auth()
   * Renamed in _define_author()

 - In function _builder()
   * Renamed in _define_builder()

 - In function _arch()
   * Renamed in _define_arch()

 - In function _source()
   * Renamed in _define_source_url()

 - In function _tarball()
   * Renamed in _set_tarball_name()

 - In function _dir()
   * Renamed in _set_dir_name()

 - In function _patch()
   * Renamed in _write_patch()
   * Fix "rm" section

 - In function _build_type()
   * Renamed in _set_build_type()

 - In function _special()
   * Renamed in _write_special_op()

 - In function _doc()
   * Renamed in _select_docs
 -
   
0.1
 - First release
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda 6C33C » mer mag 11, 2011 7:27

Ho provato copiarlo 2 votle ma la versione 0.3 mi da questo errore:

bash-4.1# ./SlackBuild_Creator
./SlackBuild_Creator: line 943: warning: here-document at line 91 delimited by end-of-file (wanted `EOF')
./SlackBuild_Creator: line 944: syntax error: unexpected end of file
Avatar utente
6C33C
Packager
Packager
 
Messaggi: 254
Iscritto il: gio ott 12, 2006 15:09
Località: Rimini
Nome Cognome: Giorgio
Slackware: 14.0 x86_64
Kernel: 3.9.7
Desktop: kde 4.10.4 ,razorqt

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda brainvision » mer mag 11, 2011 8:24

6C33C ha scritto:Ho provato copiarlo 2 votle ma la versione 0.3 mi da questo errore:

bash-4.1# ./SlackBuild_Creator
./SlackBuild_Creator: line 943: warning: here-document at line 91 delimited by end-of-file (wanted `EOF')
./SlackBuild_Creator: line 944: syntax error: unexpected end of file


stavo per postare lo stesso identico problema! ;)
Avatar utente
brainvision
Packager
Packager
 
Messaggi: 756
Iscritto il: ven dic 26, 2008 18:23
Località: bologna (bo)
Nome Cognome: Leonardo Totaro
Slackware: x86_64-current
Kernel: 3.7.1
Desktop: xfce 4.10

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda danix » mer mag 11, 2011 8:37

se copiate dal forum fate attenzione che phpbb non abbia inserito degli spazi indesiderati..

@jimmy_page_89:
converrebbe un tar.gz anche delle ultime versioni, così lo si può provare più agilmente..
Avatar utente
danix
Staff
Staff
 
Messaggi: 3280
Iscritto il: ven ott 27, 2006 18:32
Località: Siderno (RC)
Nome Cognome: Danilo M.
Slackware: 64 14.0
Kernel: 3.2.29
Desktop: fluxbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » mer mag 11, 2011 11:14

Avete ragione, risolvo subito
Allegati
slk_crt.tar.gz
(6.55 KiB) Scaricato 45 volte
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda brainvision » mer mag 11, 2011 11:18

danix ha scritto:se copiate dal forum fate attenzione che phpbb non abbia inserito degli spazi indesiderati..


giusto.. risolto :)
Avatar utente
brainvision
Packager
Packager
 
Messaggi: 756
Iscritto il: ven dic 26, 2008 18:23
Località: bologna (bo)
Nome Cognome: Leonardo Totaro
Slackware: x86_64-current
Kernel: 3.7.1
Desktop: xfce 4.10

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda ZeroUno » mer mag 11, 2011 12:34

Tempo fa ne feci uno io (incompleto). Una caratteristica che mi piaceva: accettava in input solo l'url; il resto delle opzioni base se lo prendeva da solo (se l'url era standard; ma se ne potrebbe fare uno intelligente che si fa diversi controlli, lo scompatta pure e cerca da solo cose che possono essere utili o che fanno il pacchetto poco diverso)
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg
Codice: Seleziona tutto
1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111
Avatar utente
ZeroUno
Staff
Staff
 
Messaggi: 4304
Iscritto il: ven giu 02, 2006 13:52
Località: Roma / Castelli
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » mer mag 11, 2011 12:41

ZeroUno ha scritto:Tempo fa ne feci uno io (incompleto). Una caratteristica che mi piaceva: accettava in input solo l'url; il resto delle opzioni base se lo prendeva da solo (se l'url era standard; ma se ne potrebbe fare uno intelligente che si fa diversi controlli, lo scompatta pure e cerca da solo cose che possono essere utili o che fanno il pacchetto poco diverso)

E' una cosa che avrei voluto fare anche io, ma ho troppo limitate conoscenze di bash, sed & affini
(tant'è che i pochissimi pezzi in sed sono solo frutto di faticose ricerche con google)

Anche se comunque alcuni lavori a mano sono comunque da fare (configurazione, operazioni extra, patch)
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » mer mag 11, 2011 12:46

Le cose che vorrei fare per il rilascio della 1.0 ( :lol: :lol: ) ora sono:
- Download di files aggiuntivi (è roba di due secondi, ma non mi andava di farla stanotte)
- Scelta di editare con vim (o altro) lo SB pronto (anche qui due secondi, ma sono più slack dello slack a volte)
- Evitare di dover per forza creare un file, ma magari buttare quello da scrivere in vim (con il parametro "-", senza apici, si può fare), ma dargli già un nome per salvarlo (e questa sarebbe una cosa carina)

Alla fin fine vorrei farlo diventare una sorta di "suite per pacchettizzatori", con scrittura dello SB, compilazione e up in diretta (magari con un'interfaccia a menu, e non sequenziale come ora...)
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda danix » mer mag 11, 2011 14:27

jimmy_page_89 ha scritto:Avete ragione, risolvo subito

scusa se rompo, comunque se hai intenzione di proseguire lo sviluppo ti conviene IMHO aggiornare di volta in volta il primo post e il relativo allegato, così se il thread si allunga non bisogna andare avanti nelle pagine per trovare le ultime versioni.. ;)

just my 2 cents..
Avatar utente
danix
Staff
Staff
 
Messaggi: 3280
Iscritto il: ven ott 27, 2006 18:32
Località: Siderno (RC)
Nome Cognome: Danilo M.
Slackware: 64 14.0
Kernel: 3.2.29
Desktop: fluxbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda Blallo » lun mag 30, 2011 1:36

Nuova versione! 0.4

- Aggiunto download di altri files
- Cambiamento impostazioni di default
- Aggiunta del proprio contatto come "last builder" definita nello script e non più a richiesta (molto più comodo)
- Corretto bug patch (non inseriva eventuali righe per patchare)

Codice e tarball al primo post
Io sono il detective Arsenio Magret, e porto sempre la camicia TATUATA!
Avatar utente
Blallo
Packager
Packager
 
Messaggi: 3214
Iscritto il: ven ott 12, 2007 10:37
Località: Torino / Torremaggiore (FG)
Nome Cognome: Savino Liguori
Slackware: 14.1 / 12.2
Kernel: 3.12.2-ck
Desktop: Openbox

Re: Slackbuild Creator - Utility per creare Slackbuilds

Messaggioda ZeroUno » lun mag 30, 2011 8:50

Per Documentations dai qualche default, per esempio [A-Z]* (come da ultimo template) o (visto che sono quasi sempre presenti) README INSTALL o qualcos'altro o una scelta multipla (un menù che ti consenta di scegliere più volte).

Gli autori in lista potresti inserirli tutti (così si ha anche se medesimo). Si potrebbe anche fare un file di configurazione.

Per slack-desc come default metterei o create o I do not want it.
Per doinst.sh: il default che hai messo è I don't need it. (DEFAULT) ma premendo invio mi chiede l'url.
(Nota: se il download fallisce muore lo script.)

Aggiungi la scelta del tag (se faccio pacchetti per slacky io metto sl ma se faccio personali ci metto altro per chiarezza)

Consenti al termine (o ogni tanto) di rivedere le scelte.

Poi la cosa migliore sarebbe utilizzare 'dialog'


Nel tarball aggiungi file a correto (e metti in una sottodirectory)
slackbuild_creator-0.4.tar.gz :
slackbuild_creator-0.4/slackbuild_creator.sh
slackbuild_creator-0.4/README.TXT
slackbuild_creator-0.4/doc/ChangeLog.txt
slackbuild_creator-0.4/src/slackbuild_creator.sh
slackbuild_creator-0.4/Makefile
slackbuild_creator-0.4/doc/AUTHORS
slackbuild_creator-0.4/doc/LICENSE
slackbuild_creator-0.4/dist/slackbuild_creator.SlackBuild
slackbuild_creator-0.4/dist/slack-desc

in README.TXT ci metti il link a questo topic.

(forse ho esagerato un po' :-) )


edit:
non sarebbe più corretto slackbuild maker?
Packages finder: slakfinder.org | Slackpkg+, per aggiungere repository a slackpkg
Codice: Seleziona tutto
1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111
Avatar utente
ZeroUno
Staff
Staff
 
Messaggi: 4304
Iscritto il: ven giu 02, 2006 13:52
Località: Roma / Castelli
Nome Cognome: Matteo Rossini
Slackware: current
Kernel: slack-current
Desktop: ktown-latest
Distribuzione: 01000000-current

Prossimo

Torna a Programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 2 ospiti