#!/bin/sh

# Copyright (C) 2003, 2005 MySQL AB
# Use is subject to license terms
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA

#
# preflight - this script will be executed before the MySQL PKG
# installation will be performed.
#
# If this package has been compiled with a prefix ending with "mysql" (e.g.
# /usr/local/mysql or /opt/mysql), it will rename any previously existing
# directory with this name before installing the new package (which includes
# a symlink named "mysql", pointing to the newly installed directory, which
# is named mysql-<version>)
#

PREFIX="@prefix@"
BASENAME=`basename $PREFIX`

if [ -d $PREFIX -a ! -L $PREFIX -a $BASENAME = "mysql" ] ; then
	mv $PREFIX $PREFIX.bak
fi


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
   Copyright (C) 2003 MySQL AB
   Use is subject to license terms

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-->
<plist version="1.0">
<dict>
	<key>Description</key>
	<string>MySQL @VERSION@@MYSQL_SERVER_SUFFIX@</string>
	<key>OrderPreference</key>
	<string>None</string>
	<key>Provides</key>
	<array>
		<string>MySQL</string>
	</array>
	<key>Uses</key>
	<array>
		<string>Network</string>
		<string>Resolver</string>
	</array>
	</dict>
</plist>


#!/bin/bash
#
# Backup script for MySQL 5.5 on RHEL5 using XtraBackup
#
# Requires: xtrabackup, bash, awk, coreutils
#
# Copyright (C) 2011 Daniel van Eeden
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

## Settings ##
PATH="/bin:/usr/bin"
BACKUPDIR="/var/mysql/backups/xtrabackup"
MINFREE_M="5000"
INNOBACKUPEX_OPTIONS=""
RETENTION_DAYS="7"

## Logic ##
timestamp=`date +%Y%m%d_%H%M%S_%Z`
export PATH;

if [ ! -x "/usr/bin/innobackupex-1.5.1" ]; then
  echo "ERROR: /usr/bin/innobackupex-1.5.1 is not executable."
  exit 1
fi

if [ ! -d ${BACKUPDIR} ]; then
  echo "ERROR: ${BACKUPDIR} is not a directory."
  exit 2
fi

freespace_m=`df -k ${BACKUPDIR} | awk '{ if ($4 ~ /^[0-9]*$/) { print int($4/1024) } }'`
if [ ${freespace_m} -le ${MINFREE_M} ]; then
  echo "ERROR: There is less than ${MINFREE_M} MB of free space on ${BACKUPDIR}"
  exit 3
fi

# Remove backups older than $RETENTION_DAYS
find /var/mysql/backups/xtrabackup -name "*_*_*_xtrabackup\.tar\.bz2" -type f -mtime +${RETENTION_DAYS}

# Create the backup
/usr/bin/innobackupex-1.5.1 ${INNOBACKUPEX_OPTIONS} --stream=tar /tmp 2> ${BACKUPDIR}/${timestamp}_xtrabackup.log | bzip2 > ${BACKUPDIR}/${timestamp}_xtrabackup.tar.bz2


#!/bin/sh

PATH=/usr/local/gnu-autotools/bin/:$PATH
export PATH

# Start from one level above the build directory
if [ -f version ]; then
    cd ..
fi

if [ \! -f build/version ]; then
    echo "Can't find source directory"
    exit 1
fi

# BSD make's "OBJDIR" support freaks out the automake-generated
# Makefile.  Effectively disable it.
export MAKEOBJDIRPREFIX=/junk

# Start from the build directory, where the version file is located
if [ -f build/version ]; then
    cd build
fi

if [ \! -f version ]; then
    echo "Can't find version file"
    exit 1
fi

# Update the build number in the 'version' file.
# Separate number from additional alpha/beta/etc marker
MARKER=`cat version | sed 's/[0-9.]//g'`
# Bump the number
VN=`cat version | sed 's/[^0-9.]//g'`
# Build out the string.
VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER"

cd ..

# Clean up the source dir as much as we can.
/bin/sh build/clean.sh

