ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# For best results, add the following lines to ~/.bashrc:
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# if [ -f /path/to/sssd-source/contrib/fedora/bashrc_sssd ]; then
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# . /path/to/sssd-source/contrib/fedora/bashrc_sssd
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# fi
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Determine the architecture of the platform we're running on
2e2909686735ceb62f6b64972b3f30f7005e26aaNikolai KondrashovSSS_ARCH=$(uname -m)
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Determine the lib and libdir locations
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen GallagherSSS_LIB=$(rpm --eval %{_lib})
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen GallagherSSS_LIBDIR=$(rpm --eval %{_libdir})
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Add the following line to your .bashrc if you want SSSD to throw errors on
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# compiler warnings (recommended)
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# SSS_WERROR=-Werror
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Determine the number of available processors on the system for parallel make
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# invocation.
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen GallagherPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Configure invocation for use on Fedora systems, based on the %configure RPM
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov# macro from the redhat-rpm-config package. This function assumes you are
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov# building in a parallel build directory beneath the source directory. All
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov# other functions in this script will assume that the location is
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# /path/to/sssd-source/$SSS_ARCH
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovfedconfig()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov ../configure \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --build=$SSS_ARCH-unknown-linux-gnu \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --host=$SSS_ARCH-unknown-linux-gnu \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --program-prefix= \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --prefix=/usr \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --exec-prefix=/usr \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --bindir=/usr/bin \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --sbindir=/usr/sbin \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --sysconfdir=/etc \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --datadir=/usr/share \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --includedir=/usr/include \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --libdir=$SSS_LIBDIR \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --libexecdir=/usr/libexec \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --localstatedir=/var \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --sharedstatedir=/var/lib \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --mandir=/usr/share/man \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --infodir=/usr/share/info \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --enable-nsslibdir=/$SSS_LIB \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --enable-pammoddir=/$SSS_LIB/security \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --with-krb5-rcache-dir=/var/cache/krb5rcache \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --with-initscript=systemd \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --with-syslog=journald \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --with-test-dir=/dev/shm \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --enable-all-experimental-features \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov --cache-file=/tmp/fedconfig.cache \
8b83e6b0867576fcefb60b19dbcd4fcee3e6e862Nikolai Kondrashov ${SSSD_NO_MANPAGES-} \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov# Completely purge the current working directory, then recreate
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# and reconfigure it. This is best used when you are making changes to the m4
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# macros or the configure scripts.
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovreconfig()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov autoreconf -if \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && rm -Rf $SSS_ARCH/ \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && mkdir $SSS_ARCH/ \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && cd $SSS_ARCH/ \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && fedconfig "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Set the list of warnings that you want to detect (and in the case of remake
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# and chmake want to treat as errors)
2930ff3863961403d89a0b1147c14b82f91ad7ebStephen GallagherSSS_WARNINGS='-Wall \
2930ff3863961403d89a0b1147c14b82f91ad7ebStephen Gallagher -Wextra \
2930ff3863961403d89a0b1147c14b82f91ad7ebStephen Gallagher -Wno-unused-parameter \
2930ff3863961403d89a0b1147c14b82f91ad7ebStephen Gallagher -Wno-sign-compare \
2930ff3863961403d89a0b1147c14b82f91ad7ebStephen Gallagher -Wformat-security'
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Build (or finish building) all objects and then run the build-tests against
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# them. This builds with optimizations turned off and GDB debugging symbols.
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovchmake()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
cabc0511873778fddc318951d1a329c2a2945731Pavel Reichl make V=0 \
cabc0511873778fddc318951d1a329c2a2945731Pavel Reichl CFLAGS+="-ggdb3 $SSS_WARNINGS ${SSS_WERROR-} -O0 -Wp,-U_FORTIFY_SOURCE" \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov -j$PROCESSORS check "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Clean the build directory and rebuild all objects, then run the build-tests
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# against them. This builds with optimizations turned off and GDB debugging
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# symbols.
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovremake()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov make clean > /dev/null && chmake "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Clean the build directory and rebuild all objects, hiding most of the build
0b5422c874a0d234b864a28cf18489a7e7ef17f6Nikolai Kondrashov# output except for warnings and errors. This builds with default
0b5422c874a0d234b864a28cf18489a7e7ef17f6Nikolai Kondrashov# optimization and without debugging symbols.
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovwarn()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov make clean >/dev/null \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && make CFLAGS+="$SSS_WARNINGS" -j$PROCESSORS tests > /dev/null "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Install the built sources to the current system, cleaning up the LDB modules
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# and making sure that the NSS and PAM modules have the right SELinux context.
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovsssinstall()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov sudo make -j$PROCESSORS install \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && sudo rm -f $SSS_LIBDIR/ldb/modules/ldb/memberof.la \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov && sudo restorecon -v /$SSS_LIB/libnss_sss.so.2 \
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov /$SSS_LIB/security/pam_sss.so
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Alias to generate a patch or series of patches that meet SSSD submission
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# guidelines.
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# Usage:
ccaea33f064842b16c7c9efeb50028cacdee6b2fStephen Gallagher# genpatch -N (where N is the number of patches to submit)
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashovgenpatch()
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov{
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov git format-patch -M -C --patience --full-index "$@"
bde0fb63858b8ac0315b2c0fd5ce37b19430f656Nikolai Kondrashov}