Skip to content

Instantly share code, notes, and snippets.

@pldubouilh
Last active March 18, 2025 06:55
Show Gist options
  • Save pldubouilh/c5703052986bfdd404005951dee54683 to your computer and use it in GitHub Desktop.
Save pldubouilh/c5703052986bfdd404005951dee54683 to your computer and use it in GitHub Desktop.
deb2ipk script - easy conversion from deb to opkg package (ipk)
#!/bin/bash
# inspired from https://github.com/jordansissel/fpm/issues/1323#issuecomment-450613806
if [ $# -ne 2 ]; then
echo 'USAGE: ./deb2ipk.sh arch input-deb'
echo 'WARNING: for amd64 set arch as x86_64'
exit 1
fi
set -e
set -x
TMP_PATH=`mktemp -d`
cp $2 $TMP_PATH
pushd $TMP_PATH
DEB_NAME=`ls *.deb`
ar x $DEB_NAME
rm -rf $DEB_NAME
mkdir control
pushd control
tar xf ../control.tar.gz
sed "s/Architecture:\\ \w*/Architecture:\\ $1/g" ./control -i
cat control
tar czf ../control.tar.gz ./*
popd
tar czf $DEB_NAME.ipk control.tar.gz data.tar.gz debian-binary
rename s/.deb.ipk/_"$1".ipk/ "$DEB_NAME".ipk
popd
cp $TMP_PATH/*.ipk .
# opkg install mything.ipk
@firu82
Copy link

firu82 commented Nov 28, 2023

hello test the script in arch and ubunti and have error in rename part

@MarkusPettersson98
Copy link

@firu82 The rename command used in this script is actually Lary Wall's perl script which is also called rename: https://superuser.com/a/302393, which is not the same as the default rename program on Ubuntu and Fedora at least.

@czzzwww
Copy link

czzzwww commented Mar 18, 2025

cupswrapperDCP7060D-2.0.4-2.i386.deb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment