1
0
mirror of https://github.com/rancher/os.git synced 2025-09-09 02:31:36 +00:00

Refactor build

This commit is contained in:
Darren Shepherd
2021-08-31 11:14:03 -07:00
parent e38bab4144
commit 3040e886dc
56 changed files with 2098 additions and 292 deletions

8
scripts/ci Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd $(dirname $0)
./test
./validate
./package

11
scripts/entry Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
mkdir -p bin dist
if [ -e ./scripts/$1 ]; then
./scripts/"$@"
else
exec "$@"
fi
chown -R $DAPPER_UID:$DAPPER_GID .

34
scripts/package Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/..
export TAG
make iso
TARGETS="iso"
if [ -n "$DOCKER_PASSWORD" ]; then
docker login -u "$DOCKER_USERNAME" -p "${DOCKER_PASSWORD}"
PUSH=true
fi
if [ "$PUSH" = "true" ]; then
make push
fi
TARGETS=qcow
if [ "$PUSH" = "true" ] && [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
TARGETS="${TARGETS} all-amis"
fi
export GIT_COMMIT=${COMMIT}
make -j8 ${TARGETS}
mkdir -p dist
for i in build/output.*; do
mv -f $i dist/rancheros-${TAG}${i##build/output}
echo Built: dist/rancheros-${TAG}${i##build/output}
done

30
scripts/run Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
set -e -x
mkdir -p build
cd build
if [ ! -e disk.img ]; then
qemu-img create -f qcow2 disk.img 40g
fi
touch meta-data
touch user-data
rm -f seed.iso
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
#-bios /usr/share/qemu/OVMF.fd \
qemu-system-x86_64 \
-enable-kvm \
-m ${MEMORY:=4096} \
-machine accel=${ACCEL:="kvm"} \
-smp cores=4 \
-nographic \
-serial mon:stdio \
-rtc base=utc,clock=rt \
-chardev socket,path=qga.sock,server,nowait,id=qga0 \
-device virtio-serial \
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
-drive if=virtio,media=disk,file=disk.img \
-drive if=ide,media=cdrom,file=${1:-output.iso} \
-drive if=ide,media=cdrom,file=seed.iso

7
scripts/test Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running tests
go test -cover -tags=test ./...

21
scripts/validate Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running validation
PACKAGES="$(go list ./...)"
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi
echo Running validation
echo Running: golangci-lint
golangci-lint run
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"

27
scripts/version Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi
SUFFIX="-${ARCH}"
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
fi