home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / linux / 8491 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  10.4 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!serval!phys1.physics.wsu.edu!hlu
  2. From: hlu@phys1.physics.wsu.edu (Hongjiu Lu)
  3. Newsgroups: comp.os.linux
  4. Subject: another bug in install.2.x
  5. Message-ID: <1992Aug17.195139.23064@serval.net.wsu.edu>
  6. Date: 17 Aug 92 19:51:39 GMT
  7. Sender: news@serval.net.wsu.edu (USENET News System)
  8. Organization: Washington State University
  9. Lines: 492
  10.  
  11. shared/libm.a is deleted by mistake. This is the new one.
  12.  
  13. -- 
  14. H.J.
  15. Gcc/libc maintainer for Linux.
  16. ----
  17. #!/bin/sh
  18. # installation of gcc 2.xxx
  19.  
  20. # do something to kernel souce
  21. kernelstuff ()
  22. {
  23.   workdir=$1
  24.   srcdir=$2
  25.  
  26. # we may have something in there.
  27.  
  28.   for d in asm linux; do
  29.     if [ -d /usr/include/${d} ]; then
  30.       for f in /usr/include/${d}/*.h; do
  31.     if [ -f $f ]; then 
  32.       mv $f ${srcdir}/include/$d
  33.     fi
  34.       done
  35.       /bin/rm -rf /usr/include/${d}
  36.     fi
  37.   done
  38. }
  39.  
  40. # install jump table
  41. jumptable ()
  42. {
  43.   DIR=$1
  44.   VER=$2
  45.   REL=$3
  46.   M=$4
  47.  
  48.   mv $DIR/libc.so.${REL} /lib
  49.   mv $DIR/lib${M}.so.${REL} /lib/libm.so.${REL}
  50.  
  51.   ln -s -f /lib/libc.so.${REL} /lib/libc.so.${VER}
  52.   ln -s -f /lib/libm.so.${REL} /lib/libm.so.${VER}
  53. }
  54.  
  55. checkreturn ()
  56. {
  57.   if [ $? != 0 ]
  58.   then
  59.     echo Failed to $1.
  60.     exit 1
  61.   fi
  62. }
  63.  
  64. fixfiles ()
  65. {
  66.   VERBOSE=$1
  67.   VER=$2
  68.   BINS=$3
  69.  
  70.   if [ $VERBOSE = yes ]; then set -x; fi
  71.  
  72.   cd /usr/bin
  73.   chown bin:bin $BINS
  74.   chmod 755 $BINS
  75.  
  76.   chown -R bin:bin /usr/include /usr/g++-include /lib /usr/lib/gcc-lib
  77.   chmod -R 755 /lib /usr/lib/gcc-lib
  78.  
  79.   # this is for the header files
  80.   chmod 755 /usr/include /usr/g++-include
  81.   # Yes, 'find' would be cleaner and faster, but it is not on rootdisk
  82.   cd /usr/include
  83.   chmod 775 *
  84.   chmod 664 *.h
  85.   chmod 664 */*
  86.   cd /usr/g++-include
  87.   chmod 775 *
  88.   chmod 664 *.h
  89.   chmod 664 */*
  90.  
  91.   chmod 664 /usr/lib/gcc-lib/i386-linux/${VER}/*.?
  92.   chmod 664 /usr/lib/gcc-lib/i386-linux/${VER}/shared/*.?
  93. }
  94.  
  95. # check if it is a directory.
  96. checkdir ()
  97. {
  98.   if [ x${1}x = xx ]
  99.   then
  100.     echo No directory to check.
  101.     return 1
  102.   fi
  103.  
  104.   for f in $*
  105.   do
  106.     if [ ! -d $f ]; then
  107.       echo There is no such a directory, $f.
  108.       echo Please make sure there is one and it has right stuffs in it.
  109.       exit 1
  110.     fi
  111.   done
  112.   return 0
  113. }
  114.  
  115. checkbinfile ()
  116. {
  117.   for f in $*
  118.   do
  119.     if [ ! -f /bin/$f -a ! -f /usr/bin/$f ]; then
  120.       echo There is no such a file, $f.
  121.       return 1
  122.     fi
  123.   done
  124.   return 0
  125. }
  126.  
  127. checkfile ()
  128. {
  129.   if [ x${1}x = xx ]
  130.   then
  131.     echo No file to check.
  132.     return 1
  133.   fi
  134.  
  135.   for f in $*
  136.   do
  137.     if [ ! -f $f ]; then
  138.       echo There is no such a file, $f.
  139.       echo Please make sure there is one and it has right stuffs in it.
  140.       exit 1
  141.     fi
  142.   done
  143.   return 0
  144. }
  145.  
  146. checkroot ()
  147. {
  148.   uid=`id | sed -e 's/uid=\([0-9]*\)/\1/' -e 's/[^a-z0-9=].*//'`
  149.   if [ $? != 0 ]
  150.   then
  151.     echo Fail to get \"root\" id. You may need a working \"id\" and
  152.     echo \"sed\".
  153.     exit 1
  154.   fi
  155.  
  156.   if [ x${uid}x != x0x ]
  157.   then
  158.     echo You have to be root to run this script.
  159.     exit 1
  160.   fi
  161. }
  162.  
  163. usage ()
  164. {
  165.   echo Usage: sh $1 [-v] version {kernel src dir}
  166.   echo Note: \"sh\" must be zsh or bash.
  167.   exit 1
  168. }
  169.  
  170. checkroot
  171.  
  172. VERBOSE=no
  173.  
  174. if [ $# != 2 -a $# != 3 ]
  175. then
  176.   usage $0
  177. fi
  178.  
  179. case $1 in
  180. -v)
  181.   shift
  182.   set -x
  183.   VERBOSE=yes
  184.   ;;
  185. esac
  186.  
  187. if [ $# != 2 ]
  188. then
  189.   usage $0
  190. fi
  191.  
  192. VERSION=$1
  193. echo Installing gcc ${VERSION} ......
  194.  
  195. # kernel src dir
  196. KERNELSRCDIR=$2
  197.  
  198. #ln is not on rootdisk, let's use cp
  199. #LN="cp -s"
  200. #HDLN="cp -l"
  201. LN="ln -s"
  202. HDLN="ln"
  203. MV="mv -f"
  204. RM=/bin/rm
  205. PREFIX=/usr
  206. #LN="echo ln"
  207. #MV="echo mv"
  208. #PREFIX=/local
  209. LIBDIR=${PREFIX}/lib/gcc-lib/i386-linux/${VERSION}
  210. SHAREDLIBDIR=${LIBDIR}/shared
  211. JUMPLIBDIR=${LIBDIR}/jump
  212. SHIMAGEDIR=/lib
  213.  
  214. # change it by hand
  215. JUMP_VERSION=2
  216. JUMP_RELEASE=${JUMP_VERSION}.2
  217.  
  218. #create directories first
  219.  
  220. if [ -f $SHIMAGEDIR ]
  221. then
  222.   echo $SHIMAGEDIR should be directory. Remove it first!
  223.   exit 1
  224. fi
  225.  
  226. if [ ! -d $SHIMAGEDIR ]
  227. then
  228.   mkdir $SHIMAGEDIR
  229.  if [ $? != 0 ]
  230.  then
  231.    echo Unable to create directory: $SHIMAGEDIR. You may have to create
  232.    echo some paths in $SHIMAGEDIR first by hand.
  233.    exit 1
  234.   fi
  235. fi
  236.  
  237. echo gcc ${VERSION} will only work with a 387 or the kernel above 0.95.
  238. # ask if there is a 387.
  239. echo "Do you have a 387? [y/n] "
  240. read MATH
  241. if [ x${MATH}x = "xyx" ]
  242. then
  243.   MATH=hard
  244. else
  245.   MATH=soft
  246. fi
  247.  
  248. echo Check if we get the files.
  249. WORKDIR=`echo ${VERSION}*`
  250. if [ "${WORKDIR}" = "${VERSION}""*" ]
  251. then
  252.   echo No files to install. You need at least
  253.   echo 1. ${VERSION}misc.tar.Z
  254.   echo 2. ${VERSION}db.tar.Z
  255.   echo "3. ${VERSION}lib.tar.Z"
  256.   if [ ${VERSION} = 2.2.2d ]; then
  257.     echo "4. binutils.tar.Z"
  258.   else
  259.     echo "4. binutils.tar.Z (optional)"
  260.   fi
  261.   echo "5. xxxinc.tar.Z (header files also used by kernel source)"
  262.   exit 1
  263. fi
  264.  
  265. KERNELINC=`echo *inc.ta*`
  266. if [ "${KERNELINC}" = "*"inc.ta"*" ]
  267. then
  268.   echo You need xxxinc.tar.Z for the whole set of the header files
  269.   echo to use gcc ${VERSION}.
  270.   exit 1
  271. fi
  272.  
  273. echo Check ${VERSION}db.tar.Z and ${VERSION}misc.tar.Z
  274. checkfile ${VERSION}db.tar.Z ${VERSION}misc.tar.Z
  275.  
  276. # check those
  277. BINS="as86 ld86 ar as gprof ld nm objdump ranlib size strip"
  278. echo Check binaries.
  279. checkbinfile "${BINS}"
  280. if [ $? != 0 -o ${VERSION} = 2.2.2d ]
  281. then
  282.   checkfile binutils.tar.Z
  283. fi
  284.  
  285. LIBFILE=
  286.  
  287. # optional in gcc 2.2.2d. false.
  288. if [ ${VERSION} != xxxxxxx ]
  289. then
  290.   checkfile ${VERSION}lib.tar.Z
  291.   LIBFILE=${VERSION}lib.tar.Z
  292. else
  293.   # maybe it has gcc 2.2.2 file.
  294.   if [ -f 2.2.2lib.tar.Z ]; then
  295.     BBFILE=2.2.2lib.tar.Z
  296.   else
  297.     OLDLIBDIR=/usr/lib/gcc-lib/i386-linux/2.2.2
  298.     # it neens gcc 2.2.2d file.
  299.     if [ ! -d ${OLDLIBIR} ]; then
  300.       checkfile ${VERSION}lib.tar.Z
  301.       LIBFILE=${VERSION}lib.tar.Z
  302.     else
  303.       # can I use gcc 2.2.2
  304.       if [ ! -f ${OLDLIBDIR}/cc1 -o ! -f ${OLDLIBDIR}/cc1plus ]
  305.       then
  306.     checkfile ${VERSION}lib.tar.Z
  307.     LIBFILE=${VERSION}lib.tar.Z
  308.       fi
  309.     fi
  310.   fi
  311. fi
  312.  
  313. # double check the kernel sources
  314. checkdir $KERNELSRCDIR
  315. checkdir $KERNELSRCDIR/include/linux $KERNELSRCDIR/include/asm
  316.  
  317. WORKDIR=`pwd`
  318.  
  319. cd /usr
  320.  
  321. # optional
  322. if [ -f ${WORKDIR}/binutils.tar.Z ]
  323. then
  324.   echo installing binutils.tar.Z
  325. #  tar xvvofz ${WORKDIR}/binutils.tar.Z
  326.   zcat ${WORKDIR}/binutils.tar.Z | tar xvvof -
  327. fi
  328.  
  329. # optional
  330. if [ x${LIBFILE}x != xx ]
  331. then
  332.   echo installing ${LIBFILE}
  333. # tar xvvofz ${WORKDIR}/${LIBFILE}
  334.   zcat ${WORKDIR}/${LIBFILE} | tar xvvof -
  335. fi
  336.  
  337. echo installing ${VERSION}db.tar.Z.
  338. #tar xvvofz ${WORKDIR}/${VERSION}db.tar.Z
  339. zcat ${WORKDIR}/${VERSION}db.tar.Z | tar xvvof -
  340.  
  341. echo installing ${VERSION}misc.tar.Z.
  342. #tar xvvofz ${WORKDIR}/${VERSION}misc.tar.Z
  343. zcat ${WORKDIR}/${VERSION}misc.tar.Z | tar xvvof -
  344.  
  345. $RM -rf /usr/include/const.h /usr/include/asm /usr/include/linux
  346.  
  347. echo installing ${KERNELINC}
  348. #tar xvvofz ${WORKDIR}/${KERNELINC}
  349. zcat ${WORKDIR}/${KERNELINC} | tar xvvof -
  350.  
  351. $RM -rf /usr/include/sys/asy.h
  352.  
  353. if [ ${VERSION} = xxxxx ]
  354. then
  355.   if [ ! -f ${LIBDIR}/cc1 -o ! -f ${LIBDIR}/cc1plus ]
  356.   then
  357.     if [ x${OLDLIBDIR}x = xx ]
  358.     then
  359.       echo While installing gcc 2.2.2d, you don't have cc1/cc1plus
  360.       echo and you don't have gcc 2.2.2. This installation script is
  361.       echo wrong. Please use
  362.       echo "    sh $0 -v verson [kernel src dir]"
  363.       echo "    Note: \"sh\" must be zsh or bash."
  364.       echo to see what is wrong and report it to hlu@eecs.wsu.edu.
  365.       echo Thanks.
  366.       exit 1
  367.     else
  368.       $HDLN ${OLDLIBDIR}/cc1 ${OLDLIBDIR}/cc1plus ${LIBDIR}
  369.     fi
  370.   fi
  371. fi
  372.  
  373. #checkfile $LIBDIR/lib$MATH.a
  374. checkfile $LIBDIR/lib$MATH.a \
  375.     $LIBDIR/cpp $JUMPLIBDIR/libc.so.${JUMP_RELEASE} \
  376.     $JUMPLIBDIR/lib${MATH}.so.${JUMP_RELEASE}
  377.  
  378. # not used
  379. #    $SHAREDLIBDIR/libc.${VERSION} 
  380. #    $SHAREDLIBDIR/lib${MATH}.${VERSION}
  381.  
  382. if [ -f $SHIMAGEDIR/libc.${VERSION} -o -f $SHIMAGEDIR/libm.${VERSION} ]
  383. then
  384.   echo There is a libc.${VERSION} or libm.${VERSION} in $SHIMAGEDIR.
  385.   echo Do you want to deleted them? [y/n]
  386.   read answer
  387.   if [ x${answer}x = "xyx" ]
  388.   then
  389.     $RM -f $SHIMAGEDIR/libc.${VERSION} $SHIMAGEDIR/libm.${VERSION}
  390.   else
  391.     echo Give up.
  392.     exit 1
  393.   fi
  394. fi
  395.  
  396. if [ -f $SHIMAGEDIR/libc.so.${JUMP_RELEASE} -o -f $SHIMAGEDIR/libm.so.${JUMP_RELEASE} ]
  397. then
  398.   echo There is a libc.so.${JUMP_RELEASE} or libm.so.${JUMP_RELEASE} in $SHIMAGEDIR.
  399.   echo Do you want to deleted them? [y/n]
  400.   read answer
  401.   if [ x${answer}x = "xyx" ]; then
  402.     $RM -f $SHIMAGEDIR/libc.so.${JUMP_RELEASE} $SHIMAGEDIR/libm.so.${JUMP_RELEASE}
  403.   else
  404.     echo Give up.
  405.     exit 1
  406.   fi
  407. fi
  408.  
  409. #echo moving the shared image.
  410. #$MV $SHAREDLIBDIR/libc.${VERSION} $SHIMAGEDIR
  411. #$MV $SHAREDLIBDIR/lib${MATH}.${VERSION} $SHIMAGEDIR/libm.${VERSION}
  412.  
  413. $RM -f $LIBDIR/libm.a
  414. $HDLN $LIBDIR/lib$MATH.a $LIBDIR/libm.a
  415. checkreturn "$HDLN $LIBDIR/lib$MATH.a $LIBDIR/libm.a"
  416.  
  417. #$HDLN $SHAREDLIBDIR/lib$MATH.a $SHAREDLIBDIR/libm.a
  418. #checkreturn "$HDLN $SHAREDLIBDIR/lib$MATH.a $SHAREDLIBDIR/libm.a"
  419.  
  420. echo install jump table.
  421. jumptable $JUMPLIBDIR $JUMP_VERSION $JUMP_RELEASE $MATH
  422.  
  423. $RM -rf /usr/lib/cpp /lib/cpp
  424.  
  425. $LN $LIBDIR/cpp /usr/lib/cpp
  426. checkreturn "$LN $LIBDIR/cpp /usr/lib/cpp"
  427. $LN $LIBDIR/cpp /lib/cpp
  428. checkreturn "$LN $LIBDIR/cpp /lib/cpp"
  429.  
  430. if [ -f /usr/include/stddef.h -o -f /usr/include/stdarg.h ]
  431. then
  432.   echo The version-dependent stddef.h and stdarg.h should not be in
  433.   echo /usr/include. Please take a look at
  434.   echo "    /usr/lib/gcc-lib/i386-linux/${VERSION}/include"
  435.   exit 1
  436. fi
  437.  
  438. if [ ! -f /usr/include/time.h ]
  439. then
  440.   echo You have to install xxxxinc.tar.Z first!
  441.   exit 1
  442. fi
  443.  
  444. echo "Do you have kernel source on line? [y/n] "
  445. read MATH
  446. if [ $MATH = "n" ]
  447. then
  448.    echo Oops. gcc ${VERSION} needs at least the header files from
  449.    echo the kernel source, i.e. linux/include/linux.
  450.    exit 1
  451. fi
  452.  
  453. echo Ignore the error message.
  454.  
  455. $RM -rf ${KERNELSRCDIR}/include/*.h  ${KERNELSRCDIR}/include/sys
  456. if [ -f ${KERNELSRCDIR}/include/a.out.h ]
  457. then
  458.   echo 'Fail to clean ${KERNELSRCDIR}/include/*.h and'
  459.   echo '${KERNELSRCDIR}/include/sys.'
  460.   exit 1
  461. fi
  462.  
  463. checkdir ${KERNELSRCDIR}/include/asm ${KERNELSRCDIR}/include/linux
  464.  
  465. kernelstuff $WORKDIR $KERNELSRCDIR
  466.  
  467. $LN  ${KERNELSRCDIR}/include/asm /usr/include
  468. if [ $? != 0 ]
  469. then
  470.    echo Fail to make a link from ${KERNELSRCDIR}/include/asm to
  471.    echo /usr/include/asm.
  472.    exit 1
  473. fi
  474.  
  475. $LN ${KERNELSRCDIR}/include/linux /usr/include
  476. if [ $? != 0 ]
  477. then
  478.    echo Fail to make a link from ${KERNELSRCDIR}/include/linux to
  479.    echo /usr/include/linux.
  480.    exit 1
  481. fi
  482.  
  483. echo No more error messages.
  484.  
  485. echo Fixing the files.
  486. fixfiles ${VERBOSE} ${VERSION} "${BINS}"
  487.  
  488. # for future use
  489. # gcc -V 2.xxx will read this file.
  490. cd $LIBDIR
  491. chmod 755 /usr/bin/gcc
  492. /usr/bin/gcc -dumpspecs > specs
  493.  
  494. if [ $? != 0 ]
  495. then
  496.   echo Error during the installation of gcc ${VERSION}
  497.   exit 1
  498. fi
  499.  
  500. echo Done! gcc ${VERSION} has been installed.
  501. echo Please get rid of all the \"-nostdinc -I\" from Makefiles in
  502. echo kernel source and then do a fresh "make dep".
  503.