Class: Yast::VendorClass

Inherits:
Module
  • Object
show all
Defined in:
src/modules/Vendor.rb

Instance Method Summary collapse

Instance Method Details

#DriverUpdate1Object

DriverUpdate copy /update/* to target:/tmp/update/ !! can only be called in inst_finish !!



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'src/modules/Vendor.rb', line 51

def DriverUpdate1
  updatefiles = Convert.convert(
    WFM.Read(path(".local.dir"), ["/update", []]),
    from: "any",
    to:   "list <string>"
  )
  if Ops.less_or_equal(Builtins.size(updatefiles), 0)
    Builtins.y2milestone("No files in /update, skipping driver update...")
    return
  end

  Builtins.y2milestone("Extracting driver update...")

  # clean up, just in case
  SCR.Execute(path(".target.bash"), "/usr/bin/rm -rf /tmp/update")

  # copy log file
  WFM.Execute(
    path(".local.bash"),
    Ops.add(
      Ops.add(
        "l=/var/log/driverupdate.log ; [ -f $l ] && /bin/cat $l " + ">> '",
        String.Quote(Installation.destdir)
      ),
      "$l'"
    )
  )

  # copy all update files from inst-sys to installed system
  WFM.Execute(
    path(".local.bash"),
    Ops.add(
      Ops.add(
        "/bin/cp -a /update " + "'",
        String.Quote(Installation.destdir)
      ),
      "/tmp/update'"
    )
  )

  logfile = "/var/log/zypp/history"

  runcmd = Ops.add(
    Ops.add(
      Ops.add(
        Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(
                Ops.add(
                  Ops.add(
                    Ops.add(
                      Ops.add(
                        Ops.add(
                          Ops.add(
                            Ops.add(
                              Ops.add(
                                Ops.add(
                                  # Logging extracting the driver update
                                  "cd /; \n" \
                                  "for i in /tmp/update/[0-9]*/install ; do \n" \
                                  "    echo \"# Installing Driver Update from $i\">>",
                                  logfile
                                ),
                                "; \n"
                              ),
                              "    TMPFILE=\"/tmp/update/${i}rpm_install_tmpfile\"; \n"
                            ),
                            "    [ -x \"/bin/mktemp\" ] && TMPFILE=`/bin/mktemp`; \n"
                          ),
                          # Extracting the driver update archives
                          "    cd $i; \n"
                        ),
                        "    [ -f \"update.tar.gz\" ] && /bin/tar -zxf \"update.tar.gz\"; \n"
                      ),
                      "    [ -f \"update.tgz\" ] && /bin/tar -zxf \"update.tgz\"; \n"
                    ),
                    # Installing all extracted RPMs
                    "    rpm -Uv --force *.rpm 1>>$TMPFILE 2>>$TMPFILE; \n"
                  ),
                  # Logging errors
                  "    [ -s \"$TMPFILE\" ] && echo \"# Additional rpm output:\">>"
                ),
                logfile
              ),
              " && sed 's/^\\(.*\\)/# \\1/' $TMPFILE>>"
            ),
            logfile
          ),
          "; \n"
        ),
        "    rm -rf $TMPFILE; \n"
      ),
      # Running update.post script
      "    [ -f \"update.post\" ] && /bin/chmod +x \"update.post\" && " \
      "\"./update.post\" \"$i\"; \n"
    ),
    "done;"
  )

  Builtins.y2milestone(
    "Calling:\n" \
    "---------------------------------------------------------\n" \
    "%1\n" \
    "---------------------------------------------------------",
    runcmd
  )

  # unpack update files and run update.post scripts
  # via SCR chrooted into the installed system
  cmd = Convert.to_map(SCR.Execute(path(".target.bash_output"), runcmd))
  Builtins.y2milestone("Driver Update deployment returned: %1", cmd)

  nil
end

#DriverUpdate2Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'src/modules/Vendor.rb', line 167

def DriverUpdate2
  updatefiles = Convert.convert(
    WFM.Read(path(".local.dir"), ["/update", []]),
    from: "any",
    to:   "list <string>"
  )
  return if Ops.less_or_equal(Builtins.size(updatefiles), 0)

  # run update.post2 scripts
  SCR.Execute(
    path(".target.bash"),
    "cd / ; for i in /tmp/update/[0-9]*/install ; do " \
    "    [ -f \"$i/update.post2\" ] && /bin/chmod +x \"$i/update.post2\" && " \
    "\"$i/update.post2\" \"$i\" ; " \
    "done"
  )

  # remove driver update dir
  SCR.Execute(path(".target.bash"), "/usr/bin/rm -rf /tmp/update")

  nil
end

#mainObject



38
39
40
41
42
# File 'src/modules/Vendor.rb', line 38

def main
  Yast.import "Installation"
  Yast.import "Directory"
  Yast.import "String"
end