[SCM] GUI front-end for Debian Live. branch, master, updated. 72023d3200637edc6b81b8cc8d240b376a0d14df
Chris Lamb
chris at chris-lamb.co.uk
Wed Jul 9 23:14:02 UTC 2008
The following commit has been merged in the master branch:
commit 130f477f97a7b2b6125a8bab2aa13c0d3411f4b8
Author: Chris Lamb <chris at chris-lamb.co.uk>
Date: Thu Jul 10 00:09:58 2008 +0100
Make build process cancellable.
Signed-off-by: Chris Lamb <chris at chris-lamb.co.uk>
diff --git a/LiveMagic/controllers/build.py b/LiveMagic/controllers/build.py
index f773fed..6b77f57 100644
--- a/LiveMagic/controllers/build.py
+++ b/LiveMagic/controllers/build.py
@@ -1,7 +1,6 @@
import os
import pwd
import sys
-import shutil
import gobject
import subprocess
@@ -10,6 +9,9 @@ BUILDING, CANCELLED, CANCELLED_CLEAN, FAILED, \
from LiveMagic.utils import find_resource
+LOG_FILE = 'build-log.txt'
+STATUS_FILE = './status'
+
class BuildController(object):
def do_show_build_window(self, build_close_callback):
@@ -18,7 +20,7 @@ class BuildController(object):
self.uid, self.gid = [int(x) for x in self.options.build_for.split(':', 2)]
- f = open(os.path.join(os.getcwd(), 'build-log.txt'), 'w')
+ f = open(os.path.join(LOG_FILE), 'w')
f.write('I: live-magic respawned as root')
f.close()
@@ -47,14 +49,16 @@ class BuildController(object):
return True
def on_vte_child_exited(self, *_):
- status_filename = os.path.join(os.getcwd(), '.status')
-
def _exec(*cmds):
args = ['/bin/sh', '-c', '; '.join(cmds)]
self.view.vte_terminal.fork_command(args[0], args, None, os.getcwd())
def set_cleaning_status():
- os.remove(status_filename)
+ try:
+ os.remove(STATUS_FILE)
+ except:
+ # This may fail as we removed the build directory
+ pass
self.view.set_build_uncancellable()
self.view.set_build_titles("Cleaning build process",
"Purging unnecessary parts of the build system...")
@@ -75,8 +79,8 @@ class BuildController(object):
def ok_clean():
set_cleaning_status()
_exec('lh_clean --chroot --stage --source --cache',
- 'rm -rf config/ binary/',
- 'chown -R %d:%d .' % (self.uid, self.gid))
+ 'rm -rvf config/ binary/',
+ 'chown -Rv %d:%d .' % (self.uid, self.gid))
return OK
def failed():
@@ -86,8 +90,8 @@ class BuildController(object):
def failed_clean():
set_cleaning_status()
- _exec('lh_clean --purge', 'rm -rf config/',
- 'chown -R . %d:%d' % (self.uid, self.gid))
+ _exec('lh_clean --purge', 'rm -rvf config/',
+ 'chown -Rv . %d:%d' % (self.uid, self.gid))
return FAILED
def cancelled():
@@ -97,13 +101,13 @@ class BuildController(object):
def cancelled_clean():
set_cleaning_status()
- _exec('lh_clean --purge', 'rm -rf $(pwd)')
+ _exec('lh_clean --purge', 'rm -rvf $(pwd)')
return CANCELLED
if self.state == BUILDING:
self.state = FAILED_CLEAN
try:
- f = open(status_filename)
+ f = open(STATUS_FILE)
try:
if f.read().strip() == 'ok':
self.state = OK_CLEAN
diff --git a/LiveMagic/controllers/wizard.py b/LiveMagic/controllers/wizard.py
index 454400d..6aa44d2 100644
--- a/LiveMagic/controllers/wizard.py
+++ b/LiveMagic/controllers/wizard.py
@@ -44,16 +44,28 @@ class WizardController(object):
p = subprocess.Popen(cmd)
os.waitpid(p.pid, 0)
+
try:
+ # If build-log.txt exists, we had a successful build
os.stat(os.path.join(self.model.dir, 'build-log.txt'))
gtk.main_quit()
return
except:
pass
+ try:
+ os.stat(self.model.dir)
+ except:
+ # If the build directory does not exist, we cancelled the build
+ break
+
self.view.do_undim_wizard()
os.chdir('..')
- shutil.rmtree(self.model.dir)
+ try:
+ shutil.rmtree(self.model.dir)
+ except:
+ # Tree may not exist if we cancelled build
+ pass
threading.Thread(target=gain_superuser).start()
diff --git a/TODO b/TODO
index 61b34d1..a7b2492 100644
--- a/TODO
+++ b/TODO
@@ -4,8 +4,6 @@ live-magic TODO
Release blockers
----------------
- * Build process needs to be cancellable
-
* Ability to select location of build in the wizard
Other
--
GUI front-end for Debian Live.
More information about the debian-live-changes
mailing list