Added glusterfs{,-client} builds.

This commit is contained in:
Darren 'Tadgy' Austin 2022-10-11 22:57:00 +01:00
commit a1717622c3
18 changed files with 1089 additions and 0 deletions

1
source/glusterfs-client/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.tar.*

View file

@ -0,0 +1,3 @@
# Custom packages required to build this package.
liburcu
liburing

View file

@ -0,0 +1,32 @@
# Version: 0.3.5
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
install_file() {
# $1 = Path of file to process (without leading /, with .new extension)
[[ -z "$1" ]] || [[ ! -e "$1" ]] && return
local OLDFILE="${1%.new}"
if [[ ! -e "$OLDFILE" ]]; then
mv "$1" "$OLDFILE"
elif [[ -L "$OLDFILE" ]]; then
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " is a symbolic link - the incoming .new file was not written"
echo " to it in order to prevent clobbering something important."
echo
elif [[ "$(md5sum <"$OLDFILE")" == "$(md5sum <"$1")" ]]; then
rm -f "$1"
else
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " has been customised since original installation and was not"
echo " replaced with the incoming .new file."
echo
fi
}
# Install new configuration files.
install_file "etc/logrotate.d/glusterfs.new"

View file

@ -0,0 +1,359 @@
#!/bin/bash
# Version: 0.6.12
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
########################################################################
# None of this section requires editing. #
# Scroll down to the "Begin section that will require editing" marker. #
########################################################################
# Silence shellcheck.
# shellcheck disable=SC2015,SC2174
# extglob is required.
shopt -s extglob
# Functions.
check_installed() {
# $1 = The package name to check is installed.
[[ -z "$1" ]] && return 1
printf "%s\\n" /var/lib/pkgtools/packages/* | grep -P "^/var/lib/pkgtools/packages/\Q$1\E-([^-]*)-([^-]*)-([^-]*)$" >/dev/null 2>&1
return $?
}
die() {
# $1 = The message to write to stderr on exit.
printf "\\033[1;31;40m%s: %s\\033[0;39m\\n" "${0##*/}" "${1:-Abort}" >&2
exit 1
}
# Make sure to be in the build directory.
# shellcheck disable=SC2164
cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)"
# Read global buildconf settings.
# shellcheck disable=SC1091
[[ -e ../buildconf ]] && {
. ../buildconf 2>/dev/null || die "Error sourcing global buildconf"
}
# Package specific buildconf settings.
# shellcheck disable=SC2015,SC1090
[[ -e "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" ]] && . "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" 2>/dev/null || \
die "Error sourcing package buildconf"
# Package storage path.
# Be safe and leave it in /tmp by default (can be overridden).
# shellcheck disable=SC2016
[[ -z "$PKG_STORE" ]] && PKG_STORE='/tmp/pkg-store/$DIST_OS_ID-$DIST_OS_VERSION_ID'
# Package configuration archive path.
[[ -z "$PKG_CONFIG_ARCHIVE" ]] && PKG_CONFIG_ARCHIVE="/tmp/pkg-config-archive"
# Parse command line options.
while (( $# > 0 )); do
if [[ "$1" =~ ^-(-)?f(orce)?$ ]]; then
BUILD_FORCE=1
elif [[ "$1" =~ ^-(-)?k(eep-configs)?$ ]]; then
BUILD_KEEPCONFIGS=1
elif [[ "$1" =~ ^-(-)?n(o-cleanup)?$ ]]; then
BUILD_CLEANUP=0
elif [[ "$1" =~ ^-(-)?v(ersion)?$ ]]; then
printf "%s=\"%s\"\\n" "NAME" "$PKG_NAME"
printf "%s=\"%s\"\\n" "VERSION" "$PKG_VERSION"
printf "%s=\"%s\"\\n" "BUILD" "$PKG_BUILD$PKG_TAG"
exit 0
else
printf "%s: %s: %s\\n" "${0##*/}" "Invalid option" "$1" >&2
printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[[-f|--force] [-k|--keep-configs] [-n|--no-cleanup]]|[-v|--version]]" >&2
exit 1
fi
shift
done
# Pre-build checks.
(( ${BUILD_FORCE:-0} != 1 )) && {
while read -r PKG; do
check_installed "$PKG" && die "Conflicting package installed: $PKG"
done < <(printf "%s " "${BUILD_CONFLICTS[@]}")
while read -r PKG; do
check_installed "$PKG" || die "Required package not installed: $PKG"
done < <(printf "%s " "${BUILD_REQUIRES[@]}")
}
# Gather some system information.
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^ID=" /etc/os-release)
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^VERSION_ID=" /etc/os-release)
# Try to detect a 'current' build environment.
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^VERSION_CODENAME=" /etc/os-release)
[[ "$DIST_OS_VERSION_CODENAME" == "current" ]] && DIST_OS_VERSION_ID="current"
unset DIST_OS_VERSION_CODENAME
# Build environment.
BUILD_WORKDIR="${BUILD_WORKDIR:-/tmp/pkg-build}"
BUILD_ROOT="$BUILD_WORKDIR/pkg-$PKG_NAME"
BUILD_PREFIX="${BUILD_PREFIX:-/opt}"
BUILD_ALTCC="${BUILD_ALTCC:-}"
BUILD_ALTCXX="${BUILD_ALTCXX:-}"
BUILD_NUMJOBS="${BUILD_NUMJOBS:-7}"
case "${BUILD_ARCH:=$(uname -m)}" in
i[45]86)
BUILD_CFLAGS="${BUILD_CFLAGS:--march="$BUILD_ARCH" -mtune=i586 -O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-$BUILD_ARCH}"
;;
i686)
BUILD_CFLAGS="${BUILD_CFLAGS:--march="$BUILD_ARCH" -mtune=pentium4 -O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-$BUILD_ARCH}"
;;
x86_64|x86-64)
DIST_OS_ID="slackware64"
BUILD_CFLAGS="${BUILD_CFLAGS:--march=x86-64-v2 -mtune=ivybridge -O2 -fPIC}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
BUILD_LIBDIRSUFFIX="64"
PKG_ARCH="${PKG_ARCH:-x86_64}"
;;
aarch64)
DIST_OS_ID="slackwareaarch64"
BUILD_CFLAGS="${BUILD_CFLAGS:-O2 -fPIC}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
BUILD_LIBDIRSUFFIX="64"
PKG_ARCH="${PKG_ARCH:-aarch64}"
;;
arm*)
DIST_OS_ID="slackwarearm"
BUILD_CFLAGS="${BUILD_CFLAGS:-O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-arm}"
;;
*)
die "Unsupported build architecture: $BUILD_ARCH"
;;
esac
# Now all possible changes to variables in PKG_STORE and PKG_CONFIG_ARCHIVE are complete, expand out the embedded variables.
eval "$(declare -p PKG_STORE PKG_CONFIG_ARCHIVE | sed -re 's/\\\$/$/g')"
# Sanity.
SRC_DIR="$(pwd)"
umask 0022
[[ ! -e "$BUILD_WORKDIR" ]] && { mkdir -p -m 750 "$BUILD_WORKDIR" || die "Failed to create working directory"; }
rm -rf "$BUILD_ROOT" && mkdir -m 755 "$BUILD_ROOT" || die "Failed to clear build root"
[[ -n "${SRC_DIRNAMES[*]}" ]] && { rm -rf "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || die "Failed to clear source directories"; }
# Get sources if they aren't downloaded already.
[[ -n "${SRC_DOWNLOADS[*]}" ]] && {
WGET="$(command -v wget)"
I=0
while read -r SRC; do
[[ ! -e "${SRC_FILENAMES[I]}" ]] && {
[[ -z "$WGET" ]] && die "wget is required to download sources"
"$WGET" -t 3 -c -T 30 -w 5 --retry-connrefused --retry-on-host-error --no-check-certificate --passive-ftp -O "${SRC_FILENAMES[I]}" "$SRC" || \
{ rm "${SRC_FILENAMES[I]}"; die "Failed to download source file: $SRC"; }
}
[[ "$(md5sum "${SRC_FILENAMES[I]}" | cut -d' ' -f1)" != "${SRC_MD5SUMS[I]}" ]] && die "md5sum verification failed: ${SRC_FILENAMES[I]}"
(( I++ ))
done < <(printf "%s\\n" "${SRC_DOWNLOADS[@]}")
}
# Unpack sources.
[[ -n "${SRC_FILENAMES[*]}" ]] && {
while read -r SRC; do
case "$SRC" in
*.tar.*|*.t?z)
tar -xv -C "$BUILD_WORKDIR" -f "$SRC" || die "Failed to extract source: $SRC"
;;
*.zip|*.ZIP)
unzip -d "$BUILD_WORKDIR" "$SRC" || die "Failed to extract source: $SRC"
;;
*)
die "Un-handled source archive format: ${SRC##*.}"
;;
esac
done < <(printf "%s\\n" "${SRC_FILENAMES[@]}")
}
# Fix any weird permissions on sources.
[[ -n "${SRC_DIRNAMES[*]}" ]] && { chown -R root:root "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" && chmod -R go-w "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || \
die "Failed to correct source directory permissions"; }
# Standard ./configure options.
CONFIGURE_OPTS=("${BUILD_ALTCC:+CC=$BUILD_ALTCC}" "${BUILD_ALTCXX:+CXX=$BUILD_ALTCXX}" "--prefix=$BUILD_PREFIX"
"--libdir=$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX" "--sysconfdir=/etc" "--localstatedir=/var" "--mandir=$BUILD_PREFIX/man"
"--infodir=$BUILD_PREFIX/info" "--build=$PKG_ARCH-slackware-linux" "--enable-shared" "--disable-static")
# Process each of the sources.
for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
# Be in the source directory.
cd "$BUILD_WORKDIR/${SRC_DIRNAMES[I]:?Failed to change to source directory}" || die "Failed to change to source directory"
############################################
# Begin section that will require editing. #
############################################
# Build each source in the array.
case "$I" in
0)
# Patch before build.
# zcat "$SRC_DIR/patches/EDITME.diff.gz" | patch -p0 || die "Source patching failed for: EDITME.diff.gz"
# Configure.
./autogen.sh || die "Source ./autogen.sh failed: ${SRC_FILENAMES[I]%-*}"
CFLAGS="$BUILD_CFLAGS" CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" ./configure "${CONFIGURE_OPTS[@]}" \
--docdir="$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" --without-tcmalloc --without-server || \
die "Source ./configure failed: ${SRC_FILENAMES[I]%-*}"
# Build and install.
make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" V=1 && make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" DESTDIR="$BUILD_ROOT" V=1 install || \
die "Failed to build and install source: ${SRC_FILENAMES[I]%-*}"
# Install extras.
mkdir "$BUILD_ROOT/etc/bash_completion.d/" && cp extras/command-completion/gluster.bash "$BUILD_ROOT/etc/bash_completion.d/gluster" || \
die "Failed to install bash completion: ${SRC_FILENAMES[I]%-*}"
# Remove unwanted paths from the package.
rm "$BUILD_ROOT/etc/ganesha/"* && rmdir "$BUILD_ROOT/etc/ganesha" && rmdir "$BUILD_ROOT/var/"{run/gluster,run} || \
die "Failed to remove unwanted files: ${SRC_FILENAMES[I]%-*}"
# Package documentation.
mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" && cp --parents AUTHORS COMMITMENT COPYING-GPLV2 \
COPYING-LGPLV3 ChangeLog INSTALL NEWS README.md THANKS "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" || \
die "Documentation copy failed: ${SRC_FILENAMES[I]%-*}"
;;
*)
die "Un-handled source file - no build configuration"
;;
esac
done
# Move the package configuration files into the archive.
[[ -e "$BUILD_ROOT/etc/${PKG_NAME%-client}" ]] && {
(( ${BUILD_KEEPCONFIGS:-0} == 0 )) && {
rm -rf "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}"
mkdir -p -m 755 "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/${PKG_NAME%-client}" || \
die "Failed to create directory: $PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/${PKG_NAME%-client}"
mv "$BUILD_ROOT/etc/${PKG_NAME%-client}"/* "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/${PKG_NAME%-client}" || \
die "Failed to move configuration files to archive"
}
}
##################################################
# End of the only section that required editing. #
##################################################
# Set up for sed replacements.
SED_OPTS=("-e" "s:%BUILD_PREFIX%:$BUILD_PREFIX:g" "-e" "s:%BUILD_LIBDIR%:$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX:g" "-e" "s:%BUILD_ARCH%:$BUILD_ARCH:g"
"-e" "s:%DIST_OS_ID%:$DIST_OS_ID:g" "-e" "s:%DIST_OS_VERSION_ID%:$DIST_OS_VERSION_ID:g" "-e" "s:%PKG_NAME%:$PKG_NAME:g"
"-e" "s:%PKG_VERSION%:$PKG_VERSION:g" "-e" "s:%PKG_FILE_VERSION%:${PKG_VERSION//-/_}:g" "-e" "s:%PKG_ARCH%:$PKG_ARCH:g"
"-e" "s:%PKG_BUILD%:$PKG_BUILD:g" "-e" "s:%PKG_TAG%:${PKG_TAG//-/_}:g" "-e" "s:%PKG_EXT%:$PKG_EXT:g")
# Add extra configuration/scripts.
for DIR in cron.d cron.hourly cron.daily cron.weekly cron.monthly default logrotate.d profile.d rc.d; do
[[ -e "$SRC_DIR/$DIR" ]] && {
mkdir -p -m 755 "$BUILD_ROOT/etc/$DIR" || die "Failed to create directory: /etc/$DIR"
for FILE in "$SRC_DIR/$DIR"/*; do
sed -r "${SED_OPTS[@]}" <"$FILE" >"$BUILD_ROOT/etc/$DIR/${FILE##*/}" && chmod --reference="$FILE" "$BUILD_ROOT/etc/$DIR/${FILE##*/}" || \
die "Failed to copy $DIR/${FILE##*/} into package"
done
}
done
# Slackware packages don't ship with hardlinks (I don't know why...).
HARDLINKS="$(find "$BUILD_ROOT" -type f -links +1 | tr $'\n' ' ')"
[[ -n "$HARDLINKS" ]] && die "Found hardlinked files in package: $HARDLINKS"
# Strip binaries.
find "$BUILD_ROOT" -type f -exec file {} + | grep -E "ELF.*(executable|shared object)" | cut -d: -f1 | xargs -r strip --strip-unneeded || \
die "Failed to stip object files"
# Move man and info pages if required.
for DIR in "$BUILD_ROOT/$BUILD_PREFIX/share/man" "$BUILD_ROOT/usr/share/man" "$BUILD_ROOT/$BUILD_PREFIX/share/info" "$BUILD_ROOT/usr/share/info"; do
[[ -e "$DIR" ]] && {
mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/${DIR##*/}" || die "Failed to create $BUILD_PREFIX/${DIR##*/} directory"
mv "$DIR"/* "$BUILD_ROOT/$BUILD_PREFIX/${DIR##*/}" && rmdir "$DIR" || die "Failed to move $DIR to correct directory"
}
done
# Handle man pages.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/man" ]] && {
find "$BUILD_ROOT/$BUILD_PREFIX/man" -regextype posix-extended -type f -regex "^$BUILD_ROOT/$BUILD_PREFIX/man/([^/]*/)?man.*/.*\.[[:digit:]n]{1}[^.]*$" \
-exec gzip -9 {} + || die "Failed to compress man pages"
find "$BUILD_ROOT/$BUILD_PREFIX/man" -type l -printf 'if [[ -e "%h/%l.gz" ]]; then (cd "%h" && ln -sf "%l.gz" "%f.gz" && rm -f "%f") || \
die "Failed to fix symlink: %f"; else die "Dangling symlink: %p"; fi\n' | bash || die "Man pages' symlinks correction failed"
}
# Compress and fix info pages.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/info" ]] && {
rm -f "$BUILD_ROOT/$BUILD_PREFIX/info/dir"
find "$BUILD_ROOT/$BUILD_PREFIX/info" -regextype posix-extended -type f -regex "^$BUILD_ROOT/$BUILD_PREFIX/info/.*(\.info){1}(-[[:digit:]]+)?$" \
-exec gzip -9 {} + || die "Failed to compress info pages"
find "$BUILD_ROOT/$BUILD_PREFIX/info" -type l -printf 'if [[ -e "%h/%l.gz" ]]; then (cd "%h" && ln -sf "%l.gz" "%f.gz" && rm -f "%f") || \
die "Failed to fix symlink: %f"; else die "Dangling symlink: %p"; fi\n' | bash || die "Info pages' symlink correction failed"
}
# Fix paths for perl modules.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX/perl5" ]] && {
find "$BUILD_ROOT/$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX/perl5" -name .packlist -exec sed -ri -e "s:^$BUILD_ROOT::g" \
-e "s:^($BUILD_PREFIX|/usr){1}/share:$BUILD_PREFIX:g" \
-e "s:^$BUILD_PREFIX/man/([^/]*/)?(man.*)/(.*)\.([[:digit:]n]){1}([^.])*$:$BUILD_PREFIX/man/\1\2/\3\.\4\5\.gz:g" \
-e "s:^$BUILD_PREFIX/info/(.*)(\.info){1}(-[[:digit:]]+)?$:$BUILD_PREFIX/info/\1\2\3.gz:g" {} + || die "Failed to modify incorrect perl paths"
find "$BUILD_ROOT" -name perllocal.pod -exec rm -f {} + # Should never fail
# Note: These will fail if $BUILD_ROOT == /usr, but are required to clean left over directories from perllocal.pod removal.
rmdir "$BUILD_ROOT/usr/lib$BUILD_LIBDIRSUFFIX/perl5" 2>/dev/null # OK to fail
rmdir "$BUILD_ROOT/usr/lib$BUILD_LIBDIRSUFFIX" 2>/dev/null # OK to fail
rmdir "$BUILD_ROOT/usr" 2>/dev/null # OK to fail
}
# /opt/<package>{,-<version>} is a special case.
# Technically, the FHS requires everything in /opt to be contained in its own package directory,
# so - assuming this technicallity is in use - make symlinks into the standard /opt dirs.
[[ "$BUILD_PREFIX" =~ ^/opt/$PKG_NAME.* ]] && {
(cd "$BUILD_ROOT/opt" &&
for DIR in bin doc include info lib lib64 libexec man sbin share; do
[[ -e "${BUILD_PREFIX##*/}/$DIR" ]] && { mkdir -m 755 "$DIR" && (cd "$DIR" && lndir -silent "../${BUILD_PREFIX##*/}/$DIR)") || exit 1; }
done) || die "Failed to link /opt paths"
}
# Copy pkgtool special files into the package.
mkdir -m 755 "$BUILD_ROOT/install" || die "Failed to make /install directory"
for FILE in doinst.sh douninst.sh slack-{conflicts,desc,required,suggests}; do
[[ -e "$SRC_DIR/$FILE" ]] && {
sed -r -e '/(^#|^$|-handy-ruler-)/ d' "${SED_OPTS[@]}" <"$SRC_DIR/$FILE" >"$BUILD_ROOT/install/$FILE" || \
die "Failed to copy in pkgtool special file: $FILE"
}
done
# Build the package.
cd "$BUILD_ROOT" || die "Failed to cd to BUILD_ROOT to build package"
rm -f "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}".*
makepkg -l y -p -c n --acls --xattrs "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT" || \
die "Package creation failed"
# Clean up after ourselves.
(( ${BUILD_CLEANUP:-1} == 1 )) && rm -rf "$BUILD_ROOT" "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}"
# Move package to the store.
{ mkdir -p -m 755 "$PKG_STORE" && rm -f "$PKG_STORE/$PKG_NAME"* && \
mv "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT" "$PKG_STORE"; } || \
die "Failed to move package to store - package left in $BUILD_WORKDIR"
printf "\\033[1;32;40m%s:\\n %s\\033[0;39m\\n" "Package built and moved to store" \
"$PKG_STORE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT"

