source: branches/stable/mindi/install.sh @ 933

Last change on this file since 933 was 933, checked in by bruno, 13 years ago

Fix a rpm build issue on x86_64

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1#!/bin/bash
2#
3# $Id: install.sh 933 2006-11-15 17:30:04Z bruno $
4#
5
6if [ ! -f "mindi" ] ; then
7    echo "Please 'cd' to the directory you have just untarred." >> /dev/stderr
8    exit 1
9fi
10
11if [ "_$PREFIX" != "_" ]; then
12    local=$PREFIX
13    if [ -f /usr/local/sbin/mindi ]; then
14        echo "WARNING: /usr/local/sbin/mindi exists. You should probably remove it !"
15    fi
16    conf=$CONFDIR/mindi
17    echo $PATH | grep /usr/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add /usr/sbin to your PATH."
18else
19    local=/usr/local
20    if [ -f /usr/sbin/mindi ]; then
21        echo "WARNING: /usr/sbin/mindi exists. You should probably remove the mindi package !"
22    fi
23    conf=$local/etc/mindi
24    echo $PATH | grep $local/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add $local/sbin to your PATH."
25fi
26
27if uname -a | grep Knoppix > /dev/null || [ -e "/ramdisk/usr" ] ; then
28    local=/ramdisk/usr
29    export PATH=/ramdisk/usr/sbin:/ramdisk/usr/bin:/$PATH
30fi
31
32MINDIVER=`cat VERSION`
33MINDIREV=`cat REVISION`
34echo "mindi ${MINDIVER}-r${MINDIREV} will be installed under $local"
35
36if [ _"$MANDIR" == _"" ]; then
37    MANDIR=$local/share/man/man8
38else
39    MANDIR=$MANDIR/man8
40fi
41if [ _"$DOCDIR" == _"" ]; then
42    DOCDIR=$local/share/doc/mindi-$MINDIVER
43else
44    DOCDIR=$DOCDIR/mindi-$MINDIVER
45fi
46if [ _"$LIBDIR" == _"" ]; then
47    locallib=$LIBDIR
48else
49    ARCH=`/bin/arch`
50    echo $ARCH | grep -E '^i[0-9]86$' &> /dev/null && ARCH=i386 && locallib=$local/lib
51    echo $ARCH | grep -E '^x86_64$' &> /dev/null && locallib=$local/lib64
52    echo $ARCH | grep -E '^ia64$' &> /dev/null && locallib=$local/lib
53    export ARCH
54fi
55
56echo "Creating target directories ..."
57install -m 755 -d $conf $locallib/mindi $MANDIR $local/sbin $DOCDIR
58
59echo "Copying files ..."
60install -m 644 isolinux.cfg msg-txt sys-disk.raw.gz isolinux-H.cfg syslinux.cfg syslinux-H.cfg dev.tgz $locallib/mindi
61install -m 644 deplist.txt $conf
62
63cp -af rootfs aux-tools $locallib/mindi
64chmod 755 $locallib/mindi/rootfs/sbin/*
65chmod 755 $locallib/mindi/aux-tools/sbin/*
66
67# Substirute variables for init
68perl -pi -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~ ; s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" $locallib/mindi/rootfs/sbin/init
69
70# Substirute variables for mindi
71if [ "$RPMBUILDMINDI" = "true" ]; then
72    sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=/usr~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=/etc/mindi~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" mindi > $local/sbin/mindi
73else
74    sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=$local~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=$conf~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" mindi > $local/sbin/mindi
75fi
76chmod 755 $local/sbin/mindi
77install -m 755 parted2fdisk.pl $local/sbin
78install -m 755 analyze-my-lvm $locallib/mindi
79
80install -m 644 mindi.8 $MANDIR
81install -m 644 ChangeLog COPYING README README.busybox README.ia64 README.pxe TODO INSTALL svn.log $DOCDIR
82
83if [ ! -f $locallib/mindi/rootfs/bin/busybox ]; then
84        echo "WARNING: no busybox found, mindi will not work on this arch ($ARCH)"
85fi
86
87# Managing parted2fdisk
88if [ "$ARCH" = "ia64" ] ; then
89    (cd $local/sbin && ln -sf parted2fdisk.pl parted2fdisk)
90    make -f Makefile.parted2fdisk DEST=$locallib/mindi install
91    if [ -f $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH ]; then
92        echo "Installing parted2fdisk ..."
93        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $locallib/mindi/rootfs/sbin/parted2fdisk
94        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $local/sbin/parted2fdisk
95    else
96        echo "WARNING: no parted2fdisk found, mindi will not work on this arch ($ARCH)"
97    fi
98else
99    # FHS requires fdisk under /sbin
100    (cd $local/sbin && ln -sf /sbin/fdisk parted2fdisk)
101    echo "Symlinking fdisk to parted2fdisk"
102    ( cd $locallib/mindi/rootfs/sbin && ln -sf fdisk parted2fdisk)
103fi
104# Remove left parted2fdisk
105rm -f $locallib/mindi/rootfs/sbin/parted2fdisk-*
106
107if [ "$RPMBUILDMINDI" != "true" ]; then
108    chown -R root:root $locallib/mindi $conf $DOCDIR
109    chown root:root $local/sbin/mindi $MANDIR/mindi.8 $locallib/mindi/analyze-my-lvm $local/sbin/parted2fdisk.pl
110    if [ "$ARCH" = "ia64" ] ; then
111        chown root:root $local/sbin/parted2fdisk
112    fi
113fi
114
115# Special case for SuSE family where doc is put elsewhere in the RPM
116if [ -e /etc/SuSE-release ]; then
117    rm -rf $DOCDIR
118fi
119
120# Special case for Debian family where doc is put elsewhere in the DEB
121if [ -e /etc/debian_version ]; then
122    rm -rf $DOCDIR
123fi
124
125exit 0
Note: See TracBrowser for help on using the repository browser.