Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions scripts/build-docker-img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@
#
# SPDX-License-Identifier: BSD-3-Clause

set -e
#set -e

cmd_p=$(which podman)
cmd_d=$(which docker)

if [ ! -z $cmd_p ]; then
echo "Use podman ..."
cmd=$cmd_p
elif [ ! -z $cmd_d ]; then
echo "Use docker ..."
cmd=$cmd_d
else
echo "Error:Please install docker or podman firstly!"
exit 1
fi

# See if we can migrate data from Old docker image if existing
./check-and-migrate.sh
./check-and-migrate.sh $cmd

VERSION_SCRIPT=$(dirname "${BASH_SOURCE[0]}")/version.sh
. ${VERSION_SCRIPT}
Expand Down Expand Up @@ -54,7 +68,7 @@ DOCKER_OPTIONS+=" -f ${USE_THIS_DOCKERFILE} "
DOCKER_OPTIONS+=" -t $CURRENT_DOCKER_IMAGE_TAG"

# Build docker image
docker $DOCKER_OPTIONS $*
$cmd $DOCKER_OPTIONS $*

echo -e "\nBuilt or updated the docker image, now installing or configuring Core tools\n"

Expand Down
9 changes: 5 additions & 4 deletions scripts/check-and-migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@

RENAME_TAG=hyp-dev-term:1.10
OLD_TAG=hyp:dev-term
cmd=$1

OLD_TAG_ID=`docker images --format="{{.Repository}}:{{.Tag}} {{.ID}}" | grep "hyp:dev-term" | cut -d " " -f 2`
NEW_TAG_ID=`docker images --format="{{.Repository}}:{{.Tag}} {{.ID}}" | grep "hyp-dev-term" | cut -d " " -f 2`
OLD_TAG_ID=`$cmd images --format="{{.Repository}}:{{.Tag}} {{.ID}}" | grep "hyp:dev-term" | cut -d " " -f 2`
NEW_TAG_ID=`$cmd images --format="{{.Repository}}:{{.Tag}} {{.ID}}" | grep "hyp-dev-term" | cut -d " " -f 2`

# If old tag exists then extract the volumes and discard it
if [[ ! -z $OLD_TAG_ID ]]; then
# Tag the old image to newer format
docker image tag $OLD_TAG $RENAME_TAG
$cmd image tag $OLD_TAG $RENAME_TAG

# Remove old tag
docker image rm $OLD_TAG
$cmd image rm $OLD_TAG
echo "Renamed old tag to new format, now the tag for old image is $RENAME_TAG"

echo ""
Expand Down
17 changes: 15 additions & 2 deletions scripts/new-term.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
#
# SPDX-License-Identifier: BSD-3-Clause

set -e
#set -e
cmd_p=$(which podman)
cmd_d=$(which docker)

if [ ! -z $cmd_p ]; then
echo "Use podman ..."
cmd=$cmd_p
elif [ ! -z $cmd_d ]; then
echo "Use docker ..."
cmd=$cmd_d
else
echo "Error:Please install docker or podman firstly!"
exit 1
fi

VERSION_SCRIPT=$(dirname "${BASH_SOURCE[0]}")/version.sh
. ${VERSION_SCRIPT}
Expand All @@ -13,4 +26,4 @@ if [[ -z "$DOCKER_TAG" ]]; then
DOCKER_TAG=" hyp-dev-term:${CURRENT_VER} "
fi

docker exec -it `docker ps | grep "${DOCKER_TAG}" | cut -d ' ' -f 1` /bin/bash
$cmd exec -it `$cmd ps | grep "${DOCKER_TAG}" | cut -d ' ' -f 1` /bin/bash
19 changes: 17 additions & 2 deletions scripts/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
#
# SPDX-License-Identifier: BSD-3-Clause

set -e
#set -e

cmd_p=$(which podman)
cmd_d=$(which docker)

if [ ! -z $cmd_p ]; then
echo "Use podman ..."
cmd=$cmd_p
elif [ ! -z $cmd_d ]; then
echo "Use docker ..."
cmd=$cmd_d
else
echo "Error:Please install docker or podman firstly!"
exit 1
fi

VERSION_SCRIPT=$(dirname "${BASH_SOURCE[0]}")/version.sh
. ${VERSION_SCRIPT}
Expand All @@ -19,6 +33,7 @@ if [[ -z "${HOST_TO_DOCKER_SHARED_DIR}" ]]; then
HOST_TO_DOCKER_SHARED_DIR=`pwd`
fi


# add as many port mappings required as a single entry or a range
if [[ -z "$NO_PORT_MAP" ]]; then
#PORT_MAPPINGS=" -p 1234-1235:1234-1235 "
Expand All @@ -32,7 +47,7 @@ if [[ -z "$DOCKER_TAG" ]]; then
DOCKER_TAG=" hyp-dev-term:${CURRENT_VER} "
fi

docker run --privileged -h ${DOCKER_MACHINE_NAME} -it \
$cmd run --privileged -h ${DOCKER_MACHINE_NAME} -it \
${PORT_MAPPINGS} \
${ADDITIONAL_DOCKER_ARGS} \
-v tools-vol:/usr/local/mnt \
Expand Down
1 change: 1 addition & 0 deletions scripts/utils/build-crosvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -e
if [[ ! -f ./crosvm ]]; then
echo "Building crosvm from folder `pwd`"
cd ./crosvm-src
mount --make-shared /
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an unrelated change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No! It is used to fix build error when I use podman container to build this images

./tools/dev_container sh -c "cargo build --features gunyah --target aarch64-unknown-linux-gnu --release --no-default-features && cp /scratch/cargo_target/aarch64-unknown-linux-gnu/release/crosvm ."

echo "Completed building crosvm binary, copying to parent folder"
Expand Down