Доброго времени суток, не так давно я писал статью со скриптом для сборки deb-пакета для Komodo Edit.
В новой версии Komodo Edit 7.0 внесены некоторые изменения в именовании архива (откуда бралась нужная информация) и в расположении запускающего бинарника, поэтому пришлось немного переписать скрипт для сборки deb-пакета.
Под катом обновленный скрипт, который также совместим с версиями < 7.0
Скрипт теперь такой:
#!/bin/bash
################################################################################
# #
# This script makes Komodo Edit package for Debian and Ubuntu #
# #
################################################################################
# backup IFS variable
OLD_IFS=$IFS
UMASK=`umask`
# the archive filename
archive_name=""
# Package version number
VERSION=""
# Installer version
I_VER=6
# Package revision number
REVISION=""
# package Architecture
ARCH=""
# Where we are now :)
FULL_PATH=`pwd`
# temporary subfolder
TEMP_PATH="temp-komodo-pkg"
# Full extract path
EXTR_PATH=$FULL_PATH/$TEMP_PATH
# Installation script
SCRIPT="install.sh"
# temporary installation path
TEMP_BUILD_PATH="$EXTR_PATH/temp-build"
# real installation path
BUILD_PATH="$EXTR_PATH/build"
# installation prefix
PREFIX=usr
# delete temporary files
opt_del_temp="1"
# Make submenu Komodo Edit in Development Menu
opt_submenu=""
# Size for Pixmaps Icon
pixmaps_size="48x48"
# show script usage
usage()
{
cat < /dev/null
if [ "$?" != 0 ]; then
umask $UMASK
exit 5
fi
echo "Done"
SCRIPT=$EXTR_PATH/`ls $EXTR_PATH`/$SCRIPT
mkdir "$TEMP_BUILD_PATH"
mkdir "$BUILD_PATH"
umask $UMASK
}
install_komodo()
{
umask 022
$SCRIPT -I "$TEMP_BUILD_PATH/$PREFIX" -s
umask $UMASK
}
# precompile some python scripts at lib/mozilla subfolder
# and change start komodo script
prepare_komodo()
{
umask 022
echo "Preparing Komodo scripts ..."
$TEMP_BUILD_PATH/$PREFIX/lib/python/bin/python -O -mcompileall $TEMP_BUILD_PATH/$PREFIX/lib/mozilla/
case "$I_VER" in
7) ;; #nothing to do in new algorithm
*) sed -i -e 's/$INSTALLDIR/lib/$INSTALLDIR/share/komodo-edit/lib/i' $TEMP_BUILD_PATH/$PREFIX/bin/komodo;;
esac
echo "Scripts preparing done."
umask $UMASK
}
mv_package_files()
{
umask 022
mkdir -p $BUILD_PATH/$PREFIX/bin
mkdir -p $BUILD_PATH/$PREFIX/share/komodo-edit/lib
mkdir -p $BUILD_PATH/$PREFIX/share/komodo-edit/doc
echo -n "Moving files for package. Please wait ..."
# Move main script
mv $TEMP_BUILD_PATH/$PREFIX/bin/* $BUILD_PATH/$PREFIX/bin/
case "$I_VER" in
7) # create new symlink
rm -f $BUILD_PATH/$PREFIX/bin/komodo
ln -s ../share/komodo-edit/lib/mozilla/komodo $BUILD_PATH/$PREFIX/bin/komodo
# move docs
mv $TEMP_BUILD_PATH/$PREFIX/share/doc $BUILD_PATH/$PREFIX/share/komodo-edit/doc/
;;
*) # move docs
mv $TEMP_BUILD_PATH/$PREFIX/share/doc/* $BUILD_PATH/$PREFIX/share/komodo-edit/doc/
mv $TEMP_BUILD_PATH/$PREFIX/share/doc/.css $BUILD_PATH/$PREFIX/share/komodo-edit/doc/
;;
esac
# Move all libs
mv $TEMP_BUILD_PATH/$PREFIX/lib/* $BUILD_PATH/$PREFIX/share/komodo-edit/lib/
echo "Done"
umask $UMASK
}
make_icons()
{
umask 022
echo -n "Creating icons ..."
SIZES="64x64 48x48 32x32 24x24 22x22 16x16"
mkdir -p $BUILD_PATH/$PREFIX/share/icons/hicolor/128x128/apps
cp -p $TEMP_BUILD_PATH/$PREFIX/share/icons/komodo128.png $BUILD_PATH/$PREFIX/share/icons/hicolor/128x128/apps/komodo.png
WORK_PATH=$BUILD_PATH/$PREFIX/share/icons/hicolor
for size in $SIZES
do
mkdir -p $WORK_PATH/$size/apps
$CONVERTER $WORK_PATH/128x128/apps/komodo.png -resize $size $WORK_PATH/$size/apps/komodo.png
done
mkdir -p $BUILD_PATH/usr/share/pixmaps
cp $BUILD_PATH/$PREFIX/share/icons/hicolor/$pixmaps_size/apps/komodo.png $BUILD_PATH/usr/share/pixmaps/
echo "Done"
umask $UMASK
}
make_menu_entries()
{
umask 022
echo -n "Make menu entries ..."
mkdir -p $BUILD_PATH/usr/share/menu
filename=$BUILD_PATH/usr/share/menu/komodo-edit
echo "?package(komodo-edit):needs="x11" section="Apps/Programming" " > $filename
echo " title="Komodo Edit" command="/$PREFIX/bin/komodo %F" " >> $filename
echo " icon="/usr/share/pixmaps/komodo.png" " >> $filename
echo "" >> $filename
if [ -z "$opt_submenu" ]; then
echo "Done"
category="Development;"
depends=""
umask $UMASK
return
fi
category="Komodo;"
depends="xdg-utils"
mkdir -p $BUILD_PATH/etc/xdg/menus/applications-merged
filename=$BUILD_PATH/etc/xdg/menus/applications-merged/komodo-edit.menu
echo ' $filename
echo '"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">' >> $filename
echo '
' >> $filename
echo ' ' >> $filename
echo '' >> $filename
mkdir -p $BUILD_PATH/usr/share/desktop-directories
filename=$BUILD_PATH/usr/share/desktop-directories/komodoedit.directory
echo '[Desktop Entry]' > $filename
echo 'Encoding=UTF-8' >> $filename
echo 'Type=Directory' >> $filename
echo 'Name=Komodo Edit' >> $filename
echo 'Icon=komodo' >> $filename
echo "Done"
umask $UMASK
}
make_desktop_files()
{
umask 022
echo -n "Make desktop files ..."
mkdir -p $BUILD_PATH/usr/share/applications
filename=$BUILD_PATH/usr/share/applications/komodo-edit.desktop
echo '[Desktop Entry]' > $filename
echo 'Type=Application' >> $filename
echo 'Name=Komodo Edit' >> $filename
echo 'Encoding=UTF-8' >> $filename
echo 'Icon=komodo' >> $filename
echo 'Exec=komodo %F' >> $filename
echo "Categories=$category" >> $filename
echo 'Terminal=false' >> $filename
echo 'Comment=Dynamic Languages Web-Editor' >> $filename
echo 'GenericName=Dynamic Web-pages Editor' >> $filename
if [ -z "$opt_submenu" ]; then
echo "Done"
umask $UMASK
return
fi
filename=$BUILD_PATH/usr/share/applications/komodo-license.desktop
echo '[Desktop Entry]' > $filename
echo 'Type=Application' >> $filename
echo 'Name=License' >> $filename
echo 'Encoding=UTF-8' >> $filename
echo 'Icon=txt' >> $filename
echo "Exec=xdg-open /$PREFIX/share/komodo-edit/doc/license.txt" >> $filename
echo "Categories=$category" >> $filename
echo 'Terminal=false' >> $filename
filename=$BUILD_PATH/usr/share/applications/komodo-relnotes.desktop
echo '[Desktop Entry]' > $filename
echo 'Type=Application' >> $filename
echo 'Name=Release Notes' >> $filename
echo 'Encoding=UTF-8' >> $filename
echo 'Icon=html' >> $filename
echo "Exec=xdg-open /$PREFIX/share/komodo-edit/doc/relnotes.html" >> $filename
echo "Categories=$category" >> $filename
echo 'Terminal=false' >> $filename
echo "Done"
umask $UMASK
}
make_control_file()
{
umask 022
echo -n "Make Debian control file ..."
mkdir -p $BUILD_PATH/DEBIAN
#calculate installed size
full_size=`du -s $BUILD_PATH/usr | awk '{print $1}'`
filename=$BUILD_PATH/DEBIAN/control
echo "Package: komodo-edit" > $filename
echo "Version: $VERSION-$REVISION" >> $filename
echo "Architecture: $ARCH" >> $filename
echo "Section: web" >> $filename
echo "Priority: optional" >> $filename
echo "Installed-Size: $full_size" >> $filename
if [ -n "$depends" ]; then
echo "Depends: $depends" >> $filename
fi
echo "Homepage: www.activestate.com" >> $filename
echo "Maintainer: KernelPanic :) " >> $filename
echo "Description: Komodo Edit is a free, open source editor from dynamic language experts." >> $filename
echo " Komodo Edit, based on the award-winning Komodo IDE, offers sophisticated support" >> $filename
echo " for all major scripting languages, including in-depth autocomplete and calltips, " >> $filename
echo " multi-language file support, syntax coloring and syntax checking, Vi emulation, " >> $filename
echo " Emacs key bindings." >> $filename
echo " It provides dynamic language expertise for Perl, PHP, Python, Ruby, and Tcl, plus JavaScript, " >> $filename
echo " CSS, HTML, and XML, and template languages like RHTML, Template-Toolkit, HTML-Smarty " >> $filename
echo " and Django." >> $filename
echo "Done"
umask $UMASK
}
make_package()
{
fakeroot dpkg-deb -b $BUILD_PATH ./
}
del_temporary()
{
if [ -n "$opt_del_temp" ]; then
echo -n "Delete temporary files and directories ..."
rm -rf $EXTR_PATH
echo "Done"
else
rm -rf $TEMP_BUILD_PATH
echo "Temporary files may be found at temp-komodo-pkg/ folder"
fi
}
check_args $@
package_name_parse $archive_name
check_funcs
unpack_archive $archive_name
install_komodo
prepare_komodo
mv_package_files
make_icons
make_menu_entries
make_desktop_files
make_control_file
make_package
del_temporary
echo "All Done. Package is ready :)"
exit 0
Изменения коснулись функций:
— package_name_parse;
— prepare_komodo;
— mv_package_files.
Также добавлена новая переменная «версии инсталлятора» I_VER.