Moises Henriquez avatar Moises Henriquez committed 2decb51

Added support for custom build options and user-supplied doinst.sh

Comments (0)

Files changed (6)

 VPACKAGER TO-DO LIST
 
-* Move start/stop buttons out of the notebook and make them visible from
-  any tab. Dedicate the first tab to the job queue and move the output tab
-  to be the last.
-      ==== OR ====
-  Remove the status tab entirely?
+* 3/14/11 - Add support for parsing custom configure options and
+  adding a user-specified doinst.sh script
+   -- > Completed 3/15/11
 
-* Add a configuration dialog that allows the following settings to be set
-  + packager name
-  + database path
-  + default source location.

src/vpackager/bot.py

             return shutil.copy2(srcuri, workdir)
         return
 
+    def process_doinst(self, doinstURI, workdir):
+        if doinstURI in ("", None):
+            return
+        if doinstURI.startswith('/'):
+            return shutil.copy2(doinstURI,
+                                os.path.join(workdir, 'doinst.sh'))
+        else:
+            self.print_to_log(
+                "\n +++ Downloading post-install script %s\n"% doinstURI)
+            os.chdir(workdir)
+            return urllib.urlretrieve(doinstURI, 'doinst.sh')
+
     def process_description(self, descuri, workdir):
         """ Copy or download the package description to the right place"""
         if not descuri:
             self.process_source(job_info['srcURI'], workdir)
             # Process the package description
             self.process_description(job_info['descURI'], workdir)
+            # Process the specified post-install script
+            self.process_doinst(job_info['doinstURI'], workdir)
             # Process any patches added to the build
             self.process_patches(job_info['patches'], workdir)
             # cd back to the original workdir (just in case)

src/vpackager/buildutils.py

         return bottools.Execute('installpkg %s'% fullpath)
 
 
-    def makeSlackBuild(self, buildno='1', packager=_packager):
+    def makeSlackBuild(self, buildno='1', packager=_packager,
+                       config=""):
         """ Generate a slackbuild using sbbuilder to build this source"""
         ### Use sbbuilder to create a slackbuild for his package.
         ### The only diff from using this vs sbbuilder itself is that
 
         # call the sbbuilder binary
         proc = bottools.Execute(
-            'sbbuilder --package=%s --version=%s --type=%s --build=%s --user=%s' %(
-                self.app, self.ver, self.builder, buildno, packager))
+            'sbbuilder --package=%s --version=%s --type=%s --build=%s --user=%s --configure_options=%s' %(
+                self.app, self.ver, self.builder, buildno, packager, config))
         proc.run()
         if proc.popen.returncode > 0:
             # the process failed
         self.builder = srctype
         self.link = link
 
-    def makeSlackBuild(self, buildno='1', packager=_packager):
+    def makeSlackBuild(self, buildno='1', packager=_packager, config=""):
         """ Generate the build script for this source """
         try:
             os.makedirs(_sources_home)
             os.chdir(_sources_home)
         except:
             raise MissingSourcesHomeError
-        cm = 'sbbuilder --package=%s --version=%s --type=%s '% (self.app,
+        cm = 'sbbuilder --package=%s --version=%s --type=%s'% (self.app,
                 self.ver, self.builder) + \
-                '--build=%s --user=%s --link=%s'% (buildno,
-                        packager, self.link)
+                '--build=%s --user=%s --link=%s --configure_options=%s'% (buildno,
+                        packager, self.link, config)
         proc = bottools.Execute(cm)
         proc.run()
         if proc.popen.returncode > 0:

src/vpackager/dbutils.py

         release text,
         type text,
         install text,
+        config_options text,
+        doinstURI text,
         patches text)''')
         db.commit()
 
         cursor.execute('''
         create table history(id integer primary key,
         app text, ver text, srcURI text, descURI text,
-        release text, type text, patches text, buildstart text,
+        release text, type text, config_options text,
+        doinstURI text, patches text, buildstart text,
         buildend text, stdout text, result text)''')
         db.commit()
 
         return self.close()
 
     def NewJob(self, app, ver, srcURI, descURI, release, _type,
-            install, patches):
+            install, config_options, doinstURI, patches):
         """ Add a new job to the job queue"""
-        t = (app, ver, srcURI, descURI, release, _type, install, patches)
+        t = (app, ver, srcURI, descURI, release, _type, install,
+             config_options, doinstURI,patches)
         db, cursor = self._open()
         cursor.execute('''
         insert into queue (app, ver, srcURI, descURI, release, type,
-        install, patches) values (?,?,?,?,?,?,?,?)''', t)
+        install,config_options, doinstURI,
+        patches) values (?,?,?,?,?,?,?,?,?,?)''', t)
         db.commit()
         self.notify(data = self.GetQueue(), group='queue')
         return self.close()
 
     def UpdateJob(self, _id, app, ver, srcURI, descURI, release,
-                  _type, install, patches):
+                  _type, install, config_options, doinstURI, patches):
         """ Update job information on an existing job"""
         db, cursor = self._open()
