[buildd-tools-devel] schroot variables

shawn wilson ag4ve.us at gmail.com
Thu Oct 10 19:31:26 UTC 2013


I want to change the path where schroot looks for what to copy.
However, I'm getting a strange error:
 % schroot -c test -- ls /
E: 19basefs: error: copyfiles file '/etc/schroot/copy/test' does not exist
E: test-eb5cb9ea-cee1-49f5-a82d-9a334ad61b69: Chroot setup failed:
stage=setup-start
 % ls -l /etc/schroot/copy/test
-rw-r--r-- 1 root root 8 Oct 10 05:26 /etc/schroot/copy/test

# schroot.conf
[test]
type=directory
description=Test
users=swilson
directory=/opt/schroot/test
profile=default
setup.basefs=base/test
setup.copyfiles=copy/test

I see setup.d/20copyfile tests -n and -f - both should be true:
swlap1 /etc/schroot # cat copy/test
/bin/ls
swlap1 /etc/schroot # ls -l copy/test
-rw-r--r-- 1 root root 8 Oct 10 05:26 copy/test

I'm guessing I'm not doing something or setup.copyfiles is incorrect?
The goal is to have the profile be the same and just modify the
copyfiles and basefs. basefs, which I created 19basefs for but isn't
getting to that branch because I don't have a base/test yet. However,
as soon as I touch base/test, and try to start, I get:
E: 19basefs: error: copyfiles file '/etc/schroot/copy/test' does not exist
E: test-e8d69f6a-a158-41e9-bff7-8831eb258c34: Chroot setup failed:
stage=setup-start

(Minor modifications to handle directories which I see issues with,
but it isn't what I'm seeing, so....)

## 20copyfile

#!/bin/sh
# Copyright © 2005-2007  Roger Leigh <rleigh at debian.org>
#
# schroot is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# schroot is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################

set -e

. "$SETUP_DATA_DIR/common-data"
. "$SETUP_DATA_DIR/common-functions"
. "$SETUP_DATA_DIR/common-config"

if [ "$VERBOSE" = "verbose" ]; then
    CP_VERBOSE="--verbose"
fi

# Copy a file if the source and destination differ
# $1: source file
# $2: destination file
copy_file()
{
    if [ -e "$1" ]; then

        COPY="true"

        if [ -e "$2" ]; then

            # Device and inode
            da=$(/usr/bin/stat --format="%d %i" "$1")
            # This one can fail since it might not exist yet
            db=$(/usr/bin/stat --format="%d %i" "$2" 2>/dev/null || :)

            if [ "$da" = "$db" ]; then
                COPY="false"
            elif [ -L "$2" ]; then
                # Copy if destination is a symlink
                :
            elif [ -f "$1" ] && [ -f "$2" ]; then
                # Content
                ca=$(/usr/bin/md5sum "$1" | sed -e
's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
                cb=$(/usr/bin/md5sum "$2" 2>/dev/null || :)
                cb=$(echo "$cb" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
                # Copy only if file contents differ
                if [ "$ca" = "$cb" ]; then
                    COPY="false"
                fi
            fi
        fi

        # Copy only if files are different
        if [ "$COPY" = "true" ]; then
            if [ -f "$1" ]; then
                cp --preserve=all $CP_VERBOSE "$1" "$2"

                # Copy libraries if the file is executable
                if [ -n $(file -i "$1" | grep 'application' >
/dev/null 2>&1) ]; then
                    libs=$(ldd "$1" | grep -Po '([-a-zA-Z0-9_\/\.]+)'
| grep -P '\/.*\.so')
                    while read lib; do
                        copy_file "$lib" "${CHROOT_PATH}$lib"
                    done < "$libs"
                fi
            else
                # Copy non-regular file directly
                cp -a $CP_VERBOSE "$1" "$2"
            fi
        fi

    else
        fatal "Not copying nonexistent file: $file"
    fi
}

if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then

    if [ -n "$SETUP_COPYFILES" ]; then
        if [ -f "$SETUP_COPYFILES" ]; then
            while read path; do
                if echo "$file" | egrep -q '^(#|$)' ; then
                    continue
                fi

                while read file; do
                    if echo "$file" | grep -q '^/'; then
                        copy_file "$file" "${CHROOT_PATH}$file"
                    else
                        warn "Not copying file with relative path: $file"
                    fi
                done < "$(find $path -type f)"
            done < "$SETUP_COPYFILES"
        else
            fatal "copyfiles file '$SETUP_COPYFILES' does not exist"
        fi
    fi

fi



More information about the Buildd-tools-devel mailing list