Skip to content

Instantly share code, notes, and snippets.

@pldubouilh
Last active September 27, 2024 11:56
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
@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.

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