View file

@ -0,0 +1,16 @@
# Package details.
PKG_NAME="$(basename "${BASH_SOURCE[0]}" .buildconf)"
PKG_VERSION="10.3"
PKG_BUILD="1"
PKG_TAG="${PKG_TAG:-_tadgy}"
PKG_EXT="${PKG_EXT:-txz}"
# Sources - the details in these arrays must all match per indicies.
SRC_DOWNLOADS=("https://download.gluster.org/pub/gluster/glusterfs/${PKG_VERSION%%.*}/${PKG_VERSION%-client}/${PKG_NAME%-client}-$PKG_VERSION.tar.gz")
SRC_MD5SUMS=("9c795c8479f244e81bca5b2499a480cc")
SRC_FILENAMES=("${PKG_NAME%-client}-$PKG_VERSION.tar.gz")
SRC_DIRNAMES=("${PKG_NAME%-client}-$PKG_VERSION")
# Build configuration.
BUILD_REQUIRES=('curl' 'libaio' 'libtirpc' 'liburing' 'libxml' 'openssl' 'readline' 'userspace-rcu')
BUILD_CONFLICTS=("$PKG_NAME")

View file

@ -0,0 +1,7 @@
/var/log/glusterfs/*.log {
sharedscripts
postrotate
killall -HUP glusterfs >/dev/null 2>&1 || true
killall -HUP glusterd >/dev/null 2>&1 || true
endscript
}

View file

@ -0,0 +1,19 @@
# Version: 0.2.5
# Package description syntax:
# * There must be exactly 11 lines which begin with the package name and ':'.
# * Line up the first '|' of the ruler with the ':' following the package name.
# * A single space should be left after the ':' before any description text.
# * The end '|' of the ruler marks the last columm which should contain text.
|-----handy-ruler------------------------------------------------------|
%PKG_NAME%: glusterfs-client (Scalable elastic network filesystem)
%PKG_NAME%:
%PKG_NAME%: GlusterFS is a scalable network filesystem. Using common off the
%PKG_NAME%: shelf hardware, you can create large, distributed storage solutions.
%PKG_NAME%:
%PKG_NAME%: This is the client package, without the server components.
%PKG_NAME%:
%PKG_NAME%:
%PKG_NAME%: Warning: This package does not contain any configuration files.
%PKG_NAME%:
%PKG_NAME%: Packaged by: Darren 'Tadgy' Austin. Built for: %DIST_OS_ID%-%DIST_OS_VERSION_ID%.

View file

@ -0,0 +1,20 @@
# Version: 0.2.3
# This is the list of packages which, if the package currently being installed
# is to operate correctly, must be installed on the system - its dependancies.
# For example, 'spamassassin' requires the 'perl' package to operate.
# Packages must be listed one per line and are case sensitive. If multiple
# packages could satisfy a single dependancy (such as 'openssl-solibs' and
# 'openssl' for the SSL library) the packages should be listed in the format:
# <pkg1> | <pkg2> [| <pkg3> ...]
# Specific package versions can be specified using = >= =< < > operators.
# The = operator requires the full package version string (eg, 1.2.3-x86_64-5).
# The >= =< < > operators, can use the short package version string
# (eg, 1.2.3) or the full version string. This file is only used by slapt-get.
curl
libaio
libtirpc
liburing
libxml
openssl | openssl-solibs
readline
userspace-rcu

1
source/glusterfs/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.tar.*

View file

@ -0,0 +1,3 @@
# Custom packages required to build this package.
liburcu
liburing

View file

@ -0,0 +1,7 @@
# These are the common settings used in rc.d scripts, but there may be more per script:
# SERVICE_ENVIRONMENT=() # Extra environment passed to $SERVICE_EXEC. Must be an array.
# SERVICE_EXTRA_ARGS=() # Extra arguments passed to $SERVICE_EXEC. Must be an array.
# SERVICE_LOGFILE="" # Logfile to use for $SERVICE_EXEC. Default: /var/log/glusterfs/glusterd.log.
# SERVICE_LOGLEVEL="" # Level to use for logging by $SERVICE_EXEC. Default: WARNING.
# SLAY_DELAY="" # Delay between the SIGTERM and SIGKILL on a 'stop'. Default: 2s.
# RESTART_DELAY="" # Delay between stopping and starting on a 'restart'. Default: 2s.

View file

@ -0,0 +1,51 @@
# Version: 0.3.5
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
install_file() {
# $1 = Path of file to process (without leading /, with .new extension)
[[ -z "$1" ]] || [[ ! -e "$1" ]] && return
local OLDFILE="${1%.new}"
if [[ ! -e "$OLDFILE" ]]; then
mv "$1" "$OLDFILE"
elif [[ -L "$OLDFILE" ]]; then
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " is a symbolic link - the incoming .new file was not written"
echo " to it in order to prevent clobbering something important."
echo
elif [[ "$(md5sum <"$OLDFILE")" == "$(md5sum <"$1")" ]]; then
rm -f "$1"
else
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " has been customised since original installation and was not"
echo " replaced with the incoming .new file."
echo
fi
}
# Install new configuration files.
install_file "etc/default/glusterd.new"
install_file "etc/logrotate.d/glusterfs.new"
# Add service start to rc.local
RC="rc.glusterd"
fgrep "/etc/rc.d/$RC" etc/rc.d/rc.local >/dev/null 2>&1 || {
echo >>etc/rc.d/rc.local
echo "[[ -x /etc/rc.d/$RC ]] /etc/rc.d/$RC start" >>etc/rc.d/rc.local
}
# Add service shutdown to rc.local_shutdown
fgrep "/etc/rc.d/$RC" etc/rc.d/rc.local_shutdown >/dev/null 2>&1 || {
# If rc.local_shutdown doesn't exist, create it.
[[ -e etc/rc.d/rc.local_shutdown ]] || {
echo "#!/bin/bash" >etc/rc.d/rc.local_shutdown
chmod 755 etc/rc.d/rc.local_shutdown
}
echo >>etc/rc.d/rc.local_shutdown
echo "[[ -x /etc/rc.d/$RC ]] && /etc/rc.d/$RC stop" >>etc/rc.d/rc.local_shutdown
}

View file

@ -0,0 +1,359 @@
#!/bin/bash
# Version: 0.6.12
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
########################################################################
# None of this section requires editing. #
# Scroll down to the "Begin section that will require editing" marker. #
########################################################################
# Silence shellcheck.
# shellcheck disable=SC2015,SC2174
# extglob is required.
shopt -s extglob
# Functions.
check_installed() {
# $1 = The package name to check is installed.
[[ -z "$1" ]] && return 1
printf "%s\\n" /var/lib/pkgtools/packages/* | grep -P "^/var/lib/pkgtools/packages/\Q$1\E-([^-]*)-([^-]*)-([^-]*)$" >/dev/null 2>&1
return $?
}
die() {
# $1 = The message to write to stderr on exit.
printf "\\033[1;31;40m%s: %s\\033[0;39m\\n" "${0##*/}" "${1:-Abort}" >&2
exit 1
}
# Make sure to be in the build directory.
# shellcheck disable=SC2164
cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)"
# Read global buildconf settings.
# shellcheck disable=SC1091
[[ -e ../buildconf ]] && {
. ../buildconf 2>/dev/null || die "Error sourcing global buildconf"
}
# Package specific buildconf settings.
# shellcheck disable=SC2015,SC1090
[[ -e "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" ]] && . "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" 2>/dev/null || \
die "Error sourcing package buildconf"
# Package storage path.
# Be safe and leave it in /tmp by default (can be overridden).
# shellcheck disable=SC2016
[[ -z "$PKG_STORE" ]] && PKG_STORE='/tmp/pkg-store/$DIST_OS_ID-$DIST_OS_VERSION_ID'
# Package configuration archive path.
[[ -z "$PKG_CONFIG_ARCHIVE" ]] && PKG_CONFIG_ARCHIVE="/tmp/pkg-config-archive"
# Parse command line options.
while (( $# > 0 )); do
if [[ "$1" =~ ^-(-)?f(orce)?$ ]]; then
BUILD_FORCE=1
elif [[ "$1" =~ ^-(-)?k(eep-configs)?$ ]]; then
BUILD_KEEPCONFIGS=1
elif [[ "$1" =~ ^-(-)?n(o-cleanup)?$ ]]; then
BUILD_CLEANUP=0
elif [[ "$1" =~ ^-(-)?v(ersion)?$ ]]; then
printf "%s=\"%s\"\\n" "NAME" "$PKG_NAME"
printf "%s=\"%s\"\\n" "VERSION" "$PKG_VERSION"
printf "%s=\"%s\"\\n" "BUILD" "$PKG_BUILD$PKG_TAG"
exit 0
else
printf "%s: %s: %s\\n" "${0##*/}" "Invalid option" "$1" >&2
printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[[-f|--force] [-k|--keep-configs] [-n|--no-cleanup]]|[-v|--version]]" >&2
exit 1
fi
shift
done
# Pre-build checks.
(( ${BUILD_FORCE:-0} != 1 )) && {
while read -r PKG; do
check_installed "$PKG" && die "Conflicting package installed: $PKG"
done < <(printf "%s " "${BUILD_CONFLICTS[@]}")
while read -r PKG; do
check_installed "$PKG" || die "Required package not installed: $PKG"
done < <(printf "%s " "${BUILD_REQUIRES[@]}")
}
# Gather some system information.
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^ID=" /etc/os-release)
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^VERSION_ID=" /etc/os-release)
# Try to detect a 'current' build environment.
# shellcheck disable=SC2046
declare DIST_OS_$(grep "^VERSION_CODENAME=" /etc/os-release)
[[ "$DIST_OS_VERSION_CODENAME" == "current" ]] && DIST_OS_VERSION_ID="current"
unset DIST_OS_VERSION_CODENAME
# Build environment.
BUILD_WORKDIR="${BUILD_WORKDIR:-/tmp/pkg-build}"
BUILD_ROOT="$BUILD_WORKDIR/pkg-$PKG_NAME"
BUILD_PREFIX="${BUILD_PREFIX:-/opt}"
BUILD_ALTCC="${BUILD_ALTCC:-}"
BUILD_ALTCXX="${BUILD_ALTCXX:-}"
BUILD_NUMJOBS="${BUILD_NUMJOBS:-7}"
case "${BUILD_ARCH:=$(uname -m)}" in
i[45]86)
BUILD_CFLAGS="${BUILD_CFLAGS:--march="$BUILD_ARCH" -mtune=i586 -O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-$BUILD_ARCH}"
;;
i686)
BUILD_CFLAGS="${BUILD_CFLAGS:--march="$BUILD_ARCH" -mtune=pentium4 -O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-$BUILD_ARCH}"
;;
x86_64|x86-64)
DIST_OS_ID="slackware64"
BUILD_CFLAGS="${BUILD_CFLAGS:--march=x86-64-v2 -mtune=ivybridge -O2 -fPIC}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
BUILD_LIBDIRSUFFIX="64"
PKG_ARCH="${PKG_ARCH:-x86_64}"
;;
aarch64)
DIST_OS_ID="slackwareaarch64"
BUILD_CFLAGS="${BUILD_CFLAGS:-O2 -fPIC}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
BUILD_LIBDIRSUFFIX="64"
PKG_ARCH="${PKG_ARCH:-aarch64}"
;;
arm*)
DIST_OS_ID="slackwarearm"
BUILD_CFLAGS="${BUILD_CFLAGS:-O2}"
BUILD_CXXFLAGS="${BUILD_CXXFLAGS:-$BUILD_CFLAGS}"
BUILD_LDFLAGS="${BUILD_LDFLAGS:-}"
BUILD_MAKEFLAGS=( "${BUILD_MAKEFLAGS[@]}" )
PKG_ARCH="${PKG_ARCH:-arm}"
;;
*)
die "Unsupported build architecture: $BUILD_ARCH"
;;
esac
# Now all possible changes to variables in PKG_STORE and PKG_CONFIG_ARCHIVE are complete, expand out the embedded variables.
eval "$(declare -p PKG_STORE PKG_CONFIG_ARCHIVE | sed -re 's/\\\$/$/g')"
# Sanity.
SRC_DIR="$(pwd)"
umask 0022
[[ ! -e "$BUILD_WORKDIR" ]] && { mkdir -p -m 750 "$BUILD_WORKDIR" || die "Failed to create working directory"; }
rm -rf "$BUILD_ROOT" && mkdir -m 755 "$BUILD_ROOT" || die "Failed to clear build root"
[[ -n "${SRC_DIRNAMES[*]}" ]] && { rm -rf "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || die "Failed to clear source directories"; }
# Get sources if they aren't downloaded already.
[[ -n "${SRC_DOWNLOADS[*]}" ]] && {
WGET="$(command -v wget)"
I=0
while read -r SRC; do
[[ ! -e "${SRC_FILENAMES[I]}" ]] && {
[[ -z "$WGET" ]] && die "wget is required to download sources"
"$WGET" -t 3 -c -T 30 -w 5 --retry-connrefused --retry-on-host-error --no-check-certificate --passive-ftp -O "${SRC_FILENAMES[I]}" "$SRC" || \
{ rm "${SRC_FILENAMES[I]}"; die "Failed to download source file: $SRC"; }
}
[[ "$(md5sum "${SRC_FILENAMES[I]}" | cut -d' ' -f1)" != "${SRC_MD5SUMS[I]}" ]] && die "md5sum verification failed: ${SRC_FILENAMES[I]}"
(( I++ ))
done < <(printf "%s\\n" "${SRC_DOWNLOADS[@]}")
}
# Unpack sources.
[[ -n "${SRC_FILENAMES[*]}" ]] && {
while read -r SRC; do
case "$SRC" in
*.tar.*|*.t?z)
tar -xv -C "$BUILD_WORKDIR" -f "$SRC" || die "Failed to extract source: $SRC"
;;
*.zip|*.ZIP)
unzip -d "$BUILD_WORKDIR" "$SRC" || die "Failed to extract source: $SRC"
;;
*)
die "Un-handled source archive format: ${SRC##*.}"
;;
esac
done < <(printf "%s\\n" "${SRC_FILENAMES[@]}")
}
# Fix any weird permissions on sources.
[[ -n "${SRC_DIRNAMES[*]}" ]] && { chown -R root:root "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" && chmod -R go-w "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || \
die "Failed to correct source directory permissions"; }
# Standard ./configure options.
CONFIGURE_OPTS=("${BUILD_ALTCC:+CC=$BUILD_ALTCC}" "${BUILD_ALTCXX:+CXX=$BUILD_ALTCXX}" "--prefix=$BUILD_PREFIX"
"--libdir=$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX" "--sysconfdir=/etc" "--localstatedir=/var" "--mandir=$BUILD_PREFIX/man"
"--infodir=$BUILD_PREFIX/info" "--build=$PKG_ARCH-slackware-linux" "--enable-shared" "--disable-static")
# Process each of the sources.
for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
# Be in the source directory.
cd "$BUILD_WORKDIR/${SRC_DIRNAMES[I]:?Failed to change to source directory}" || die "Failed to change to source directory"
############################################
# Begin section that will require editing. #
############################################
# Build each source in the array.
case "$I" in
0)
# Patch before build.
# zcat "$SRC_DIR/patches/EDITME.diff.gz" | patch -p0 || die "Source patching failed for: EDITME.diff.gz"
# Configure.
./autogen.sh || die "Source ./autogen.sh failed: ${SRC_FILENAMES[I]%-*}"
CFLAGS="$BUILD_CFLAGS" CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" ./configure "${CONFIGURE_OPTS[@]}" \
--docdir="$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" --without-tcmalloc || \
die "Source ./configure failed: ${SRC_FILENAMES[I]%-*}"
# Build and install.
make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" V=1 && make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" DESTDIR="$BUILD_ROOT" V=1 install || \
die "Failed to build and install source: ${SRC_FILENAMES[I]%-*}"
# Install extras.
mkdir "$BUILD_ROOT/etc/bash_completion.d/" && cp extras/command-completion/gluster.bash "$BUILD_ROOT/etc/bash_completion.d/gluster" || \
die "Failed to install bash completion: ${SRC_FILENAMES[I]%-*}"
# Remove unwanted paths from the package.
rm "$BUILD_ROOT/etc/ganesha/"* && rmdir "$BUILD_ROOT/etc/ganesha" && rmdir "$BUILD_ROOT/var/"{run/gluster,run} || \
die "Failed to remove unwanted files: ${SRC_FILENAMES[I]%-*}"
# Package documentation.
mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" && cp --parents AUTHORS COMMITMENT COPYING-GPLV2 \
COPYING-LGPLV3 ChangeLog INSTALL NEWS README.md THANKS "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.*|t?z|zip)}" || \
die "Documentation copy failed: ${SRC_FILENAMES[I]%-*}"
;;
*)
die "Un-handled source file - no build configuration"
;;
esac
done
# Move the package configuration files into the archive.
[[ -e "$BUILD_ROOT/etc/$PKG_NAME" ]] && {
(( ${BUILD_KEEPCONFIGS:-0} == 0 )) && {
rm -rf "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}"
mkdir -p -m 755 "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/$PKG_NAME" || \
die "Failed to create directory: $PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/$PKG_NAME"
mv "$BUILD_ROOT/etc/$PKG_NAME"/* "$PKG_CONFIG_ARCHIVE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}/etc/$PKG_NAME" || \
die "Failed to move configuration files to archive"
}
}
##################################################
# End of the only section that required editing. #
##################################################
# Set up for sed replacements.
SED_OPTS=("-e" "s:%BUILD_PREFIX%:$BUILD_PREFIX:g" "-e" "s:%BUILD_LIBDIR%:$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX:g" "-e" "s:%BUILD_ARCH%:$BUILD_ARCH:g"
"-e" "s:%DIST_OS_ID%:$DIST_OS_ID:g" "-e" "s:%DIST_OS_VERSION_ID%:$DIST_OS_VERSION_ID:g" "-e" "s:%PKG_NAME%:$PKG_NAME:g"
"-e" "s:%PKG_VERSION%:$PKG_VERSION:g" "-e" "s:%PKG_FILE_VERSION%:${PKG_VERSION//-/_}:g" "-e" "s:%PKG_ARCH%:$PKG_ARCH:g"
"-e" "s:%PKG_BUILD%:$PKG_BUILD:g" "-e" "s:%PKG_TAG%:${PKG_TAG//-/_}:g" "-e" "s:%PKG_EXT%:$PKG_EXT:g")
# Add extra configuration/scripts.
for DIR in cron.d cron.hourly cron.daily cron.weekly cron.monthly default logrotate.d profile.d rc.d; do
[[ -e "$SRC_DIR/$DIR" ]] && {
mkdir -p -m 755 "$BUILD_ROOT/etc/$DIR" || die "Failed to create directory: /etc/$DIR"
for FILE in "$SRC_DIR/$DIR"/*; do
sed -r "${SED_OPTS[@]}" <"$FILE" >"$BUILD_ROOT/etc/$DIR/${FILE##*/}" && chmod --reference="$FILE" "$BUILD_ROOT/etc/$DIR/${FILE##*/}" || \
die "Failed to copy $DIR/${FILE##*/} into package"
done
}
done
# Slackware packages don't ship with hardlinks (I don't know why...).
HARDLINKS="$(find "$BUILD_ROOT" -type f -links +1 | tr $'\n' ' ')"
[[ -n "$HARDLINKS" ]] && die "Found hardlinked files in package: $HARDLINKS"
# Strip binaries.
find "$BUILD_ROOT" -type f -exec file {} + | grep -E "ELF.*(executable|shared object)" | cut -d: -f1 | xargs -r strip --strip-unneeded || \
die "Failed to stip object files"
# Move man and info pages if required.
for DIR in "$BUILD_ROOT/$BUILD_PREFIX/share/man" "$BUILD_ROOT/usr/share/man" "$BUILD_ROOT/$BUILD_PREFIX/share/info" "$BUILD_ROOT/usr/share/info"; do
[[ -e "$DIR" ]] && {
mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/${DIR##*/}" || die "Failed to create $BUILD_PREFIX/${DIR##*/} directory"
mv "$DIR"/* "$BUILD_ROOT/$BUILD_PREFIX/${DIR##*/}" && rmdir "$DIR" || die "Failed to move $DIR to correct directory"
}
done
# Handle man pages.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/man" ]] && {
find "$BUILD_ROOT/$BUILD_PREFIX/man" -regextype posix-extended -type f -regex "^$BUILD_ROOT/$BUILD_PREFIX/man/([^/]*/)?man.*/.*\.[[:digit:]n]{1}[^.]*$" \
-exec gzip -9 {} + || die "Failed to compress man pages"
find "$BUILD_ROOT/$BUILD_PREFIX/man" -type l -printf 'if [[ -e "%h/%l.gz" ]]; then (cd "%h" && ln -sf "%l.gz" "%f.gz" && rm -f "%f") || \
die "Failed to fix symlink: %f"; else die "Dangling symlink: %p"; fi\n' | bash || die "Man pages' symlinks correction failed"
}
# Compress and fix info pages.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/info" ]] && {
rm -f "$BUILD_ROOT/$BUILD_PREFIX/info/dir"
find "$BUILD_ROOT/$BUILD_PREFIX/info" -regextype posix-extended -type f -regex "^$BUILD_ROOT/$BUILD_PREFIX/info/.*(\.info){1}(-[[:digit:]]+)?$" \
-exec gzip -9 {} + || die "Failed to compress info pages"
find "$BUILD_ROOT/$BUILD_PREFIX/info" -type l -printf 'if [[ -e "%h/%l.gz" ]]; then (cd "%h" && ln -sf "%l.gz" "%f.gz" && rm -f "%f") || \
die "Failed to fix symlink: %f"; else die "Dangling symlink: %p"; fi\n' | bash || die "Info pages' symlink correction failed"
}
# Fix paths for perl modules.
[[ -e "$BUILD_ROOT/$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX/perl5" ]] && {
find "$BUILD_ROOT/$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX/perl5" -name .packlist -exec sed -ri -e "s:^$BUILD_ROOT::g" \
-e "s:^($BUILD_PREFIX|/usr){1}/share:$BUILD_PREFIX:g" \
-e "s:^$BUILD_PREFIX/man/([^/]*/)?(man.*)/(.*)\.([[:digit:]n]){1}([^.])*$:$BUILD_PREFIX/man/\1\2/\3\.\4\5\.gz:g" \
-e "s:^$BUILD_PREFIX/info/(.*)(\.info){1}(-[[:digit:]]+)?$:$BUILD_PREFIX/info/\1\2\3.gz:g" {} + || die "Failed to modify incorrect perl paths"
find "$BUILD_ROOT" -name perllocal.pod -exec rm -f {} + # Should never fail
# Note: These will fail if $BUILD_ROOT == /usr, but are required to clean left over directories from perllocal.pod removal.
rmdir "$BUILD_ROOT/usr/lib$BUILD_LIBDIRSUFFIX/perl5" 2>/dev/null # OK to fail
rmdir "$BUILD_ROOT/usr/lib$BUILD_LIBDIRSUFFIX" 2>/dev/null # OK to fail
rmdir "$BUILD_ROOT/usr" 2>/dev/null # OK to fail
}
# /opt/<package>{,-<version>} is a special case.
# Technically, the FHS requires everything in /opt to be contained in its own package directory,
# so - assuming this technicallity is in use - make symlinks into the standard /opt dirs.
[[ "$BUILD_PREFIX" =~ ^/opt/$PKG_NAME.* ]] && {
(cd "$BUILD_ROOT/opt" &&
for DIR in bin doc include info lib lib64 libexec man sbin share; do
[[ -e "${BUILD_PREFIX##*/}/$DIR" ]] && { mkdir -m 755 "$DIR" && (cd "$DIR" && lndir -silent "../${BUILD_PREFIX##*/}/$DIR)") || exit 1; }
done) || die "Failed to link /opt paths"
}
# Copy pkgtool special files into the package.
mkdir -m 755 "$BUILD_ROOT/install" || die "Failed to make /install directory"
for FILE in doinst.sh douninst.sh slack-{conflicts,desc,required,suggests}; do
[[ -e "$SRC_DIR/$FILE" ]] && {
sed -r -e '/(^#|^$|-handy-ruler-)/ d' "${SED_OPTS[@]}" <"$SRC_DIR/$FILE" >"$BUILD_ROOT/install/$FILE" || \
die "Failed to copy in pkgtool special file: $FILE"
}
done
# Build the package.
cd "$BUILD_ROOT" || die "Failed to cd to BUILD_ROOT to build package"
rm -f "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}".*
makepkg -l y -p -c n --acls --xattrs "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT" || \
die "Package creation failed"
# Clean up after ourselves.
(( ${BUILD_CLEANUP:-1} == 1 )) && rm -rf "$BUILD_ROOT" "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}"
# Move package to the store.
{ mkdir -p -m 755 "$PKG_STORE" && rm -f "$PKG_STORE/$PKG_NAME"* && \
mv "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT" "$PKG_STORE"; } || \
die "Failed to move package to store - package left in $BUILD_WORKDIR"
printf "\\033[1;32;40m%s:\\n %s\\033[0;39m\\n" "Package built and moved to store" \
"$PKG_STORE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT"