-        t = (app, ver, srcURI, descURI, release, _type, install, patches, _id)
+        t = (app, ver, srcURI, descURI, release, _type, install,
+             config_options, doinstURI, patches, _id)
         try:
             cursor.execute('''
                 UPDATE queue set app=?, ver=?, srcURI=?, descURI=?,
-                release=?, type=?, install=? ,patches=? WHERE id=?''', t)
+                release=?, type=?, install=? , config_options=?,
+                doinstURI=?, patches=? WHERE id=?''', t)
             db.commit()
             self.notify(self.GetQueue(), group='queue')
         except:
         db, cursor = self._open()
         t = (job_id,)
         cursor.execute('''
-        select id, app, ver, srcURI, descURI, release, type from queue where
-        id=?''',t)
+        select id, app, ver, srcURI, descURI, release, type, config_options,
+        doinstURI from queue where id=?''',t)
         res = cursor.next()
         cursor.execute('''
         insert into history (id, app, ver, srcURI, descURI, release, type,
-        buildstart, result) values (?,?,?,?,?,?,?,CURRENT_TIMESTAMP,
-        'Running')''', res)
+        config_options, doinstURI, buildstart, result)
+        values (?,?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP, 'Running')''', res)
         cursor.execute('delete from queue where id=?', t)
         db.commit()
         # Notify the observers of the changes.
             retval['descURI'] = ret[4]
             retval['release'] = ret[5]
             retval['type'] = ret[6]
-            retval['patches'] = ret[7]
-            retval['buildstart'] = ret[8]
-            retval['buildend'] = ret[9]
-            retval['stdout'] = ret[10]
-            retval['result'] = ret[11]
+            retval['config'] = ret[7]
+            retval['doinstURI'] = ret[8]
+            retval['patches'] = ret[9]
+            retval['buildstart'] = ret[10]
+            retval['buildend'] = ret[11]
+            retval['stdout'] = ret[12]
+            retval['result'] = ret[13]
         else:
             retval = {}
         self.close()
             retval['release'] = ret[5]
             retval['type'] = ret[6]
             retval['install'] = ret[7]
-            retval['patches'] = ret[8]
+            retval['config'] = ret[8]
+            retval['doinstURI'] = ret[9]
+            retval['patches'] = ret[10]
         else:
             retval = None
         self.close()

src/vpackager/guitools.py

         mod.append(['Description URI', info['descURI']])
         mod.append(['Source Type', info['type']])
         mod.append(['Install After Build', info['install']=="1"])
+        mod.append(['Custom build options', info['config']])
+        mod.append(['Post-install script', info['doinstURI']])
         if patchlist:
             mod.append(['Patches to be applied', patchlist[0]])
             for x in range(1, len(patchlist)):
         mod.append(['Build Ended', info['buildend']])
         mod.append(['Build Result', info['result']])
         mod.append(['Output Log', info['stdout']])
+        mod.append(['Custom Build Options', info['config']])
+        mod.append(['Post-install script', info['doinstURI']])
         if patches:
             patchlist = patches.split(',')
             patchlist = (['Patches Applied', patchlist[0]])
         self.patches = []
         self.release = 1
         self.install = False
-        self.patchesbox = self._patchesbox()
+        self.config_options = ""
+        self.doinstURI = ""
+        self.advancedbox = self._advancedbox()
         self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
         self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
         self.set_has_separator(True)
         body.pack_start(bbox, False, True, 2)
         # Patches box
         #exPatches = gtk.expander_new_with_mnemonic('Patches')
-        exPatches = gtk.Expander('Patches')
-        exPatches.add(self.patchesbox)
+        exPatches = gtk.Expander('Advanced Options')
+        exPatches.add(self.advancedbox)
         exPatches.connect('notify::expanded', self._expander_event)
         body.pack_start(exPatches, True, True, 4)
 
         self.app = data
         self.appEntry.set_text((data or ""))
 
+    def set_config(self, data):
+        self.configEntry.set_text((data or ""))
+        self.config_options = data
+
+    def set_doinst(self, data):
+        self.doinstEntry.set_text((data or ""))
+        self.doinstURI = data
+
     def set_src(self, data):
         self.SrcURI = data
         self.srcentry.set_text((data or ""))
             model.append([patch])
         return
 
-    def _patchesbox(self):
+    def _advancedbox(self):
+        gbox = gtk.VBox()
         box = gtk.HBox()
+        frmpatches = gtk.Frame('Patches')
         rbox = gtk.VBox()
         lst = gtk.ListStore(str)
         cr = gtk.CellRendererText()
         btDelPatch.connect('clicked', self._del_patch_event)
         rbox.pack_start(btAddPatch, False ,False, 2)
         rbox.pack_start(btDelPatch, False ,False, 2)
-        return box
+        frmpatches.add(box)
+
+        # Add an area to provide custom configure options.
+        lb = gtk.Label("Extra configure options. (Autoconf sources only)")
+        lb.set_property('xalign', 0.0)
+        entry_conf_options = gtk.Entry()
+        self.configEntry = entry_conf_options
+        entry_conf_options.connect('changed', self.on_conf_options_change)
+        doinstbox = gtk.HBox()
+        doinst_lb = gtk.Label('Post Install Script:')
+        doinst_lb.set_property('xalign', 0.0)
+        gbox.pack_start(doinst_lb, False, True, 2)
+        doinst_en = gtk.Entry()
+        self.doinstEntry = doinst_en
+        doinst_bt = vButton(stock=gtk.STOCK_OPEN, label='Select')
+        doinst_bt.connect('clicked', self.on_select_doinst)
+        doinst_en.set_tooltip_text('Enter URL, path or click "Select"')
+        #doinstbox.pack_start(doinst_lb, False, False, 2)
+        doinstbox.pack_start(doinst_en, True, True, 2)
+        doinstbox.pack_start(doinst_bt, False, False, 2)
+        gbox.pack_start(doinstbox, False, True, 2)
+        gbox.pack_start(lb, False, True, 2)
+        gbox.pack_start(entry_conf_options, False, True, 2)
+        gbox.pack_start(frmpatches, True, True, 2)
+
+
+        return gbox
+
+    def on_conf_options_change(self, widget=None):
+        self.config_options = widget.get_text()
+
+    def on_select_doinst(self, widget=None):
+        """Pop a dialog to select the install script"""
+        dia = FilePicker(title="Select post-install script",
+                         forsrc=False, plaintxt=True)
+        res = dia.run()
+        dia.hide()
+        if res == gtk.STOCK_OK:
+            self.doinstEntry.set_text(dia.get_filename())
+            self.doinstURI = self.doinstEntry.get_text()
+        return
+
 
     def _expander_event(self, widget=None, user_data=None):
         ''' Resize the dialog to display the newly added widgets'''
-        ht = self.patchesbox.get_allocation()[-2]
-        ht = int(max(ht, 495)*0.25)
+        ht = self.advancedbox.get_allocation()[-2]
+        ht = int(max(ht, 820)*0.25)
         wwid,whei =  self.get_size()
         if widget.get_expanded():
-            self.patchesbox.show()
+            self.advancedbox.show()
             self.resize(wwid, whei + ht)
         else:
-            self.patchesbox.hide()
+            self.advancedbox.hide()
             self.resize(wwid, whei - ht)
         return
 

src/vpackager/viewcontrollers.py

         dia.set_app(cur_details['app'])
         dia.set_version(cur_details['ver'])
         dia.set_patches(cur_details['patches'].split(','))
+        dia.set_config(cur_details['config'])
+        dia.set_doinst(cur_details['doinstURI'])
 
         res = dia.run()
         dia.hide()
                 release = dia.release,
                 _type = dia.srctype,
                 install = dia.install,
+                doinstURI = dia.doinstURI,
+                config_options = dia.config_options,
                 patches = ','.join(dia.patches))
             if ret is True:
                 # Something went wrong, maybe the bot was running and the
                     dia.destroy()
         return
 
-
     def _show_queue(self, widget=None):
         """ Force the queue to be displayed"""
         return self.model.RefreshQueue()
                 release = dia.release,
                 _type = dia.srctype,
                 install = dia.install,
-                patches = ','.join(dia.patches))
+                patches = ','.join(dia.patches),
+                doinstURI = dia.doinstURI,
+                config_options = dia.config_options)
+
         else:
             ret = dia.destroy
         return ret
         dia.set_version(info['ver'])
         dia.set_src(info['srcURI'])
         dia.set_desc(info['descURI'])
+        dia.set_config(info['config'])
+        dia.set_doinst(info['doinstURI'])
         if info['patches'] not in (
             '', None, 'None'):
             dia.set_patches(info['patches'].split(','))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.