Skip to content

Commit 1b3dd08

Browse files
committed
Initial Travis-CI YML and build script for CentOS 7.
1 parent 159759f commit 1b3dd08

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if: tag IS present
2+
os: linux
3+
dist: bionic
4+
language: shell
5+
addons:
6+
apt:
7+
packages:
8+
- qemu-utils
9+
script:
10+
- chmod +x ./build.sh
11+
- ./build.sh
12+
deploy:
13+
provider: releases
14+
edge: true
15+
token:
16+
secure: EekgmyJgs39xNpuJV3vpS+VPrLjupCsiXYTfJfOpKhDtyJfG1PkgRbW/wZ2kkJBNFZyThLoCqkVwaey0i8wd7uXlh5H84cHi7w/jIqGMuqtpjT0CRDNmfEK9nf2uitUPdBwwsyqQA0cHrGZlE6jYlkApID9++AWo6MFp1wlpOULXR0IwjQYl0A6PlplN4+BOV+7ayy7uhPdP93R2i6ySscwUct2zSHWuD9sibur6XIDcoXK0LsElLJ6qguNFzntR/5PvikcRhb1E9/KLkjKfvF7YphGFh/0Y3ruchZPx28wOxNXXrmkkxK6Rn9jDifNzcRgDIGrkngVy7jFMkR6WwFTuSWZSRCnRA/vp3ObEUNDtPF2yS7lvr/OAYNRpjA829DRmcbuGJJX/f5YViTXSroMKmKfr657heXtV0907wmFL0j1kn/JpJBhAUzhAen5SQfzDKeiqn5uEPbUzUxDEifOD6x37E+2Qb197fM5G6HIdcPJQ7gUkARH9aKegG7/SUhRyQz/jLEGVA641iVXnXWq3g22wgqaBS04ldLY+TPa13IDCrktXVKIhu4M2jz3VAFPsKQvcAdWykR2GAOxW0+KkRzJ5RFm1glZbxFpa1a3t41KlVsCeCPf7+VZ9sDoIj9ImNP8ZBXyfqYp6CCvrZ0Ixei2UFf0el7yO5YbMIfQ=
17+
file: 'wsl/dist/*.zip'
18+
on:
19+
repo: mishamosher/CentOS-WSL
20+
tags: true
21+
all_branches: true

build.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
# Environment variables for the CentOS cloud image
4+
ARCH="x86_64"
5+
OS_VER="7"
6+
ROOTFS_VER="2003"
7+
ROOTFS_FN="CentOS-${OS_VER}-${ARCH}-GenericCloud-${ROOTFS_VER}.qcow2"
8+
ROOTFS_URL="http://cloud.centos.org/centos/${OS_VER}/images/${ROOTFS_FN}"
9+
10+
# Environment variables for Yuk7's wsldl
11+
LNCR_BLD="20040300"
12+
LNCR_ZIP="icons.zip"
13+
LNCR_NAME="CentOS"
14+
LNCR_FN=${LNCR_NAME}.exe
15+
LNCR_ZIPFN=${LNCR_NAME}${OS_VER}.exe
16+
LNCR_URL="https://github.com/yuk7/wsldl/releases/download/${LNCR_BLD}/${LNCR_ZIP}"
17+
18+
# Waits until a file appears or disappears
19+
# - $1 File path to wait for its existence
20+
# - [$2] The string 'a' to wait until the file appears, or 'd' to wait until the file disappears
21+
# - [$3] Timeout in seconds
22+
waitFile() {
23+
local START=$(cut -d '.' -f 1 /proc/uptime)
24+
local MODE=${2:-"a"}
25+
until [[ "${MODE}" = "a" && -e "$1" ]] || [[ "${MODE}" = "d" && ( ! -e "$1" ) ]]; do
26+
sleep 1s
27+
if [ -n "$3" ]; then
28+
local NOW=$(cut -d '.' -f 1 /proc/uptime)
29+
local ELAPSED=$(( NOW - START ))
30+
if [ $ELAPSED -ge "$3" ]; then break; fi
31+
fi
32+
done
33+
}
34+
35+
# Create a work dir
36+
mkdir wsl
37+
cd wsl
38+
39+
# Download the CentOS cloud image and Yuk7's WSLDL
40+
wget --no-verbose ${ROOTFS_URL} -O ${ROOTFS_FN}
41+
wget --no-verbose ${LNCR_URL} -O ${LNCR_ZIP}
42+
43+
# Extract the CentOS WSL launcher
44+
unzip ${LNCR_ZIP} ${LNCR_FN}
45+
46+
# Clean up
47+
rm ${LNCR_ZIP}
48+
49+
# Mount the qcow2 image
50+
sudo mkdir mntfs
51+
sudo modprobe nbd
52+
sudo qemu-nbd -c /dev/nbd0 --read-only ./${ROOTFS_FN}
53+
waitFile /dev/nbd0p1 "a" 30
54+
sudo mount -o ro /dev/nbd0p1 mntfs
55+
56+
# Clone the qcow2 image contents to a writable directory
57+
sudo cp -a mntfs rootfs
58+
59+
# Unmount the qcow2 image
60+
sudo umount mntfs
61+
sudo qemu-nbd -d /dev/nbd0
62+
waitFile /dev/nbd0p1 "d" 30
63+
sudo rmmod nbd
64+
sudo rmdir mntfs
65+
66+
# Clean up
67+
rm ${ROOTFS_FN}
68+
69+
# Create a tar.gz of the rootfs
70+
sudo tar -zcpf rootfs.tar.gz -C ./rootfs .
71+
sudo chown "$(id -un)" rootfs.tar.gz
72+
73+
# Clean up
74+
sudo rm -rf rootfs
75+
76+
# Create the distribution zip of WSL CentOS
77+
mkdir out
78+
mkdir dist
79+
mv -f ${LNCR_FN} ./out/${LNCR_ZIPFN}
80+
mv -f rootfs.tar.gz ./out/
81+
pushd out
82+
zip -r ../dist/CentOS${OS_VER}.zip ./*
83+
popd
84+
85+
# Clean up
86+
rm -rf out

0 commit comments

Comments
 (0)