Coder Social home page Coder Social logo

sergeyivanovdevelop / deb-package-creation Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 78 KB

This repository contains the code of the simplest program in the C programming language and step by step instructions on how to package this software into a deb package.

License: Other

Makefile 51.23% C 48.77%
bash c debian-packages makefile

deb-package-creation's Introduction

Simple-OS

Creation deb-package

Creation deb-package · GitHub license C Makefile deb-package LinkedIn Telegram

This repository contains the code of the simplest program in the C programming language and step by step instructions on how to package this software into a deb package.

💻 Getting Started

Stage 1

  1. Go to home directory and clone repository from github: cd ~ && git clone https://[email protected]/SergeyIvanovDevelop/DEB-Package-Creation && cd DEB-Package-Creation

Stage 2

  1. Initial data: there is a directory ~/DEB-Package-Creation/Example_deb_create, and it contains empty directory Create_deb. Go to Example_deb_create: cd Example_deb_create

Stage 3

  1. Install everything you need to build the C program and build the deb packages: sudo apt-get install build-essential dh-make

Stage 4

  1. Create file hello_world_deb.c and Makefile (if they are not) to it in directory Create_deb
hello_world_deb.c :
---------------------------
int main() {
    printf(“Hello, World\n”);
    return 0;
}
---------------------------	
Makefile :
---------------------------
all:
	gcc hello_world_deb.c -o hello_world_deb

clean:
	rm hello_world_deb || true
---------------------------

and create empty directory Run_deb: mkdir Run_deb

Stage 5

  1. We build the executable file (from the Create_deb directory): make -f Makefile

The hello_world_deb file should appear in the Create_deb directory

Stage 6

  1. From the Create_deb directory, execute the command to create the Create_deb/debian directory (a service directory for building a deb package): dh_make -p mydebpackagename_0.0.1 --createorig

, where mydebpackagename_0.0.1 is the name and version of the deb package, respectively

In the terminal for executing this command, 2 questions will be asked.

1st question: Type of package: (single, indep, library, python) [s/i/l/p]?".

Must select "s"

2nd question: "Maintainer Name : Sergey Email-Address : sergey@unknown Date : Thu, 16 Jul 2020 10:55:34 +0300 Package Name : mydebpackagename Version : 0.0.1 License : blank Package Type : single Are the details correct? [Y/n/q]".

Must select "Y"

If the command is successful, the runtime terminal will display "Done. Please edit the files in the debian/ subdirectory now."

Stage 7

  1. Change to the Create_deb/debian directory (from the Create_dir directory): cd debian

Stage 8

  1. Open the changelog file for editing: nano changelog

Stage 9

  1. Change the word unstable to the word trusty. Save and exit the file (Ctrl+O, Ctrl+X)

Stage 10

  1. Open the rules file for editing: nano rules

Stage 11

  1. In the % target, before the dh $@ command, add the following line: mkdir ~/DEB-Package-Creation/Example_deb_create/Run_deb/mydebpackagename_dir || true

We will place the executable file of our program in this folder.

Note: "|| true" is necessary so that when trying to re-create the ~/DEB-Package-Creation/Example_deb_create/Run_deb/mydebpackagename_dir directory, the deb package creation script does not throw an error (and this script tries to execute this command several times (duplicating this command for some internal purposes - you can see on the Internet how to avoid this by overriding various default targets - but this problem is easier and more elegantly solved)

Stage 12

  1. Create a file mydebpackagename.install and open it for editing:
mydebpackagename.install:
------------------------------------
hello_world_deb.c /home/user/DEB-Package-Creation/Example_deb_create/Run_deb/mydebpackagename_dir
hello_world_deb /home/user/DEB-Package-Creation/Example_deb_create/Run_deb/mydebpackagename_dir
Makefile /home/user/DEB-Package-Creation/Example_deb_create/Run_deb/mydebpackagename_dir
------------------------------------

Stage 13

  1. Now you need to change to the Create_deb directory from the Create_deb/debian directory: cd ..

Stage 14

  1. From the Create_deb directory, you need to run the command to build the deb package: dpkg-buildpackage

Stage 15

  1. After that, you need to go down one directory from the Create_deb directory (to the Example_deb_create directory): cd ..

Stage 16

  1. Run the ls command and make sure that the file mydebpackagename_0.0.1-1_amd64.deb has actually been created: ls

Stage 17

  1. Run the command to install the deb package: sudo dpkg -i mydebpackagename_0.0.1-1_amd64.deb

Stage 18

  1. From the Example_deb_create directory change to the Example_deb_create/Run_deb/mydebpackagename_dir directory: cd Run_deb/mydebpackagename_dir

Stage 19

  1. Make sure there are 3 files there (hello_world_deb.c, hello_world_deb, Makefile): ls

Stage 20

  1. Run the hello_world_deb executable and make sure it is running (the line Hello, World should appear in the console): ./hello_world_deb

Stage 21

  1. If the line is displayed - congratulations, you have correctly compiled and installed a simple deb package with your own software!

📑 Licence

Creation deb-package is CC BY-NC-SA 3.0 licensed.

deb-package-creation's People

Contributors

sergeyivanovdevelop avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.