-
Notifications
You must be signed in to change notification settings - Fork 6
/
debootstrap_architecture_template.yml
188 lines (149 loc) · 6.96 KB
/
debootstrap_architecture_template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
jobs:
- job: startAgent
variables:
AWS_INSTANCE_ID: ${{ parameters.aws_instance_id }}
condition: ne(variables['AWS_INSTANCE_ID'], '')
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadSecureFile@1
name: awsCredentials
inputs:
secureFile: 'credentials'
- task: DownloadSecureFile@1
name: awsConfig
inputs:
secureFile: 'config'
- script: |
mkdir -p "${HOME}/.aws"
cp "$(awsCredentials.secureFilePath)" "${HOME}/.aws/credentials"
cp "$(awsConfig.secureFilePath)" "${HOME}/.aws/config"
displayName: 'Copy credentials'
- script: |
aws ec2 start-instances --instance-ids $(AWS_INSTANCE_ID)
displayName: 'Start instance'
- job: ${{ parameters.arch }}
${{ if ne(parameters.aws_instance_id, '') }}:
dependsOn: [ startAgent ]
pool:
${{ if ne(parameters.pool_name, '') }}:
name: ${{ parameters.pool_name }}
${{ if ne(parameters.pool_vmImage, '') }}:
vmImage: ${{ parameters.pool_vmImage }}
variables:
PREBOOTSTRAP_ARCH: ${{ parameters.arch }}
PREBOOTSTRAP_QEMU_ARCH: ${{ parameters.qemu_arch }}
PREBOOTSTRAP_RELEASE: bookworm
AWS_INSTANCE_ID: ${{ parameters.aws_instance_id }}
steps:
- script: |
sudo apt-get update -y -q
sudo apt-get install -y -q curl gnupg debootstrap qemu-user-static
displayName: 'Installing build dependencies'
- script: |
sudo rm -rf rootfs
mkdir rootfs
displayName: 'Creating rootfs folder'
- script: |
sudo bash -c "debootstrap --verbose --variant=minbase --foreign --arch=$(PREBOOTSTRAP_ARCH) \
--include=sudo,locales,git,ssh,gnupg,apt-transport-https,wget,ca-certificates,less,curl,bash-completion,vim,\
man-db,socat,gcc-12-base,iputils-ping,dos2unix,psmisc,rsync,iproute2,apt-utils \
$(PREBOOTSTRAP_RELEASE) ./rootfs/"
displayName: 'Using debootstrap to create rootfs'
- script: |
# shellcheck disable=SC2164
cd rootfs
sudo mkdir -p sys
sudo mkdir -p proc
sudo mkdir -p dev/pts
sudo mount --bind /dev dev/
sudo mount --bind /sys sys/
sudo mount --bind /proc proc/
sudo mount --bind /dev/pts dev/pts/
displayName: 'Entering chroot to mount dev, sys, proc and dev/pts'
- script: |
sudo cp /usr/bin/qemu-"$(PREBOOTSTRAP_QEMU_ARCH)"-static rootfs/usr/bin/
displayName: Copy static QEMU to rootfs
- script: |
sudo chmod +x rootfs/usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static
displayName: Marking static [rootfs/usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static] as executable
- script: |
sudo chroot rootfs/ /bin/bash -c "/debootstrap/debootstrap --second-stage --verbose"
displayName: Manually setting up debootstrap
- script: |
sudo cp linux_files/profile rootfs/etc/profile
sudo chmod 644 rootfs/etc/profile
displayName: 'Installing default profile'
- script: |
sudo cp linux_files/setup rootfs/etc/setup
displayName: 'Installing Pengwin bootstrap script'
- script: |
sudo chroot rootfs/ /bin/bash -c "bash /etc/setup --silent --install --debug"
displayName: 'Running Pengwin bootstrap script'
- script: |
sudo chroot rootfs/ /bin/bash -c "echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen"
sudo chroot rootfs/ /bin/bash -c "update-locale LANGUAGE=en_US.UTF-8 LC_ALL=C"
displayName: 'Configuring language settings'
- script: |
sudo chroot rootfs/ /bin/bash -c "echo 'Defaults lecture_file = /etc/sudoers.lecture' >> /etc/sudoers"
sudo chroot rootfs/ /bin/bash -c "echo 'Enter your UNIX password below. This is not your Windows password.' > /etc/sudoers.lecture"
displayName: 'Configuring sudo message'
- script: |
sudo chroot rootfs/ apt-get -y -q install xclip gnome-themes-extra gtk2-engines-murrine dbus dbus-x11 mesa-utils libqt5core5a binutils libnss3 libegl1-mesa mesa-vdpau-drivers mesa-vulkan-drivers mesa-va-drivers vainfo nano
sudo chroot rootfs/ /bin/bash -c "yes 'N' | apt-get -y -q dist-upgrade"
sudo chroot rootfs/ strip --remove-section=.note.ABI-tag /usr/lib/$(PREBOOTSTRAP_QEMU_ARCH)-linux-gnu/libQt5Core.so.5
displayName: 'Installing additional packages'
- script: |
sudo chroot rootfs/ apt-get -y -q autoremove
sudo chroot rootfs/ apt-get -y -q autoclean
sudo chroot rootfs/ apt-get -y -q clean
displayName: 'Clean up apt cache'
- script: |
sudo chroot rootfs/ /bin/bash -c "echo 'source /etc/vim/vimrc' > /etc/skel/.vimrc"
sudo chroot rootfs/ /bin/bash -c "echo 'syntax on' >> /etc/skel/.vimrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set background=dark' >> /etc/skel/.vimrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set visualbell' >> /etc/skel/.vimrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set noerrorbells' >> /etc/skel/.vimrc"
sudo chroot rootfs/ /bin/bash -c "echo '\$include /etc/inputrc' > /etc/skel/.inputrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set bell-style none' >> /etc/skel/.inputrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set show-all-if-ambiguous on' >> /etc/skel/.inputrc"
sudo chroot rootfs/ /bin/bash -c "echo 'set show-all-if-unmodified on' >> /etc/skel/.inputrc"
displayName: 'Add defaults for readline and vim'
- script: |
sudo rm rootfs/usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static
displayName: Deleting QEMU from chroot
- script: |
cd rootfs && sudo tar -zcvf $(Build.ArtifactStagingDirectory)/install_$(PREBOOTSTRAP_ARCH)_rootfs.tar.gz --exclude proc --exclude dev --exclude sys --exclude='boot/*' ./*
displayName: 'Compressing rootfs'
- script: |
sudo cp /usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static rootfs/usr/bin/
displayName: Copy static QEMU to rootfs
- script: |
sudo chmod +x rootfs/usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static
displayName: Marking static [rootfs/usr/bin/qemu-$(PREBOOTSTRAP_QEMU_ARCH)-static] as executable
- script: |
cd rootfs
sudo mkdir -p sys
sudo mkdir -p proc
sudo mkdir -p dev/pts
sudo mount --bind /dev dev/
sudo mount --bind /sys sys/
sudo mount --bind /proc proc/
sudo mount --bind /dev/pts dev/pts/
cd ..
condition: ne('${{ parameters.pool_vmImage }}', '')
displayName: 'Entering chroot to mount dev, sys, proc and dev/pts'
- script: |
sudo chroot rootfs/ /bin/bash -c "git clone https://github.com/WhitewaterFoundry/pengwin-setup.git"
sudo chroot rootfs/ /bin/bash -c "cd pengwin-setup && git checkout development && cd -"
sudo chroot rootfs/ /bin/bash -c "cp -r pengwin-setup/tests /usr/local/bin/ && chmod -R +x /usr/local/bin/tests"
sudo chroot rootfs/ /bin/bash -c "cd /usr/local/bin/tests && source ./install_shunit2.sh && ./run_tests.sh"
displayName: Run unit tests
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'rootfs/usr/local/bin/tests/results/*.xml'
- task: PublishBuildArtifacts@1
- script: |
sudo shutdown -r 1
displayName: Clean up