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

« back to all changes in this revision

Viewing changes to bin/schroot/setup/20copyfiles

  • 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
#!/bin/sh
 
2
# Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
 
3
#
 
4
# schroot is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, either version 3 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# schroot is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
# General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see
 
16
# <http://www.gnu.org/licenses/>.
 
17
#
 
18
#####################################################################
 
19
 
 
20
set -e
 
21
 
 
22
if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
 
23
  . "$CHROOT_SCRIPT_CONFIG"
 
24
fi
 
25
 
 
26
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
27
  VERBOSE="--verbose"
 
28
fi
 
29
 
 
30
# Copy a file if the source and destination differ
 
31
# $1: source file
 
32
# $2: destination file
 
33
copy_file()
 
34
{
 
35
    if [ -r "$1" ]; then
 
36
        if [ -r "$2" ]; then
 
37
 
 
38
            # Device and inode
 
39
            da=$(/usr/bin/stat --format="%d %i" "$1")
 
40
            db=$(/usr/bin/stat --format="%d %i" "$2")
 
41
 
 
42
            # Content
 
43
            ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
 
44
            cb=$(/usr/bin/md5sum "$2" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
 
45
 
 
46
            # Copy if files are different
 
47
            if [ "$da" != "$db" ]; then
 
48
                if [ "$ca" != "$cb" ]; then
 
49
                    cp $VERBOSE "$1" "$2"
 
50
                fi
 
51
            fi
 
52
 
 
53
        else
 
54
 
 
55
            # Copy if destination file does not exist
 
56
            cp $VERBOSE "$1" "$2"
 
57
 
 
58
        fi
 
59
 
 
60
    else
 
61
        echo "W: Not copying nonexistent file: $file"
 
62
    fi
 
63
}
 
64
 
 
65
if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
 
66
    while read file ; do
 
67
        if echo "$file" | grep -q '^/'; then
 
68
            copy_file "$file" "${CHROOT_PATH}$file"
 
69
        else
 
70
            echo "W: Not copying file with relative path: $file"
 
71
        fi
 
72
    done < "$COPYFILES"
 
73
fi
 
74