⬆️ ⬇️

Slackware. Src2pkg utility or how not to make a dump out of

Sooner or later, any beginner Linux user will be faced with the need to build a program from source. The reasons for this can be very different, ranging from sports interest and ending with a handwritten / self-corrected program.



Typing in Google “how to build a program from source”, a beginner Linux user will immediately come across a well-known mantra:

./configure

make

make install


This is how the system turns into a trash can. Here you put hundreds of programs this way, and now try to remove 50 of them. At best, you will be helped by downloading the same source version as the installed program, ./configure with the same parameters, make and only then make uninstall, and then if the developer took care of uninstalling his creation. In the worst case, crawl through all the folders on your system and clean all the files associated with the program with your hands.



And the one and the other method is tedious, long and with a bunch of nuances. Therefore, we will explore a different way to install programs, using the example of Slackware OS 13.



So. For a start, I hasten to please all the slave ducks (and grieve the slackers). The package manager is there in the slak, was and will be there .

')

Yes, it is not as functional as Debian or Ubuntu, and the packages there are not deb and not rpm. But who said that this is bad?



The package in the slak is a tgz-archive (and also from the 13th version also txz), consisting of binaries and an installation script. To install the package, use the installpkg command, to remove-removepkg.



UPD: thanks for the comment kyb27



I will explain the principle of the installation method under consideration. We have the source code, of which we use the src2pkg utility to make a package, which we then install through installpkg. The advantage of this installation method is that at any time we can demolish our program with the command removepkg.



With the theory finished, let's move on to practice.



There should be no problems with installing the src2pkg program. Still, I will explain with an example (all commands from the root):

mkdir /home/src2pkg

cd /home/src2pkg

wget distro.ibiblio.org/pub/linux/distributions/amigolinux/download/src2pkg/src2pkg-2.2-noarch-3.tgz

installpkg src2pkg-2.2-noarch-3.tgz


Everything, the utility is installed.



Now let's try using it to build and install the mc program.

mkdir /home/mc

cd /home/mc

wget --content-disposition www.midnight-commander.org/downloads/40


UPD: for the remark thanks to Toseter .



Now we read mana, configurations, etc., if we need compilation options for the program. If not, it is still easier.

In my case, the team to build a package of sorts had a trace. view:

root@ironnet:/home/mc# src2pkg -e='--sysconfdir=/etc/mc --without-x --without-edit' -C mc-4.7.0.4.tar.bz2

Where:

-e - option to compile with parameters

- - put the created package in the current directory

mc-4.7.0.4.tar.bz2 - sorts file



The conclusion is this:

Found source archive: mc-4.7.0.4.tar.bz2

Deleting old build files - Done

Creating working directories:

PKG_DIR=/tmp/mc-4.7.0.4-i486-1

SRC_DIR=/tmp/mc-4.7.0.4-src-1

Unpacking source archive - Done

Correcting source permissions - Done

Checking for patches - None found

Found configure script - Done

Configuring sources using:

LDFLAGS="-Wl,-L/lib,-L/usr/lib" CFLAGS="-O2 -m32 -march=i486 -mtune=i686" ./configure --prefix=/usr --sysconfdir=/etc/mc - -without-x --without-edit --libdir=/usr/lib

Configuration has been - Successful!

Compiling sources - Using: 'make'

Compiling has been - Successful!

Checking for Makefile rule: 'install' Okay

Creating content in JAIL root - Using: 'make install'

Safe content creation - Successful!

Processing package content:

Correcting package permissions - Done

Stripping ELF binaries - Using: strip -p --strip-unneeded Done

Checking for standard documents - Done

Compressing man pages - Done

Creating slack-desc - From default text

Searching for links in: mc-4.7.0.4-i486-1 - Done

Adding links to doinst.sh - Adding links-creation to the doinst.sh

Deleting symbolic links - Removing links from the package directory

Rechecking package correctness -

Checking for misplaced dirs - Done

Rechecking package permissions - Done

Creating package: mc-4.7.0.4-i486-1.tgz - Done

Package Creation - Successful! Package Location:

/home/mc/mc-4.7.0.4-i486-1.tgz


Package is ready. We put it:

root@ironnet:/home/mc# installpkg mc-4.7.0.4-i486-1.tgz

Verifying package mc-4.7.0.4-i486-1.tgz.

Installing package mc-4.7.0.4-i486-1.tgz:

PACKAGE DESCRIPTION:

# mc

#

# No description was given for this package.

#

# Packaged by src2pkg

Executing install script for mc-4.7.0.4-i486-1.tgz.

Package mc-4.7.0.4-i486-1.tgz installed.


Panels opened, everything is in order. Congratulations on successful installation.

To remove our package, use the command

removepkg mc-4.7.0.4-i486-1.tgz

Naturally, after some time we forget which version of mc we have. But there is a way out.



To quickly find out exactly which MC package is installed in our system, run the command:



ls /var/log/packages/mc*



Which will return to us the name of our package, and at the same time the version of mc.

A little bit of taste in the end:

The src2pkg program has many more options, including creating a package from sorts with a preliminary download of the latter into a temporary directory.



UPD: quietly and quietly updated version of the program.

Source: https://habr.com/ru/post/91073/



All Articles