Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## OPKG package forger
- MIN_PARAMS=2
- if [ $# -lt $MIN_PARAMS ] || [ ! -d "$2" ]; then
- echo " Usage: $0 yourpackage.ipk IPK_BASE_FOLDER"
- exit 1
- fi
- IPKFILE="$1"
- IPKDIR="$2"
- IPKAR="True" ## Set as True to generate debian-archive AR IPK
- runchecks(){
- if [ ! -d control ] || [ ! -d data ]; then
- echo " ERROR: IPK folders 'control', 'data' missing."
- exit 1
- fi
- debian_binary=$(cat debian_binary)
- if [ "$debian_binary" != "2.0" ]; then
- echo " ERROR: incompatible or missing debian_binary"
- exit 1
- fi
- }
- runfixes(){
- mkdir -pv control data
- touch control/control
- find './control' -name '*inst' -print0 2>/dev/null | xargs chmod -v a+x
- find './control' -name '*rm' -print0 2>/dev/null | xargs chmod -v a+x
- }
- forgecontrol(){
- echo " Collecting control.tar ..."
- tar -cvf control.tar --numeric-owner --group=0 --owner=0 -C control ./
- echo " Compressing control.tar.gz ..."
- gzip -9v < control.tar > control.tar.gz
- }
- forgedata(){
- echo " Collecting data.tar ..."
- tar -cvf data.tar --numeric-owner --group=0 --owner=0 -C data ./
- echo " Compressing data.tar.gz ..."
- gzip -9v < "data.tar" > "data.tar.gz"
- }
- forgeipk(){
- echo " Collecting packagetemp.tar ..."
- tar -cvf packagetemp.tar --numeric-owner --group=0 --owner=0 ./debian_binary ./control.tar.gz ./data.tar.gz
- echo " Compressing $IPKFILE ..."
- gzip -0v < packagetemp.tar > "$IPKFILE"
- echo " Done. Created: $IPKFILE"
- if [ -n "$IPKAR" ]; then
- echo " Compressing debian-archive"
- rm "$IPKFILE"
- ar rv "$IPKFILE" debian_binary ./data.tar.gz ./control.tar.gz
- fi
- }
- clean(){
- rm -v data.tar data.tar.gz control.tar control.tar.gz
- rm -v packagetemp.tar
- }
- ##main(){
- cd "$IPKDIR" || exit 1
- if ! runchecks
- then runfixes
- exit 1
- fi
- forgecontrol && \
- forgedata && \
- forgeipk #&& \
- #clean
- #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement