tags 354257 + patch thanks Hi,
I have now implemented this suggestion, and I have attached a diff for you. This should apply to the 0.2.4 source tarball at people.debian.org/~rleigh/. Otherwise, you could always apply it directly to CVS (http://alioth.debian.org/scm/?group_id=30471 module schroot). If you enable "run-setup-scripts" for a "plain" chroot, it will now start a session (try schroot -l --all-sessions"), and you can use -b/-r/-e properly. 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.
Index: ChangeLog =================================================================== RCS file: /cvsroot/buildd-tools/schroot/ChangeLog,v retrieving revision 1.244 diff -u -r1.244 ChangeLog --- ChangeLog 24 Feb 2006 20:26:07 -0000 1.244 +++ ChangeLog 25 Feb 2006 00:09:33 -0000 @@ -1,3 +1,28 @@ +2006-02-25 Roger Leigh <[EMAIL PROTECTED]> + + * Update tests. + + * schroot/setup/10mount: Allow plain chroots to run the mount + script. For plain chroots, bind mount LOCATION on MOUNT_LOCATION. + + * schroot/setup/00check: For plain chroots, verify + CHROOT_LOCATION, rather than CHROOT_PATH (because CHROOT_PATH does + not exist at this point). + + * schroot/sbuild-session.cc + (run_impl): In addition to all other chroot types, if chroot is a + chroot_plain chroot with setup scripts enabled, set the mount + location to the session id. + + * schroot/sbuild-chroot-plain.cc + (get_path): New virtual method to override base class + implementation. When setup scripts are enabled, return the mount + location, or else the location. + (setup_lock): When setup scripts are enabled, write out a session + metadata. + (get_session_flags): When setup scripts are enabled, enable + SESSION_CREATE, or else 0. + 2006-02-24 Roger Leigh <[EMAIL PROTECTED]> * schroot/schroot.conf.5.in: Document "location" for block-device Index: schroot/sbuild-chroot-plain.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot-plain.cc,v retrieving revision 1.21 diff -u -r1.21 sbuild-chroot-plain.cc --- schroot/sbuild-chroot-plain.cc 24 Feb 2006 20:26:07 -0000 1.21 +++ schroot/sbuild-chroot-plain.cc 25 Feb 2006 00:09:33 -0000 @@ -56,6 +56,17 @@ chroot::set_location(location); } +std::string +chroot_plain::get_path () const +{ + // When running setup scripts, we are session-capable, so the path + // is the bind-mounted location, rather than the original location. + if (get_run_setup_scripts() == true) + return get_mount_location(); + else + return get_location(); +} + std::string const& chroot_plain::get_chroot_type () const { @@ -77,12 +88,25 @@ bool lock) { /* By default, plain chroots do no locking. */ + /* Create or unlink session information. */ + if (get_run_setup_scripts() == true) + { + if ((type == SETUP_START && lock == true) || + (type == SETUP_STOP && lock == false)) + { + bool start = (type == SETUP_START); + setup_session_info(start); + } + } } sbuild::chroot::session_flags chroot_plain::get_session_flags () const { - return static_cast<session_flags>(0); + if (get_run_setup_scripts() == true) + return SESSION_CREATE; + else + return static_cast<session_flags>(0); } void Index: schroot/sbuild-chroot-plain.h =================================================================== RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot-plain.h,v retrieving revision 1.19 diff -u -r1.19 sbuild-chroot-plain.h --- schroot/sbuild-chroot-plain.h 24 Feb 2006 20:26:07 -0000 1.19 +++ schroot/sbuild-chroot-plain.h 25 Feb 2006 00:09:33 -0000 @@ -59,6 +59,9 @@ virtual void set_location (std::string const& location); + virtual std::string + get_path () const; + virtual std::string const& get_chroot_type () const; Index: schroot/sbuild-session.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-session.cc,v retrieving revision 1.37 diff -u -r1.37 sbuild-session.cc --- schroot/sbuild-session.cc 24 Feb 2006 20:26:07 -0000 1.37 +++ schroot/sbuild-session.cc 25 Feb 2006 00:09:34 -0000 @@ -323,13 +323,16 @@ /* If a chroot mount location has not yet been set, and the chroot is not a plain chroot, set a mount location with the session id. */ - if (chroot->get_mount_location().empty() && - dynamic_cast<chroot_plain *>(chroot.get()) == 0) - { - std::string location(std::string(SCHROOT_MOUNT_DIR) + "/" + - this->session_id); - chroot->set_mount_location(location); - } + { + chroot_plain *plain = dynamic_cast<chroot_plain *>(chroot.get()); + if (chroot->get_mount_location().empty() && + (plain == 0 || plain->get_run_setup_scripts() == true)) + { + std::string location(std::string(SCHROOT_MOUNT_DIR) + "/" + + this->session_id); + chroot->set_mount_location(location); + } + } /* Chroot types which create a session (e.g. LVM devices) need the chroot name respecifying. */ Index: schroot/setup/00check =================================================================== RCS file: /cvsroot/buildd-tools/schroot/schroot/setup/00check,v retrieving revision 1.11 diff -u -r1.11 00check --- schroot/setup/00check 24 Feb 2006 20:26:07 -0000 1.11 +++ schroot/setup/00check 25 Feb 2006 00:09:34 -0000 @@ -33,8 +33,8 @@ case "$CHROOT_TYPE" in plain) - if [ ! -d "$CHROOT_PATH" ]; then - echo "$CHROOT_PATH does not exist" + if [ ! -d "$CHROOT_LOCATION" ]; then + echo "$CHROOT_LOCATION does not exist" exit 1 fi ;; Index: schroot/setup/10mount =================================================================== RCS file: /cvsroot/buildd-tools/schroot/schroot/setup/10mount,v retrieving revision 1.8 diff -u -r1.8 10mount --- schroot/setup/10mount 24 Feb 2006 20:26:07 -0000 1.8 +++ schroot/setup/10mount 25 Feb 2006 00:09:34 -0000 @@ -38,10 +38,12 @@ # FSCK_VERBOSE="-V" fi -if [ "$CHROOT_TYPE" = "file" -o "$CHROOT_TYPE" = "block-device" -o "$CHROOT_TYPE" = "lvm-snapshot" ]; then +if [ "$CHROOT_TYPE" = "plain" -o "$CHROOT_TYPE" = "file" -o "$CHROOT_TYPE" = "block-device" -o "$CHROOT_TYPE" = "lvm-snapshot" ]; then - # Until session management is introduced, the snapshot name is - # static. It should be fixed in SbuildSession. + if [ "$CHROOT_TYPE" = "plain" ]; then + CHROOT_MOUNT_OPTIONS="--bind" + CHROOT_MOUNT_DEVICE="$CHROOT_LOCATION" + fi if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then CHROOT_MOUNT_DEVICE="$CHROOT_LVM_SNAPSHOT_DEVICE" Index: test/sbuild-chroot-block-device.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/test/sbuild-chroot-block-device.cc,v retrieving revision 1.6 diff -u -r1.6 sbuild-chroot-block-device.cc --- test/sbuild-chroot-block-device.cc 24 Feb 2006 20:26:07 -0000 1.6 +++ test/sbuild-chroot-block-device.cc 25 Feb 2006 00:09:34 -0000 @@ -47,6 +47,7 @@ CPPUNIT_TEST(test_mount_options); CPPUNIT_TEST(test_chroot_type); CPPUNIT_TEST(test_setup_env); + CPPUNIT_TEST(test_session_flags); CPPUNIT_TEST(test_print_details); CPPUNIT_TEST(test_print_config); CPPUNIT_TEST_SUITE_END(); @@ -107,7 +108,7 @@ void test_session_flags() { CPPUNIT_ASSERT(chroot->get_session_flags() == - sbuild::chroot::SESSION_CREATE); + static_cast<sbuild::chroot::session_flags>(0)); } void test_print_details() Index: test/sbuild-chroot-file.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/test/sbuild-chroot-file.cc,v retrieving revision 1.6 diff -u -r1.6 sbuild-chroot-file.cc --- test/sbuild-chroot-file.cc 24 Feb 2006 20:26:07 -0000 1.6 +++ test/sbuild-chroot-file.cc 25 Feb 2006 00:09:34 -0000 @@ -46,6 +46,7 @@ CPPUNIT_TEST(test_file); CPPUNIT_TEST(test_chroot_type); CPPUNIT_TEST(test_setup_env); + CPPUNIT_TEST(test_session_flags); CPPUNIT_TEST(test_print_details); CPPUNIT_TEST(test_print_config); CPPUNIT_TEST_SUITE_END(); Index: test/sbuild-chroot-lvm-snapshot.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/test/sbuild-chroot-lvm-snapshot.cc,v retrieving revision 1.6 diff -u -r1.6 sbuild-chroot-lvm-snapshot.cc --- test/sbuild-chroot-lvm-snapshot.cc 24 Feb 2006 20:26:07 -0000 1.6 +++ test/sbuild-chroot-lvm-snapshot.cc 25 Feb 2006 00:09:34 -0000 @@ -48,6 +48,7 @@ CPPUNIT_TEST(test_snapshot_options); CPPUNIT_TEST(test_chroot_type); CPPUNIT_TEST(test_setup_env); + CPPUNIT_TEST(test_session_flags); CPPUNIT_TEST(test_print_details); CPPUNIT_TEST(test_print_config); CPPUNIT_TEST_SUITE_END(); Index: test/sbuild-chroot-plain.cc =================================================================== RCS file: /cvsroot/buildd-tools/schroot/test/sbuild-chroot-plain.cc,v retrieving revision 1.6 diff -u -r1.6 sbuild-chroot-plain.cc --- test/sbuild-chroot-plain.cc 24 Feb 2006 20:26:07 -0000 1.6 +++ test/sbuild-chroot-plain.cc 25 Feb 2006 00:09:34 -0000 @@ -96,6 +96,10 @@ void test_session_flags() { CPPUNIT_ASSERT(chroot->get_session_flags() == + static_cast<sbuild::chroot::session_flags>(0)); + + chroot->set_run_setup_scripts(true); + CPPUNIT_ASSERT(chroot->get_session_flags() == sbuild::chroot::SESSION_CREATE); }
pgpYM9ZxUecMn.pgp
Description: PGP signature