Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6f9f979093
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 349 lines (327 sloc) 8.639 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
#!/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.2.0"} # CHANGE TO WHAT WE NEED
PROG_FULL="$PROG_NAME-$PROG_VERS" # SHOULD BE TOP FOLDER'S NAME
PROG_BALL="$PROG_FULL.tar.bz2" # CAN BE OTHER THAN $PROG_FULL
# PLACE URL ACCORDINGLY!
PROG_PATH="http://downloads.sourceforge.net/gtkglext/"
PROG_LOAD="${PROG_PATH}${PROG_BALL}"
# ASSIGN DOCS ACCORDINGLY!
PROG_DOCS="AUTHORS COPYING* ChangeLog NEWS README TODO"
# 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 \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--disable-static \
--enable-debug=no \
--build=$PACK_ARCH-slackware-linux
# PLACE ADDITIONAL CONFIG HERE
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------------------------------------------------------|
gtkglext: GtkGLExt (an OpenGL extension to GTK)
gtkglext:
gtkglext: This package is composed of GdkGLExt library and GtkGLExt library.
gtkglext: GdkGLExt library provides the GDK objects which support OpenGL
gtkglext: rendering in GTK. GtkGLExt library provides the GtkWidget API
gtkglext: add-ons to make GTK+ widgets OpenGL-capable.
gtkglext:
gtkglext: http://www.k-3d.org/gtkglext/Main_Page
gtkglext:
gtkglext:
gtkglext:
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
#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
Something went wrong with that request. Please try again.