deb2lz4 anyone?
deb2lz4 anyone?
I need a script "deb to xzm" with LZ4 compression.
deb2lz4 anyone?
This one should do it:
Code: Select all
#!/bin/bash
[[ "$(id -u)" -ne 0 ]] && exec sudo "$0" "$@"
notify() {
local color_code=$1 message=$2
tput setaf "$color_code"; echo "$message"; tput sgr0
}
# Validate input
if [ $# -ne 1 ] || [[ "$1" != *.deb ]] || [ ! -f "$1" ]; then
notify 1 "Usage: ${0##*/} <package.deb>"
exit 1
fi
# Definitions
DEB_FILE=$(realpath "$1")
TEMP_DIR=$(mktemp -d) || { notify 1 "Error: Failed to create temporary directory"; exit 1; }
MODULE="${DEB_FILE%.deb}.xzm"
# clean exit
trap 'rm -rf "$TEMP_DIR"' EXIT
# Unpack
bsdtar -xpf "$DEB_FILE" -C "$TEMP_DIR" || {
notify 1 "Error: $DEB_FILE couldn't be extracted"
exit 1
}
DATA_ARCHIVE=$(find "$TEMP_DIR" -name "data.tar.*" -print -quit)
[ -n "$DATA_ARCHIVE" ] && bsdtar -xpf "$DATA_ARCHIVE" -C "$TEMP_DIR" || {
notify 1 "Error: data.tar.* couldn't be extracted from $DEB_FILE"
exit 1
}
rm -f "$TEMP_DIR"/control.tar.* "$TEMP_DIR"/data.tar.* "$TEMP_DIR"/debian-binary
# Adjust ownership
chown -R 0:0 "$TEMP_DIR"
# Repack
(mksquashfs "$TEMP_DIR" "$MODULE" -comp lz4 -quiet && notify 2 "LZ4 module created: $MODULE") || notify 1 "Error: $MODULE couldn't be created"
Last edited by M. Eerie on 17 Apr 2025, 17:56, edited 2 times in total.
> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
Thank you, M. Eerie
I assume this script also works in PorteuX ?
Question:
The module extension is always .xzm
How can you determine which compression is used?
I assume this script also works in PorteuX ?
Question:
The module extension is always .xzm
How can you determine which compression is used?
deb2lz4 anyone?
Should do it. It uses standard tools included in binutils package.
You can simply:
Code: Select all
file <your-module.xzm>
> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
Hi,
the script doesn't work
the script doesn't work
Code: Select all
guest@porteux:~/Downloads$ ./deb2lz4 microsoft-edge-stable_135.0.3179.73-1_amd64.deb
ar: invalid option -- C
Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
ar -M [<mri-script]
...
...
Error: microsoft-edge-stable_135.0.3179.73-1_amd64.deb couldn't be extracted
deb2lz4 anyone?
Sorry for that. I've updated the script above.
> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
The updated script still contained errors.
I had it corrected by the AI at perplexity.ai.
Now it works.
Here is the corrected script:
I had it corrected by the AI at perplexity.ai.
Now it works.
Here is the corrected script:
Code: Select all
#!/bin/bash
# Check for valid input
if [ $# -ne 1 ] || [[ "$1" != *.deb ]] || [ ! -f "$1" ]; then
tput setaf 1; echo "Usage: $0 <package.deb>"; tput sgr0
exit 1
fi
# Definitions
DEB_FILE="$1"
TEMP_DIR=$(mktemp -d)
MODULE="${DEB_FILE%.deb}.xzm"
# Unpack
cd "$TEMP_DIR" || { tput setaf 1; echo "Error: directory doesn't exists"; tput sgr0; exit 1; }
ar x "$DEB_FILE" || { tput setaf 1; echo "Error: $1 couldn't be extracted"; tput sgr0; rm -rf "$TEMP_DIR"; exit 1; }
DATA_ARCHIVE=$(find "$TEMP_DIR" -name "data.tar.*")
if [[ -z "$DATA_ARCHIVE" ]] || ! tar -xf "$DATA_ARCHIVE" -C "$TEMP_DIR"; then # Korrektur hier
tput setaf 1; echo "Error: data.tar.* couldn't be extracted from $1"; tput sgr0; rm -rf "$TEMP_DIR"; exit 1
fi
# Repack & clean
if sudo mksquashfs "$TEMP_DIR" "$MODULE" -comp lz4 -quiet; then
tput setaf 2; echo "LZ4 module created: $MODULE"
else
tput setaf 1; echo "Error: $MODULE couldn't be created"
fi
tput sgr0
rm -rf "$TEMP_DIR"
exit 0
deb2lz4 anyone?
I don't see any functional change in the version that "now works".
The only difference (aside from the last line 'exit 0,' which is not really necessary) is in the way it is evaluated whether $DATA_ARCHIVE exists OR if the tar command fails to extract it, in which case the exit code 1 (error) is returned.
By De Morgan's second law,
NOT ( A OR B ) = NOT A AND NOT B
where the term on the left would correspond to my code and the one on the right to the one provided by you Perplexity AI.
The truth table of the OR logic gate ( A || B ) is:
Code: Select all
| $DATA_ARCHIVE is empty 'A' | tar extraction fail 'B' | A || B | Error condition |
|----------------------------|-------------------------|--------|------------------|
| 0 | 0 | 0 | No |
| 0 | 1 | 1 | Yes |
| 1 | 0 | 1 | Yes |
| 1 | 1 | 1 | Yes |
Code: Select all
[[ -z "$DATA_ARCHIVE" || ! tar -xf "$DATA_ARCHIVE" -C "$TEMP_DIR" ]] && { tput setaf 1; echo "Error: data.tar.* couldn't be extracted from $1"; tput sgr0; rm -rf "$TEMP_DIR"; exit 1; }
Code: Select all
if [[ -z "$DATA_ARCHIVE" ]] || ! tar -xf "$DATA_ARCHIVE" -C "$TEMP_DIR"; then # Korrektur hier
tput setaf 1; echo "Error: data.tar.* couldn't be extracted from $1"; tput sgr0; rm -rf "$TEMP_DIR"; exit 1
fi

> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
Hi Eerie,
Your script doesn't work for me:
Your script doesn't work for me:
Code: Select all
guest@porteux:~/Downloads$ ./script-eerie /home/guest/Downloads/microsoft-edge-stable_135.0.3179.73-1_amd64.deb
./script-eerie: line 19: conditional binary operator expected
./script-eerie: line 19: syntax error »-xf«
./script-eerie: line 19: `[[ -z "$DATA_ARCHIVE" || ! tar -xf "$DATA_ARCHIVE" -C "$TEMP_DIR" ]] && { tput setaf 1; echo "Error: data.tar.* couldn't be extracted from $1"; tput sgr0; rm -rf "$TEMP_DIR"; exit 1; }'
deb2lz4 anyone?
I have rewritten the code and checked its correct operation apart from some improvement.
> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
Hi Eerie,
If I use your script, the size of the generated xzm module is 321.0 MiB.
If I use the above script #7 (generated by the AI) the size of the generated xzm module is 483.0 MiB.
How can this be explained?
using your script:
using script from AI:
If I use your script, the size of the generated xzm module is 321.0 MiB.
If I use the above script #7 (generated by the AI) the size of the generated xzm module is 483.0 MiB.
How can this be explained?
using your script:
Code: Select all
guest@porteux:~/Downloads$ ./deb2lz4Eerie /home/guest/Downloads/microsoft-edge-stable_135.0.3179.73-1_amd64.deb
Passwort:
[=============================================================|] 4702/4702 100%
LZ4 module created: /home/guest/Downloads/microsoft-edge-stable_135.0.3179.73-1_amd64.xzm
Code: Select all
guest@porteux:~/Downloads$ ./deb2lz4 /home/guest/Downloads/microsoft-edge-stable_135.0.3179.73-1_amd64.deb
Passwort:
[=============================================================/] 6001/6001 100%
LZ4 module created: /home/guest/Downloads/microsoft-edge-stable_135.0.3179.73-1_amd64.xzm
deb2lz4 anyone?
Video to see the explanation
Final size should be 219,5 Mb.
Short answer: Your AI code most likely is including the extracted .tar.xz archives from .deb package, thus duplicating stuff.
> Does not compute_ 
https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741
deb2lz4 anyone?
Hi M. Eerie,
"Video to see the explanation"
But:
VEED
This Video has been archived
The video is not available to watch at this time
"Video to see the explanation"
But:
VEED
This Video has been archived
The video is not available to watch at this time