source: trunk/mindi/install.sh @ 1079

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

merge -r1045:1078 £SVN_M/branches/stable

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1#!/bin/bash
2#
3# $Id: install.sh 1079 2007-01-28 16:58:18Z 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=${HEAD}$PREFIX
13    sublocal=$PREFIX
14    if [ -f /usr/local/sbin/mindi ]; then
15        echo "WARNING: /usr/local/sbin/mindi exists. You should probably remove your manual installation !"
16    fi
17    if [ "_$CONFDIR" != "_" ]; then
18        conf=${HEAD}$CONFDIR/mindi
19        subconf=$CONFDIR/mindi
20    else
21        echo "CONFDIR should be defined if PREFIX is defined"
22        exit -1
23    fi
24    echo $PATH | grep /usr/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add /usr/sbin to your PATH."
25else
26    local=/usr/local
27    sublocal=$local
28    if [ -f /usr/sbin/mindi ]; then
29        echo "WARNING: /usr/sbin/mindi exists. You should probably remove the mindi package !"
30    fi
31    conf=$local/etc/mindi
32    subconf=$conf
33    echo $PATH | grep $local/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add $local/sbin to your PATH."
34fi
35
36if uname -a | grep Knoppix > /dev/null || [ -e "/ramdisk/usr" ] ; then
37    local=/ramdisk/usr
38    sublocal=$local
39    conf=/ramdisk/etc
40    subconf=$conf
41    export PATH=/ramdisk/usr/sbin:/ramdisk/usr/bin:/$PATH
42fi
43
44MINDIVER=`cat VERSION`
45MINDIREV=`cat REVISION`
46echo "mindi ${MINDIVER}-r${MINDIREV} will be installed under $local"
47
48if [ _"$MANDIR" == _"" ]; then
49    MANDIR=$local/share/man/man8
50else
51    MANDIR=${HEAD}$MANDIR/man8
52fi
53if [ _"$DOCDIR" == _"" ]; then
54    DOCDIR=$local/share/doc/mindi-$MINDIVER
55else
56    DOCDIR=${HEAD}$DOCDIR/mindi-$MINDIVER
57fi
58if [ _"$LIBDIR" == _"" ]; then
59    ARCH=`/bin/arch`
60    echo $ARCH | grep -E '^i[0-9]86$' &> /dev/null && ARCH=i386 && locallib=$local/lib
61    echo $ARCH | grep -E '^x86_64$' &> /dev/null && locallib=$local/lib64
62    echo $ARCH | grep -E '^ia64$' &> /dev/null && locallib=$local/lib
63    sublocallib="$locallib/mindi"
64else
65    locallib=${HEAD}$LIBDIR
66    sublocallib="$LIBDIR/mindi"
67fi
68
69echo "Creating target directories ..."
70install -m 755 -d $conf $conf/deplist.d $locallib/mindi $MANDIR $local/sbin $DOCDIR
71
72echo "Copying files ..."
73install -m 644 isolinux.cfg msg-txt sys-disk.raw.gz isolinux-H.cfg syslinux.cfg syslinux-H.cfg dev.tgz $locallib/mindi
74install -m 644 distributions/conf/deplist.d/* $conf/deplist.d
75install -m 444 distributions/conf/mindi.conf.dist $conf
76#
77# Compute mindi.conf.dist (cecked by mindi) to avoid changes here
78# Modify the checksum file so that path is correct at execution time
79#
80md5sum $conf/mindi.conf.dist > $conf/mindi.conf.dist.md5
81perl -pi -e "s~$conf~$subconf~" $conf/mindi.conf.dist.md5
82#
83# Example of mindi.conf
84#
85cat > $conf/mindi.conf << EOF
86#
87# Configuration file for mindi
88#
89# By default values are taken from $conf/mindi.conf.dist
90# You can override them here
91#
92# e.g.
93#
94#mindi_tmp_dir="/var/tmp"
95#
96EOF
97chmod 644 $conf/mindi.conf
98install -m 644 distributions/conf/deplist.d/* $conf/deplist.d
99install -m 444 distributions/conf/mindi.conf.dist $conf
100cat > $conf/mindi.conf << EOF
101#
102# Configuration file for mindi
103#
104# By default values are taken from $conf/mindi.conf.dist
105# You can override them here
106#
107# e.g.
108#
109#mindi_tmp_dir="/var/tmp"
110#
111EOF
112chmod 644 $conf/mindi.conf
113
114#
115# Example of deplist.txt
116#
117cat > $conf/deplist.txt << EOF
118# mindi additional dependency list
119#
120# NB:
121# You have to give an absolute path
122# If you want to add something, just add it on its own line. K.I.S.S.
123
124EOF
125chmod 644 $conf/deplist.txt
126
127cp -af rootfs aux-tools $locallib/mindi
128if [ -e FindDistroFailsafe ]; then
129    cp -af FindDistroFailsafe $locallib/mindi
130fi
131chmod 755 $locallib/mindi/rootfs/sbin/*
132chmod 755 $locallib/mindi/aux-tools/sbin/*
133
134# Substirute variables for init
135perl -pi -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~ ; s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" $locallib/mindi/rootfs/sbin/init
136
137# Substitute variables for mindi
138sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=$sublocal~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=$subconf~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" -e "s~^MINDI_LIB=LLL~MINDI_LIB=$sublocallib~" mindi > $local/sbin/mindi
139chmod 755 $local/sbin/mindi
140install -m 755 parted2fdisk.pl $local/sbin
141install -m 755 analyze-my-lvm $locallib/mindi
142
143install -m 644 mindi.8 $MANDIR
144install -m 644 ChangeLog COPYING README README.busybox README.ia64 README.pxe TODO INSTALL svn.log $DOCDIR
145
146if [ ! -f $locallib/mindi/rootfs/bin/busybox ]; then
147        echo "WARNING: no busybox found, mindi will not work on this arch ($ARCH)"
148fi
149
150# Managing parted2fdisk
151if [ "$ARCH" = "ia64" ] ; then
152    (cd $local/sbin && ln -sf parted2fdisk.pl parted2fdisk)
153    make -f Makefile.parted2fdisk DEST=$locallib/mindi install
154    if [ -f $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH ]; then
155        echo "Installing parted2fdisk ..."
156        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $locallib/mindi/rootfs/sbin/parted2fdisk
157        install -s -m 755 $locallib/mindi/rootfs/sbin/parted2fdisk-$ARCH $local/sbin/parted2fdisk
158    else
159        echo "WARNING: no parted2fdisk found, mindi will not work on this arch ($ARCH)"
160    fi
161else
162    # FHS requires fdisk under /sbin
163    (cd $local/sbin && ln -sf /sbin/fdisk parted2fdisk)
164    echo "Symlinking fdisk to parted2fdisk"
165    ( cd $locallib/mindi/rootfs/sbin && ln -sf fdisk parted2fdisk)
166fi
167# Remove left parted2fdisk
168rm -f $locallib/mindi/rootfs/sbin/parted2fdisk-*
169
170if [ "$RPMBUILDMINDI" != "true" ]; then
171    chown -R root:root $locallib/mindi $conf $DOCDIR
172    chown root:root $local/sbin/mindi $MANDIR/mindi.8 $locallib/mindi/analyze-my-lvm $local/sbin/parted2fdisk.pl
173    if [ "$ARCH" = "ia64" ] ; then
174        chown root:root $local/sbin/parted2fdisk
175    fi
176fi
177
178# Special case for SuSE family where doc is put elsewhere in the RPM
179if [ -e /etc/SuSE-release ]; then
180    rm -rf $DOCDIR
181fi
182
183# Special case for Debian family where doc is put elsewhere in the DEB
184if [ -e /etc/debian_version ]; then
185    rm -rf $DOCDIR
186fi
187
188exit 0
Note: See TracBrowser for help on using the repository browser.