29. glibc

wget http://www.gnuwakes.org/depot/1.0/main/sources/glibc-2.21.tar.xz

tar -xf glibc-2.21.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/glibc.patch
cd glibc-2.21
patch -p1 < ../glibc.patch 
cd ..

SOURCES_DIR=$PWD/glibc-2.21
INSTALL_DIR=$PWD/glibc-2.21-install
BUILD_DIR=$PWD/glibc-2.21-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure   \
  --prefix=/usr          \
  --disable-profile      \
  --enable-kernel=2.6.32 \
  --enable-obsolete-rpc  \
&& \
  make && make install_root=$INSTALL_DIR install

#
#  post install
#

# nscd
# we don't create /var/run/nscd as /var/run is a symlink to /run
# which is a tmpfs fs fir systemd
cp -v $SOURCES_DIR/nscd/nscd.conf $INSTALL_DIR/etc/nscd.conf
mkdir -pv $INSTALL_DIR/var/db/nscd

install -v -Dm644 $SOURCES_DIR/nscd/nscd.tmpfiles \
  $INSTALL_DIR/usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 $SOURCES_DIR/nscd/nscd.service \
  $INSTALL_DIR/lib/systemd/system/nscd.service

# zoneinfo
tar -xf $SOURCES_DIR/tzdata2015a.tar.gz

ZONEINFO=$INSTALL_DIR/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}

for tz in etcetera southamerica northamerica europe africa antarctica  \
  asia australasia backward pacificnew systemv
do
  zic -L /dev/null   -d $ZONEINFO       -y "sh yearistype.sh" ${tz}
  zic -L /dev/null   -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
  zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done

cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO

# ld
rm $INSTALL_DIR/etc/ld.so.cache
cat > $INSTALL_DIR/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/lib64
/usr/lib64

/usr/local/lib
/opt/lib

EOF

cat >> $INSTALL_DIR/etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf

EOF
mkdir -pv $INSTALL_DIR/etc/ld.so.conf.d

# nsswitch
cat > $INSTALL_DIR/etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

hosts: files dns myhostname
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF

# netgroup
touch $INSTALL_DIR/etc/netgroup