Fixes to docker routine and error handling

This commit is contained in:
Vitaly Parakhin 2015-05-12 18:04:36 +03:00
parent 5dc5aae400
commit b27d1e1030
2 changed files with 37 additions and 17 deletions

View File

@ -469,12 +469,15 @@ rm -f "$fuel_config_temp"
# Generate list of MOS dependencies
export apt_altstate=`mktemp -d --suffix="-apt-altstate"`
export FUEL_BRANCH
export BINROOT
if [[ "$DOCKER_MODE" = "true" ]]; then
if [[ "$DOCKER_MODE" = "true" ]]; then
( docker ps -a | grep fuel-createmirror ) && docker rm -f fuel-createmirror
# docker pull ubuntu:latest
docker -D run --net=bridge --rm -a stdout -a stderr -i -t --privileged -e FUEL_BRANCH=$FUEL_BRANCH -e BINROOT=$BINROOT -e apt_altstate=$apt_altstate -v $BINROOT:$BINROOT:rw -v $apt_altstate:$apt_altstate:rw ubuntu:latest $BINROOT/util/partial_ubuntu.sh || fatal "Cannot calculate list of dependencies"
docker -D run -d --name=fuel-createmirror --net=host -a stdout -a stderr -i -t --privileged -e FUEL_BRANCH=$FUEL_BRANCH -e BINROOT=$BINROOT -e apt_altstate=$apt_altstate -v $BINROOT:$BINROOT:rw -v $apt_altstate:$apt_altstate:rw ubuntu:latest
dockerctl shell fuel-createmirror $BINROOT/util/partial_ubuntu.sh || fatal "Cannot calculate list of dependencies"
# cleanup ubuntu container
docker images | awk '/ubuntu/ { print $3; }' | xargs --no-run-if-empty docker rmi -f
docker rm -f fuel-createmirror
else
$BINROOT/util/partial_ubuntu.sh || fatal "Cannot calculate list of dependencies"
fi

View File

@ -77,24 +77,41 @@ fi
. $BINROOT/config/common.cfg
#mkdir -p ${MIRROR_ROOT} || die "Cannot create ${MIRROR_ROOT}, exiting."
#mkdir -p ${LOG_ROOT} || die "Cannot create ${LOG_ROOT}, exiting."
#[ "$1" != "ubuntu" ] && $BINROOT/deb-mirror $BINROOT/config/mos-ubuntu-updatesonly.cfg
#[ "$1" != "mos" ] && $BINROOT/deb-mirror $BINROOT/config/ubuntu.cfg
mkdir -p ${MIRROR_ROOT} || die "Cannot create ${MIRROR_ROOT}, exiting."
mkdir -p ${LOG_ROOT} || die "Cannot create ${LOG_ROOT}, exiting."
if [[ "$1" != "ubuntu" ]]; then
. $BINROOT/config/mos-ubuntu-updatesonly.cfg
echo " * INFO: MOS mirror was created at: $LOCAL_DIR"
print_repositories $LOCAL_DIR full
$BINROOT/deb-mirror $BINROOT/config/mos-ubuntu-updatesonly.cfg
EC_MOS=$?
fi
if [[ "$1" != "mos" ]]; then
. $BINROOT/config/ubuntu.cfg
if [[ $PARTIAL_UPSTREAM = "1" ]]; then
echo " * INFO: Ubuntu partial mirror was created at: $PARTIAL_UPSTREAM_PATH"
print_repositories $PARTIAL_UPSTREAM_PATH
else
echo " * INFO: Ubuntu mirror was created at: $LOCAL_DIR"
$BINROOT/deb-mirror $BINROOT/config/ubuntu.cfg
EC_UBUNTU=$?
fi
if [[ "$1" != "ubuntu" ]]; then
if [[ "$EC_MOS" == "0" ]]; then
. $BINROOT/config/mos-ubuntu-updatesonly.cfg
echo " * INFO: MOS mirror was created at: $LOCAL_DIR"
print_repositories $LOCAL_DIR full
else
echo " * FATAL: Creation of MOS mirror FAILED, check logs at $LOG_ROOT"
fi
fi
if [[ "$1" != "mos" ]]; then
if [[ "$EC_UBUNTU" == "0" ]]; then
. $BINROOT/config/ubuntu.cfg
if [[ $PARTIAL_UPSTREAM = "1" ]]; then
echo " * INFO: Ubuntu partial mirror was created at: $PARTIAL_UPSTREAM_PATH"
print_repositories $PARTIAL_UPSTREAM_PATH
else
echo " * INFO: Ubuntu mirror was created at: $LOCAL_DIR"
print_repositories $LOCAL_DIR full
fi
else
echo " * FATAL: Creation of Ubuntu mirror FAILED, check logs at $LOG_ROOT"
fi
fi
exit ( $EC_MOS || $EC_UBUNTU )