View file

@ -0,0 +1,16 @@
# Package details.
PKG_NAME="$(basename "${BASH_SOURCE[0]}" .buildconf)"
PKG_VERSION="10.3"
PKG_BUILD="1"
PKG_TAG="${PKG_TAG:-_tadgy}"
PKG_EXT="${PKG_EXT:-txz}"
# Sources - the details in these arrays must all match per indicies.
SRC_DOWNLOADS=("https://download.gluster.org/pub/gluster/glusterfs/${PKG_VERSION%%.*}/$PKG_VERSION/$PKG_NAME-$PKG_VERSION.tar.gz")
SRC_MD5SUMS=("9c795c8479f244e81bca5b2499a480cc")
SRC_FILENAMES=("$PKG_NAME-$PKG_VERSION.tar.gz")
SRC_DIRNAMES=("$PKG_NAME-$PKG_VERSION")
# Build configuration.
BUILD_REQUIRES=('curl' 'libaio' 'libtirpc' 'liburing' 'libxml' 'openssl' 'readline' 'userspace-rcu')
BUILD_CONFLICTS=("$PKG_NAME")

View file

@ -0,0 +1,21 @@
/var/log/glusterfs/*.log {
sharedscripts
postrotate
killall -HUP glusterfs >/dev/null 2>&1 || true
killall -HUP glusterd >/dev/null 2>&1 || true
endscript
}
/var/log/glusterfs/bricks/*.log {
sharedscripts
postrotate
killall -HUP glusterfsd >/dev/null 2>&1 || true
endscript
}
/var/log/glusterfs/snaps/*/*.log {
sharedscripts
postrotate
killall -HUP $(pgrep -f "glusterfs.*snapd") >/dev/null 2>&1 || true
endscript
}

