M01: Introduction to Operating Systems TU3: Installing specific purpose software
ASIX1
Prąctical Exercise 4 (Part 3): How to create tarball and .deb packages - bash.  Installing complex programs from a tarball file
13-05-2021

PRACTICAL EXERCISE 4 (PART 3): HOW TO CREATE tarball AND .deb PACKAGES - BASH. INSTALLING COMPLEX PROGRAMS FROM A TARBALL FILE

1- How to build a tarball and .deb package for a bash script

Make a new project directory called loginteller3 on your system. Change to the newly created directory. Start an instance of Geany and write the following source codes in bash language:

#!/bin/bash
# loginteller3.sh -  shows your current login name and the contents of your personal folder in a tree-like format
# 20230516 - jobima & dacomo
clear
echo "Your login name at the system is : $USER"
echo

echo "Your UID NUMBER at the system is : $UID"
echo
echo
echo "Press  the <Enter> key to show the contents of your personal folder"
read
echo
tree /home/$USER
exit 0


Create a  Makefile archive to install and uninstall loginteller3.sh on your system:

#############################################################################
# Makefile for building: loginteller3.sh
# 20230516 - jobima & dacomo
#############################################################################
#

####### Installing and uninstalling programs and options
INSTALL_PROGRAM = install -p -m 755
REMOVE_PROGRAM     = rm -f
####### Files and directories

DESTDIR       = /usr/local/bin
TARGET        = loginteller3.sh
####### Install and uninstall. Be careful, you have to write a TAB character at the beginnig of each command. Do not write whitespace characters.
install: $(TARGET)
    $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)/
$(TARGET)
uninstall:
    $(REMOVE_PROGRAM) $(DESTDIR)/$(TARGET)


Create a  README archive to install and uninstall loginteller3.sh on your system:

*******************************************
*                                          *
* loginteller3 v1.01                       *
* Copyright (C) 2010-2023, XXXXXXX         *
*                                          *
********************************************

Welcome to the loginteller3 program!  This program, once installed as
/usr/local/bin/loginteller3,  tells current uid and login name at the system.


SOURCES
=========

Web:      http://www.fjeclot.cat/software/utils/loginteller3/
FTP:      ftp://ftp.fjeclot.cat/pub/utils/loginteller3.tar.gz


INSTALLATION
============

Installation of loginteller3  is quite easy.   Simply follow these steps:

1. Installing:

       # sudo make install

2. You are finished.


REMOVAL
====================

Removal and cleaning of loginteller2  is quite easy as well.   Simply follow these steps:

1. Uninstalling:

       # sudo make uninstall

2. You are finished.



INSTALLING AND UNINSTALLING A .DEB PACKAGE
==========================================

Installing and unistalling a .deb package of loginteller2 version 1.01 release 1 is quite easy. Simply follow these steps:

1. Installing:

       # sudo dpkg -i install loginteller3_1.01-1_amd64.deb

2. Uninstalling :

       # sudo dpkg -r loginteller3


LICENSE
=======

The  loginteller3 program  is  distributed  under the  terms  of the  GNU
General Public  License.  The  copyright on this  program belongs  to XXX
YYY.  The actual license appears in file /usr/share/common-license/GPL.

Even though  the GNU General Public  License does NOT require  you to send
your modifications back to the author,  it is considered "good form" to do
so,  as this  allows your  modifications  to be  incorporated into  future
versions of the program, allowing others to benefit from them.


FEEDBACK
========

Your comments, suggestions, corrections and enhancements are always warmly
welcomed!  Please send these to:

E-mail:   feedback@fjeclot.cat


Run the following command to create a tarball package

dacomo@inf1-dacomo:~/loginteller3$ tar cfz loginteller3-1.01.tar.gz loginteller3.sh README Makefile

Run the following command to create a .deb package:

dacomo@inf1-dacomo:~/loginteller3$ checkinstall --install=no --deldesc=yes --deldoc=yes --delspec=no -d 0 --backup=no

and create a new .deb package with the following configuration:

0 -  Maintainer: [ dacomo@inf1-dacomo ]
1 -  Summary: [
Another tool that tells current login name and UID number at the system ]
2 -  Name:    [ loginteller3 ]
3 -  Version: [ 0.1 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ utilities ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ loginteller3 ]
9 -  Alternate source location: [  ]
10 - Requires: [ tree ]
11 - Recommends: [ ]
12 - Suggests: [ ]
13 - Provides: [ loginteller3 ]
14 - Conflicts: [  ]
15 - Replaces: [  ]


Pay close attention to the entry 10 - Requires:. In order to work properly, loginteller3.sh needs tree installed on the system and therefore, you have to fill correctly this entry.


Now a new .deb package loginteller3_1.01-1_amd.64.deb has been build in your working directory. Now, you can Install loginteller3_1.3-2_amd64.deb running:

dacomo@inf1-dacomo:~/loginteller3$ sudo dpkg -i loginteller3_1.01-1_amd64.deb
[sudo] password for dacomo:
electing previously unselected package loginteller3.
(Reading database ... 238295 files and directories currently installed.)
Preparing to unpack loginteller3_1.01-1_amd64.deb ...
Unpacking loginteller3 (1.01-1) ...
Setting up loginteller3 (1.01-1) ...

Afterwards, if you run the following command:


dacomo@inf1-dacomo:~/loginteller3$ aptitude search loginteller3

your terminal will show you the following message:

i    loginteller3                - Another tool that tells current login name at the system

If you want to remove the loginteller3  package from your system run the following command:  sudo  dpkg  -r  loginteller3 
Reading database ... 300678 files and directories currently installed.)
Removing loginteller2 (0.3-2) ...
dpkg: warning: while removing loginteller3, directory '/usr/local/bin' not empty so not removed
(NOTE:  Do not worry about this warning message)


Now:
    - Uninstall tree running: aptitude remove tree
    - Try to install again loginteller3 -> What happens????


 

2- Example of installing a complex program from tarball files

a) Building and installing a text editor called joe from a tarball file:
    Step 1) Donwload from joe-4.6.tar.gz from https://downloads.sourceforge.net/joe-editor/joe-4.6.tar.gz
    Step 2) Extract contents:  tar xfz joe-editor/joe-4.6.tar.gz
    Step 3) Change to the newly created joe-4.6 directory.
    Step 4) Read INSTALL.md and Installation of JOE at https://www.linuxfromscratch.org/blfs/view/svn/postlfs/joe.html
    Step 5) Run: ./configure --prefix=/usr --sysconfdir=/etc --docdir=/usr/share/doc/joe-4.6
  --> Check that a Makefile was created
    Step 6) Run:  make --> Check that object files and a binary where created in a directory called joe.
    Step 7) Run: sudo make install
    Step 8) Run joe. Just type:  joe

b) Uninstalling and cleaning:
    Step 1) Run: sudo make uninstall --> If you type joe the operating system shows "bash: /usr/bin/joe: No such file or directory".
   Step 2) Run: make clean --> Check that object files and a binary where removed from directory joe.
    Step 3)
Additionally, you can remove joe-4.6 directory and joe.4.6.tar.gz file.