Skip to content

Commit

Permalink
scripts: generate meta descriptor when creating kernel into capstan repo
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozaczuk committed Oct 24, 2019
1 parent 361bcbc commit d44e7c6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
37 changes: 26 additions & 11 deletions scripts/build-capstan-mpm-packages
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ build_osv_image() {
echo "-------------------------------------"
}

determine_platform() {
if [ -f /etc/os-release ]; then
PLATFORM=$(grep PRETTY_NAME /etc/os-release | cut -d = -f 2 | grep -o -P "[^\"]+")
elif [ -f /etc/lsb-release ]; then
PLATFORM=$(grep DISTRIB_DESCRIPTION /etc/lsb-release | cut -d = -f 2 | grep -o -P "[^\"]+")
else
PLATFORM="Unknown Linux"
fi
}

prepare_package() {
local app_or_module_name="$1"
local package_dir="$PACKAGES/$app_or_module_name"
Expand Down Expand Up @@ -124,19 +134,13 @@ prepare_package() {
package_version="1.0.0"
fi

if [ -f /etc/os-release ]; then
platform=$(grep PRETTY_NAME /etc/os-release | cut -d = -f 2 | grep -o -P "[^\"]+")
elif [ -f /etc/lsb-release ]; then
platform=$(grep DISTRIB_DESCRIPTION /etc/lsb-release | cut -d = -f 2 | grep -o -P "[^\"]+")
else
platform="Unknown Linux"
fi
determine_platform

rm -rf $package_dir
mkdir -p $package_dir

cd $package_dir && $CAPSTAN package init --name "$package_name" --title "$package_title" \
--author "Anonymous" --version "$package_version" --platform "$platform"
--author "Anonymous" --version "$package_version" --platform "$PLATFORM"

if [ -f "$module_yaml" ]; then
grep -P '^require:|^-' $module_yaml >> $package_dir/meta/package.yaml
Expand Down Expand Up @@ -225,6 +229,14 @@ build_osv_image_loader_and_bootstrap_package() {
#Copy loader.img as osv-loader.qemu
mkdir -p $CAPSTAN_LOCAL_REPO/repository/osv-loader/
cp -a $OSV_BUILD/loader.img $CAPSTAN_LOCAL_REPO/repository/osv-loader/osv-loader.qemu
determine_platform
cat << EOF > $CAPSTAN_LOCAL_REPO/repository/osv-loader/index.yaml
format_version: "1"
version: "$OSV_VERSION"
created: $(date +'%Y-%m-%d %H:%M')
description: "OSv kernel"
platform: "$PLATFORM"
EOF

# Create bootstrap package
prepare_package empty
Expand Down Expand Up @@ -289,7 +301,7 @@ build_openjdk11-zulu-package() {
# OTHER
#----------------

build_kernel_and_standard_osv_apps() {
build_kernel_and_standard_osv_modules() {
ASK=1
build_osv_image_loader_and_bootstrap_package

Expand Down Expand Up @@ -369,8 +381,11 @@ build_test_apps() {

case "$1" in
kernel)
echo "Building kernel and standard apps ..."
build_kernel_and_standard_osv_apps;;
echo "Building kernel ..."
build_osv_image_loader_and_bootstrap_package;;
kernel_and_modules)
echo "Building kernel and standard modules ..."
build_kernel_and_standard_osv_modules;;
jdk)
echo "Building Java 8 and 11 JREs ..."
build_java_jdk_packages;;
Expand Down
25 changes: 25 additions & 0 deletions scripts/tests/compose_and_test_selected_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
OSV_DIR=$(readlink -f $(dirname $0)/../..)
CAPSTAN_REPO=$HOME/.capstan

OSV_VERSION=$($OSV_DIR/scripts/osv-version.sh | cut -d - -f 1 | grep -Po "[^v]*")
OSV_COMMIT=$($OSV_DIR/scripts/osv-version.sh | grep -Po "\-g.*" | grep -oP "[^-g]*")

if [ "$OSV_COMMIT" != "" ]; then
OSV_VERSION="$OSV_VERSION-$OSV_COMMIT"
fi

argv0=${0##*/}
usage() {
cat <<-EOF
Expand Down Expand Up @@ -40,6 +47,16 @@ shift $((OPTIND - 1))
TEST_APP_PACKAGE_NAME="$1"
TEST_OSV_APP_NAME="$2"

determine_platform() {
if [ -f /etc/os-release ]; then
PLATFORM=$(grep PRETTY_NAME /etc/os-release | cut -d = -f 2 | grep -o -P "[^\"]+")
elif [ -f /etc/lsb-release ]; then
PLATFORM=$(grep DISTRIB_DESCRIPTION /etc/lsb-release | cut -d = -f 2 | grep -o -P "[^\"]+")
else
PLATFORM="Unknown Linux"
fi
}

compose_test_app()
{
local APP_NAME=$1
Expand All @@ -66,6 +83,14 @@ compose_test_app()
if [ "$LOADER" != "osv-loader" ]; then
mkdir -p "$CAPSTAN_REPO/repository/$LOADER"
cp -a $OSV_DIR/build/last/loader.img "$CAPSTAN_REPO/repository/$LOADER/$LOADER.qemu"
determine_platform
cat << EOF > $CAPSTAN_REPO/repository/$LOADER/index.yaml
format_version: "1"
version: "$OSV_VERSION"
created: $(date +'%Y-%m-%d %H:%M')
description: "OSv kernel"
platform: "$PLATFORM"
EOF
LOADER_OPTION="--loader_image $LOADER"
echo "Using latest OSv kernel from $OSV_DIR/build/last/loader.img !"
fi
Expand Down

0 comments on commit d44e7c6

Please sign in to comment.