3
# add (already existing) user to sudoers and create passwd/group
4
# entries and a work directory for the user in the chroot
7
echo >&2 "Usage: add_sbuild_user </path/to/chroot> <dist> <user>"
8
echo >&2 " <dist> is one of stable, testing, unstable"
12
if [ $# -ne 3 ]; then usage; fi
17
if [ ! -d $CHROOT/etc ]; then
18
echo >&2 "..$CHROOT doesn't appear to be a chroot"
22
if [ $DIST != stable -a $DIST != testing -a $DIST != unstable ]; then
23
echo >&2 "..\"$DIST\" not an allowed distribution"
27
if ! getent passwd $USR >/dev/null; then
28
echo >&2 "..no such user: $USR"
34
You must manually add $USR to /etc/sudoers:
36
# visudo -- run this command as root and add the following lines:
38
$USR ALL=NOPASSWD: ALL
39
Defaults:$USR env_keep+="APT_CONFIG DEBIAN_FRONTEND SHELL"
41
You can do this in another shell or by suspending this script with
42
^Z (fg to return when done).
3
# Copyright (C) 2006-2007 Roger Leigh <rleigh@debian.org>
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.
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.
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
25
print STDERR "Usage: $0 <username>\n";
29
usage() if (@ARGV < 1);
34
my $user = getpwnam($_);
37
$status += system("/usr/sbin/adduser", "$_", "sbuild");
39
print STDERR "W: User \"$_\" does not exist\n";
47
Next, copy the example sbuildrc file to the user's home directory and
48
set the variables for your system:
45
echo -n "Continue? (Y/n) "
48
if [ x$ANS != xY -a x$ANS != xy -a x$ANS != x ]; then
52
echo ..adding $USR to sbuild group
55
echo ..copy sudoers to chroot
56
cp /etc/sudoers $CHROOT/etc/sudoers
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
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
68
echo ..create chroot work directory for $USR
69
mkdir -p $CHROOT/build/$USR
70
chown $USR:sbuild $CHROOT/build/$USR
72
echo ..create chroot home directory for $USR
73
HOMEDIR="$CHROOT$(getent passwd $USR | awk -v FS=":" '{ print $6 }')"
75
chown $USR:sbuild $HOMEDIR
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.
85
ln -s $CHROOT ~$USR/build/chroot-$DIST
87
You may also want to add this symlink to more easily find your
88
chroot work directory:
90
ln -s $HOMEDIR ~$USR/build/chbuild
92
Copy the example sbuildrc file to your home directory and set
93
the variables for your system.
95
cp /usr/share/doc/sbuild/examples/example.sbuildrc ~/.sbuildrc
53
my $home = (getpwnam($_))[7];
54
print STDERR " cp /usr/share/doc/sbuild/examples/example.sbuildrc $home/.sbuildrc\n";
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
106
------------------------------------------------------------------------
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>