summaryrefslogtreecommitdiffstats
path: root/setup_env.sh
blob: 85a5ad898e62935af88ed385c261f36a41cc7f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
#  Script to setup the LinHES development enviroment
# ./setup_env.sh ( i586|i686|x86_64 )  devID 
# This script assumes that /tmp is usable.
MIRROR_DIR=../pkg_repo


function arg_check {
case $1 in
    i586) ARCH=$1 ;;
    i686) ARCH=$1 ;;
    x86_64) ARCH=$1 ;;
    *)
        echo "invalid arch specified"
        echo "valid options include i586, i686 and x86_64"
        echo "EX:  ./setup_env.sh i686 "
        exit 1
        ;;
    esac

if [ ! x$2 = x ]
then
	#check if developer template is present
	if [ -d templates/developers/$2 ]
	then
		echo "found the template for $2 "
		FOUNDTEMPLATE="TRUE"
	else
		echo "couldn't find templates/developers/$2"
		exit 2
	fi
fi

}


function pacman_check {
    which pacman
    status=$?
    if [ ! $status = 0 ]
    then
        echo "Can not find pacman in the path, please install pacman"
        exit 1
    fi
}



#-----------------------------------------------
arg_check $1 $2
pacman_check


cd build_tools/clarch
./setup_links.sh
cd -
#create the local pkg dir's for mirror and creating pkg's
[ -e $MIRROR_DIR     ] || mkdir -p $MIRROR_DIR
for i in i586 i686 x86_64
do
    [ -e $MIRROR_DIR/$i     ] || mkdir -p $MIRROR_DIR/$i
    for y in core extra core-testing extra-testing chroot-devel
    do
       [ -e $MIRROR_DIR/$i/$y     ] || mkdir -p $MIRROR_DIR/$i/$y
    done
done
[ -e $MIRROR_DIR/sources     ] || mkdir -p $MIRROR_DIR/sources
[ -e $MIRROR_DIR/packages    ] || mkdir -p $MIRROR_DIR/packages

#correct pacman.conf to use the correct ARCH to build the chroot
sed -e "s/REPLACEME/$ARCH/g" templates/pacman.conf.chroot > /tmp/pacman.conf.chroot

#create the chroot
./mkarchroot -f  -C /tmp/pacman.conf.chroot ../build_root.$ARCH base base-devel cdrkit unison openssh
status=$?
if [ !  $status  = 0 ]
then
    echo
    echo "********************************************************"
    echo "***   An error occured creating the chroot       ***"
    echo "********************************************************"
    exit 1
fi
#clear out the default resolve.con
mv -f ../build_root.$ARCH/etc/resolv.conf ../build_root.$ARCH/etc/resolv.conf.orig

if [ x$FOUNDTEMPLATE = xTRUE ]
then
	#check for login run
	if [ -f templates/developers/$2/loginrun.sh ]
	then
		cp -f templates/developers/$2/loginrun.sh ../build_root.$ARCH/root/loginrun.sh
	fi

	if [ -f templates/developers/$2/custom_chroot.sh ]
	then
		cd templates/developers/$2
		./custom_chroot.sh $ARCH
		cd -
	fi
fi

#create custom enter_dev_chroot.sh script
sed -e "s/REPLACEME/$ARCH/g" templates/enter_dev_chroot.sh > ../enter_dev_chroot.$ARCH.sh
chmod 755 ../enter_dev_chroot.$ARCH.sh
echo "********************************************************"
echo "**    To enter the chroot (build_root.$ARCH) run:    **"
echo "**         cd ..                                     **"
echo "**          ./enter_dev_chroot.$ARCH.sh              **"
echo "********************************************************"


#copy makepkg.conf into the chroot
sed -e "s/i686/$ARCH/g" templates/makepkg.conf >  ../build_root.$ARCH/etc/makepkg.conf
#copy pacman.conf into the chroot
sed -e "s/REPLACEME/$ARCH/g" templates/pacman.conf.chroot > ../build_root.$ARCH/etc/pacman.conf

cd ..