Julien Jehannet avatar Julien Jehannet committed c0c64b9

some renaming + cool C90autoshell script

Comments (0)

Files changed (2)

lgp-hook-autoshell.diff

+# HG changeset patch
+# Date 1304553077 -7200
+# User Julien Jehannet <julien@smaf.org>
+# Parent 7519ed15d99adc2eb15ffe3accdd439c4bdcc4bb
+lgp: new C90autoshell hook to enter into debug shell
+
+New:
+* By adding '--debug=autoshell' parameter to the lgp build command,
+  you will enter automatically in a shell for a build in failure
+
+diff --git a/etc/lgp/hooks/C00msg b/etc/lgp/hooks/C00msg
+deleted file mode 100755
+--- a/etc/lgp/hooks/C00msg
++++ /dev/null
+@@ -1,8 +0,0 @@
+-#!/bin/bash
+-
+-. /tmp/hooks/lgp.functions
+-
+-printf "\a"
+-echo
+-eprint_hook "Sorry, the build process failed for '$(basename "$SUDO_COMMAND" .dsc)' in '$DIST/$ARCH' image !"
+-echo
+diff --git a/etc/lgp/hooks/C10shell b/etc/lgp/hooks/C90autoshell
+rename from etc/lgp/hooks/C10shell
+rename to etc/lgp/hooks/C90autoshell
+--- a/etc/lgp/hooks/C10shell
++++ b/etc/lgp/hooks/C90autoshell
+@@ -1,26 +1,30 @@
+ #!/bin/bash
+-# Invoke shell if build fails and if LGP_AUTO_ENTER_SHELL is set in your ~/.pbuilderrc
++# Invoke shell if lgp build was invoked with "--debug=autoshell" option
++# this kind of debug hooks only works with local pbuilder set up (needs sudo)
+ 
+ . /tmp/hooks/lgp.functions
+ 
+-if [ -n "$LGP_AUTO_ENTER_SHELL" ]; then
+-	export TERM=linux
+-	export TMOUT=1200
+-	export PS1="[$(basename "$SUDO_COMMAND" .dsc) / ${DIST}] \w\$ "
+-	apt-get install -y --force-yes vim less bash >/dev/null &
+-	echo
+-	print_hook "You're entering into the image used to build the package,\n"\
+-	           "         because LGP_AUTO_ENTER_SHELL has been found in environment."
+-	echo
+-	echo "TMOUT set to $TMOUT seconds."
+-	echo "Type exit or Ctrl-D (i.e. EOF) to escape."
+-	echo
++case "${SUDO_COMMAND}" in 
++	*--autoshell*)
++		export TERM=linux
++		export TMOUT=1200
+ 
+-	cd /tmp/buildd/*/debian/..
+-	/bin/bash < /dev/tty > /dev/tty 2> /dev/tty
+-else
+-	echo "If you want to enter into the chroot image to debug, you have to edit your ~/.pbuilderrc with:"
+-	echo
+-	echo "    export LGP_AUTO_ENTER_SHELL=y"
+-	echo
+-fi
++		apt-get install -y --force-yes vim less bash >/dev/null &
++
++		# Set informative prompt (with --norc)
++		export PS1="[lgp: ${DIST}/${ARCH}] \w \$ "
++		# Change to build directory
++		cd /tmp/buildd/*/debian/..
++
++		echo
++		printf "\a"
++		echo
++		eprint_hook "Sorry, the build process failed for '$DIST/$ARCH' image !"
++		eprint_hook "You're now entering now into the shell used for the build."
++		echo
++		echo "TMOUT set to $TMOUT seconds."
++		echo "Type exit or Ctrl-D (i.e. EOF) to escape."
++		echo
++		/bin/bash --norc < /dev/tty > /dev/tty 2> /dev/tty
++		exit 1
++esac
+diff --git a/etc/lgp/pbuilderrc.sh b/etc/lgp/pbuilderrc.sh
+--- a/etc/lgp/pbuilderrc.sh
++++ b/etc/lgp/pbuilderrc.sh
+@@ -145,10 +145,8 @@ PKGNAME_LOGFILE=yes
+ # No debconf interaction with user by default
+ export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:="noninteractive"}
+ 
+-# Set the PATH I am going to use inside pbuilder
++# Set PATH used inside pbuilder image
+ #export PATH="/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
+-# Set informative prompt
+-#export PS1="(lgp) ${DIST}/${ARCH} \$ "
+ # SHELL variable is used inside pbuilder by commands like 'su'; and they need sane values
+ export SHELL="/bin/sh"
+ export TERM=linux
+diff --git a/lgp/build.py b/lgp/build.py
+--- a/lgp/build.py
++++ b/lgp/build.py
+@@ -42,6 +42,7 @@ class Builder(SetupInfo):
+     """
+     name = "build"
+     options = DscBuilder.options + [
++               # XXX should be enabled by default ?
+                ('hooks',
+                 {'type': 'string',
+                  'default': '', # check if new HOOKS_DIR
+@@ -65,6 +66,15 @@ class Builder(SetupInfo):
+                  'help': "run in parallel with a max limit of processes",
+                  'group': 'Build',
+                 }),
++               ('debug',
++                {'type': 'csv',
++                  'dest': 'debug_hooks',
++                  'short': 'D',
++                  'metavar': "<debug hook>",
++                  'help': "list of action hook to enable in debug mode"
++                          "(available action: autoshell)",
++                 'group': 'Pbuilder',
++                }),
+               ]
+     # list of all temporary directories
+     _build_tmpdirs = []
+@@ -260,6 +270,11 @@ class Builder(SetupInfo):
+             if self.config.hooks.lower() != "no":
+                 cmd.extend(['--hookdir', self.config.hooks])
+             cmd.append('%(dscfile)s')
++            # manage extra hook parameters used in debug mode
++            if self.config.debug_hooks:
++                self.config.debug_hooks.insert(0, ' --')
++                actions = ' --'.join(self.config.debug_hooks)
++                cmd.append(actions)
+         # XXX abstract builder methods
+         elif debuilder == 'debuild':
+             cmd = ['debuild', '--no-tgz-check', '--no-lintian',
-DEBUG_INITIAL_LGP_STUFF_WITH_LOCAL_CONFIGURATION
+#DEBUG_INITIAL_LGP_STUFF_WITH_LOCAL_CONFIGURATION
 migration-clcommands.diff
 clcommands-clean.diff
 clcommands-project.diff
 build-multiprocess.diff
 logger-improvements.diff
 lgp-sign-process.diff
+lgp-hook-autoshell.diff
 DEBUG_LGP_STUFF_WITH_LOCAL_CONFIGURATION
 TODOLIST
 wip-lgp-build-source-improve.diff
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.