use BootServerRequest to upload logs to the right server
[bootmanager.git] / source / steps / InstallBase.py
1 # Copyright (c) 2003 Intel Corporation
2 # All rights reserved.
3
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7
8 #     * Redistributions of source code must retain the above copyright
9 #       notice, this list of conditions and the following disclaimer.
10
11 #     * Redistributions in binary form must reproduce the above
12 #       copyright notice, this list of conditions and the following
13 #       disclaimer in the documentation and/or other materials provided
14 #       with the distribution.
15
16 #     * Neither the name of the Intel Corporation nor the names of its
17 #       contributors may be used to endorse or promote products derived
18 #       from this software without specific prior written permission.
19
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 # EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
33 # YOUR JURISDICTION. It is licensee's responsibility to comply with any
34 # export regulations applicable in licensee's jurisdiction. Under
35 # CURRENT (May 2000) U.S. export regulations this software is eligible
36 # for export from the U.S. and can be downloaded by or otherwise
37 # exported or reexported worldwide EXCEPT to U.S. embargoed destinations
38 # which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
39 # Afghanistan and any other country to which the U.S. has embargoed
40 # goods and services.
41
42
43 import os
44
45 from Exceptions import *
46 import utils
47
48
49 def Run( vars, log ):
50     """
51     Install the base system group of RPMs
52
53     Except the following variables from the store:
54     TEMP_PATH             the path to download and store temp files to
55     SYSIMG_PATH           the path where the system image will be mounted
56                           (always starts with TEMP_PATH)
57     INSTALL_LANGS         languages for install (used by rpm)
58     CACERT_PATH           where the boot server certificates are
59                          
60     Sets the following variables:
61     None
62     
63     """
64
65     log.write( "\n\nStep: Install: Installing base OS.\n" )
66             
67     # make sure we have the variables we need
68     try:
69         TEMP_PATH= vars["TEMP_PATH"]
70         if TEMP_PATH == "":
71             raise ValueError, "TEMP_PATH"
72
73         SYSIMG_PATH= vars["SYSIMG_PATH"]
74         if SYSIMG_PATH == "":
75             raise ValueError, "SYSIMG_PATH"
76
77         INSTALL_LANGS= vars["INSTALL_LANGS"]
78         if INSTALL_LANGS == "":
79             raise ValueError, "INSTALL_LANGS"
80
81         CACERT_PATH= vars["CACERT_PATH"]
82         if CACERT_PATH == "":
83             raise ValueError, "CACERT_PATH"
84
85         SKIP_INSTALL_BASE= vars["SKIP_INSTALL_BASE"]
86         if SKIP_INSTALL_BASE:
87             log.write( "Skipping base group install\n" )
88             return 1
89
90     except KeyError, var:
91         raise BootManagerException, "Missing variable in vars: %s\n" % var
92     except ValueError, var:
93         raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
94         
95
96     # this will prevent all the locales from being installed
97     log.write( "Setting up RPM configuration in sysimg\n" )
98     utils.makedirs( "%s/etc/rpm" % SYSIMG_PATH )
99     rpm_macros= file( "%s/etc/rpm/macros" % SYSIMG_PATH, "w" )
100     rpm_macros.write( "%%_install_langs %s\n" % INSTALL_LANGS )
101     rpm_macros.write( "%_excludedocs 1\n" )
102     rpm_macros.write( "%__file_context_path /dev/null\n" )
103     rpm_macros.close()
104     rpm_macros= None
105
106     log.write( "Running base group install using yum\n" )
107
108     # groupupdate instead of groupinstall since BootstrapRPM
109     # already installed a pre-configured RPM
110     # database. 'PlanetLab' is now a subset of Fedora Core 2
111     # Core/Base plus PlanetLab specific RPMs, so that we don't
112     # have to run yum multiple times. The group is called
113     # 'PlanetLab' for backward compatibility with NodeUpdate,
114     # which is hard-coded to update the 'PlanetLab' group.
115     yum_cmd= "chroot %s yum --sslcertdir %s -y groupupdate 'PlanetLab'" % \
116              (SYSIMG_PATH, CACERT_PATH)
117
118     utils.sysexec( yum_cmd, log );
119     
120     return 1