Subversion Repositories ALCASAR

Rev

Rev 509 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 509 Rev 518
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-urpmi.sh 509 2011-03-16 23:06:13Z richard $
2
# $Id: alcasar-urpmi.sh 518 2011-03-25 16:04:12Z stephane $
3
# script de mise en place des dépots RPM 
3
# script de mise en place des dépots RPM 
4
# 3abtux & rexy
4
# 3abtux & rexy
5
 
5
 
6
 
-
 
7
VERSION="2010.2"
6
VERSION="2010.2"
8
ARCH="i586"
7
ARCH="i586"
9
#                       For french ALCASARistes
8
#                       For french ALCASARistes
10
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
9
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
11
#                       For International install
10
#                       For International install
12
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
11
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
13
MIRROR_NBR=2
12
MIRROR_NBR=2
14
 
13
 
15
rpm_repository_sync ()
14
rpm_repository_sync ()
16
{
15
{
17
echo ${!MIRRORLIST}
16
echo ${!MIRRORLIST}
18
urpmi.removemedia -a
17
urpmi.removemedia -a
19
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
18
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
20
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
19
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
21
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
20
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
22
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
21
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
23
}
22
}
24
 
23
 
25
# extract the current Mandriva version and hardware architecture (i586 ou X64)
24
# extract the current Mandriva version and hardware architecture (i586 ou X64)
26
fic=`cat /etc/product.id`
25
fic=`cat /etc/product.id`
27
old="$IFS"
26
old="$IFS"
28
IFS=","
27
IFS=","
29
set $fic
28
set $fic
30
for i in $*
29
for i in $*
31
do
30
do
32
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
31
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
33
	then 
32
	then 
34
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
33
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
35
		if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ] 
34
		if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ] 
36
		then
35
		then
37
		      echo "La migration automatique du système ne peut être réalisée."
36
		      echo "La migration automatique du système ne peut être réalisée."
38
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
37
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
39
		      echo "The automatic system update can't perform."
38
		      echo "The automatic system update can't perform."
40
		      echo "Do a manual update (see doc)."
39
		      echo "Do a manual update (see doc)."
41
		exit 1		
40
		exit 1		
42
		fi
41
		fi
43
	fi
42
	fi
44
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
43
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
45
	then 
44
	then 
46
		ARCH=`echo $i|cut -d"=" -f2`
45
		ARCH=`echo $i|cut -d"=" -f2`
47
	fi
46
	fi
48
done
47
done
49
IFS="$old"
48
IFS="$old"
50
# Set the RPM repository
49
# Set the RPM repository
51
try_nb="0"; nb_repository="0"
50
try_nb="0"; nb_repository="0"
52
while [ "$nb_repository" != "4" ]
51
while [ "$nb_repository" != "4" ]
53
do
52
do
54
	try_nb=`expr $try_nb + 1`
53
	try_nb=`expr $try_nb + 1`
55
	MIRRORLIST="MIRRORLIST$try_nb"
54
	MIRRORLIST="MIRRORLIST$try_nb"
56
	rpm_repository_sync 
55
	rpm_repository_sync 
57
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
56
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
58
	if [ "$nb_repository" != "4" ]
57
	if [ "$nb_repository" != "4" ]
59
	then
58
	then
60
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
59
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
61
		echo "An error occurs when synchronising the repositories N°$try_nb"
60
		echo "An error occurs when synchronising the repositories N°$try_nb"
62
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
61
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
63
		then
62
		then
64
			echo
63
			echo
65
			echo "Relancez l'installation ultérieurement."
64
			echo "Relancez l'installation ultérieurement."
66
			echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
65
			echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
67
			echo "Try an other install later."
66
			echo "Try an other install later."
68
			echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
67
			echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
69
			exit 1
68
			exit 1
70
		fi
69
		fi
71
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
70
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
72
		echo "Do you wan't to try a synchronisation with an other repository?"
71
		echo "Do you wan't to try a synchronisation with an other repository?"
73
		response=0
72
		response=0
74
		PTN='^[oOnNyY]$'
73
		PTN='^[oOnNyY]$'
75
		until [[ $(expr $response : $PTN) -gt 0 ]]
74
		until [[ $(expr $response : $PTN) -gt 0 ]]
76
		do
75
		do
77
			read response
76
			read response
78
		done
77
		done
79
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
78
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
80
		then
79
		then
81
			exit 1
80
			exit 1
82
		fi
81
		fi
83
	fi
82
	fi
84
done
83
done
85
# download RPM in cache 
84
# download RPM in cache 
86
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
85
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
87
echo "Updated RPM download. Please wait ..."
86
echo "Updated RPM download. Please wait ..."
88
echo "Il est temps d'aller prendre un café :-) "
87
echo "Il est temps d'aller prendre un café :-) "
89
echo "You should now take a Beer ;-) "
88
echo "You should now take a Beer ;-) "
90
urpmi --downloader wget --auto --auto-update --quiet --test --retry 2
89
urpmi --downloader wget --auto --auto-update --quiet --test --retry 2
91
if [ "$?" != "0" ]
90
if [ "$?" != "0" ]
92
then
91
then
93
	echo
92
	echo
94
	echo "Une erreur a été détectée lors de la récupération des paquetages."
93
	echo "Une erreur a été détectée lors de la récupération des paquetages."
95
	echo "Relancez l'installation ultérieurement."
94
	echo "Relancez l'installation ultérieurement."
96
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
95
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
97
	echo "An error occurs when downloading"
96
	echo "An error occurs when downloading"
98
	echo "Try an other install later."
97
	echo "Try an other install later."
99
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
98
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
100
	exit 1
99
	exit 1
101
fi
100
fi
102
# update with cached RPM
101
# update with cached RPM
103
urpmi --auto --auto-update
102
urpmi --auto --auto-update
104
# cleaning
103
# cleaning
105
urpme --auto --auto-orphans
104
urpme --auto --auto-orphans
106
exit 0
105
exit 0
107
 
106
 
108
 
107