summaryrefslogtreecommitdiffstats
path: root/contrib/fedora/bashrc_sssd
blob: 7301b520c6b0e9487e94f3855a2eb2ec2468f15f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# 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 \
        --with-krb5-rcache-dir=/var/cache/krb5rcache \
        --with-initscript=systemd \
        --with-syslog=journald \
        --with-test-dir=/dev/shm \
        --enable-all-experimental-features \
        --cache-file=/tmp/fedconfig.cache \
        ${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 \
              -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 -O0 $SSS_WARNINGS ${SSS_WERROR-}" \
         -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()
{
    sudo make -j$PROCESSORS 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 "$@"
}