Saturday, March 31, 2012

How to make debian package (.deb) with scripts

When I port my qt projects to Ubuntu/Debian Linux systems, I provided the compiled debian package, a deb file for users. I use a GUI debian package creator to make a deb package. Today when I browser qt-components, I got this bash script that can create deb file easily:

MAKE='make -j4'

cd `dirname $0`

rm -rf debian
mkdir debian
cd debian

mkdir -p "usr/share/applications"

echo "[Desktop Entry]" > "$desktop_file_meenotes"
echo "Version=1.0" >> "$desktop_file_meenotes"
echo "Name=MeeNotes" >> "$desktop_file_meenotes"
echo "GenericName=MeeNotes" >> "$desktop_file_meenotes"
echo "Comment=MeeNotes" >> "$desktop_file_meenotes"
echo "Exec=/opt/meenotes/MeeNotes" >> "$desktop_file_meenotes"
echo "Terminal=false" >> "$desktop_file_meenotes"
echo "Type=Application" >> "$desktop_file_meenotes"
mkdir -p DEBIAN


echo "Package: meenotes" > "$control_file"
echo "Version: 1.0" >> "$control_file"
echo "Architecture: all" >> "$control_file"
echo "Maintainer: Qt developers" >> "$control_file"
echo "Description: Qt components MeeNotes" >> "$control_file"

[ ! -f "../Makefile" ] && (cd ..; qmake)
(export INSTALL_ROOT=`pwd`; $MAKE install)

mkdir -p opt/meenotes

cp -ar ../MeeNotes opt/meenotes/
cp -ar ../resource opt/meenotes/resource

cd ..
dpkg-deb --build debian
mv debian.deb meenotes.deb

No comments:

Post a Comment