Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

glibc-2.12.1

By: a guest on Oct 8th, 2010  |  syntax: None  |  size: 14.53 KB  |  views: 55  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2.  
  3. # Copyright 2006, 2008, 2009, 2010  Patrick J. Volkerding, Sebeka, MN, USA
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. #    notice, this list of conditions and the following disclaimer.
  11. #
  12. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  15. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22.  
  23. ## build glibc-$VERSION for Slackware
  24.  
  25. VERSION=${VERSION:-2.12.1}
  26. CHECKOUT=${CHECKOUT:-""}
  27. BUILD=${BUILD:-1}
  28. ARCH=${ARCH:-x86_64}
  29. TARGET=${TARGET:-x86_64}
  30.  
  31. CVSVER=${VERSION}${CHECKOUT}
  32.  
  33. # NOTE!!!  glibc needs to be built against the sanitized kernel headers,
  34. # which will be installed under /usr/include by the kernel-headers package.
  35. # Be sure the correct version of the headers package is installed BEFORE
  36. # building glibc!
  37.  
  38. CWD=$(pwd)
  39. # Temporary build location.  This should not be a directory
  40. # path a non-root user could create later...
  41. TMP=${TMP:-/glibc-tmp-$(mcookie)}
  42. mkdir -p $TMP
  43.  
  44. NUMJOBS=${NUMJOBS:--j2}
  45.  
  46. # Sanity check on the version number in the install scripts:
  47. if ! grep -vq libutil-$VERSION}.so $CWD/doinst.sh-glibc ; then
  48.   echo "FATAL:  doinst.sh scripts have wrong version numbers."
  49.   exit 1
  50. fi
  51.  
  52. # This function fixes a doinst.sh file for x86_64.
  53. # With thanks to Fred Emmott.
  54. fix_doinst() {
  55.   if [ "x$LIBDIRSUFFIX" = "x" ]; then
  56.     return;
  57.   fi;
  58.   # Fix "( cd usr/lib ;" occurrences
  59.   sed -i "s#lib ;#lib${LIBDIRSUFFIX} ;#" install/doinst.sh
  60.   # Fix "lib/" occurrences
  61.   sed -i "s#lib/#lib${LIBDIRSUFFIX}/#g" install/doinst.sh
  62.   # Fix "( cd lib" occurrences
  63.   sed -i "s#( cd lib\$#( cd lib${LIBDIRSUFFIX}#" install/doinst.sh
  64.  
  65.   if [ "$ARCH" = "x86_64" ]; then
  66.     sed -i 's#ld-linux.so.2#ld-linux-x86-64.so.2#' install/doinst.sh
  67.   fi
  68. }
  69.  
  70. # This is a patch function to put all glibc patches in the build script
  71. # up near the top.
  72. apply_patches() {
  73.   #Fix build with make 3.82
  74.   cat $CWD/glibc-2.12.1-make-3.82-compatibility.patch | patch -p1 --verbose || exit 1
  75.   # Use old-style locale directories rather than a single (and strangely
  76.   # formatted) /usr/lib/locale/locale-archive file:
  77.   zcat $CWD/glibc.locale.no-archive.diff.gz | patch -p1 --verbose || exit 1
  78.   # The is_IS locale is causing a strange error about the "echn" command
  79.   # not existing.  This patch reverts is_IS to the version shipped in
  80.   # glibc-2.5:
  81.   zcat $CWD/is_IS.diff.gz | patch -p1 --verbose || exit 1
  82.   # Fix NIS netgroups:
  83.   zcat $CWD/glibc.nis-netgroups.diff.gz | patch -p1 --verbose || exit 1
  84.   # Support ru_RU.CP1251 locale:
  85.   zcat $CWD/glibc.ru_RU.CP1251.diff.gz | patch -p1 --verbose || exit 1
  86.   # Fix missing MAX macro in getcwd.c:
  87.   zcat $CWD/glibc.getcwd.max.macro.diff.gz | patch -p1 --verbose || exit 1
  88.   # Fix resolver problem with glibc-2.9:
  89.   zcat $CWD/glibc-2.10-dns-no-gethostbyname4.diff.gz | patch -p0 --verbose || exit 1
  90.   # This reverts a patch that was made to glibc to fix "namespace leakage",
  91.   # which seems to cause some build failures (e.g. with conntrack):
  92.   zcat $CWD/glibc.revert.to.fix.build.breakages.diff.gz | patch -p1 --verbose || exit 1
  93.   # Update the timezone information.
  94.   ( cd timezone
  95.     tar xzf $CWD/tzdata?????.tar.gz
  96.     chown root:root *
  97.     mv yearistype.sh yearistype
  98.     chmod 644 *
  99.     chmod 755 yearistype
  100.     mkdir tzcode
  101.     cd tzcode
  102.     tar xzf $CWD/tzcode?????.tar.gz
  103.     chown -R root:root .
  104.     chmod 644 *
  105.     cp -a *.c *.h ..
  106.   )
  107. }
  108.  
  109. # I'll break this out as an option for fun  :-)
  110. case $ARCH  in
  111.   i386)
  112.     OPTIMIZ="-O3 -march=i386 -mcpu=i686"
  113.     LIBDIRSUFFIX=""
  114.     ;;
  115.   i486)
  116.     OPTIMIZ="-O3 -march=i486 -mtune=i686"
  117.     LIBDIRSUFFIX=""
  118.     ;;
  119.   i586)
  120.     OPTIMIZ="-O3 -march=i586"
  121.     LIBDIRSUFFIX=""
  122.     ;;
  123.   i686)
  124.     OPTIMIZ="-O3 -march=i686"
  125.     LIBDIRSUFFIX=""
  126.     ;;
  127.   athlon)
  128.     OPTIMIZ="-O3 -march=athlon"
  129.     LIBDIRSUFFIX=""
  130.     ;;
  131.   s390)
  132.     OPTIMIZ="-O3"
  133.     LIBDIRSUFFIX=""
  134.     ;;
  135.   x86_64)
  136.     OPTIMIZ="-O3 -fPIC"
  137.     LIBDIRSUFFIX="64"
  138.     ;;
  139.   *)
  140.     OPTIMIZ="-O3"
  141.     LIBDIRSUFFIX=""
  142.     ;;
  143. esac
  144.  
  145. # This is going to be the initial $DESTDIR:
  146. export PKG=$TMP/package-glibc-incoming-tree
  147. PGLIBC=$TMP/package-glibc
  148. PSOLIBS=$TMP/package-glibc-solibs
  149. PZONE=$TMP/package-glibc-zoneinfo
  150. PI18N=$TMP/package-glibc-i18n
  151. PPROFILE=$TMP/package-glibc-profile
  152. PDEBUG=$TMP/package-glibc-debug
  153.  
  154. # Empty these locations first:
  155. for dir in $PKG $PGLIBC $PSOLIBS $PZONE $PI18N $PPROFILE $PDEBUG ; do
  156.   if [ -d $dir ]; then
  157.     rm -rf $dir
  158.   fi
  159.   mkdir -p $dir
  160. done
  161. if [ -d $TMP/glibc-$VERSION ]; then
  162.   rm -rf $TMP/glibc-$VERSION
  163. fi
  164.  
  165. # Create an incoming directory structure for glibc to be built into:
  166. mkdir -p $PKG/lib${LIBDIRSUFFIX}
  167. mkdir -p $PKG/sbin
  168. mkdir -p $PKG/usr/bin
  169. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
  170. mkdir -p $PKG/usr/sbin
  171. mkdir -p $PKG/usr/include
  172. mkdir -p $PKG/usr/doc
  173. mkdir -p $PKG/usr/man
  174. mkdir -p $PKG/usr/share
  175. mkdir -p $PKG/var/db/nscd
  176. mkdir -p $PKG/var/run/nscd
  177.  
  178. # Begin extract/compile:
  179. cd $TMP
  180. rm -rf glibc-$CVSVER
  181. tar xvf $CWD/glibc-$CVSVER.tar.xz \
  182.   || tar xvf $CWD/glibc-$CVSVER.tar.bz2 \
  183.   || tar xvf $CWD/glibc-$CVSVER.tar.gz
  184. cd glibc-$CVSVER
  185.  
  186. chown -R root:root .
  187. find . -perm 666 -exec chmod 644 {} \;
  188. find . -perm 664 -exec chmod 644 {} \;
  189. find . -perm 600 -exec chmod 644 {} \;
  190. find . -perm 444 -exec chmod 644 {} \;
  191. find . -perm 400 -exec chmod 644 {} \;
  192. find . -perm 440 -exec chmod 644 {} \;
  193. find . -perm 777 -exec chmod 755 {} \;
  194. find . -perm 775 -exec chmod 755 {} \;
  195. find . -perm 511 -exec chmod 755 {} \;
  196. find . -perm 711 -exec chmod 755 {} \;
  197. find . -perm 555 -exec chmod 755 {} \;
  198.  
  199. # Clean up leftover CVS directories:
  200. find . -type d -name CVS -exec rm -r {} \; 2> /dev/null
  201.  
  202. # Apply patches; exit if any fail.
  203. apply_patches
  204. if [ ! $? = 0 ]; then
  205.   exit 1
  206. fi
  207.  
  208. # Make build directory:
  209. mkdir build-glibc-$VERSION
  210. cd build-glibc-$VERSION
  211.  
  212. echo "BUILDING DAS NPTL GLIBC"
  213. CFLAGS="-g $OPTIMIZ -D_FORTIFY_SOURCE=0" \
  214. ../configure \
  215.   --prefix=/usr \
  216.   --libdir=/usr/lib${LIBDIRSUFFIX} \
  217.   --enable-kernel=2.6.18 \
  218.   --with-headers=/usr/include \
  219.   --enable-add-ons=libidn,nptl \
  220.   --enable-profile \
  221.   --disable-multilib \
  222.   --infodir=/usr/info \
  223.   --mandir=/usr/man \
  224.   --with-tls \
  225.   --with-__thread \
  226.   --without-cvs \
  227.   --build=$ARCH-slackware-linux
  228.  
  229. make $NUMJOBS || make || exit 1
  230. make install install_root=$PKG || exit 1
  231. make localedata/install-locales install_root=$PKG || exit 1
  232.  
  233. # The prevailing standard seems to be putting unstripped libraries in
  234. # /usr/lib/debug/ and stripping the debugging symbols from all the other
  235. # libraries.
  236. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/debug
  237. cp -a $PKG/lib${LIBDIRSUFFIX}/l*.so* $PKG/usr/lib${LIBDIRSUFFIX}/debug
  238. cp -a $PKG/usr/lib${LIBDIRSUFFIX}/*.a $PKG/usr/lib${LIBDIRSUFFIX}/debug
  239. # Don't need debug+profile:
  240. ( cd $PKG/usr/lib${LIBDIRSUFFIX}/debug ; rm -f *_p.* )
  241. # NOTE:  Is there really a reason for the glibc-debug package?
  242. # If you're debugging glibc, you can also compile it, right?
  243.  
  244. ## COMMENTED OUT:  There's no reason for profile libs to include -g information.
  245. ## Put back unstripped profiling libraries:
  246. #mv $PKG/usr/lib${LIBDIRSUFFIX}/debug/*_p.a $PKG/usr/lib${LIBDIRSUFFIX}
  247. # It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile.
  248.  
  249. # I don't think "strip -g" causes the pthread problems.  It's --strip-unneeded that does.
  250. strip -g $PKG/lib${LIBDIRSUFFIX}/l*.so*
  251. strip -g $PKG/usr/lib${LIBDIRSUFFIX}/l*.so*
  252. strip -g $PKG/usr/lib${LIBDIRSUFFIX}/lib*.a
  253.  
  254. # Back to the sources dir to add some files/docs:
  255. cd $TMP/glibc-$CVSVER
  256.  
  257. # We'll automatically install the config file for the Name Server Cache Daemon.
  258. # Perhaps this should also have some commented-out startup code in rc.inet2...
  259. mkdir -p $PKG/etc
  260. cat nscd/nscd.conf > $PKG/etc/nscd.conf.new
  261.  
  262. # Install some scripts to help select a timezone:
  263. mkdir -p $PKG/var/log/setup
  264. cp -a $CWD/timezone-scripts/setup.timeconfig $PKG/var/log/setup
  265. chown root:root $PKG/var/log/setup/setup.timeconfig
  266. chmod 755 $PKG/var/log/setup/setup.timeconfig
  267. mkdir -p $PKG/usr/sbin
  268. cp -a $CWD/timezone-scripts/timeconfig $PKG/usr/sbin
  269. chown root:root $PKG/usr/sbin/timeconfig
  270. chmod 755 $PKG/usr/sbin/timeconfig
  271.  
  272. ## Install docs:
  273. ( mkdir -p $PKG/usr/doc/glibc-$VERSION
  274.   cp -a \
  275.     BUGS CONFORMANCE COPYING COPYING.LIB FAQ INSTALL LICENSES NAMESPACE \
  276.     NEWS NOTES PROJECTS README README.libm \
  277.     $PKG/usr/doc/glibc-$VERSION
  278. )
  279.  
  280. # Don't forget to add the /usr/share/zoneinfo/localtime -> /etc/localtime symlink! :)
  281. if [ ! -r $PKG/usr/share/zoneinfo/localtime ]; then
  282.   ( cd $PKG/usr/share/zoneinfo ; ln -sf /etc/localtime . )
  283. fi
  284.  
  285. # OK, there are some very old Linux standards that say that any binaries in a /bin or
  286. # /sbin directory (and the directories themselves) should be group bin rather than
  287. # group root, unless a specific group is really needed for some reason.
  288. #
  289. # I can't find any mention of this in more recent standards docs, and always thought
  290. # that it was pretty cosmetic anyway (hey, if there's a reason -- fill me in!), so
  291. # it's possible that this ownership change won't be followed in the near future
  292. # (it's a PITA, and causes many bug reports when the perms change is occasionally
  293. # forgotten).
  294. #
  295. # But, it's hard to get me to break old habits, so we'll continue the tradition here:
  296. #
  297. # No, no we won't.  You know how we love to break traditions.
  298.  
  299. # Strip most binaries:
  300. ( cd $PKG
  301.   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
  302.   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null
  303. )
  304.  
  305. # Fix info dir:
  306. rm $PKG/usr/info/dir
  307. gzip -9 $PKG/usr/info/*
  308.  
  309. # This is junk
  310. rm $PKG/etc/ld.so.cache
  311. ( cd $PKG
  312.   find . -name "*.orig" -exec rm {} \;
  313. )
  314.  
  315. ##################################
  316. # OK, time to make some packages #
  317. ##################################
  318.  
  319. # glibc-zoneinfo.  We will start with an easy one to avoid breaking a sweat.  ;-)
  320. cd $PZONE
  321. # Install some scripts to help select a timezone:
  322. mkdir -p $PZONE/var/log/setup
  323. cp -a $CWD/timezone-scripts/setup.timeconfig $PZONE/var/log/setup
  324. chown root:root $PZONE/var/log/setup/setup.timeconfig
  325. chmod 755 $PZONE/var/log/setup/setup.timeconfig
  326. mkdir -p $PZONE/usr/sbin
  327. cp -a $CWD/timezone-scripts/timeconfig $PZONE/usr/sbin
  328. chown root:root $PZONE/usr/sbin/timeconfig
  329. chmod 755 $PZONE/usr/sbin/timeconfig
  330. mkdir $PZONE/install
  331. cat $CWD/doinst.sh-glibc-zoneinfo > $PZONE/install/doinst.sh
  332. cat $CWD/slack-desc.glibc-zoneinfo > $PZONE/install/slack-desc
  333. mkdir -p $PZONE/usr/share
  334. cd $PZONE/usr/share
  335. cp -a --verbose $PKG/usr/share/zoneinfo .
  336. cd $PZONE
  337. mkdir -p $PZONE/etc
  338. # This is already hard-coded into doinst.sh (like it'll be there anyway ;-):
  339. rm -f etc/localtime
  340. # Wrap it up:
  341. makepkg -l y -c n $TMP/glibc-zoneinfo-$VERSION-noarch-$BUILD.txz
  342.  
  343. # glibc-profile:
  344. cd $PPROFILE
  345. mkdir -p usr/lib${LIBDIRSUFFIX}
  346. # Might as well just grab these with 'mv' to simplify things later:
  347. mv $PKG/usr/lib${LIBDIRSUFFIX}/lib*_p.a usr/lib${LIBDIRSUFFIX}
  348. # Profile libs should be stripped.  Use the debug libs to debug...
  349. ( cd usr/lib${LIBDIRSUFFIX} ; strip -g *.a )
  350. mkdir install
  351. cp -a $CWD/slack-desc.glibc-profile install/slack-desc
  352. makepkg -l y -c n $TMP/glibc-profile-$VERSION-$ARCH-$BUILD.txz
  353.  
  354. # THIS IS NO LONGER PACKAGED (or is it?  might be better to let it be made, and then ship it or not...)
  355. # glibc-debug:
  356. cd $PDEBUG
  357. mkdir -p usr/lib${LIBDIRSUFFIX}
  358. # Might as well just grab these with 'mv' to simplify things later:
  359. mv $PKG/usr/lib${LIBDIRSUFFIX}/debug usr/lib${LIBDIRSUFFIX}
  360. mkdir install
  361. cp -a $CWD/slack-desc.glibc-debug install/slack-desc
  362. makepkg -l y -c n $TMP/glibc-debug-$VERSION-$ARCH-$BUILD.txz
  363. ## INSTEAD, NUKE THESE LIBS
  364. #rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/debug
  365.  
  366. # glibc-i18n:
  367. cd $PI18N
  368. mkdir -p usr/lib${LIBDIRSUFFIX}
  369. rm -rf usr/lib${LIBDIRSUFFIX}/locale
  370. cp -a $PKG/usr/lib${LIBDIRSUFFIX}/locale usr/lib${LIBDIRSUFFIX}
  371. mkdir -p usr/share
  372. cp -a $PKG/usr/share/i18n usr/share
  373. cp -a $PKG/usr/share/locale usr/share
  374. mkdir install
  375. cp -a $CWD/slack-desc.glibc-i18n install/slack-desc
  376. makepkg -l y -c n $TMP/glibc-i18n-$VERSION-$ARCH-$BUILD.txz
  377.  
  378. # glibc-solibs:
  379. cd $PSOLIBS
  380. mkdir -p etc/profile.d
  381. cp -a $CWD/profile.d/* etc/profile.d
  382. chown -R root:root etc
  383. chmod 755 etc/profile.d/*
  384. mkdir -p lib${LIBDIRSUFFIX}
  385. cp -a $PKG/lib${LIBDIRSUFFIX}/* lib${LIBDIRSUFFIX}
  386. ( cd lib${LIBDIRSUFFIX}
  387.   mkdir incoming
  388.   mv *so* incoming
  389.   mv incoming/libSegFault.so .
  390. )
  391. mkdir -p usr
  392. cp -a $PKG/usr/bin usr
  393. mv usr/bin/ldd .
  394. rm usr/bin/*
  395. mv ldd usr/bin
  396. mkdir -p usr/lib${LIBDIRSUFFIX}
  397. # The gconv directory has a lot of stuff, but including it here will save some problems.
  398. # Seems standard elsewhere.
  399. cp -a $PKG/usr/lib${LIBDIRSUFFIX}/gconv usr/lib${LIBDIRSUFFIX}
  400. # Another manpage abandoned by GNU...
  401. #mkdir -p usr/man/man1
  402. #cp -a $PKG/usr/man/man1/ldd.1.gz usr/man/man1
  403. mkdir -p usr/libexec
  404. cp -a $PKG/usr/libexec/pt_chown usr/libexec
  405. # Same usr.bin deal:
  406. cp -a $PKG/sbin .
  407. mv sbin/ldconfig .
  408. rm sbin/*
  409. mv ldconfig sbin
  410. mkdir install
  411. cp -a $CWD/slack-desc.glibc-solibs install/slack-desc
  412. cp -a $CWD/doinst.sh-glibc-solibs install/doinst.sh
  413. fix_doinst
  414. # Ditch links:
  415. find . -type l -exec rm {} \;
  416. # Build the package:
  417. makepkg -l y -c n $TMP/glibc-solibs-$VERSION-$ARCH-$BUILD.txz
  418.  
  419. # And finally, the complete "all-in-one" glibc package is created
  420. # from whatever was leftover:
  421. cd $PGLIBC
  422. mv $PKG/* .
  423. mkdir -p etc/profile.d
  424. cp -a $CWD/profile.d/* etc/profile.d
  425. chown -R root:root etc
  426. chmod 755 etc/profile.d/*
  427. # Ditch links (these are in doinst.sh-glibc):
  428. find . -type l -exec rm {} \;
  429. mkdir install
  430. cp -a $CWD/slack-desc.glibc install/slack-desc
  431. cp -a $CWD/doinst.sh-glibc install/doinst.sh
  432. fix_doinst
  433. ( cd lib${LIBDIRSUFFIX}
  434.   mkdir incoming
  435.   mv *so* incoming
  436.   mv incoming/libSegFault.so .
  437. )
  438. # Build the package:
  439. /sbin/makepkg -l y -c n $TMP/glibc-$VERSION-$ARCH-$BUILD.txz
  440.  
  441. # Done!
  442. echo
  443. echo "glibc packages built in $TMP!"