Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6f9f979093
Fetching contributors…

Cannot retrieve contributors at this time

executable file 360 lines (336 sloc) 8.969 kB
#!/bin/sh
# INFO FOR PROGRAM TO BE BUILT
THIS_NAME="$(basename $0)"
THIS_PATH="$(dirname $0)"
PROG_NAME=${PROG_NAME:="$(basename $THIS_NAME .${THIS_NAME##*.})"}
PROG_VERS=${PROG_VERS:="1.6.2"} # CHANGE TO WHAT WE NEED
PROG_FULL="$PROG_NAME-$PROG_VERS" # SHOULD BE TOP FOLDER'S NAME
PROG_BALL="$PROG_FULL.tar.gz" # CAN BE OTHER THAN $PROG_FULL
# PLACE URL ACCORDINGLY!
PROG_PATH="http://geda.seul.org/release/v${PROG_VERS%.*}/$PROG_VERS/"
PROG_LOAD="${PROG_PATH}${PROG_BALL}"
# ASSIGN DOCS ACCORDINGLY!
PROG_DOCS="AUTHORS COPYING ChangeLog INSTALL NEWS README"
# DEPS LIST? (build-time?)
PROG_DEPS=""
# CHECK MACHINE ARCH!
if [[ "$ARCH" == "" ]]; then
ARCH="$(uname -m)"
case "$ARCH" in
i?86) ARCH="i486" ;;
arm*) ARCH="arm" ;;
esac
fi
# OUTPUT PACKAGE PARAMS
BUILD_TAG=${BUILD_TAG:="1_my1"}
PACK_TYPE=${PACK_TYPE:="tgz"}
PACK_ARCH=${PACK_ARCH:="$ARCH"}
PACK_PATH=${PACK_PATH:="/tmp"}
PACK_BALL=${PACK_BALL:="$PROG_NAME-$PROG_VERS-$PACK_ARCH-$BUILD_TAG.$PACK_TYPE"}
# BUILD-RELATED PATH
CURR_PATH=$(cd $THIS_PATH; pwd)
TEMP_PATH=${TEMP_PATH:="/tmp/my1/slackbuild"}
DEST_PATH=$TEMP_PATH/package-$PROG_NAME
# COMMAND-LINE OPTIONS
CHK_DOWNLOAD=${CHK_DOWNLOAD:="NO"}
CHK_LOADONLY=${CHK_LOADONLY:="NO"}
CHK_MOVEPACK=${CHK_MOVEPACK:="NO"}
function prepare_source()
{
# PREPARE SOURCE MANUALLY
return
}
function do_build()
{
# ACTUAL BUILD PROCESS
CFLAGS="$SLACKCFLAGS" \
CXXFLAGS="$SLACKCFLAGS" \
./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--mandir=/usr/man \
--docdir=/usr/doc/$PROG_FULL \
--build=$PACK_ARCH-slackware-linux$ARCHQUADLET
make
make install DESTDIR=$DEST_PATH
}
function do_pre_build()
{
# PLACE FIX/PRE-BUILD SCRIPT HERE!
return
}
function do_post_build()
{
# PLACE FIX/POST-BUILD SCRIPT HERE!
return
}
function do_install_stuff()
{
# COPY INSTALLATION-RELATED FILE(S)
mkdir -p $DEST_PATH/install
RULER_SPC="$(printf "%*s" ${#PROG_NAME} "")";
THIS_SLACKDESC=$(cat <<SLACK-DESC
# 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 ':'.
${RULER_SPC}|-----handy-ruler------------------------------------------------------|
geda-gaf: gEDA (gnu EDA base package)
geda-gaf:
geda-gaf: gEDA/gaf: Schematic capture, netlister, symbols, symbol checker,
geda-gaf: and utils. This is the base package for the gnu EDA toolset.
geda-gaf:
geda-gaf: gschem is the schematic captur tool.
geda-gaf: gnetlist is for creating netlists.
geda-gaf: gattrib allows the batch updating of attributes.
geda-gaf:
geda-gaf: http://www.gpleda.org/
geda-gaf:
SLACK-DESC
)
echo "$THIS_SLACKDESC" > $DEST_PATH/install/slack-desc
THIS_DOINSTSH=$(cat <<DOINSTSH
if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications
fi
if [ -x /usr/bin/update-mime-database ]; then
/usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
if [ -x /usr/bin/gtk-update-icon-cache ]; then
/usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
fi
fi
DOINSTSH
)
echo "$THIS_DOINSTSH" > $DEST_PATH/install/doinst.sh
}
function do_post_package()
{
# PLACE POST-PACKAGE SCRIPT HERE!
show_deps
}
# ONLY TEMPLATES BELOW THIS LINE
function show_deps()
{
if [[ "$PROG_DEPS" != "" ]] ; then
echo -n "This software '$PROG_NAME' requires: "
for dep in "$PROG_DEPS" ; do
echo -n "$dep "
dep="$(cd ${THIS_PATH};pwd)/${dep}.SlackBuild"
if [[ -r "$dep" ]] ; then
echo -n "($dep)"
else
echo -n "(not found!)"
fi
done
echo
fi
}
function check_param()
{
while [[ "$1" != "" ]]; do
case $1 in
--load )
CHK_DOWNLOAD="YES"
;;
--load-only )
CHK_DOWNLOAD="YES"
CHK_LOADONLY="YES"
;;
--move-here )
MOVE_PATH=$CURR_PATH
CHK_MOVEPACK="YES"
;;
--move )
shift
MOVE_PATH=$1
CHK_MOVEPACK="YES"
[[ ! -d "$MOVE_PATH" ]] &&
echo "Invalid '--move' path ($MOVE_PATH)!" && exit 1
MOVE_PATH=$(cd $MOVE_PATH;pwd)
;;
--show-deps )
show_deps
exit 0
;;
* )
echo "Unknown parameter ($1)!" && exit 1
;;
esac
shift
done
# set these as early as possible?
set -e # exit immediately when non-zero exit status
trap 'echo "$0 FAILED at line $LINENO!"' ERR
}
function do_download()
{
local fname="$1"
local label="$2"
local cpath="$(pwd)"
[[ "$fname" == "" ]] && exit 1 # shouldn't be here?
[[ "$label" == "" ]] && label="$fname"
echo -n "Downloading $label: "
wget --progress=dot "$fname" 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
echo -ne "\b\b\b\b DONE!\n"
[[ ! -r "$label" ]] &&
echo "Cannot download source $cpath/$label!" && exit 1
local chk_perm=$(get_userngrp $cpath)
[[ "$chk_perm" != "" ]] && chown $chk_perm $cpath/$label
}
function check_source()
{
local chk_path="$(pwd)"
cd $CURR_PATH
if [[ ! -r "$PROG_BALL" ]]; then
if [[ "$CHK_DOWNLOAD" == "YES" ]]; then
do_download $PROG_LOAD $PROG_BALL
else
echo "Source $CURR_PATH/$PROG_BALL not found!" && exit 1
fi
fi
cd $chk_path
[[ "$CHK_LOADONLY" == "YES" ]] && exit 0
return 0
}
function check_buildenv()
{
# CHECK ENVIRONMENT!
case "$PACK_ARCH" in
"i486")
SLACKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
ARCHQUADLET=""
;;
"i686")
SLACKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
ARCHQUADLET=""
;;
"x86_64")
SLACKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
ARCHQUADLET=""
;;
"arm")
SLACKCFLAGS="-O2 -march=armv4t"
LIBDIRSUFFIX=""
ARCHQUADLET="-gnueabi"
;;
*)
SLACKCFLAGS="-O2"
LIBDIRSUFFIX=""
ARCHQUADLET=""
;;
esac
}
function prepare_build()
{
rm -rf $DEST_PATH
mkdir -p $TEMP_PATH $DEST_PATH $PACK_PATH
cd $TEMP_PATH
rm -rf $PROG_FULL
tar xvf $CURR_PATH/$PROG_BALL
if [[ -d $PROG_FULL ]]; then
cd $PROG_FULL
elif [[ -d $PROG_NAME ]]; then
cd $PROG_NAME
else
echo "Cannot find path '$PROG_FULL' or '$PROG_NAME'! Aborting!"
exit 1
fi
chown -R root:root .
chmod -R u+r+w,go+r-w,a+X-s-t .
}
function strip_binaries()
{
find $DEST_PATH | xargs file | grep -e "executable" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
find $DEST_PATH | xargs file | grep -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
}
function check_manual_info()
{
# PREPARE MAN PAGES?
if [[ -d $DEST_PATH/usr/man ]]; then
find $DEST_PATH/usr/man -type f -exec gzip -9 {} \;
for i in $(find $DEST_PATH/usr/man -type l) ; do
ln -s $( readlink $i ).gz $i.gz
rm $i
done
fi
# PREPARE INFO PAGES?
if [[ -d $DEST_PATH/usr/info ]]; then
gzip -9 $DEST_PATH/usr/info/*.info
rm -f $DEST_PATH/usr/info/dir
fi
}
function check_documentation()
{
mkdir -p $DEST_PATH/usr/doc/$PROG_FULL
cat $CURR_PATH/$THIS_NAME > $DEST_PATH/usr/doc/$PROG_FULL/$THIS_NAME
[[ "$the_docs" == "" ]] && return
cp -a $PROG_DOCS $DEST_PATH/usr/doc/$PROG_FULL
}
function get_userngrp()
{
local chk_this=$1
local chk_path
local chk_user chk_grpn
[[ "$chk_this" == "." ]] && chk_this=$(pwd)
[[ "$chk_this" == ".." ]] && chk_this=$(cd .. ;pwd)
[[ ! -r "$chk_this" ]] && echo -e "Cannot read '$chk_this'!" 1>&2 && return
chk_path=$(cd $(dirname $chk_this);pwd)
chk_this=$(basename $chk_this)
chk_user=$(ls -l "${chk_path}/" | grep -e "${chk_this}$")
set -- $chk_user
chk_user=$3
chk_grpn=$4
echo -n "$chk_user:$chk_grpn"
}
function make_slackpkg()
{
cd $DEST_PATH
/sbin/makepkg -l y -c n $PACK_PATH/$PACK_BALL
if [[ "$CHK_MOVEPACK" == "YES" ]]; then
local chk_perm=$(get_userngrp $MOVE_PATH)
[[ "$chk_perm" != "" ]] && chown $chk_perm $PACK_PATH/$PACK_BALL
mv $PACK_PATH/$PACK_BALL $MOVE_PATH/
echo -e "\nPackage $PACK_PATH/$PACK_BALL moved to $MOVE_PATH!\n"
fi
}
# CHECK COMMAND-LINE PARAMETER - TEMPLATE
check_param $@
# ONLY ROOT CAN BUILD!
[[ $UID -ne 0 ]] && echo "[ERROR] Must run as root! Aborting!" && exit 1
# IN CASE SOURCE FROM REPO - CUSTOM (OPTIONAL)
prepare_source
# CHECK IF SOURCE EXISTS - TEMPLATE
check_source
# CHECK THE BUILD ENVIRONMENT - TEMPLATE
check_buildenv
# PREPARE FOR THE BUILD - TEMPLATE
prepare_build
# EXTRA STUFF - CUSTOM (OPTIONAL)
do_pre_build
# ACTUAL BUILD PROCESS - CUSTOM (STANDARD)
do_build
# EXTRA STUFF - CUSTOM (OPTIONAL)
do_post_build
# STRIP SIZE OF BINARIES - TEMPLATE
strip_binaries
# PREPARE MAN & INFO PAGES - TEMPLATE
check_manual_info
# COPY DOCUMENTATION FILE(S) - TEMPLATE
check_documentation
# PREP FOR INSTALLATION - CUSTOM (STANDARD)
do_install_stuff
# MAKE SLACKWARE PACKAGE - TEMPLATE
make_slackpkg
# EXTRA POST-PACKAGING - CUSTOM (OPTIONAL)
do_post_package
Jump to Line
Something went wrong with that request. Please try again.