Roger Leigh <[EMAIL PROTECTED]> writes:

> For linux32 support on 64-bit arches, it would be nice if all commands
> run inside the chroot could be prefixed with "linux32".  This could be
> implemented more generally by adding the ability to prefix a command
> with a custom command on a per-chroot basis, by adding a
> "command-prefix" to the configuration file.

An updated patch is attached.  This one is against current CVS, rather
than the current release (which is in incoming).  It's the same as the
original except for ChangeLog and debian/changelog.


Regards,
Roger

-- 
Roger Leigh
                Printing on GNU/Linux?  http://gutenprint.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
? schroot/sbuild-sourcedeps.cc
? schroot/sbuild-sourcedeps.h
Index: ChangeLog
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/ChangeLog,v
retrieving revision 1.253
diff -u -r1.253 ChangeLog
--- ChangeLog	27 Feb 2006 12:31:52 -0000	1.253
+++ ChangeLog	27 Feb 2006 12:33:15 -0000
@@ -1,5 +1,22 @@
 2006-02-27  Roger Leigh  <[EMAIL PROTECTED]>
 
+	* schroot/schroot.conf.5.in: Document "command-prefix" option.
+
+	* schroot/sbuild-session.cc
+	(run_child): Concatenate command_prefix and command to get the
+	command to run in the chroot.
+
+	* schroot/sbuild-chroot.cc
+	(get_command_prefix): New method to get command prefix.
+	(set_command_prefix): New method to set command prefix.
+	(print_details): Display command_prefix if set.
+	(get_keyfile): Set command-prefix in keyfile.
+	(set_keyfile): Get command-prefix from keyfile.
+
+	* schroot/sbuild-chroot.h: New member command_prefix.
+
+2006-02-27  Roger Leigh  <[EMAIL PROTECTED]>
+
 	* Remove bashisms in all setup and run shell scripts (test "-o"
 	and "function" in shell functions).  Thanks to Clint Adams for
 	this patch.
Index: schroot/sbuild-chroot.cc
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot.cc,v
retrieving revision 1.31
diff -u -r1.31 sbuild-chroot.cc
--- schroot/sbuild-chroot.cc	26 Feb 2006 21:48:49 -0000	1.31
+++ schroot/sbuild-chroot.cc	27 Feb 2006 12:33:15 -0000
@@ -41,7 +41,8 @@
   mount_device(),
   active(false),
   run_setup_scripts(false),
-  run_session_scripts(false)
+  run_session_scripts(false),
+  command_prefix()
 {
 }
 
@@ -225,6 +226,18 @@
   this->run_session_scripts = run_session_scripts;
 }
 
+string_list const&
+sbuild::chroot::get_command_prefix () const
+{
+  return this->command_prefix;
+}
+
+void
+sbuild::chroot::set_command_prefix (string_list const& command_prefix)
+{
+  this->command_prefix = command_prefix;
+}
+
 void
 sbuild::chroot::setup_env (environment& env)
 {
@@ -318,6 +331,9 @@
 			   static_cast<bool>(get_session_flags() &
 					     chroot::SESSION_CREATE));
 
+  if (!get_command_prefix().empty())
+    stream << format_details(_("Command Prefix"), get_command_prefix());
+
   /* Non user-settable properties are listed last. */
   if (!get_location().empty())
     stream << format_details(_("Location"),
@@ -371,6 +387,9 @@
   if (get_active())
     keyfile.set_value(this->name, "mount-device",
 		      get_mount_device());
+
+  keyfile.set_list_value(this->name, "command-prefix",
+			 get_command_prefix());
 }
 
 void
@@ -431,6 +450,11 @@
 			keyfile::PRIORITY_OPTIONAL : keyfile::PRIORITY_DISALLOWED,
 			mount_device))
     set_mount_device(mount_device);
