You are not logged in.

#1 2013-03-24 12:40:56

mytbk
Member
Registered: 2012-05-27
Posts: 22

interesting script to install a debian package in arch

I just wrote a script called arch-dpkg.sh to install a deb package directly into system and can be recognized by pacman.

#!/bin/sh

infogrep(){
	grep "$1" control|cut -d' ' -f2-
}

if [ ! -n "$1" ]; then
	echo "Please specify your deb file."
	exit
fi

DEBNAME="$1"
FILENAME=$(basename ${DEBNAME})
WORKDIR="/tmp/work/${FILENAME}"
DATADIR="${WORKDIR}/datadir"
install -d ${DATADIR}
cd "$(dirname ${DEBNAME})"
ln -s "${PWD}/${FILENAME}" "${WORKDIR}/${FILENAME}"
cd ${WORKDIR}
ar x ${FILENAME}
tar xpf data.tar.gz -C ${DATADIR}
tar xpf control.tar.gz

NAME=$(infogrep "^Package: ")
VERSION=$(infogrep "^Version: ")
DESC=$(infogrep "^Description: ")
URL=$(infogrep "^Homepage: ")
LICENSE=$(infogrep "^Priority: ")
ARCH=$(infogrep "^Architecture: ")
DATE=$(date +%s)
PACKAGER=$(infogrep "^Maintainer: ")
SIZE=$(du -sb ${DATADIR}|cut -f1)
POSTINST=postinst
POSTRM=postrm

if [ "${ARCH}" == "amd64" ]; then
	ARCH='x86_64'
else
	ARCH='i686'
fi

LABELS=('%NAME%' '%VERSION%' '%DESC%' '%URL%' '%LICENSE%' '%ARCH%' '%BUILDDATE%' '%INSTALLDATE%' '%PACKAGER%' '%SIZE%')
DATA=("$NAME" "$VERSION" "$DESC" "$URL" "$LICENSE" "$ARCH" "$DATE" "$DATE" "$PACKAGER" "$SIZE")

let i=0
while [ $i -lt ${#LABELS[@]} ]; do
	echo -e "${LABELS[$i]}\n${DATA[$i]}\n" >> desc
	let i=$(($i+1))
done

echo '%FILES%' > files
find datadir >> files

echo 'post_install(){' > install
cat "${POSTINST}" >> install
echo '}' >> install
echo 'post_remove(){' >> install
cat "${POSTRM}" >> install
echo '}' >> install

ALPMDIR="/var/lib/pacman/local/${NAME}-${VERSION}"
install -d "${ALPMDIR}"
mv desc files install "${ALPMDIR}"
rsync -av ${DATADIR}/* /
sh ${POSTINST}

rm -rf ${WORKDIR}

Offline

Board footer

Powered by FluxBB