2

How do you create your own package in Linux, just like cd, ls, or any third party package?

All I know is how to create a .sh file, write a script in it and execute it using:

bash file_name

But in addition to that I want to understand in more depth. Please explain the complete steps from downloading using apt-get to how to run it.

  • 2
    The easy part is to create the application, the tool. The difficult part is to get it accepted as a linux package (as part of an officially supported repository). A simpler alternative for Ubuntu is to upload it to a PPA at Launchpad or provide the tool in some [other] kind of container via for example GitHub. – sudodus Jun 12 '21 at 10:12
  • This link might be a good starting point for what you want: https://askubuntu.com/questions/1300540/how-to-duplicate-a-ubuntu-system-for-distribution – C.S.Cameron Jun 12 '21 at 11:49
  • 2
    Please unlearn the "create a .sh file and write your script in it and execute it using "bash file_name" paradigm - script files should use an appropriate shebang to indicate which interpreter should run them, rather than having the user specify an interpreter on the command line. – steeldriver Jun 12 '21 at 11:58

1 Answers1

7

I am assuming you want to write a new program and distribute it as a Debian package in Ubuntu.

Suppose you have the bash script, hello, and you have marked it as executable

#!/bin/bash
echo "Hello World"
  1. Now create a Debian package which will place this hello file in /usr/bin. The linked answer is about a single python script, but it works the same way with a bash script. Once installed, it can be run from the terminal with:

    username@computer~$ hello
    
  2. Upload the Debian source to a Launchpad PPA, so that users can add it to their system, and subsequently download it with apt.

  3. You can later submit it to Debian's repositories, so that it can be directly installed in Ubuntu and other derivatives of Debian (although I don't know if Debian maintainers allow simple bash scripts to be added to their repositories. But you can put any program in your own Launchpad PPA).

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212