-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from balena-io/add-build-script
Add automation build script
- Loading branch information
Showing
5 changed files
with
113 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
Dockerfile | ||
.git | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,20 @@ | ||
# Use this dockerfile to build the qemu binary | ||
FROM debian:stretch | ||
|
||
FROM debian:jessie | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
autoconf \ | ||
bison \ | ||
build-essential \ | ||
flex \ | ||
libglib2.0-dev \ | ||
libtool \ | ||
make \ | ||
pkg-config \ | ||
python \ | ||
libpixman-1-dev \ | ||
zlib1g-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN apt-get -q update \ | ||
&& apt-get -qqy install \ | ||
build-essential \ | ||
zlib1g-dev \ | ||
libpixman-1-dev \ | ||
python \ | ||
libglib2.0-dev \ | ||
pkg-config \ | ||
curl \ | ||
jq \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/src/qemu | ||
|
||
COPY . /usr/src/qemu | ||
|
||
|
||
ARG TARGET_ARCH=arm-linux-user | ||
RUN ./configure --target-list=$TARGET_ARCH --static --extra-cflags="-DCONFIG_RTNETLINK" | ||
|
||
RUN make -j $(nproc) | ||
CMD ./build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Use this dockerfile to build the qemu binary | ||
|
||
FROM debian:jessie | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
autoconf \ | ||
bison \ | ||
build-essential \ | ||
flex \ | ||
libglib2.0-dev \ | ||
libtool \ | ||
make \ | ||
pkg-config \ | ||
python \ | ||
libpixman-1-dev \ | ||
zlib1g-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/src/qemu | ||
|
||
COPY . /usr/src/qemu | ||
|
||
|
||
ARG TARGET_ARCH=arm-linux-user | ||
RUN ./configure --target-list=$TARGET_ARCH --static --extra-cflags="-DCONFIG_RTNETLINK" | ||
|
||
RUN make -j $(nproc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
docker build -t qemu-builder . | ||
|
||
docker run --rm -e ACCOUNT=$ACCOUNT \ | ||
-e REPO=$REPO \ | ||
-e ACCESS_TOKEN=$ACCESS_TOKEN \ | ||
-e QEMU_VERSION=$QEMU_VERSION \ | ||
-e RELEASE_BRANCH=$RELEASE_BRANCH \ | ||
-e RELEASE_COMMIT=$RELEASE_COMMIT qemu-builder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
|
||
git checkout "$RELEASE_COMMIT" | ||
|
||
TARGETS="arm aarch64" | ||
|
||
for TARGET in $TARGETS; do | ||
BINARY_NAME="qemu-$TARGET-static" | ||
PACKAGE_NAME="qemu-$QEMU_VERSION-$TARGET" | ||
|
||
./configure --target-list="$TARGET-linux-user" --static --extra-cflags="-DCONFIG_RTNETLINK" \ | ||
&& make -j $(nproc) \ | ||
&& strip "$TARGET-linux-user/qemu-$TARGET" \ | ||
&& mkdir -p "$PACKAGE_NAME" \ | ||
&& cp "$TARGET-linux-user/qemu-$TARGET" "$PACKAGE_NAME/$BINARY_NAME" | ||
|
||
tar -cvzf "$PACKAGE_NAME.tar.gz" "$PACKAGE_NAME" | ||
done | ||
|
||
ARM_SHA256=$(sha256sum "qemu-$QEMU_VERSION-arm.tar.gz") | ||
AARCH64_SHA256=$(sha256sum "qemu-$QEMU_VERSION-aarch64.tar.gz") | ||
echo "arm: $ARM_SHA256, aarch64: $AARCH64_SHA256" | ||
|
||
if [ -z "$ACCOUNT" ] || [ -z "$REPO" ] || [ -z "$ACCESS_TOKEN" ]; then | ||
echo "Please set value for ACCOUNT, REPO and ACCESS_TOKEN!" | ||
exit 1 | ||
fi | ||
|
||
# Create a release | ||
rm -f request.json response.json | ||
cat > request.json <<-EOF | ||
{ | ||
"tag_name": "v$QEMU_VERSION", | ||
"target_commitish": "$RELEASE_BRANCH", | ||
"name": "v$QEMU_VERSION", | ||
"body": "Release of version v$QEMU_VERSION. \nqemu-$QEMU_VERSION-arm.tar.gz - SHA256: ${ARM_SHA256% *}. \nqemu-$QEMU_VERSION-aarch64.tar.gz - SHA256: ${AARCH64_SHA256% *}", | ||
"draft": false, | ||
"prerelease": false | ||
} | ||
EOF | ||
curl --data "@request.json" --header "Content-Type:application/json" \ | ||
"https://api.github.com/repos/$ACCOUNT/$REPO/releases?access_token=$ACCESS_TOKEN" \ | ||
-o response.json | ||
# Parse response | ||
RELEASE_ID=$(cat response.json | jq '.id') | ||
echo "RELEASE_ID=$RELEASE_ID" | ||
|
||
# Upload data | ||
curl -H "Authorization:token $ACCESS_TOKEN" -H "Content-Type:application/x-gzip" \ | ||
--data-binary "@qemu-$QEMU_VERSION-arm.tar.gz" \ | ||
"https://uploads.github.com/repos/$ACCOUNT/$REPO/releases/$RELEASE_ID/assets?name=qemu-$QEMU_VERSION-arm.tar.gz" | ||
|
||
# Upload data | ||
curl -H "Authorization:token $ACCESS_TOKEN" -H "Content-Type:application/x-gzip" \ | ||
--data-binary "@qemu-$QEMU_VERSION-aarch64.tar.gz" \ | ||
"https://uploads.github.com/repos/$ACCOUNT/$REPO/releases/$RELEASE_ID/assets?name=qemu-$QEMU_VERSION-aarch64.tar.gz" |