~ubuntu-branches/ubuntu/maverick/schroot/maverick-updates

« back to all changes in this revision

Viewing changes to sbuild/sbuild-chroot.cc

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2008-01-20 22:51:04 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20080120225104-3zhs8gk9byqigato
Tags: 1.1.6-1
* New upstream development release.
* Acknowledge NMU.  Thanks to Lucas Nussbaum for fixing the Boost
  library names following another incompatible change in Boost
  (Closes: #439215).
* debian/control: Suggest lvm2 instead of lvm-common (Closes: #452263).
* debian/copyright:
  - Update with new GIT source code repository location.
  - Update licence to GPLv3.
* debian/schroot.init: Update licence to GPLv3.
* bin/schroot/setup/20network, bin/schroot/setup/30passwd: For files to
  copy, compare file device, inode and contents to avoid copying
  identical files (Closes: #428808).
* If unknown keys are present in the configuration file, print a warning
  message to alert the user (Closes: #459658).
* The filesystems to mount in the chroot may be customised by the system
  administrator through the use of an fstab file on a per-chroot basis,
  and a new helper utility, schroot-mount (Closes: #395062, #427047).
  Thanks for your patience while we took the time to implement this the
  right way.
* Update Vietnamese translation (Closes: #461531).  Thanks to Clytie
  Siddall.
* debian/schroot.preinst: Add rm_conffile function to remove
  /etc/schroot/setup.d/20network and /etc/schroot/setup.d/30passwd for
  versions prior to this.  These are replaced by
  /etc/schroot/setup.d/20copyfiles.
* debian/schroot.NEWS: Document conffile changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
 
1
/* Copyright © 2005-2008  Roger Leigh <rleigh@debian.org>
2
2
 *
3
 
 * schroot is free software; you can redistribute it and/or modify it
 
3
 * schroot is free software: you can redistribute it and/or modify it
4
4
 * under the terms of the GNU General Public License as published by
5
 
 * the Free Software Foundation; either version 2 of the License, or
 
5
 * the Free Software Foundation, either version 3 of the License, or
6
6
 * (at your option) any later version.
7
7
 *
8
8
 * schroot is distributed in the hope that it will be useful, but
11
11
 * General Public License for more details.
12
12
 *
13
13
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program; if not, write to the Free Software
15
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16
 
 * MA  02111-1307  USA
 
14
 * along with this program.  If not, see
 
15
 * <http://www.gnu.org/licenses/>.
17
16
 *
18
17
 *********************************************************************/
19
18
 
27
26
#include "sbuild-chroot-lvm-snapshot.h"
28
27
#include "sbuild-lock.h"
29
28
 
30
 
#include <algorithm>
31
29
#include <cerrno>
32
30
#include <map>
33
 
#include <set>
34
31
#include <utility>
35
32
 
36
33
#include <ext/stdio_filebuf.h>
62
59
      emap(sbuild::chroot::DEVICE_ABS,      N_("Device must have an absolute path")),
63
60
      emap(sbuild::chroot::DEVICE_LOCK,     N_("Failed to lock device")),
64
61
      emap(sbuild::chroot::DEVICE_NOTBLOCK, N_("File is not a block device")),
65
 
      emap(sbuild::chroot::DEVICE_STAT,     N_("Failed to stat device")),
66
62
      emap(sbuild::chroot::DEVICE_UNLOCK,   N_("Failed to unlock device")),
67
63
      emap(sbuild::chroot::FILE_ABS,        N_("File must have an absolute path")),
68
64
      emap(sbuild::chroot::FILE_LOCK,       N_("Failed to acquire file lock")),
69
65
      emap(sbuild::chroot::FILE_NOTREG,     N_("File is not a regular file")),
70
66
      emap(sbuild::chroot::FILE_OWNER,      N_("File is not owned by user root")),
71
67
      emap(sbuild::chroot::FILE_PERMS,      N_("File has write permissions for others")),
72
 
      emap(sbuild::chroot::FILE_STAT,       N_("Failed to stat file")),
73
68
      emap(sbuild::chroot::FILE_UNLOCK,     N_("Failed to discard file lock")),
74
69
      emap(sbuild::chroot::LOCATION_ABS,    N_("Location must have an absolute path")),
75
70
      // TRANSLATORS: unlink refers to the C function which removes a file
394
389
  env.add("CHROOT_PATH", get_path());
395
390
  env.add("CHROOT_MOUNT_DEVICE", get_mount_device());
396
391
  env.add("CHROOT_SCRIPT_CONFIG", normalname(std::string(PACKAGE_SYSCONF_DIR) +  '/' + get_script_config()));
 
392
  env.add("CHROOT_SESSION_CREATE",
 
393
          static_cast<bool>(get_session_flags() & SESSION_CREATE));
 
394
  env.add("CHROOT_SESSION_CLONE",
 
395
          static_cast<bool>(get_session_flags() & SESSION_CLONE));
 
396
  env.add("CHROOT_SESSION_PURGE",
 
397
          static_cast<bool>(get_session_flags() & SESSION_PURGE));
397
398
}
398
399
 
399
400
void
480
481
    .add(_("Run Execution Scripts"), get_run_exec_scripts())
481
482
    .add(_("Script Configuration"), get_script_config())
482
483
    .add(_("Session Managed"),
483
 
         static_cast<bool>(get_session_flags() & chroot::SESSION_CREATE));
 
484
         static_cast<bool>(get_session_flags() & chroot::SESSION_CREATE))
 
485
    .add(_("Session Cloned"),
 
486
         static_cast<bool>(get_session_flags() & chroot::SESSION_CLONE))
 
487
    .add(_("Session Purged"),
 
488
         static_cast<bool>(get_session_flags() & chroot::SESSION_PURGE));
484
489
 
485
490
  if (!get_command_prefix().empty())
486
491
    detail.add(_("Command Prefix"), get_command_prefix());
570
575
}
571
576
 
572
577
void
573
 
sbuild::chroot::set_keyfile (keyfile const& keyfile)
 
578
sbuild::chroot::set_keyfile (keyfile const& keyfile,
 
579
                             string_list&   used_keys)
574
580
{
 
581
  // Keys which are used elsewhere, but should be counted as "used".
 
582
  used_keys.push_back("type");
 
583
 
 
584
  string_list keys = keyfile.get_keys(get_name());
 
585
  for (string_list::const_iterator pos = keys.begin();
 
586
       pos != keys.end();
 
587
       ++pos)
 
588
    {
 
589
      static regex description_keys("^description\\[.*\\]$");
 
590
      if (regex_search(*pos, description_keys))
 
591
        used_keys.push_back(*pos);
 
592
    }
 
593
 
575
594
  // This is set not in the configuration file, but set in the keyfile
576
595
  // manually.  The user must not have the ability to set this option.
577
596
  keyfile::get_object_value(*this, &chroot::set_active,
578
597
                            keyfile, get_name(), "active",
579
598
                            keyfile::PRIORITY_REQUIRED);
 
599
  used_keys.push_back("active");
580
600
 
581
601
  keyfile::get_object_value(*this, &chroot::set_run_setup_scripts,
582
602
                            keyfile, get_name(), "run-setup-scripts",
583
603
                            keyfile::PRIORITY_OPTIONAL);
 
604
  used_keys.push_back("run-setup-scripts");
584
605
 
585
606
  keyfile::get_object_value(*this, &chroot::set_run_exec_scripts,
586
607
                            keyfile, get_name(), "run-session-scripts",
587
608
                            keyfile::PRIORITY_DEPRECATED);
 
609
  used_keys.push_back("run-session-scripts");
588
610
  keyfile::get_object_value(*this, &chroot::set_run_exec_scripts,
589
611
                            keyfile, get_name(), "run-exec-scripts",
590
612
                            keyfile::PRIORITY_OPTIONAL);
 
613
  used_keys.push_back("run-exec-scripts");
591
614
 
592
615
  keyfile::get_object_value(*this, &chroot::set_script_config,
593
616
                            keyfile, get_name(), "script-config",
594
617
                            keyfile::PRIORITY_OPTIONAL);
 
618
  used_keys.push_back("script-config");
595
619
 
596
620
  keyfile::get_object_value(*this, &chroot::set_priority,
597
621
                            keyfile, get_name(), "priority",
598
622
                            keyfile::PRIORITY_OPTIONAL);
 
623
  used_keys.push_back("priority");
599
624
 
600
625
  keyfile::get_object_list_value(*this, &chroot::set_aliases,
601
626
                                 keyfile, get_name(), "aliases",
602
627
                                 keyfile::PRIORITY_OPTIONAL);
 
628
  used_keys.push_back("aliases");
603
629
 
604
630
  keyfile::get_object_value(*this, &chroot::set_environment_filter,
605
631
                            keyfile, get_name(), "environment-filter",
606
632
                            keyfile::PRIORITY_OPTIONAL);
 
633
  used_keys.push_back("environment-filter");
607
634
 
608
635
  keyfile::get_object_value(*this, &chroot::set_description,
609
636
                            keyfile, get_name(), "description",
610
637
                            keyfile::PRIORITY_OPTIONAL);
 
638
  used_keys.push_back("description");
611
639
 
612
640
  keyfile::get_object_list_value(*this, &chroot::set_users,
613
641
                                 keyfile, get_name(), "users",
614
642
                                 keyfile::PRIORITY_OPTIONAL);
 
643
  used_keys.push_back("users");
615
644
 
616
645
  keyfile::get_object_list_value(*this, &chroot::set_groups,
617
646
                                 keyfile, get_name(), "groups",
618
647
                                 keyfile::PRIORITY_OPTIONAL);
 
648
  used_keys.push_back("groups");
619
649
 
620
650
  keyfile::get_object_list_value(*this, &chroot::set_root_users,
621
651
                                 keyfile, get_name(), "root-users",
622
652
                                 keyfile::PRIORITY_OPTIONAL);
 
653
  used_keys.push_back("root-users");
623
654
 
624
655
  keyfile::get_object_list_value(*this, &chroot::set_root_groups,
625
656
                                 keyfile, get_name(), "root-groups",
626
657
                                 keyfile::PRIORITY_OPTIONAL);
 
658
  used_keys.push_back("root-groups");
627
659
 
628
660
  keyfile::get_object_value(*this, &chroot::set_mount_location,
629
661
                            keyfile, get_name(), "mount-location",
630
662
                            get_active() ?
631
663
                            keyfile::PRIORITY_REQUIRED :
632
664
                            keyfile::PRIORITY_DISALLOWED);
 
665
  used_keys.push_back("mount-location");
633
666
 
634
667
  keyfile::get_object_value(*this, &chroot::set_mount_device,
635
668
                            keyfile, get_name(), "mount-device",
636
669
                            get_active() ?
637
670
                            keyfile::PRIORITY_OPTIONAL :
638
671
                            keyfile::PRIORITY_DISALLOWED);
 
672
  used_keys.push_back("mount-device");
639
673
 
640
674
  keyfile::get_object_list_value(*this, &chroot::set_command_prefix,
641
675
                                 keyfile, get_name(), "command-prefix",
642
676
                                 keyfile::PRIORITY_OPTIONAL);
 
677
  used_keys.push_back("command-prefix");
643
678
 
644
679
  keyfile::get_object_value(*this, &chroot::set_persona,
645
680
                            keyfile, get_name(), "personality",
646
681
                            keyfile::PRIORITY_OPTIONAL);
 
682
  used_keys.push_back("personality");
647
683
}