Commits

Moises Henriquez  committed 131817a

Added "View Build Script" feature to display the slackbuild right from the GUI

  • Participants
  • Parent commits 76e7f59

Comments (0)

Files changed (2)

File src/vpackager/dbviews.py

         QueueView.__init__(self)
         self.banner_label.set_label('Job History')
         self.rc_menu = RCMenu(items=['About Job', 'Rebuild Job',
-                                     'View Build Log'])
+                                     'View Build Log', 'View Build Script'])
 
     def tree_click_event(self, tree, event, data=None):
         """ Events triggered with the treeview is clicked """

File src/vpackager/viewcontrollers.py

 import dbviews
 import guitools
 import os
+import preferences
 
 __author__ = 'M0E-lnx'
 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
         self.view.rc_menu.connect_item('rebuild_job', self._rebuild_job_event)
         self.view.rc_menu.connect_item('view_build_log',
                                        self._view_build_log_event)
+        self.view.rc_menu.connect_item('view_build_script',
+                                       self._view_build_script_event)
         # Connect the searchbox.
         box = self.view.exposed_widgets['searchbox']
         box.connect('icon_press', self.searchbox_icon_press)
         if dia.run():
             return dia.destroy()
 
+    def _view_build_script_event(self, widget=None):
+        """ Display the build script that was generated to build this task"""
+        details = self.model.GetTaskDetails(self.view._selectedjob)
+        app = details['app']
+        ver = details['ver']
+        # Get the path to the script
+        srcshome = preferences.VPConf().GetSetting('sources_home')
+        scriptpath = os.path.join(srcshome, app, ver, 'src',
+                                  '%s.SlackBuild'% app)
+        if not os.path.exists(scriptpath):
+            # Error: Cannot find build script.
+            txt = 'Unable to find build script for this task.  ' +\
+                  'This can happen when the build tree is removed manually.'
+            dia = guitools.message.Error(text=txt, parent=self._parentwindow)
+            #if dia.run():
+            #    dia.destroy()
+            #    return
+        else:
+            dia = guitools.LogDisplay(
+                title='%s.SlackBuild'% app,
+                parent = self._parentwindow,
+                logpath = scriptpath)
+        if dia.run():
+            dia.destroy()
+        return
+
     def _about_task_event(self, widget=None):
         """ Show build details about the selected job"""
         about = guitools.AboutTask(