~ubuntu-branches/ubuntu/hardy/sbuild/hardy

« back to all changes in this revision

Viewing changes to chroot/add_sbuild_user

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2007-05-18 17:46:31 UTC
  • Revision ID: james.westby@ubuntu.com-20070518174631-tvxpqt09n51bs589
Tags: 0.54
* debian/control:
  - Remove sudo from Depends.
  - Add schroot to Depends.
  - Remove schroot from Recommends.
  - Depend on dctrl-tools rather than the transitional grep-dctrl package.
    Thanks to Jonh Wendell (Closes: #417573).
* debian/rules:
  - Don't install sbuild.conf.local.
  - Install sbuild.conf into /etc/sbuild.
* debian/NEWS.Debian:
  - New file.
  - Document removal of manual source dependencies and sudo.
  - Document removal of support for building from a directory.
  - Document removal of building on the host system.
  - Document sudo->schroot migration.
  - Document change in $sbuild_mode default.
* debian/README.Debian:
  - Document removal of manual src-deps.
  - Remove requirements for chroot symlinks in working directory.
* sbuild:
  - Remove read_deps, so manual src-deps are no longer read.  The
    remainder of the manual src-deps support remains to be removed.
  - Quote all arguments to system commands such as "rm -rf", to prevent
    potential disasters.
  - Update copyrights, and encode in UTF-8.
  - Use "du -k -s" instead of "du -s" to increase portability.  Thanks to
    Martin Koeppe (Closes: #418061).
  - Compute package, version, directory and whether to download sources
    before calling fetch_source_files, because all the needed information
    is available at this point.
  - cleanup_packages:
    + Remove check for schroot when removing build dependencies, since
      schroot is the default.
    + Remove undo_specials().
  - build:
    + Remove do_apply_patches.
    + Replace "822-date" with "date -R".  Thanks to Guillem Jover for
      this patch (Closes: #415798).
    + Remove support for building from a directory.
    + Run dpkg-source from within the chroot.
    + Don't chdir before running dpkg-source.
    + Don't chdir before running dpkg-parsechangelog (do it in the
      schroot child process).
    + Remove obsolete code for running dpkg-buildpackage outside a chroot.
  - fetch_source_files:
    + Remove support for building from a directory.
    + Download sources directly into the chroot build directory.  For
      sources already existing outside the chroot, copy them into the
      chroot build directory.
    + Add extra directory, package, version and download arguments.
    + Only call dsc_md5sums once, rather than twice.
  - apply_patches: Remove.
  - get_special: Remove use of @main::global_patches.
  - Remove SVN Id:.
  - install_deps: Remove @special use.
  - unpack_special_source: Remove.
  - undo_specials: Remove.
  - filter_dependencies: Remove @special use.
  - run_script: Remove.
  - parse_one_srcdep: Remove @special use.
  - get_special: Remove.
  - write_srcdep_lock_file: Remove @special use.
  - check_srcdep_conflicts: Remove @special use.
  - dump_main_state: New function to dump the program state using
    Data::Dumper.  Use to dump the state after each build.
  - Add / separators to all users of $main::chroot_build_dir in paths.
  - Replace all users of regular expressions to strip the chroot dir
    from paths with strip_chroot_path.
  - get_dpkg_status: Print debugging messages with defined variables
    only, to avoid Perl warning.
  - verify_md5sums: Remove obsolete comment regarding chroots.
  - check_group_membership: New function to check the user is a member
    of the sbuild group (Closes: #414064).
  - Added new command-line argument --arch to specify the architecture,
    and pass this to begin_session (Closes: 410576).
* Sbuild/Chroot.pm:
  - Remove all special casing for sudo and schroot.  schroot is now the
    only supported method of accessing chroots.
  - end_session: Only attempt to end a session when $schroot_session is
    non-empty.
  - _setup_options:
    + Remove use of $chroot_only.
    + Remove trailing / from 'Build Location'.
  - init: Add newline to debugging message.
  - strip_chroot_path: New function to strip the chroot location from a
    path.
  - log_command: Correctly log commands when no APT Options stripping is
    needed.
  - get_command_internal: Set the working directory inside the chroot to
    the build location.
  - begin_session: take the architecture as a second argument, and check
    if a chroot specific for the architecture exists.
* Sbuild/Conf.pm:
  - Don't export $source_dependencies.
  - Don't define $source_dependencies.
  - Abort with an error if $source_dependencies is defined.
  - Don't export $sudo or $chroot_mode.
  - Don't define $sudo or $chroot_mode.
  - Remove sudo sanity checks.
  - Abort with an error if $sudo or $chroot_mode are defined.
  - Don't export $chroot_only.
  - Don't define $chroot_only.
  - Abort with an error if $chroot_only is defined.
  - Define and export %alternatives.  Thanks to Martin Koeppe
    (Closes: #418060).
  - Define and export @no_auto_upgrade and %watches.
  - Remove the requirement for /usr/share/sbuild/sbuild.conf.
  - Mark deprecated/obsolete variables for removal post-Lenny.
  - Set defaults from global sbuild.conf.
* sbuild.conf:
  - Remove $source_dependencies.
  - Remove $sudo.
  - Remove $chroot_only.
  - Add and document all options from Sbuild/Conf.pm.
  - Reorder into sections.
  - Merge with sbuild.conf.local, and install into /etc/sbuild.
* sbuild.conf.local:
  - Remove $source_dependencies.
  - Remove.
* example.sbuildrc:
  - Replace all options with documented options from sbuild.conf.
  - Add additional user-centric options from sbuild.conf.
  - Reorder into sections.
* sbuild.1.in: Document --arch and chroot search order.
* sbuild-setup.7.in:
  - Remove sudo setup.
  - Update user section to document sbuild group membership and
    add_sbuild_user.  Remove chroot setup, which is now handled by
    schroot (Closes: #413524).
* bin/README.bins: Remove sudo from extra package list.
* bin/updatechroot, bin/upgradechroot, bin/chrapt: Remove chroot_mode.
* chroot/add_sbuild_user:
  - Remove sudo setup instructions and copying of /etc/sudoers to the
    chroot.
  - Rewrite in perl.  Only call adduser; all other chroot setup is
    taken care of by the 50sbuild schroot chroot setup script
    (Closes: #413908).
* TODO: New file.  Document needed changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash 
2
 
#
3
 
# add (already existing) user to sudoers and create passwd/group
4
 
# entries and a work directory for the user in the chroot
5
 
 
6
 
usage () {
7
 
        echo >&2 "Usage: add_sbuild_user </path/to/chroot> <dist> <user>"
8
 
        echo >&2 "  <dist> is one of stable, testing, unstable"
9
 
        exit 1
10
 
}
11
 
 
12
 
if [ $# -ne 3 ]; then usage; fi
13
 
CHROOT=$1
14
 
DIST=$2
15
 
USR=$3
16
 
 
17
 
if [ ! -d $CHROOT/etc ]; then
18
 
        echo >&2 "..$CHROOT doesn't appear to be a chroot"
19
 
        exit 1
20
 
fi
21
 
 
22
 
if [ $DIST != stable -a $DIST != testing -a $DIST != unstable ]; then
23
 
        echo >&2 "..\"$DIST\" not an allowed distribution"
24
 
        usage
25
 
fi
26
 
 
27
 
if ! getent passwd $USR >/dev/null; then
28
 
        echo >&2 "..no such user: $USR"
29
 
        exit 1
30
 
fi
31
 
 
32
 
cat << EOF
33
 
 
34
 
You must manually add $USR to /etc/sudoers:
35
 
 
36
 
# visudo  -- run this command as root and add the following lines:
37
 
 
38
 
$USR ALL=NOPASSWD:  ALL
39
 
Defaults:$USR env_keep+="APT_CONFIG DEBIAN_FRONTEND SHELL"
40
 
 
41
 
You can do this in another shell or by suspending this script with
42
 
^Z (fg to return when done).
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# Copyright (C) 2006-2007 Roger Leigh <rleigh@debian.org>
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
18
 
 
19
use strict;
 
20
use warnings;
 
21
 
 
22
package main;
 
23
 
 
24
sub usage {
 
25
        print STDERR "Usage: $0 <username>\n";
 
26
        exit 1;
 
27
}
 
28
 
 
29
usage() if (@ARGV < 1);
 
30
 
 
31
my $status = 0;
 
32
 
 
33
foreach (@ARGV) {
 
34
        my $user = getpwnam($_);
 
35
 
 
36
        if (defined $user) {
 
37
                $status += system("/usr/sbin/adduser", "$_", "sbuild");
 
38
        } else {
 
39
                print STDERR "W: User \"$_\" does not exist\n";
 
40
                $status++;
 
41
        }
 
42
}
 
43
 
 
44
if ($status == 0) {
 
45
        print STDOUT <<EOF;
 
46
 
 
47
Next, copy the example sbuildrc file to the user's home directory and
 
48
set the variables for your system:
43
49
 
44
50
EOF
45
 
echo -n "Continue? (Y/n) "
46
 
 
47
 
read ANS
48
 
if [ x$ANS != xY -a x$ANS != xy -a x$ANS != x ]; then
49
 
        exit
50
 
fi
51
 
 
52
 
echo ..adding $USR to sbuild group
53
 
adduser $USR sbuild
54
 
 
55
 
echo ..copy sudoers to chroot
56
 
cp /etc/sudoers $CHROOT/etc/sudoers
57
 
 
58
 
echo ..add $USR to chroot /etc/passwd file
59
 
grep -v ^$USR: $CHROOT/etc/passwd >$CHROOT/etc/passwd.NEW
60
 
getent passwd $USR >> $CHROOT/etc/passwd.NEW
61
 
mv $CHROOT/etc/passwd.NEW $CHROOT/etc/passwd
62
 
 
63
 
echo ..add $USR to chroot /etc/group
64
 
grep -v ^sbuild: $CHROOT/etc/group >$CHROOT/etc/group.NEW
65
 
getent group sbuild >> $CHROOT/etc/group.NEW
66
 
mv $CHROOT/etc/group.NEW $CHROOT/etc/group
67
 
 
68
 
echo ..create chroot work directory for $USR
69
 
mkdir -p $CHROOT/build/$USR
70
 
chown $USR:sbuild $CHROOT/build/$USR
71
 
 
72
 
echo ..create chroot home directory for $USR
73
 
HOMEDIR="$CHROOT$(getent passwd $USR | awk -v FS=":" '{ print $6 }')"
74
 
mkdir -p $HOMEDIR
75
 
chown $USR:sbuild $HOMEDIR
76
 
 
77
 
cat << EOF
78
 
Successfully set up $CHROOT for ${USR}.
79
 
------------------------------------------------------------------------
80
 
You must create a symlink in base so that sbuild can find the
81
 
chroot, else sbuild will build in the base install.  Remember to
82
 
always run sbuild from that directory.
83
 
 
84
 
  mkdir ~$USR/build
85
 
  ln -s $CHROOT ~$USR/build/chroot-$DIST
86
 
 
87
 
You may also want to add this symlink to more easily find your
88
 
chroot work directory:
89
 
 
90
 
  ln -s $HOMEDIR ~$USR/build/chbuild
91
 
 
92
 
Copy the example sbuildrc file to your home directory and set
93
 
the variables for your system.
94
 
 
95
 
  cp /usr/share/doc/sbuild/examples/example.sbuildrc ~/.sbuildrc
 
51
 
 
52
        foreach (@ARGV) {
 
53
                my $home = (getpwnam($_))[7];
 
54
                print STDERR "  cp /usr/share/doc/sbuild/examples/example.sbuildrc $home/.sbuildrc\n";
 
55
        }
 
56
        print STDOUT <<EOF;
96
57
 
97
58
Now try a build:
98
59
 
99
 
  cd ~/build
100
 
  /usr/share/sbuild/chrapt $DIST apt-get update
101
 
  /usr/share/sbuild/chrapt $DIST apt-get upgrade
102
 
     - or "/usr/share/sbuild/chrapt $DIST apt-get -f install"
103
 
       first if the chroot is broken
104
 
  sbuild -v -d $DIST -p successful ed_0.2-20
105
 
 
106
 
------------------------------------------------------------------------
 
60
  cd /path/to/source
 
61
  /usr/share/sbuild/chrapt <distribution> apt-get update
 
62
  /usr/share/sbuild/chrapt <distribution> apt-get upgrade
 
63
  (or "/usr/share/sbuild/chrapt <distribution> apt-get -f install"
 
64
       first if the chroot is broken)
 
65
  sbuild -d <distribution> <package>_<version>
107
66
EOF
 
67
}
 
68
 
 
69
exit ($status ? 1:0);
108
70