Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option to allow running on docker-wsl containers, by manual partitions preparation #125

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ inputs:
description: 'Exports $GITHUB_ENV from the image environment to subsequent tasks'
required: false
default: 'no'
manual_partitions:
description: 'for docker, this option is required to manually set the partitions'
required: false
default: 'false'
outputs:
image:
description: "Path to image"
Expand Down Expand Up @@ -143,7 +147,7 @@ runs:
id: download_image
- name: Mount and optionally resize image
run: |
sudo --preserve-env=GITHUB_OUTPUT bash ${GITHUB_ACTION_PATH}/mount_image.sh ${{ steps.download_image.outputs.image }} ${{ inputs.image_additional_mb }} ${{ inputs.use_systemd_nspawn }} ${{ inputs.rootpartition }} ${{ inputs.bootpartition }}
sudo --preserve-env=GITHUB_OUTPUT bash ${GITHUB_ACTION_PATH}/mount_image.sh ${{ steps.download_image.outputs.image }} ${{ inputs.image_additional_mb }} ${{ inputs.use_systemd_nspawn }} ${{ inputs.rootpartition }} ${{ inputs.bootpartition }} ${{ inputs.manual_partitions }}
shell: bash
id: mount_image
- name: Mount CPU info
Expand Down
48 changes: 39 additions & 9 deletions mount_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ else
bootpartition=
fi

if [ $# -ge 6 ]; then

manual_partitions=$6
else
manual_partitions=
fi

echo "inside mount_image manual_partitions=${manual_partitions}"

if [ ${additional_mb} -gt 0 ]; then
dd if=/dev/zero bs=1M count=${additional_mb} >> ${image}
fi
Expand All @@ -27,15 +36,6 @@ loopdev=$(losetup --find --show --partscan ${image})
echo "Created loopback device ${loopdev}"
echo "loopdev=${loopdev}" >> "$GITHUB_OUTPUT"

if [ ${additional_mb} -gt 0 ]; then
if ( (parted --script $loopdev print || false) | grep "Partition Table: gpt" > /dev/null); then
sgdisk -e "${loopdev}"
fi
parted --script "${loopdev}" resizepart ${rootpartition} 100%
e2fsck -p -f "${loopdev}p${rootpartition}"
resize2fs "${loopdev}p${rootpartition}"
echo "Finished resizing disk image."
fi

waitForFile() {
maxRetries=60
Expand All @@ -53,13 +53,43 @@ waitForFile() {

sync
partprobe -s "${loopdev}"

# manual partitions making
if [ "x$manual_partitions" = "xyes" -o "x$manual_partitions" = "xtrue" ]; then
echo "Creating manual partitions"
partitions=$(lsblk --raw --output "MAJ:MIN" --noheadings ${loopdev} | tail -n +2)
counter=1
for i in $partitions; do
MAJ=$(echo $i | cut -d: -f1)
MIN=$(echo $i | cut -d: -f2)
if [ ! -e "${loopdev}p${counter}" ]; then mknod ${loopdev}p${counter} b $MAJ $MIN; fi
counter=$((counter + 1))
done



fi


if [ "x$bootpartition" != "x" ]; then
bootdev=$(waitForFile "${loopdev}p${bootpartition}")
else
bootdev=
fi

rootdev=$(waitForFile "${loopdev}p${rootpartition}")


if [ ${additional_mb} -gt 0 ]; then
if ( (parted --script $loopdev print || false) | grep "Partition Table: gpt" > /dev/null); then
sgdisk -e "${loopdev}"
fi
parted --script "${loopdev}" resizepart ${rootpartition} 100%
e2fsck -p -f "${loopdev}p${rootpartition}"
resize2fs "${loopdev}p${rootpartition}"
echo "Finished resizing disk image."
fi

# Mount the image
mount=${RUNNER_TEMP:-/home/actions/temp}/arm-runner/mnt
mkdir -p ${mount}
Expand Down
Loading