summaryrefslogtreecommitdiffstats
path: root/drbd
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2007-01-12 22:09:35 +0000
committer Eric Hameleers <alien@slackware.com>2007-01-12 22:09:35 +0000
commit72555019ee09e2bce5b55d79518ca8c7a962b7bb (patch)
treef37cf147f0e6784105edcd6890be63439c314e41 /drbd
parentebda82bd5a9f9f77391c955ac96999927176d818 (diff)
downloadasb-72555019ee09e2bce5b55d79518ca8c7a962b7bb.tar.gz
asb-72555019ee09e2bce5b55d79518ca8c7a962b7bb.tar.xz
Initial revision
Diffstat (limited to 'drbd')
-rwxr-xr-xdrbd/build/drbd.SlackBuild284
-rw-r--r--drbd/build/slack-desc19
2 files changed, 303 insertions, 0 deletions
diff --git a/drbd/build/drbd.SlackBuild b/drbd/build/drbd.SlackBuild
new file mode 100755
index 00000000..5ae2992f
--- /dev/null
+++ b/drbd/build/drbd.SlackBuild
@@ -0,0 +1,284 @@
+#!/bin/sh
+# $Id$
+# Copyright (c) 2007 Eric Hameleers <alien@slackware.com>
+# -----------------------------------------------------------------------------
+#
+# Slackware SlackBuild script
+# ===========================
+# By: Eric Hameleers <alien@slackware.com>
+# For: drbd
+# Descr: a network block device for high availability clusters
+# URL: http://www.drbd.org/
+# Needs: Linux kernel 2.6.x
+# Changelog:
+# 0.7.23-1: 12/Jan/2007 by Eric Hameleers <alien@slackware.com>
+# * Initial build.
+#
+# Run 'sh drbd.SlackBuild --cleanup' to build a Slackware package.
+# The package (.tgz) plus descriptive .txt file are created in /tmp .
+# Install using 'installpkg'.
+#
+# -----------------------------------------------------------------------------
+
+# --- INIT ---
+# Set initial variables:
+
+PRGNAM=drbd
+VERSION=${VERSION:-0.7.23}
+ARCH=${ARCH:-i486}
+BUILD=${BUILD:-1}
+
+DOCS="ChangeLog COPYING INSTALL README *.txt scripts/drbd.conf"
+
+# Where do we look for sources?
+CWD=`pwd`
+SRCDIR=`dirname $0`
+[ "${SRCDIR:0:1}" == "." ] && SRCDIR=${CWD}/${SRCDIR}
+
+# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
+TMP=${TMP:-/tmp/build}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+# Kernel module related parameters
+KVER=${KVER:-`uname -r`}
+KSRC=${KSRC:-/lib/modules/${KVER}/build}
+PATCHLEVEL=`echo $KVER|cut -f 2 -d '.'`
+[ $PATCHLEVEL -eq 4 ] && MODCONFFILE=modules.conf || MODCONFFILE=modprobe.conf
+
+# Input URL: http://oss.linbit.com/drbd/0.7/drbd-0.7.23.tar.gz
+SOURCE="$SRCDIR/${PRGNAM}-${VERSION}.tar.gz"
+SRCURL="http://oss.linbit.com/${PRGNAM}/0.7/${PRGNAM}-${VERSION}.tar.gz"
+
+##
+## --- with a little luck, you won't have to edit below this point --- ##
+##
+
+# Exit the script on errors:
+set -e
+trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
+# Catch unitialized variables:
+set -u
+P1=${1:-1}
+
+# Slackware 11 and up need other option (gcc > 3.3.x)
+if [ `gcc -dumpversion | tr -d '.' |cut -c 1-2` -gt 33 ]; then
+ MOPT=tune
+else
+ MOPT=cpu
+fi
+
+case "$ARCH" in
+ i386) SLKCFLAGS="-O2 -march=i386 -m${MOPT}=i686"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ i486) SLKCFLAGS="-O2 -march=i486 -m${MOPT}=i686"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ s390) SLKCFLAGS="-O2"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ powerpc) SLKCFLAGS="-O2"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ x86_64) SLKCFLAGS="-O2 -fPIC"
+ SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
+ ;;
+ athlon-xp) SLKCFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+esac
+
+if [ ! -d $TMP/tmp-$PRGNAM ]; then
+ mkdir -p $TMP/tmp-$PRGNAM # location to build the source
+elif [ "$P1" != "--oldbuild" ]; then
+ # If the "--oldbuild" parameter is present, we keep
+ # the old build files and continue;
+ # By default we remove the remnants of previous build and continue:
+ rm -rf $TMP/tmp-$PRGNAM/*
+fi
+
+if [ ! -d $PKG ]; then
+ mkdir -p $PKG # place for the package to be built
+else
+ rm -rf $PKG/* # We always erase old package's contents:
+fi
+
+if [ ! -d $OUTPUT ]; then
+ mkdir -p $OUTPUT # place for the package to be saved
+fi
+
+
+# --- SOURCE FILE AVAILABILITY ---
+
+if ! [ -f ${SOURCE} ]; then
+ if ! [ "x${SRCURL}" == "x" ]; then
+ # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
+ [ -w "$SRCDIR" ] || SOURCE="$OUTPUT/`basename $SOURCE`"
+ echo "Source '`basename ${SOURCE}`' not available yet..."
+ echo "Will download file to `dirname $SOURCE`"
+ wget -nv -O "${SOURCE}" "${SRCURL}" || true
+ if [ $? -ne 0 ]; then
+ echo "Downloading '`basename ${SOURCE}`' failed... aborting the build."
+ mv -f "${SOURCE}" "${SOURCE}".FAIL
+ exit 1
+ fi
+ else
+ echo "File '`basename ${SOURCE}`' not available... aborting the build."
+ exit 1
+ fi
+fi
+
+if [ "$P1" == "--download" ]; then
+ echo "Download complete."
+ exit 0
+fi
+
+# --- PACKAGE BUILDING ---
+
+echo "++"
+echo "|| $PRGNAM-$VERSION"
+echo "++"
+
+cd $TMP/tmp-$PRGNAM
+
+
+# --- TARBALL EXTRACTION,PATCH,MODIFY ---
+
+echo "Extracting the source archive(s) for $PRGNAM..."
+if `file ${SOURCE} | grep -q ": bzip2"`; then
+ tar -xjvf ${SOURCE}
+else
+ tar -xzvf ${SOURCE}
+fi
+cd ${PRGNAM}-${VERSION}
+
+chown -R root.root *
+find . -perm 777 -exec chmod 755 {} \;
+find . -perm 666 -exec chmod 644 {} \;
+
+
+# --- BUILDING ---
+
+echo Building ...
+
+export LDFLAGS="$SLKLDFLAGS"
+export CFLAGS="$SLKCFLAGS"
+make all doc PREFIX=$PKG/ MANDIR=/usr/man KDIR=${KSRC} \
+ 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
+
+make install PREFIX=$PKG/ MANDIR=/usr/man \
+ 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
+
+# Only install a hint to the example conf
+cat <<EOT > $PKG/etc/drbd.conf
+#
+# please have a a look at the example configuration file in
+# /usr/doc/${PRGNAM}-${VERSION}/drbd.conf
+#
+EOT
+
+# Fix the configuration files so they won't overwrite existing ones
+# on package install:
+mv $PKG/etc/drbd.conf{,.new}
+
+# Rename the init script to something Slackware compatible:
+mv $PKG/etc/rc.d/drbd $PKG/etc/rc.d/rc.drbd
+
+# Add this to the doinst.sh
+! [ -d $PKG/install ] && mkdir -p $PKG/install
+cat <<EOINS >> $PKG/install/doinst.sh
+# Handle the incoming configuration files:
+config() {
+ for infile in \$1; do
+ NEW="\$infile"
+ 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...
+ done
+}
+
+config etc/drbd.conf.new
+
+EOINS
+
+# Add this to the doinst.sh
+! [ -d $PKG/install ] && mkdir -p $PKG/install
+cat <<-EEOOTT >> $PKG/install/doinst.sh
+ # Only run depmod on matching running kernel
+ # Slackware will run depmod anyway on reboot):
+ MYMODVER=$KVER
+ MYKERNEL=\`uname -r\`
+ if [ "\$MYKERNEL" = "\$MYMODVER" ]; then
+ if [ -x sbin/depmod ]; then
+ chroot . /sbin/depmod -a \$MYKERNEL 1> /dev/null 2> /dev/null
+ fi
+ fi
+
+ EEOOTT
+
+
+# --- DOCUMENTATION ---
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
+chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/*
+
+# Move incorrectly installed man pages, if any
+if [ -d $PKG/usr/share/man ]; then
+ mv $PKG/usr/share/man $PKG/usr/ && rmdir $PKG/usr/share || true
+fi
+# Compress the man page(s)
+if [ -d $PKG/usr/man ]; then
+ find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
+ for i in `find $PKG/usr/man -type l -name "*.?"` ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+fi
+
+# Strip binaries
+( cd $PKG
+ find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+ find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+)
+
+# Compress the kernel modules
+[ $PATCHLEVEL -eq 4 ] && \
+ find $PKG/lib/modules -type f -name "*.?" -exec gzip -9 {} \;
+
+
+# --- OWNERSHIP, RIGHTS ---
+
+chmod -R o-w $PKG
+
+
+# --- PACKAGE DESCRIPTION ---
+
+mkdir -p $PKG/install
+cat $SRCDIR/slack-desc > $PKG/install/slack-desc
+if [ -f $SRCDIR/doinst.sh ]; then
+ cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
+fi
+
+
+# --- BUILDING ---
+
+# Build the package:
+cd $PKG
+makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}_${KVER}-${ARCH}-${BUILD}.tgz \
+ 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
+(cd $OUTPUT && md5sum ${PRGNAM}-${VERSION}_${KVER}-${ARCH}-${BUILD}.tgz > ${PRGNAM}-${VERSION}_${KVER}-${ARCH}-${BUILD}.tgz.md5)
+cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}_${KVER}-${ARCH}-${BUILD}.txt
+
+
+# --- CLEANUP ---
+
+# Clean up the extra stuff:
+if [ "$P1" = "--cleanup" ]; then
+ rm -rf $TMP/tmp-$PRGNAM
+ rm -rf $PKG
+fi
diff --git a/drbd/build/slack-desc b/drbd/build/slack-desc
new file mode 100644
index 00000000..d2cc9f83
--- /dev/null
+++ b/drbd/build/slack-desc
@@ -0,0 +1,19 @@
+# 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 ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+drbd: drbd (a network block device for high availability clusters)
+drbd:
+drbd: DRBD stands for Distributed Redundant Block Device driver.
+drbd: DRBD is a block device which is designed to build high availability
+drbd: clusters. This is done by mirroring a whole block device via
+drbd: (a dedicated) network. You could see it as a network raid-1.
+drbd:
+drbd:
+drbd:
+drbd: drbd home: http://www.drbd.org/
+drbd: