قالب وردپرس درنا توس
Home / Tips and Tricks / How to Install Software with Git on Linux

How to Install Software with Git on Linux



  Code on a Laptop Screen
MchlSkhrv / Shutterstock

Have you been told to "clone and create the repo" and you do not know what to do next? We'll show you how to get this program running on GitHub on Linux, even if you're a beginner.

The instructions that make up a computer program are written, edited and stored in text files. A program called compiler then processes these files. This generates the executable version of the program. The text files of instructions are called source code. The version of the program that can actually run on a computer is called a binary file or executable file.

This is a simplified version of events, but it does draw a correct, albeit generalized picture. In practice, you will find all possible variations of this model. Sometimes other programs generate the text files. In other cases, the source code is executed in an interpreter and does not need to be compiled, and so on.

However, in all software projects, the one common truth is that the source code files are the crown jewels, and they are the crown jewels.

Version Control Programs

All source code files in a project are called code bases. In large projects, many developers often work on the code base. Every code change must be traceable and identifiable. If necessary, the changes must be reversible. If different developers make changes to the same source code file, their changes need to be merged.

It is therefore not surprising that software programs called version control systems exist to facilitate the management of changes to the code base. Version control systems include all previous versions of each file in the code base, and every change is recorded, commented, and tracked.

A Trifle Called Git

Linus Torvalds, the creator of the Linux kernel, has developed a version control program called Git to manage the Linux kernel codebase. It is now the world's most widely used version control software. It is literally used by millions of people.

Git is used to store the codebase of a project in Repositories . In addition to the local repositories that reside on the developer's computers and possibly on a central server on the network, it is recommended that you have an external or remote repository.

And that's where GitHub comes in. [1

9659010] GitHub

GitHub was created as a result of the success of git . The founders recognized the emerging need for securely hosted remote Git repositories. They founded a company that provides a cloud platform where development teams can host remote repositories. As of April 2019, GitHub hosts over 100 million repositories.

If an application is an open source project, it's very likely to be hosted on GitHub. There are other repository platforms like BitBucket and GitLab, but GitHub has the lion's share of open source repositories.

Anatomy of a repository

A GitHub repository consists of folders that contain files, such as the main source code files. Usually there are many other file types in the repository. There may be documentation files, man pages, software license files, build instructions, and shell script files. There are no rules on what a repository should or should contain, but there are conventions.

If you are familiar with a kitchen, you can navigate in any kitchen. The situation is similar with repositories. Once you understand the conventions, you know where to go to find what you need.

How do you get a copy of the repository on your computer and how do you build the program into an executable binary?

The readme file

It is a tradition to include a readme file in a repository. It can be called Readme, Readme or README. It may have the extension ".md" or no extension.

Let's take a look at the GitHub repository for the Atom Editor. You will see a long list of folders and files. Scroll down and you will see the contents of the README.md file.

GitHub automatically adds the contents of the Readme file to the start page of the repository. If the Readme file has the extension ".md", it contains the markup language "Markdown". This allows developers to use style elements such as fonts, bullets and images.

 Section of the readme.md file for the github Atom Editor.

Typically a readme file The sections tell you what the project is about, what type of license it is, who is managing the project, how you are involved, and how to build the application and execute.

Find out where to find this information. Other information useful to creating the application, such as the required build tools and other dependencies, may be listed here or a link will take you to that information.

The Boxing Repository

Our mission is to clone the boxing repository. and then create the application boxes .

The repository follows the same layout as Atom. There is a list of folders and files. Underneath is the contents of the readme file. It follows the default layout for a repository, but is a smaller project, so there are fewer folders and files.

The Readme file is also shorter. It has a section called "Development". This section has a link titled "Building from Source". If we follow this link, we should find the information we need.

 Link to building instructions for the boxing application.

Typically, lightweight sleuthing is required to navigate the repository and find the information you want, but it's not difficult. Read everything carefully on the repository page. Sometimes the information is there but may not be clearly visible.

Dependencies

The Create From Sources page has a section called "Create on Linux". That's exactly what is needed. It means we need to have a C compiler, bison, and flex installed.

 Required toolkit for creating the box application

The instructions for building state that the command make should be issued, so we must also make create.

The tools required to build this application include a C compiler, Bison, Flex, make and Git (to clone the repository) your computer).

This article was about computers running the Linux distributions Ubuntu, Fedora, and Manjaro. None of the distributions had all these tools installed – something had to be installed on each one.

Installing the Tool Set

Ubuntu needed Git, Flex, Bison, and make installed. Here are the commands:

  sudo apt-get install git 

  sudo apt-get install flex 

  sudo apt-get install bison 

  sudo apt-get install make 

Fedora had to install Flex, Bison and make . Here are the commands:

  sudo dnf install flex 

  sudo dnf install bison 

  sudo dnf install make 

Manjaro had to install the GCC compiler Flex and Bison. Here are the commands:

  sudo pacman -Syu gcc 

  sudo pacman -Syu flex 

  sudo pacman -Syu bison 

Cloning the Repository

Each GitHub repository has a specific web address that Git uses to clone the repository to your computer. There is a green button labeled "Clone or Download" on the main page of the box repository.

 The

Click the button to view the web address. This is the address we need to pass to the git command when we clone the repository.

Change to the directory to which the repository is to be cloned, and then use this command. If your terminal window supports this, you can copy the web address and paste it into the command. Press Ctrl + Shift + V to paste it into a GNOME terminal window.

   

Git clones the remote repository and creates a local repository on your computer. It states that it is cloned into a directory called "boxes".

 Cloned repository in a terminal window.

The "boxes" directory is created in the directory from which you command the command. If we switch to the box directory and look at the content, we'll see the same list of files and folders we've seen on the GitHub page.

   The contents of the box repository in a terminal window. 

Great! We successfully cloned the source code and other files onto our computer. Now we have to create the application.

Creating the application

To build the application, we must follow the instructions in the GitHub repository. Sometimes we execute a particular shell file and others execute make . The build statements we follow have instructed us to do the following: make .

The utility make reads and executes a series of statements from a makefile. These instructions indicate how the program should be compiled and linked. make passes the instructions to the compiler and other build tools.

The command we are to use calls make twice. The first call to make creates the application, and the second invokes a series of tests.

The command that the build statements should use is:

  make && make test 

In the terminal window, many output lines roll by quickly. In about a minute, you will return to the command prompt.

Deploying the Box Application

The application was created and there is an executable binary file. We now have to copy the binary file into the directory / usr / bin /. That way, the shell can find it when we try to use it.

For some applications, this may be all you need to do. In other cases, you may need to copy additional files, such as man pages and configuration files, to file system locations. The latter is what we need to do with our new application because it was included in the build guide.

 File copy commands from GitHub.

Use sudo to execute these commands. The first command copies a man page to the directory man1:

  sudo cp doc / boxes.1 / usr / share / man / man1 

Next, copy the global configuration file to a directory in / usr / share /:

  sudo cp-boxes-config / usr / share / boxes 

Finally copy the binary file to / usr / bin:

  sudo cp src / boxes / usr / bin 

Testing the application box

Let's see if everything works! Try opening the man page for the boxes command. [1969017] man boxes

That's encouraging! You will see a man page explaining how to use the Fields command.

Press "Q" to exit the Man system and try to use the fields. command.

  echo Quick Start Guide Geek | Nesting 

And we get the answer:

<img class = "alignnone wp-image-429147 size-full" data-pagespeed-lazy-src = "https: //www.howtogeek. com / wp-content / uploads / 2019/07 / xgit_24.png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.i6SWUJk81N.png "alt = "Boxes Are Issued in a Terminal Window In this exercise, you should retrieve a GitHub repository and create the application.

You can use the command to wrap text that is passed to the repository in a variety of frames For example, the above format works as a comment in a C source code file, others are purely decorative, and the option -d (Theme) lets you choose the style of the frame.

  Echo: How-To Geek | Boxing -d Whirly 
  Echo How-To Geek | boxing -d c-cmt2 

There is a long list of designs to choose from. Use the following command to display them all:

  boxes -l | less 

Build complete

The steps to create from the source code are usually straightforward:

  • Read the instructions for creating in the repository.
  • Verify that the required tools are installed and reinstall any missing ones.
  • Clone the repository on your computer.
  • Follow the build instructions, which are often as simple as typing make .
  • Copy the file (s) to the required locations.

If There are any unclear steps in the build instructions, it will check if the project has a forum or community to which you can submit a question. If the application has a Web site, you may see a Contact page. The developer who manages the boxing project has his e-mail address on the info page of the box website. This is a generous gesture on his part and typical of the wider open source community.




Source link