Skip to content

Commit

Permalink
fixed limitedness of PUMP command (closes #40)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonashoechst committed Nov 4, 2021
1 parent d4bb307 commit 4cfedbe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
submodules: recursive

- name: Install dependencies
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
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
shell: bash

- name: Run pimod OpenWRT example
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ RUN apt-get update && \
qemu-user-static \
unzip \
wget \
xz-utils
xz-utils \
units

RUN mkdir /pimod
COPY . /pimod/
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
steps:
- run: sudo apt-get update
shell: bash
- run: sudo apt-get install -y binfmt-support file kpartx parted qemu qemu-user-static unzip p7zip-full wget xz-utils
- run: sudo apt-get install -y binfmt-support file kpartx parted qemu qemu-user-static unzip p7zip-full wget xz-utils units
shell: bash
- run: sudo ${{ github.action_path }}/pimod.sh ${{ inputs.pifile }}
shell: bash
20 changes: 18 additions & 2 deletions stages/20-prepare.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# PUMP increases the image's size about the given amount of megabytes.
#
# Usage: PUMP SIZE_IN_MB
# Usage: PUMP SIZE
PUMP() {
if [[ -b "${DEST_IMG}" ]]; then
echo -e "\033[0;31m### Error: Block device ${DEST_IMG} cannot be pumped.\033[0m"
return 1
fi

echo -e "\033[0;32m### PUMP ${1}\033[0m"
dd if=/dev/zero bs="${1}" count=1 >> "${DEST_IMG}"

BS="1M"

# units does not print to stderr, thus test call before using output
echo -n "pump conversion to ${BS} * "
units -t "${1}B" "${BS}B"

COUNT=$(units -t ${1}B ${BS}B)

# Ceil the number if a decimal is given.
if [[ "${COUNT}" == *.* ]]; then
COUNT=$(( $(echo "${COUNT}" | cut -d. -f1) + 1 ))
fi

echo "pump ceil: ${BS} * ${COUNT}"

dd if=/dev/zero bs="${BS}" count="${COUNT}" >> "${DEST_IMG}"

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

0 comments on commit 4cfedbe

Please sign in to comment.