. "$BST_LIB" require zip zip/present # Info-ZIP Zip 3.0: -v with no archive prints the version/compile banner. check_out zip/version "This is Zip 3.0" sh -c "zip -v 2>&1" tmp=${TMPDIR:-/tmp}/bst-zip.$$ line="the quick brown fox jumps over the lazy dog 0123456789" mkdir "$tmp" 2>/dev/null i=0 while [ $i -lt 16 ]; do printf "%s\n" "$line"; i=$((i+1)); done > "$tmp/a.txt" 2>/dev/null printf "second member\n" > "$tmp/b.txt" 2>/dev/null # create a two-member archive (deflate default) check zip/create sh -c "cd '$tmp' && zip -q ar.zip a.txt b.txt" # real ZIP container: local-file-header magic PK\003\004 check_out zip/magic "50 4b 03 04" sh -c "od -An -tx1 -N4 '$tmp/ar.zip'" # -sf (show files) lists the members without extraction check_out zip/list-a "a.txt" sh -c "cd '$tmp' && zip -sf ar.zip" check_out zip/list-b "b.txt" sh -c "cd '$tmp' && zip -sf ar.zip" # grow the archive in place (temp-archive + rename-over path) printf "third member\n" > "$tmp/c.txt" 2>/dev/null check_out zip/add "c.txt" sh -c "cd '$tmp' && zip -q ar.zip c.txt && zip -sf ar.zip" # delete a member in place; -sf must no longer show it check zip/delete sh -c "cd '$tmp' && zip -qd ar.zip b.txt && ! zip -sf ar.zip | grep -q b.txt" # store mode (-0): member bytes land verbatim, so the original text is greppable # in the archive itself -- a content check needing no unzip (not in this image) check zip/store-content sh -c "cd '$tmp' && zip -q -0 st.zip a.txt && grep -qa '$line' st.zip" # extraction roundtrip via the busybox unzip applet (Info-ZIP unzip is not in # the image): the deflated member extracts back to the original text check_out zip/roundtrip "$line" sh -c "cd '$tmp' && unzip -p ar.zip a.txt" # zipnote (ships with zip) reads the archive structure back check_out zip/zipnote "@ a.txt" sh -c "cd '$tmp' && zipnote ar.zip" rm -rf "$tmp"