135
source/glusterfs/rc.d/rc.glusterd Executable file
View file

@ -0,0 +1,135 @@
#!/bin/bash
# Version: 0.4.0
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
SERVICE_EXEC="%BUILD_PREFIX%/sbin/glusterd"
SERVICE_ARGS=('-l' '$SERVICE_LOGFILE' '-L' '$SERVICE_LOGLEVEL')
SERVICE_PIDFILE="/run/glusterd.pid"
SERVICE_LOGFILE="/var/log/glusterfs/glusterd.log"
SERVICE_LOGLEVEL="WARNING"
# Allow configuration in /etc/default to override.
# Additional available variables:
# SERVICE_ENVIRONMENT=() # Extra environment passed to $SERVICE_EXEC. Must be an array.
# SERVICE_EXTRA_ARGS=() # Extra arguments passed to $SERVICE_EXEC. Must be an array.
# SERVICE_LOGFILE="" # Logfile to use for $SERVICE_EXEC. Default: /var/log/glusterfs/glusterd.log.
# SERVICE_LOGLEVEL="" # Level to use for logging by $SERVICE_EXEC. Default: WARNING.
# SLAY_DELAY="" # Delay between the SIGTERM and SIGKILL on a 'stop'. Default: 2s.
# RESTART_DELAY="" # Delay between stopping and starting on a 'restart'. Default: 2s.
# shellcheck disable=SC1090
[[ -e "/etc/default/${0##*rc.}" ]] && { source "/etc/default/${0##*rc.}" || return 1 2>/dev/null || exit 1; }
# Now all possible changes to variables in SERVICE_ARGS are complete, expand out the embedded variables.
eval "$(declare -p SERVICE_ARGS | sed -re 's/\\\$/$/g')"
error() {
printf "%s: %s\\n" "${BASH_SOURCE[0]##*/}" "$*" >&2
}
checkconfigured() {
# This function can be used to perform any pre-start tests; hopfully to insure the daemon
# can start correctly, before actually trying to start it. A return value of 0 means the
# tests were passed and the daemon should be started. Any other value prevents the
# daemon from being started, and an error message will be emitted.
return 0
}
checkstatus() {
# shellcheck disable=SC2155
local RUNPIDS="$({ pgrep -f "$SERVICE_EXEC"; pgrep -F "$SERVICE_PIDFILE" 2>/dev/null; } | sort -u )"
if [[ -n "$RUNPIDS" ]]; then
printf "%s: %s: %s" "${BASH_SOURCE[0]##*/}" "${SERVICE_EXEC##*/}" "running"
if [[ -n "$SERVICE_PIDFILE" ]]; then
if [[ ! -e "$SERVICE_PIDFILE" ]]; then
printf "%s" ", but .pid file does not exist"
elif ! grep "\<$(<"$SERVICE_PIDFILE")\>" <<<"$RUNPIDS" >/dev/null 2>&1; then
printf "%s" ", but .pid file is stale"
fi
fi
printf "\\n"
else
printf "%s: %s: %s\\n" "${BASH_SOURCE[0]##*/}" "${SERVICE_EXEC##*/}" "stopped"
return 1
fi
return 0
}
startdaemon() {
if [[ ! -e "$SERVICE_EXEC" ]]; then
error "not found: $SERVICE_EXEC"
return 2
elif [[ ! -x "$SERVICE_EXEC" ]]; then
error "not executable: $SERVICE_EXEC"
return 2
elif ! checkconfigured; then
error "not started - pre-start checks failed"
return 2
fi
# shellcheck disable=SC2048,SC2086
${SERVICE_ENVIRONMENT:+declare ${SERVICE_ENVIRONMENT[*]};} "$SERVICE_EXEC" ${SERVICE_ARGS[*]} ${SERVICE_EXTRA_ARGS[*]}
# shellcheck disable=SC2181
if (( $? != 0 )); then
error "error starting '${SERVICE_EXEC##*/}'"
return 2
else
return 0
fi
}
stopdaemon() {
kill -TERM "$(pgrep -f "$SERVICE_EXEC" | tr $'\n' " ")" >/dev/null 2>&1
[[ -e "$SERVICE_PIDFILE" ]] && {
sleep 0.5
kill -TERM "$(<"$SERVICE_PIDFILE")" >/dev/null 2>&1
}
sleep "${SLAY_DELAY:-2}"
checkstatus >/dev/null && {
error "failed to stop gracefully - slaying"
kill -KILL "$({ cat "$SERVICE_PIDFILE"; pgrep -f "$SERVICE_EXEC"; } 2>/dev/null | sort -u | tr $'\n' " ")" >/dev/null 2>&1
}
return 0
}
case "$1" in
'start')
if checkstatus >/dev/null; then
error "${SERVICE_EXEC##*/}: already running"
printf " %s\\n" "Try: ${BASH_SOURCE[0]} status" >&2
RET=1
else
startdaemon
RET=$?
fi
;;
'stop')
if ! checkstatus >/dev/null; then
error "${SERVICE_EXEC##*/}: not running"
printf " %s\\n" "Try: ${BASH_SOURCE[0]} status" >&2
RET=1
else
stopdaemon
RET=$?
fi
;;
'restart')
checkstatus >/dev/null
(( $? != 3 )) && {
stopdaemon >/dev/null 2>&1
sleep "${RESTART_DELAY:-2}"
}
startdaemon
RET=$?
;;
'status')
checkstatus
RET=$?
;;
*)
printf "%s\\n" "Usage: ${BASH_SOURCE[0]} <start|stop|restart|status>" >&2
RET=1
;;
esac
return $RET 2>/dev/null || exit $RET

