#!/bin/sh #-- gdm for Slackware -- # Build script by Phantom X # Suggested usage: $ gdm.SlackBuild 2>&1 | tee build.log #-- # Copyright 2008, 2009, 2010 Phantom X, Goiania, Brazil. # Copyright 2006 Martijn Dekker, Groningen, Netherlands. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # http://download.gnome.org/sources/gdm PACKAGER_ID=${PACKAGER_ID:-$USER} PACKAGER=${PACKAGER:-$USER@$HOSTNAME} # Set YES for native build with gcc >= 4.2 SB_NATIVE=${SB_NATIVE:-NO} CWD=$(pwd) TMP=${TMP:-/tmp} if [ ! -d ${TMP} ]; then mkdir -p ${TMP} fi NAME=gdm PKG=${PKG:-${TMP}/package-${NAME}} VERSION=${VERSION:-2.20.10} SVER=$(echo ${VERSION} | cut -d . -f1-2) FFVER=${FFVER:-20070319} if [ "${SB_NATIVE}" = "YES" ] ;then ARCH=${ARCH:-$(uname -m)} else ARCH=${ARCH:-i686} fi if [ "${ARCH}" = "x86_64" ] ;then SLKTARGET=${SLKTARGET:-x86_64} else SLKTARGET=${SLKTARGET:-i486} fi SLKDTARGET=${SLKDTARGET:-slackware} BUILD=${BUILD:-4} NJOBS=${NJOBS:-$(( $(getconf _NPROCESSORS_ONLN) + 1 ))} DOCDIR=${PKG}/usr/doc/${NAME}-${VERSION} SBDIR=${PKG}/usr/src/slackbuilds/gnome/${NAME} PKGDEST=${PKGDEST:-${CWD}} PKGFORMAT=${PKGFORMAT:-txz} PKGNAME=${NAME}-$(echo ${VERSION} | tr - . )-${ARCH}-${BUILD}${PACKAGER_ID} DATE=$(LC_ALL=C date +%d-%b-%Y) grep --quiet '^gdm:' /etc/group && SB_HGROUP=1 grep --quiet '^gdm:' /etc/passwd && SB_HUSER=1 SRCDIR=${NAME}-${VERSION} SRCARCHIVE=${SRCDIR}.tar.bz2 SRCARCHIVE2=fedora-faces-${FFVER}.tar.bz2 DL_PROG=${DL_PROG:-wget} DL_TO=${DL_TO:-5} DL_OPTS=${DL_OPTS:-"--timeout=${DL_TO}"} GNOME_MIRROR=${GNOME_MIRROR:-http://ftp.gnome.org/pub/GNOME/sources} DL_URL="${GNOME_MIRROR}/${NAME}/${SVER}/${SRCARCHIVE}" # if source is not present, download in source rootdir if possible test -r ${CWD}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URL} || exit 1 if [ "${SB_NATIVE}" = "YES" ] ;then SLKCFLAGS="-O2 -march=native -mtune=native ${SB_ECFLAGS} -pipe" else case "${ARCH}" in i[3-6]86) SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686" ;; s390) SLKCFLAGS="-O2" ;; x86_64) SLKCFLAGS="-O2 -fPIC" ;; esac fi if [ "${ARCH}" = "x86_64" ] ;then LIBDIRSUFFIX="64" SLKCFLAGS="${SLKCFLAGS} -fPIC" else LIBDIRSUFFIX="" fi if [ -d ${PKG} ]; then # Clean up a previous build rm -rf ${PKG} fi mkdir -p ${PKG} cd ${TMP} rm -rf ${SRCDIR} tar -xvf ${CWD}/${SRCARCHIVE} || exit 1 cd ${SRCDIR} || exit 1 if [ -f ${CWD}/${SRCARCHIVE2} ] ;then tar -xvf ${CWD}/${SRCARCHIVE2} || exit 1 fi chmod -R u+w,go+r-w,a-s . # zcat ${CWD}/${NAME}.patch.gz | patch -p0 -E --backup --verbose || exit 1 if [ -r ${CWD}/apply-patches.sh ]; then . ${CWD}/apply-patches.sh || exit 1 fi sed -i -e 's|X11R6/||g' configure.ac || exit 1 sed -i -e 's|LIBWRAP_PATH=""|LIBWRAP_PATH="-lwrap"|g' \ configure configure.ac || exit 1 intltoolize --force --copy || exit 1 autoreconf -ivf || exit 1 CFLAGS="${SLKCFLAGS}" \ CXXFLAGS="${SLKCFLAGS}" \ ./configure \ --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --sbindir=/usr/bin \ --sysconfdir=/etc \ --localstatedir=/var \ --infodir=/usr/info \ --mandir=/usr/man \ --docdir=/usr/doc/${NAME}-${VERSION} \ --disable-scrollkeeper \ --with-dmconfdir=/usr/share/gdm/dm \ --enable-authentication-scheme=shadow \ --with-console-kit \ --build=${SLKTARGET}-${SLKDTARGET}-linux || exit 1 make -j${NJOBS} || make || exit 1 mkdir -p ${PKG}/etc/gdm/Init mkdir -p ${PKG}/etc/gdm/PreSession mkdir -p ${PKG}/etc/gdm/PostSession make install DESTDIR=${PKG} || exit 1 # Fix wrong path for Xsession file. sed -i -e '/^BaseXsession=/s|=.*$|=/etc/gdm/Xsession|g' \ ${PKG}/usr/share/gdm/defaults.conf # create log dir mkdir -p ${PKG}/var/log/gdm rm -f ${PKG}/usr/lib*/gtk-2.0/modules/*.a rm -f ${PKG}/usr/lib*/gtk-2.0/modules/*.la # remove the other gnome session file, since we put it in gnome-session rm -rf ${PKG}/usr/share/xsessions # This got given an unfortunate name, so revert the name for now. # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=234218 # and http://bugzilla.gnome.org/show_bug.cgi?id=403690 zcat ${CWD}/default.desktop.gz \ > ${PKG}/usr/share/gdm/BuiltInSessions/default.desktop || exit 1 # fix the "login photo" file echo "NoDisplay=true" \ >> ${PKG}/usr/share/gdm/applications/gdmphotosetup.desktop desktop-file-install --vendor gnome --delete-original \ --dir ${PKG}/usr/share/gdm/applications \ --remove-category Application \ --remove-key="Encoding" \ ${PKG}/usr/share/gdm/applications/gdmsetup.desktop || exit 1 desktop-file-install --vendor gnome --delete-original \ --dir ${PKG}/usr/share/gdm/applications \ --remove-category Application \ --remove-key="Encoding" \ ${PKG}/usr/share/gdm/applications/gdmphotosetup.desktop || exit 1 desktop-file-install --vendor "" --delete-original \ --dir ${PKG}/usr/share/gdm/applications \ --remove-category Application \ --remove-key="Encoding" \ ${PKG}/usr/share/gdm/applications/gdmflexiserver.desktop || exit 1 desktop-file-install --vendor "" --delete-original \ --dir ${PKG}/usr/share/gdm/applications \ --remove-category Application \ --remove-key="Encoding" \ ${PKG}/usr/share/gdm/applications/gdmflexiserver-xnest.desktop || exit 1 # broken install-data-local in gui/Makefile.am makes this necessary ( cd ${PKG}/usr/bin && ln -sf gdmXnestchooser gdmXnest ) rm -rf ${PKG}/var/scrollkeeper # grant access to alsa and oss devices for the gdm user mkdir -p ${PKG}/usr/share/hal/fdi/policy/20thirdparty zcat ${CWD}/90-grant-audio-devices-to-gdm.fdi.gz >\ ${PKG}/usr/share/hal/fdi/policy/20thirdparty/90-grant-audio-devices-to-gdm.fdi || exit 1 if [ -f ${CWD}/${SRCARCHIVE2} ] ;then # replace faces with the ones from fedora-faces rm -rf ${PKG}/usr/share/pixmaps/faces cp -Rpr faces ${PKG}/usr/share/pixmaps/ || exit 1 fi mv ${PKG}/etc/gdm/custom.conf \ ${PKG}/etc/gdm/custom.conf.new || exit 1 mkdir -p ${PKG}/usr/share/gdm/dm/Sessions mkdir -p ${PKG}/var/lib/gdm/.pulse chmod 0770 ${PKG}/var/lib/gdm chmod 0700 ${PKG}/var/lib/gdm/.pulse zcat ${CWD}/default.pa-for-gdm.gz > ${PKG}/var/lib/gdm/.pulse/default.pa || exit 1 chmod 0600 ${PKG}/var/lib/gdm/.pulse/default.pa find ${PKG} | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null mv ${PKG}/etc/gdm/Xsession ${PKG}/etc/gdm/Xsession.new chmod 0755 ${PKG}/etc/gdm/Xsession* mkdir -p ${PKG}/etc/X11/xinit/xinitrc.d # Add a documentation directory: mkdir -p ${DOCDIR} cp -a \ AUTHORS COPYING ChangeLog NEWS README TODO ${CWD}/ChangeLog.SB \ ${DOCDIR}/ find ${DOCDIR}/ -type d -print0 | xargs -0 chmod 0755 find ${DOCDIR}/ -type f -print0 | xargs -0 chmod 0644 # Compress and link manpages, if any: if [ -d ${PKG}/usr/share/man ]; then mv ${PKG}/usr/share/man ${PKG}/usr/man rmdir ${PKG}/usr/share fi if [ -d ${PKG}/usr/man ]; then ( cd ${PKG}/usr/man for manpagedir in $(find . -type d -name "man*") ; do ( cd ${manpagedir} for eachpage in $( find . -type l -maxdepth 1) ; do ln -s $( readlink ${eachpage} ).gz ${eachpage}.gz rm ${eachpage} done gzip -9 *.? # Prevent errors rm -f *.gz.gz ) done ) fi mkdir -p ${PKG}/install cat ${CWD}/slack-desc > ${PKG}/install/slack-desc cat ${CWD}/slack-required > ${PKG}/install/slack-required cat > ${PKG}/install/doinst.sh <<'EOF' # Figure out our root directory ROOTDIR=$(pwd) unset CHROOT if test "${ROOTDIR}" != "/"; then CHROOT="chroot ${ROOTDIR} " ROOTDIR="${ROOTDIR}/" fi GROUP_ID=42 # Set up groups. if ! grep --quiet '^gdm:' etc/group ;then ${CHROOT} /usr/sbin/groupadd \ -g ${GROUP_ID} \ gdm 2> /dev/null fi # Set up user: add it if it doesn't exist, update it if it already does. if OLD_ENTRY=$(grep --max-count=1 '^gdm:' etc/passwd) \ || OLD_ENTRY=$(grep --max-count=1 \ ':/var/lib/gdm:[a-z/]*$' etc/passwd) then # Modify existing user OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':') USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':') if test "${OLD_USER}" = "gdm"; then echo -n "Updating unprivileged user" 1>&2 else echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2 fi ${CHROOT} /usr/sbin/usermod \ -d '/var/lib/gdm' \ -u ${USER_ID} \ -s /bin/false \ -g gdm \ ${OLD_USER} else # Add new user echo -n "Creating unprivileged user" 1>&2 ${CHROOT} /usr/sbin/useradd \ -c 'GDM' \ -u ${GROUP_ID} \ -g gdm \ -s /bin/false \ -d '/var/lib/gdm' \ gdm 2> /dev/null fi EOF cat >> ${PKG}/install/doinst.sh < /dev/null 2>&1 fi if [ -x /usr/bin/gtk-update-icon-cache ]; then \${CHROOT} /usr/bin/gtk-update-icon-cache -q usr/share/icons/hicolor > /dev/null 2>&1 fi config() { NEW="\$1" OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } ## List of conf files to check. The conf files in your package should end in .new EOF ( cd ${PKG} find etc/ -name *.new -exec echo config {} ';' | sort >> ${PKG}/install/doinst.sh echo >> ${PKG}/install/doinst.sh echo '# Fix permissions' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chown root.gdm /var/lib/gdm' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chmod 1770 /var/lib/gdm' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chown gdm.gdm /var/lib/gdm/.pulse ' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chmod 0700 /var/lib/gdm/.pulse' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chown gdm.gdm /var/lib/gdm/.pulse/default.pa' >> ${PKG}/install/doinst.sh echo '${CHROOT} /bin/chmod 0600 /var/lib/gdm/.pulse/default.pa' >> ${PKG}/install/doinst.sh ) sed -i "s|_PACKAGER|${PACKAGER}|g; s|_BUILD_DATE|${DATE}|g" \ ${PKG}/install/slack-desc # Replicate slackbuild and patches if [ "${SB_REP}" = "YES" ] ;then # Replicate slackbuild and patches mkdir -p ${SBDIR}/patches install -m0644 ${CWD}/slack-desc ${CWD}/slack-required ${CWD}/ChangeLog.SB \ ${CWD}/apply-patches.sh ${CWD}/*.desktop.gz ${CWD}/default.*.gz \ ${SBDIR}/ install -m0755 ${CWD}/${NAME}.SlackBuild \ ${SBDIR}/${NAME}.SlackBuild install -m0644 ${CWD}/patches/*.gz \ ${SBDIR}/patches/ fi # Build package: set +o xtrace # no longer print commands upon execution ROOTCOMMANDS="set -o errexit -o xtrace ; cd ${PKG} ; /bin/chown --recursive root:root . ; [ \"${SB_HGROUP}\" = 1 ] && /bin/chown root.gdm ./var/lib/gdm ; /bin/chmod 1770 ./var/lib/gdm ; [ \"${SB_HGROUP}\" = 1 ] && [ \"${SB_HUSER}\" = 1 ] && /bin/chown gdm.gdm ./var/lib/gdm/.pulse ./var/lib/gdm/.pulse/default.pa ; /bin/chmod 0700 ./var/lib/gdm/.pulse ; /bin/chmod 0600 ./var/lib/gdm/.pulse/default.pa ; " ROOTCOMMANDS="${ROOTCOMMANDS} /sbin/makepkg --prepend --linkadd y --chown n ${PKGDEST}/${PKGNAME}.${PKGFORMAT} " if test ${UID} = 0; then eval ${ROOTCOMMANDS} set +o xtrace elif test "$(type -t fakeroot)" = 'file'; then echo -e "\e[1mEntering fakeroot environment.\e[0m" echo ${ROOTCOMMANDS} | fakeroot else echo -e "\e[1mPlease enter your root password.\e[0m (Consider installing fakeroot.)" /bin/su -c "${ROOTCOMMANDS}" fi # Clean up the extra stuff: if [ "$1" = "--cleanup" ]; then echo "Cleaning..." if [ -d ${TMP}/${SRCDIR} ]; then rm -rf ${TMP}/${SRCDIR} && echo "${TMP}/${SRCDIR} cleanup completed" fi if [ -d ${PKG} ]; then rm -rf ${PKG} && echo "${PKG} cleanup completed" fi rmdir ${TMP} && echo "${TMP} cleanup completed" fi exit 0