summaryrefslogtreecommitdiff
blob: 26b5630f60c8aad5565a793db2c2668f711ac989 (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
#!/bin/sh
# run like this: ocaml-rebuild.sh [-h | -f] [emerge_options]

emerge=/usr/bin/emerge

if [ "$1" = "-h" ]
then
	echo "usage: ocaml-rebuild.sh [-h | -f(orce)] [emerge_options]"
	echo "With -f, 	the packages will first be unmerged and then emerged"
	echo "with the given options to ensuree correct dependancy analysis."
	echo "Otherwise emerge is run with the --pretend flag and the given"
	echo "options."
	echo "It is recommended to keep the list of rebuilt packages printed"
	echo "in pretend mode in case something go wrong"
	exit 1
fi

if [ "$1" = "-f" ]
then
	pretend=0
	shift
else
	pretend=1
fi

depends=`find /var/db/pkg -name DEPEND -exec grep -l 'dev-lang/ocaml\\|dev-ml/findlib' {} \;`

for dep in $depends
do 
  dir=`dirname $dep`
  pkg=`basename $dir`
  category=`cat $dir/CATEGORY`

  toclean="=$category/$pkg $toclean"
  tocleanstr="\"$category/$pkg\" $tocleanstr"
  tobuild=">=$category/$pkg $tobuild"
  tobuildstr="\">=$category/$pkg\" $tobuildstr"
done

echo Cleaning $tocleanstr
echo Building $tobuildstr

if [ "$toclean" != "" ]
then
	if [ $pretend -eq 1 ]
	then
		$emerge --pretend $@ $tobuild
	else
		$emerge unmerge $toclean
		$emerge $@ $tobuild
	fi
else
	echo "Nothing to update"
fi