-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Travis-CI YML and build script for CentOS 7.
- Loading branch information
1 parent
159759f
commit 1b3dd08
Showing
2 changed files
with
107 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
if: tag IS present | ||
os: linux | ||
dist: bionic | ||
language: shell | ||
addons: | ||
apt: | ||
packages: | ||
- qemu-utils | ||
script: | ||
- chmod +x ./build.sh | ||
- ./build.sh | ||
deploy: | ||
provider: releases | ||
edge: true | ||
token: | ||
secure: EekgmyJgs39xNpuJV3vpS+VPrLjupCsiXYTfJfOpKhDtyJfG1PkgRbW/wZ2kkJBNFZyThLoCqkVwaey0i8wd7uXlh5H84cHi7w/jIqGMuqtpjT0CRDNmfEK9nf2uitUPdBwwsyqQA0cHrGZlE6jYlkApID9++AWo6MFp1wlpOULXR0IwjQYl0A6PlplN4+BOV+7ayy7uhPdP93R2i6ySscwUct2zSHWuD9sibur6XIDcoXK0LsElLJ6qguNFzntR/5PvikcRhb1E9/KLkjKfvF7YphGFh/0Y3ruchZPx28wOxNXXrmkkxK6Rn9jDifNzcRgDIGrkngVy7jFMkR6WwFTuSWZSRCnRA/vp3ObEUNDtPF2yS7lvr/OAYNRpjA829DRmcbuGJJX/f5YViTXSroMKmKfr657heXtV0907wmFL0j1kn/JpJBhAUzhAen5SQfzDKeiqn5uEPbUzUxDEifOD6x37E+2Qb197fM5G6HIdcPJQ7gUkARH9aKegG7/SUhRyQz/jLEGVA641iVXnXWq3g22wgqaBS04ldLY+TPa13IDCrktXVKIhu4M2jz3VAFPsKQvcAdWykR2GAOxW0+KkRzJ5RFm1glZbxFpa1a3t41KlVsCeCPf7+VZ9sDoIj9ImNP8ZBXyfqYp6CCvrZ0Ixei2UFf0el7yO5YbMIfQ= | ||
file: 'wsl/dist/*.zip' | ||
on: | ||
repo: mishamosher/CentOS-WSL | ||
tags: true | ||
all_branches: true |
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,86 @@ | ||
#!/bin/bash | ||
|
||
# Environment variables for the CentOS cloud image | ||
ARCH="x86_64" | ||
OS_VER="7" | ||
ROOTFS_VER="2003" | ||
ROOTFS_FN="CentOS-${OS_VER}-${ARCH}-GenericCloud-${ROOTFS_VER}.qcow2" | ||
ROOTFS_URL="http://cloud.centos.org/centos/${OS_VER}/images/${ROOTFS_FN}" | ||
|
||
# Environment variables for Yuk7's wsldl | ||
LNCR_BLD="20040300" | ||
LNCR_ZIP="icons.zip" | ||
LNCR_NAME="CentOS" | ||
LNCR_FN=${LNCR_NAME}.exe | ||
LNCR_ZIPFN=${LNCR_NAME}${OS_VER}.exe | ||
LNCR_URL="https://github.com/yuk7/wsldl/releases/download/${LNCR_BLD}/${LNCR_ZIP}" | ||
|
||
# Waits until a file appears or disappears | ||
# - $1 File path to wait for its existence | ||
# - [$2] The string 'a' to wait until the file appears, or 'd' to wait until the file disappears | ||
# - [$3] Timeout in seconds | ||
waitFile() { | ||
local START=$(cut -d '.' -f 1 /proc/uptime) | ||
local MODE=${2:-"a"} | ||
until [[ "${MODE}" = "a" && -e "$1" ]] || [[ "${MODE}" = "d" && ( ! -e "$1" ) ]]; do | ||
sleep 1s | ||
if [ -n "$3" ]; then | ||
local NOW=$(cut -d '.' -f 1 /proc/uptime) | ||
local ELAPSED=$(( NOW - START )) | ||
if [ $ELAPSED -ge "$3" ]; then break; fi | ||
fi | ||
done | ||
} | ||
|
||
# Create a work dir | ||
mkdir wsl | ||
cd wsl | ||
|
||
# Download the CentOS cloud image and Yuk7's WSLDL | ||
wget --no-verbose ${ROOTFS_URL} -O ${ROOTFS_FN} | ||
wget --no-verbose ${LNCR_URL} -O ${LNCR_ZIP} | ||
|
||
# Extract the CentOS WSL launcher | ||
unzip ${LNCR_ZIP} ${LNCR_FN} | ||
|
||
# Clean up | ||
rm ${LNCR_ZIP} | ||
|
||
# Mount the qcow2 image | ||
sudo mkdir mntfs | ||
sudo modprobe nbd | ||
sudo qemu-nbd -c /dev/nbd0 --read-only ./${ROOTFS_FN} | ||
waitFile /dev/nbd0p1 "a" 30 | ||
sudo mount -o ro /dev/nbd0p1 mntfs | ||
|
||
# Clone the qcow2 image contents to a writable directory | ||
sudo cp -a mntfs rootfs | ||
|
||
# Unmount the qcow2 image | ||
sudo umount mntfs | ||
sudo qemu-nbd -d /dev/nbd0 | ||
waitFile /dev/nbd0p1 "d" 30 | ||
sudo rmmod nbd | ||
sudo rmdir mntfs | ||
|
||
# Clean up | ||
rm ${ROOTFS_FN} | ||
|
||
# Create a tar.gz of the rootfs | ||
sudo tar -zcpf rootfs.tar.gz -C ./rootfs . | ||
sudo chown "$(id -un)" rootfs.tar.gz | ||
|
||
# Clean up | ||
sudo rm -rf rootfs | ||
|
||
# Create the distribution zip of WSL CentOS | ||
mkdir out | ||
mkdir dist | ||
mv -f ${LNCR_FN} ./out/${LNCR_ZIPFN} | ||
mv -f rootfs.tar.gz ./out/ | ||
pushd out | ||
zip -r ../dist/CentOS${OS_VER}.zip ./* | ||
popd | ||
|
||
# Clean up | ||
rm -rf out |