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