# Substitute the integer version into Libarchive's archive.h
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h
# Substitute versions into configure.ac as well
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' configure.ac
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac

set -xe
aclocal -I build/autoconf

# Note: --automake flag needed only for libtoolize from
# libtool 1.5.x; in libtool 2.2.x it is a synonym for --quiet
case `uname` in
Darwin) glibtoolize --automake -c;;
*) libtoolize --automake -c;;
esac
autoconf
autoheader
automake -a -c

./configure
make distcheck
make dist-zip


#!/bin/sh +v

# Start from the build directory, where the version file is located
if [ -f build/version ]; then
    cd build
fi

if [ \! -f version ]; then
    echo "Can't find version file"
    exit 1
fi

# Update the build number in the 'version' file.
# Separate number from additional alpha/beta/etc marker
MARKER=`cat version | sed 's/[0-9.]//g'`
# Bump the number
VN=`cat version | sed 's/[^0-9.]//g'`
# Reassemble and write back out
VN=$(($VN + 1))
rm -f version.old
mv version version.old
chmod +w version.old
echo $VN$MARKER > version
VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER"
cd ..

ANNOUNCE=`date +"%b %d, %Y:"`" libarchive $VS released"

echo $ANNOUNCE

# Add a version notice to NEWS
mv NEWS NEWS.bak
chmod +w NEWS.bak
echo > NEWS
echo $ANNOUNCE >> NEWS
cat NEWS.bak >> NEWS


#!/bin/sh

if [ \! -f build/version ]; then
    echo 'Must run the clean script from the top-level dir of the libarchive distribution' 1>&2
    exit 1
fi

#
# The automake-generated 'maintainer-clean' target does clean up a
# lot.  If that fails, try plain 'clean' in case we're using the cmake
# or other makefile.  But don't worry if we can't...
#
make maintainer-clean || make clean || true

# If we're on BSD, blow away the build dir under /usr/obj
rm -rf /usr/obj`pwd`

#
# Try to clean up a bit more...
#

find . -name '*.So' | xargs rm
find . -name '*.a' | xargs rm
find . -name '*.la' | xargs rm
find . -name '*.lo' | xargs rm
find . -name '*.o' | xargs rm
find . -name '*.orig' | xargs rm
find . -name '*.po' | xargs rm
find . -name '*.rej' | xargs rm
find . -name '*~' | xargs rm
find . -name '.depend' | xargs rm
find . -name '.deps' | xargs rm -rf
find . -name '.dirstamp' | xargs rm
find . -name '.libs' | xargs rm -rf

rm -rf autom4te.cache

rm -f Makefile.in
rm -f aclocal.m4
rm -f bsdcpio
rm -f bsdcpio_test
rm -f bsdtar
rm -f bsdtar_test
rm -f build/autoconf/compile
rm -f build/autoconf/config.*
rm -f build/autoconf/depcomp
rm -f build/autoconf/install-sh
rm -f build/autoconf/libtool.m4
rm -f build/autoconf/ltmain.sh
rm -f build/autoconf/ltoptions.m4
rm -f build/autoconf/ltsugar.m4
rm -f build/autoconf/ltversion.m4
rm -f build/autoconf/lt~obsolete.m4
rm -f build/autoconf/missing
rm -f build/pkgconfig/libarchive.pc
rm -f build/version.old
rm -f config.h
rm -f config.h.in
rm -f config.log
rm -f config.status
rm -f configure
rm -f cpio/*.1.gz
rm -f cpio/bsdcpio
rm -f cpio/test/bsdcpio_test
rm -f cpio/test/list.h
rm -f doc/html/*
rm -f doc/man/*
rm -f doc/pdf/*
rm -f doc/text/*
rm -f doc/wiki/*
rm -f libarchive/*.[35].gz
rm -f libarchive/libarchive.so*
rm -f libarchive/test/libarchive_test
rm -f libarchive/test/list.h
rm -f libarchive_test
rm -f libtool
rm -f stamp-h1
rm -f tar/*.1.gz
rm -f tar/bsdtar
rm -f tar/test/bsdtar_test
rm -f tar/test/list.h