echo ceph-$os_type-$os_version
}
-function get_branch() {
- git rev-parse --abbrev-ref HEAD
-}
-
function compile_ubuntu() {
cat <<EOF
set -ex
fi
}
+function get_upstream() {
+ git rev-parse --show-toplevel
+}
+
function get_downstream() {
local os_type=$1
local os_version=$2
local image=$(get_image_name $os_type $os_version)
- local root=$(git rev-parse --show-toplevel)
- local dir=$(dirname $root)
- local upstream=$(basename $root)
+ local upstream=$(get_upstream)
+ local dir=$(dirname $upstream)
echo "$dir/$image"
}
local os_version=$2
local image=$(get_image_name $os_type $os_version)
- local root=$(git rev-parse --show-toplevel)
- local branch=$(get_branch)
- local dir=$(dirname $root)
- local upstream=$(basename $root)
+ local upstream=$(get_upstream)
+ local dir=$(dirname $upstream)
local downstream=$(get_downstream $os_type $os_version)
+ local commit=$(git rev-parse HEAD)
(
cd $dir
if ! test -d $downstream ; then
- git clone $upstream $downstream || return 1
- cd $downstream
- git checkout -b docker-build origin/$branch || return 1
- git submodule update --init || return 1
- else
- cd $downstream
+ # Inspired by https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir
+ mkdir -p $downstream/.git || return 1
+ for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache
+ do
+ case $x in
+ */*)
+ mkdir -p "$downstream/.git/$x"
+ ;;
+ esac
+ ln -s "$upstream/.git/$x" "$downstream/.git/$x"
+ cp "$upstream/.git/HEAD" "$downstream/.git/HEAD"
+ done
fi
- git fetch origin
- git reset --hard origin/$branch || return 1
+ cd $downstream
+ git reset --hard $commit || return 1
+ git submodule sync || return 1
+ git submodule update --init || return 1
)
}
setup_container $os_type $os_version "$opts" || return 1
local downstream=$(get_downstream $os_type $os_version)
local image=$(get_image_name $os_type $os_version)
+ local upstream=$(get_upstream)
local ccache
if test -d $HOME/.ccache ; then
ccache="--volume $HOME/.ccache:$HOME/.ccache"
else
user=
fi
- local cmd="docker run $opts --rm --name $image --privileged $ccache --volume $downstream:$downstream"
+ local cmd="docker run $opts --rm --name $image --privileged $ccache"
+ cmd+=" --volume $downstream:$downstream"
+ cmd+=" --volume $upstream:$upstream"
local status=0
if test "$script" = "bash" ; then
$cmd --tty --interactive --workdir $downstream $user $dev $image bash