summaryrefslogtreecommitdiffstats
path: root/contrib/fedora
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 05:31:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 05:31:45 +0000
commit74aa0bc6779af38018a03fd2cf4419fe85917904 (patch)
tree9cb0681aac9a94a49c153d5823e7a55d1513d91f /contrib/fedora
parentInitial commit. (diff)
downloadsssd-74aa0bc6779af38018a03fd2cf4419fe85917904.tar.xz
sssd-74aa0bc6779af38018a03fd2cf4419fe85917904.zip
Adding upstream version 2.9.4.upstream/2.9.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/fedora')
-rw-r--r--contrib/fedora/bashrc_sssd124
-rwxr-xr-xcontrib/fedora/make_srpm.sh186
2 files changed, 310 insertions, 0 deletions
diff --git a/contrib/fedora/bashrc_sssd b/contrib/fedora/bashrc_sssd
new file mode 100644
index 0000000..8fb6524
--- /dev/null
+++ b/contrib/fedora/bashrc_sssd
@@ -0,0 +1,124 @@
+# For best results, add the following lines to ~/.bashrc:
+# if [ -f /path/to/sssd-source/contrib/fedora/bashrc_sssd ]; then
+# . /path/to/sssd-source/contrib/fedora/bashrc_sssd
+# fi
+
+# Determine the architecture of the platform we're running on
+SSS_ARCH=$(uname -m)
+
+# Determine the lib and libdir locations
+SSS_LIB=$(rpm --eval %{_lib})
+SSS_LIBDIR=$(rpm --eval %{_libdir})
+
+# Add the following line to your .bashrc if you want SSSD to throw errors on
+# compiler warnings (recommended)
+# SSS_WERROR=-Werror
+
+# Determine the number of available processors on the system for parallel make
+# invocation.
+PROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
+
+# Configure invocation for use on Fedora systems, based on the %configure RPM
+# macro from the redhat-rpm-config package. This function assumes you are
+# building in a parallel build directory beneath the source directory. All
+# other functions in this script will assume that the location is
+# /path/to/sssd-source/$SSS_ARCH
+fedconfig()
+{
+ ../configure \
+ --build=$SSS_ARCH-unknown-linux-gnu \
+ --host=$SSS_ARCH-unknown-linux-gnu \
+ --program-prefix= \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --sysconfdir=/etc \
+ --datadir=/usr/share \
+ --includedir=/usr/include \
+ --libdir=$SSS_LIBDIR \
+ --libexecdir=/usr/libexec \
+ --localstatedir=/var \
+ --sharedstatedir=/var/lib \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-nsslibdir=/$SSS_LIB \
+ --enable-pammoddir=/$SSS_LIB/security \
+ --enable-systemtap \
+ --with-krb5-rcache-dir=/var/cache/krb5rcache \
+ --with-initscript=systemd \
+ --with-syslog=journald \
+ --with-test-dir=/dev/shm \
+ --cache-file=/tmp/fedconfig.cache \
+ --with-passkey \
+ ${SSSD_NO_MANPAGES-} \
+ "$@"
+}
+
+# Completely purge the current working directory, then recreate
+# and reconfigure it. This is best used when you are making changes to the m4
+# macros or the configure scripts.
+reconfig()
+{
+ autoreconf -if \
+ && rm -Rf $SSS_ARCH/ \
+ && mkdir $SSS_ARCH/ \
+ && cd $SSS_ARCH/ \
+ && fedconfig "$@"
+}
+
+# Set the list of warnings that you want to detect (and in the case of remake
+# and chmake want to treat as errors)
+SSS_WARNINGS='-Wall \
+ -Wextra \
+ -Wno-unused-parameter \
+ -Wno-sign-compare \
+ -Wshadow \
+ -Wunused-variable \
+ -Wformat-security'
+
+# Build (or finish building) all objects and then run the build-tests against
+# them. This builds with optimizations turned off and GDB debugging symbols.
+chmake()
+{
+ make V=0 \
+ CFLAGS+="-ggdb3 $SSS_WARNINGS ${SSS_WERROR-} -O0 -Wp,-U_FORTIFY_SOURCE" \
+ -j$PROCESSORS check "$@"
+}
+
+# Clean the build directory and rebuild all objects, then run the build-tests
+# against them. This builds with optimizations turned off and GDB debugging
+# symbols.
+remake()
+{
+ make clean > /dev/null && chmake "$@"
+}
+
+# Clean the build directory and rebuild all objects, hiding most of the build
+# output except for warnings and errors. This builds with default
+# optimization and without debugging symbols.
+warn()
+{
+ make clean >/dev/null \
+ && make CFLAGS+="$SSS_WARNINGS" -j$PROCESSORS tests > /dev/null "$@"
+}
+
+# Install the built sources to the current system, cleaning up the LDB modules
+# and making sure that the NSS and PAM modules have the right SELinux context.
+sssinstall()
+{
+ # Force single-thread install to workaround concurrency issues
+ sudo make -j1 install \
+ && sudo rm -f $SSS_LIBDIR/ldb/modules/ldb/memberof.la \
+ && sudo restorecon -v /$SSS_LIB/libnss_sss.so.2 \
+ /$SSS_LIB/security/pam_sss.so
+}
+
+# Alias to generate a patch or series of patches that meet SSSD submission
+# guidelines.
+# Usage:
+# genpatch -N (where N is the number of patches to submit)
+genpatch()
+{
+ git format-patch -M -C --patience --full-index "$@"
+}
diff --git a/contrib/fedora/make_srpm.sh b/contrib/fedora/make_srpm.sh
new file mode 100755
index 0000000..b9c4b17
--- /dev/null
+++ b/contrib/fedora/make_srpm.sh
@@ -0,0 +1,186 @@
+#!/bin/bash
+
+# Authors:
+# Lukas Slebodnik <lslebodn@redhat.com>
+#
+# Copyright (C) 2013 Red Hat
+#
+# 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 3 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/>.
+
+PACKAGE_NAME="sssd"
+
+usage(){
+ echo "$(basename $0) [OPTIONS] [-P|--patches <patch>...]"
+ echo -e "\t-p, --prerelease Create prerelease SRPM"
+ echo -e "\t-d, --debug Enable debugging."
+ echo -e "\t-c, --clean Remove directory rpmbuild and exit."
+ echo -e "\t-P, --patches Requires list of patches for SRPM."
+ echo -e "\t-o, --output Moves the created srpm to a specific output directory."
+ echo -e "\t-v, --version Provide package version to set in spec file."
+ echo -e "\t-h, --help Print this help and exit."
+ echo -e "\t-?, --usage"
+
+ exit 1
+}
+
+add_patches(){
+ spec_file=$1
+ shift
+ source_dir=$1
+ shift
+
+ patches=("${@}")
+
+ # These keep track of our spec file substitutions.
+ i=1
+ prefix="Source0:"
+ prepprefix="%setup"
+
+ # If no patches exist, just exit.
+ if [ -z "$patches" ]; then
+ echo Creating SRPM without extra patches.
+ return 0
+ fi
+
+ # Add the patches to the specfile.
+ for p in "${patches[@]}"; do
+ cp "$p" "$source_dir"
+ p=$(basename $p)
+ echo "Adding patch to spec file - $p"
+ sed -i -e "/${prefix}/a Patch${i}: ${p}" \
+ -e "/$prepprefix/a %patch${i} -p1" \
+ "$spec_file"
+
+ prefix="Patch${i}:"
+ prepprefix="%patch${i}"
+ i=$(($i+1))
+ done
+}
+
+for i in "$@"
+do
+case $i in
+ -p|--prerelease)
+ PRERELEASE=1
+ shift
+ ;;
+ -d|--debug)
+ set -x
+ shift
+ ;;
+ -c|--clean)
+ CLEAN=1
+ shift
+ ;;
+ -P|--patches)
+ shift
+ patches=("$@")
+ break
+ ;;
+ -o|--output)
+ shift
+ OUTPUT=("$@")
+ break
+ ;;
+ -v|--version)
+ shift
+ VERSION=("$@")
+ break
+ ;;
+ -h|--help|-\?|--usage)
+ usage
+ ;;
+ *)
+ # unknown option
+ ;;
+esac
+done
+
+RPMBUILD="$(pwd)/rpmbuild"
+if [ -n "$CLEAN" ]; then
+ rm -rfv "$RPMBUILD"
+ exit 0
+fi
+
+SRC_DIR=$(git rev-parse --show-toplevel)
+rc=$?
+if [ $rc != 0 ]; then
+ echo "This script must be run from the $PACKAGE_NAME git repository!"
+ exit 1;
+fi
+
+if [ "x$SRC_DIR" = x ]; then
+ echo "Fatal: Could not find source directory!"
+ exit 1;
+fi
+
+VERSION_FILE="$SRC_DIR/version.m4"
+SPEC_TEMPLATE="$SRC_DIR/contrib/$PACKAGE_NAME.spec.in"
+
+if [ ! -f "$VERSION_FILE" ]; then
+ echo "Fatal: Could not find file version.m4 in source directory!"
+ exit 1;
+fi
+
+if [ ! -f "$SPEC_TEMPLATE" ]; then
+ echo "Fatal: Could not find $PACKAGE_NAME.spec.in in contrib subdirectory!"
+ exit 1;
+fi
+
+PACKAGE_VERSION=$(grep "\[VERSION_NUMBER\]" $VERSION_FILE \
+ | sed -e 's/.*\[//' -e 's/\]).*$//')
+if [ -n "$VERSION" ]; then
+ PACKAGE_VERSION="$VERSION"
+fi
+if [ "x$PACKAGE_VERSION" = x ]; then
+ echo "Fatal: Could parse version from file:$VERSION_FILE!"
+ exit 1;
+fi
+
+PRERELEASE_VERSION=""
+if [ -n "$PRERELEASE" ]; then
+ PRERELEASE_VERSION=.$(date +%y%m%d.%H%M%S).git$(git log -1 --pretty=format:%h)
+fi
+
+mkdir -p $RPMBUILD/BUILD
+mkdir -p $RPMBUILD/RPMS
+mkdir -p $RPMBUILD/SOURCES
+mkdir -p $RPMBUILD/SPECS
+mkdir -p $RPMBUILD/SRPMS
+
+sed -e "s/@PACKAGE_NAME@/$PACKAGE_NAME/" \
+ -e "s/@PACKAGE_VERSION@/$PACKAGE_VERSION/" \
+ -e "s/@PRERELEASE_VERSION@/$PRERELEASE_VERSION/" \
+ < "$SPEC_TEMPLATE" \
+ > "$RPMBUILD/SPECS/$PACKAGE_NAME.spec"
+
+NAME="$PACKAGE_NAME-$PACKAGE_VERSION"
+git archive --format=tar --prefix="$NAME"/ \
+ --remote="file://$SRC_DIR" \
+ HEAD \
+ | gzip > "$RPMBUILD/SOURCES/$NAME.tar.gz"
+
+cp "$SRC_DIR"/contrib/*.patch "$RPMBUILD/SOURCES" 2>/dev/null
+add_patches "$RPMBUILD/SPECS/$PACKAGE_NAME.spec" \
+ "$RPMBUILD/SOURCES" \
+ "${patches[@]}"
+
+cd $RPMBUILD
+rpmbuild --define "_topdir $RPMBUILD" \
+ -bs SPECS/$PACKAGE_NAME.spec
+
+if [ -n "$OUTPUT" ]; then
+ mv "$RPMBUILD/SRPMS/"*.src.rpm "$OUTPUT/"
+ echo "Package has been moved to the folder: $OUTPUT"
+fi