9eaf43042c5fb50b0f2f48cdea63189edacf8740
[nodeconfig.git] / PlanetLabConf / yum.conf.php
1 <?php
2 //
3 // /etc/yum.conf for production nodes
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2004-2006 The Trustees of Princeton University
7 //
8 // $Id$
9 //
10
11 // For PLC_NAME and PLC_BOOT_HOST
12 include('plc_config.php');
13
14 $PLC_NAME = PLC_NAME;
15 $PLC_BOOT_HOST = PLC_BOOT_HOST;
16
17 $oldrepos = array(array('FedoraCore2Base', 'Fedora Core 2 Base', 'stock-fc2'),
18                array('FedoraCore2Updates', 'Fedora Core 2 Updates', 'updates-fc2'),
19                array('ThirdParty', 'Third Party RPMS', '3rdparty'));
20
21 $repos = array(array('ThirdParty', 'Third Party RPMS', '3rdparty'));
22
23
24 if (isset($_REQUEST['alpha'])) {
25   $repos[] = array('PlanetLabAlpha', 'PlanetLab Alpha RPMS', 'planetlab-alpha');
26 } elseif (isset($_REQUEST['beta'])) {
27   $repos[] = array('PlanetLabBeta', 'PlanetLab Beta RPMS', 'planetlab-beta');
28 } elseif (isset($_REQUEST['rollout'])) {
29   $repos[] = array('PlanetLab', 'PlanetLab RPMS', 'planetlab-rollout');
30 } else {
31   $repos[] = array('PlanetLab', 'PlanetLab RPMS', 'planetlab');
32 }
33
34 if (isset($_REQUEST['gpgcheck'])) {
35   $gpgcheck = $_REQUEST['gpgcheck'];
36 } else {
37   $gpgcheck = 0;
38 }
39
40 // Requesting a mirror list. Yum bombs out completely if a repository
41 // is (even temporarily) unavailable, so if CoBlitz is down, provide a
42 // few more options. Make sure that gpgcheck remains enabled.  Last
43 // chance option is ourselves so that yum never fails.
44 if (isset($_REQUEST['mirrorlist']) &&
45     isset($_REQUEST['repo']) &&
46     isset($_REQUEST['releasever'])) {
47   $mirrors = array("http://coblitz.codeen.org/coblitz.planet-lab.org/pub/fedora/linux",
48                    "http://fedora.gtlib.cc.gatech.edu/pub/fedora.redhat/linux",
49                    "http://download.fedoraproject.org/pub/fedora/linux",
50                    "http://mirrors.kernel.org/fedora");
51                    #"ftp://rpmfind.net/linux/fedora",  still uses the old style of directory hierarchy
52   $releasever = $_REQUEST['releasever'];
53   switch ($_REQUEST['repo']) {
54   case "base":
55         if ( intval($releasever) >= 7 )
56         {
57                 foreach ($mirrors as $mirror) {
58                   echo "$mirror/releases/$releasever/Everything/\$ARCH/os/\n";
59                 }
60
61         } else {
62                 foreach ($mirrors as $mirror) {
63                   echo "$mirror/core/$releasever/\$ARCH/os/\n";
64                 }
65         }
66     break;
67   case "updates":
68         if ( intval($releasever) >= 7 )
69         {
70                 foreach ($mirrors as $mirror) {
71                   echo "$mirror/updates/$releasever/\$ARCH/\n";
72                 }
73
74         } else {
75                 foreach ($mirrors as $mirror) {
76                   echo "$mirror/core/updates/$releasever/\$ARCH/\n";
77                 }
78         }
79     break;
80   }
81
82   // Always list ourselves last
83   echo "https://$PLC_BOOT_HOST/install-rpms/planetlab/\n";
84   exit;
85 }
86
87 // Requesting yum.conf. See above for the mirrorlist definition.
88 echo <<<EOF
89 [main]
90 # Do not scan /etc/yum.repos.d/
91 reposdir=/dev/null
92 cachedir=/var/cache/yum
93 debuglevel=2
94 logfile=/var/log/yum.log
95 pkgpolicy=newest
96 gpgcheck=$gpgcheck
97
98 [base]
99 name=Fedora Core \$releasever - \$basearch - Base
100 mirrorlist=https://$PLC_BOOT_HOST/PlanetLabConf/yum.conf.php?mirrorlist&repo=base&releasever=\$releasever
101 gpgcheck=$gpgcheck
102 # PlanetLab builds its own versions of these tools
103 exclude=iptables kernel kernel kernel-devel kernel-smp kernel-smp-devel kernel-xen0 kernel-xen0-devel kernel-xenU kernel-xenU-devel mysql ulogd
104
105 [updates]
106 name=Fedora Core \$releasever - \$basearch - Released Updates
107 mirrorlist=https://$PLC_BOOT_HOST/PlanetLabConf/yum.conf.php?mirrorlist&repo=updates&releasever=\$releasever
108 gpgcheck=$gpgcheck
109 # PlanetLab builds its own versions of these tools
110 exclude=iptables kernel kernel kernel-devel kernel-smp kernel-smp-devel kernel-xen0 kernel-xen0-devel kernel-xenU kernel-xenU-devel mysql ulogd
111
112 EOF;
113
114 // Figure out which repositories we actually have on this
115 // machine. MyPLC installations, for instance, generally only have
116 // PlanetLab RPMS installed.
117 foreach ($repos as $repo) {
118   $id = $repo[0];
119   $name = $repo[1] . " -- " . "$PLC_NAME Central";
120   $dir = "/install-rpms/" . $repo[2];
121   $baseurl = "https://$PLC_BOOT_HOST" . $dir . "/";
122
123   if (is_dir(realpath($_SERVER['DOCUMENT_ROOT'] . $dir))) {
124     echo <<<EOF
125 [$id]
126 name=$name
127 baseurl=$baseurl
128 gpgcheck=$gpgcheck
129
130
131 EOF;
132   }
133 }
134
135 ?>