5

I created a little application using Bash and Zenity that I wish to install on my system as a native application as well as a package that I can distribute. I have a .desktop file for my application, a .png icon, and the .sh file. Where do these files go to make a "native" application, and by what process would I need to go to create a package that can be compiled to install this application on another system?

Ryan McClure
  • 6,021
  • Here is a link to a zip file with all of the files necessary to run the application--it's a simple little tea timer. :)

    To run it, simply run the script. The .desktop file probably won't work.

    https://www.dropbox.com/s/ya9futuiz33lian/GTeaKup.zip

    – Ryan McClure Feb 23 '14 at 06:16
  • Have you checked http://packaging.ubuntu.com/html/packaging-new-software.html ? – Radu Rădeanu Feb 23 '14 at 08:33

2 Answers2

3

About the first part: To start with, I would make the script executable and remove .sh extension from both the script and the .desktop file. If you want to use it system wide, then copy the whole directory, except the .desktop file, to /opt. The .desktop file would then be:

[Desktop Entry]
Version=1.0
Type=Application
Name=GTeaKup
Comment=The perfect GTK tea timer!
Exec=/bin/bash gteakup
Icon=gteacup.png
Path=/opt/GTeaKup/
Terminal=false
StartupNotify=false

...and copy that to /usr/share/applications

About the second half of your question: take a look here, especially this one is nice to start with if you never created Debian packages before. You will then get an installer like this. When you install it via the software center, it will complain, because the usual files like changelog, copyright etc. files are not included, but it works fine.

btw you do know that your script acts differently on double-click and when the ok button is chosen? ;)

Jacob Vlijm
  • 83,767
  • This works! I edited the process a little bit, and it works! :) I am trying to (for now) make a distro-neutral package that can be compiled and installed without a package manager. Eventually, I will create a debian package for it.

    I am currently fighting to figure out how to fix the script so that when the OK button is chosen, the menu repeats until an option is selected. Any thoughts?

    – Ryan McClure Feb 24 '14 at 02:40
  • ...I am afraid I am not a bash specialist, but in python, I would use the while loop (while answer is not in [list], or answer != (is not equal to) this or that, repeat question, else: do the following). Would this help: http://www.cyberciti.biz/faq/bash-while-loop/ ? – Jacob Vlijm Feb 24 '14 at 12:25
1

You can use a shell script install.sh as given below to install your tea timer script to another machine.

#!/bin/bash
install_dir="$HOME/teaKup"
current_dir="$(pwd)"
dpkg -s sox > /dev/null 2>&1
if [ $? = 0 ]; then
    mkdir $install_dir #create directory to place files.
    cp $current_dir/gteakup.sh $install_dir/ # copies the file.
    cp $current_dir/gteakup.png $install_dir/
    cp $current_dir/sound.ogg $install_dir/
    cat > $HOME/Desktop/GTeaKup.desktop << EOF # create desktop file at desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=GTeaKup
Comment=The perfect GTK tea timer!
Exec=bash $install_dir/gteakup.sh
Icon=$install_dir/gteakup.png
Terminal=false
StartupNotify=false
EOF
    chmod u+x $HOME/Desktop/GTeaKup.desktop  # give execution permission to desktop file.
else
    # ask user to install sox which is needed to use play command
    echo -e "The program 'play' is currently not installed.  You can install it by typing:\nsudo apt-get install sox"
fi

Instruction

  • put this install.sh along with other files in a zip file. No need to provide .desktop file, script will make one.
  • copy the zip file to other systems and unzip them.
  • just run bash install.sh, it will take care of the rest including coping the files in proper places and will make a desktop file to run it.

Note

Be careful with the position of EOF in install.sh. It should at the beginning of that line.

sourav c.
  • 44,715