Skip to content

Commit 4cfedbe

Browse files
committed
fixed limitedness of PUMP command (closes #40)
PUMP was implemented using dd's bs, which is limited to 2GB. In this fix the bs is set to fixed 1MB and the block count is calculated and ceiled. Caveat: Fractions of the block size can not be realized using this method, but should be not a real problem.
1 parent d4bb307 commit 4cfedbe

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
submodules: recursive
1818

1919
- name: Install dependencies
20-
run: sudo apt-get update && sudo apt-get install -y binfmt-support file kpartx lsof p7zip-full parted qemu qemu-user-static unzip wget xz-utils
20+
run: sudo apt-get update && sudo apt-get install -y binfmt-support file kpartx lsof p7zip-full parted qemu qemu-user-static unzip wget xz-utils units
2121
shell: bash
2222

2323
- name: Run pimod OpenWRT example

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ RUN apt-get update && \
1616
qemu-user-static \
1717
unzip \
1818
wget \
19-
xz-utils
19+
xz-utils \
20+
units
2021

2122
RUN mkdir /pimod
2223
COPY . /pimod/

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
steps:
1515
- run: sudo apt-get update
1616
shell: bash
17-
- run: sudo apt-get install -y binfmt-support file kpartx parted qemu qemu-user-static unzip p7zip-full wget xz-utils
17+
- run: sudo apt-get install -y binfmt-support file kpartx parted qemu qemu-user-static unzip p7zip-full wget xz-utils units
1818
shell: bash
1919
- run: sudo ${{ github.action_path }}/pimod.sh ${{ inputs.pifile }}
2020
shell: bash

stages/20-prepare.sh

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
# PUMP increases the image's size about the given amount of megabytes.
22
#
3-
# Usage: PUMP SIZE_IN_MB
3+
# Usage: PUMP SIZE
44
PUMP() {
55
if [[ -b "${DEST_IMG}" ]]; then
66
echo -e "\033[0;31m### Error: Block device ${DEST_IMG} cannot be pumped.\033[0m"
77
return 1
88
fi
99

1010
echo -e "\033[0;32m### PUMP ${1}\033[0m"
11-
dd if=/dev/zero bs="${1}" count=1 >> "${DEST_IMG}"
11+
12+
BS="1M"
13+
14+
# units does not print to stderr, thus test call before using output
15+
echo -n "pump conversion to ${BS} * "
16+
units -t "${1}B" "${BS}B"
17+
18+
COUNT=$(units -t ${1}B ${BS}B)
19+
20+
# Ceil the number if a decimal is given.
21+
if [[ "${COUNT}" == *.* ]]; then
22+
COUNT=$(( $(echo "${COUNT}" | cut -d. -f1) + 1 ))
23+
fi
24+
25+
echo "pump ceil: ${BS} * ${COUNT}"
26+
27+
dd if=/dev/zero bs="${BS}" count="${COUNT}" >> "${DEST_IMG}"
1228

1329
# Fix the GPT if necessary and resize the partition afterwards.
1430
# The fix is currently kind of hackish..

0 commit comments

Comments
 (0)