View file

@ -0,0 +1,19 @@
# Version: 0.2.5
# Package description syntax:
# * There must be exactly 11 lines which begin with the package name and ':'.
# * Line up the first '|' of the ruler with the ':' following the package name.
# * A single space should be left after the ':' before any description text.
# * The end '|' of the ruler marks the last columm which should contain text.
|-----handy-ruler------------------------------------------------------|
%PKG_NAME%: glusterfs (Scalable elastic network filesystem)
%PKG_NAME%:
%PKG_NAME%: GlusterFS is a scalable network filesystem. Using common off the
%PKG_NAME%: shelf hardware, you can create large, distributed storage solutions.
%PKG_NAME%:
%PKG_NAME%:
%PKG_NAME%:
%PKG_NAME%:
%PKG_NAME%: Warning: This package does not contain any configuration files.
%PKG_NAME%:
%PKG_NAME%: Packaged by: Darren 'Tadgy' Austin. Built for: %DIST_OS_ID%-%DIST_OS_VERSION_ID%.

View file

@ -0,0 +1,20 @@
# Version: 0.2.3
# This is the list of packages which, if the package currently being installed
# is to operate correctly, must be installed on the system - its dependancies.
# For example, 'spamassassin' requires the 'perl' package to operate.
# Packages must be listed one per line and are case sensitive. If multiple
# packages could satisfy a single dependancy (such as 'openssl-solibs' and
# 'openssl' for the SSL library) the packages should be listed in the format:
# <pkg1> | <pkg2> [| <pkg3> ...]
# Specific package versions can be specified using = >= =< < > operators.
# The = operator requires the full package version string (eg, 1.2.3-x86_64-5).
# The >= =< < > operators, can use the short package version string
# (eg, 1.2.3) or the full version string. This file is only used by slapt-get.
curl
libaio
libtirpc
liburing
libxml
openssl | openssl-solibs
readline
userspace-rcu