+
+  string_list command_prefix;
+  if (keyfile.get_list_value(this->name, "command-prefix",
+			     keyfile::PRIORITY_OPTIONAL, command_prefix))
+    set_command_prefix(command_prefix);
 }
 
 /*
Index: schroot/sbuild-chroot.h
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot.h,v
retrieving revision 1.50
diff -u -r1.50 sbuild-chroot.h
--- schroot/sbuild-chroot.h	24 Feb 2006 20:26:07 -0000	1.50
+++ schroot/sbuild-chroot.h	27 Feb 2006 12:33:16 -0000
@@ -314,6 +314,24 @@
     set_run_session_scripts (bool run_session_scripts);
 
     /**
+     * Get the command_prefix for the chroot.  This is a command to
+     * prefix to any command run in the chroot.
+     *
+     * @returns the command prefix.
+     */
+    string_list const&
+    get_command_prefix () const;
+
+    /**
+     * Set the command_prefix for the chroot.  This is a command to
+     * prefix to any command run in the chroot.
+     *
+     * @param command_prefix the command prefix.
+     */
+    void
+    set_command_prefix (string_list const& command_prefix);
+
+    /**
      * Get the type of the chroot.
      *
      * @returns the chroot type.
@@ -559,6 +577,8 @@
     bool          run_setup_scripts;
     /// Run session setup scripts?
     bool          run_session_scripts;
+    /// Command prefix.
+    string_list   command_prefix;
   };
 
 }
Index: schroot/sbuild-session.cc
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-session.cc,v
retrieving revision 1.38
diff -u -r1.38 sbuild-session.cc
--- schroot/sbuild-session.cc	25 Feb 2006 12:06:20 -0000	1.38
+++ schroot/sbuild-session.cc	27 Feb 2006 12:33:17 -0000
@@ -667,7 +667,13 @@
   /* Run login shell */
   std::string file;
 
-  string_list command = get_command();
+  string_list command(session_chroot->get_command_prefix());
+  string_list const& command_suffix = get_command();
+  for (string_list::const_iterator pos = command_suffix.begin();
+       pos != command_suffix.end();
+       ++pos)
+    command.push_back(*pos);
+
   if (command.empty() ||
       command[0].empty()) // No command
     {
Index: schroot/schroot.conf.5.in
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/schroot.conf.5.in,v
retrieving revision 1.29
diff -u -r1.29 schroot.conf.5.in
--- schroot/schroot.conf.5.in	25 Feb 2006 12:06:20 -0000	1.29
+++ schroot/schroot.conf.5.in	27 Feb 2006 12:33:17 -0000
@@ -74,7 +74,7 @@
 example, a chroot named \[lq]sid\[rq] might have an \[lq]unstable\[rq] alias
 for convenience.
 .TP
-.B run-setup-scripts=\fItrue\fP|\fIfalse\fP
+.B run\-setup\-scripts=\fItrue\fP|\fIfalse\fP
 Set whether chroot setup scripts will be run.  The default is not to run setup
 scripts (\[lq]false\[rq]), for safety reasons (so it won't clobber your passwd
 and other critical files).  The default for session-managed chroots
@@ -85,9 +85,15 @@
 true session management, because it does not make a copy of the chroot).  If
 your chroots are exclusively controlled by schroot, set to \[lq]true\[rq].
 .TP
-.B run-session-scripts=\fItrue\fP|\fIfalse\fP
+.B run\-session\-scripts=\fItrue\fP|\fIfalse\fP
 Set whether chroot session scripts will be run.  The default is are the same as
 for the \fIrun-setup-scripts\fP key.
+.TP
+.B command\-prefix=\fIcommand,option1,option2,...\fP
+A comma-separated list of a command and the options for the command.  This
+command and its options will be prefixed to all commands run inside the chroot.
+For example, if set to \[lq]linux32\[rq], this will cause all commands run in
+the chroot to have a \fBlinux32\fP prefix added.
 .SS
 Plain chroots
 .PP

Attachment: pgpBVW8tYvBCO.pgp
Description: PGP signature

Reply via email to