-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathsetup-ci-artifacts.sh
executable file
·48 lines (40 loc) · 1.38 KB
/
setup-ci-artifacts.sh
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
#!/bin/bash
# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# fail if we encounter an error, uninitialized variable or a pipe breaks
set -eu -o pipefail
TOOLS_DIR=$(dirname $0)
source "$TOOLS_DIR/functions"
say "Setup CI artifacts"
cd build/img/$(uname -m)
say "Fix executable permissions"
find "firecracker" -type f |xargs chmod -c 755
say "Generate SSH key to connect from host"
if [ ! -s id_rsa ]; then
ssh-keygen -f id_rsa -N ""
fi
for SQUASHFS in *.squashfs; do
say "Include SSH key in $SQUASHFS"
RSA=$(basename $SQUASHFS .squashfs).id_rsa
EXT4=$(basename $SQUASHFS .squashfs).ext4
[ -s $SQUASHFS.orig ] && continue
unsquashfs $SQUASHFS
mkdir -pv squashfs-root/root/.ssh
# copy the SSH key into the rootfs
if [ ! -s $RSA ]; then
# append SSH key to the squashfs image
cp -v id_rsa.pub squashfs-root/root/.ssh/authorized_keys
cp -v id_rsa $RSA
fi
# re-squash
mv -v $SQUASHFS $SQUASHFS.orig
mksquashfs squashfs-root $SQUASHFS -all-root -noappend -comp zstd
# Create rw ext4 image from ro squashfs
[ -f $EXT4 ] && continue
say "Converting $SQUASHFS to $EXT4"
truncate -s 400M $EXT4
mkfs.ext4 -F $EXT4 -d squashfs-root
rm -rf squashfs-root
done
say "Uncompress debuginfo files"
find . -name "*.debug.gz" -print0 | xargs -P4 -0 -t -n1 gunzip