0

On my system I have a few programs installed by compiling the source code directly or by some other means which do not use the package manager (for instance, I've installed TeX Live directly from the iso provided on the website), one example of them is ViM: I installed it by compiling the source code directly and run sudo make install.

The problem is that the package manager is not aware that such software is installed on my system, thus it asks me to install it (for instance, if I type apt install vim it tells me that ViM can be installed, even though I have ViM already installed on my system).

How can I make the package manager aware of the fact that the programs included in some packages have already been installed?

Thanks in advance.

EDIT: this question comes from my need to install GNU-Octave. I already have texlive installed (as I mentioned before), but nonetheless apt wants to install tex-common and texinfo. I checked if the content of the package texinfo was present by typing man texinfo before installing it, and a manual page was shown. After the installation of texinfo with apt install texinfo that manual page changed.

1
1

A package manager needs some data on the packages in order to do its magic. Things like paths, configurations files, start and stop services, pre-install and post-remove scripts, dependencies ...

If you compile from source, and the source has no build targets for the package you system uses, it would be difficult to make the system aware of the manually installed software (note that in the eyes of the package manager, nothing was installed). It amounts to creating a suitable package (say, a .deb) from the source.

So, the answer is to check if the source has build targets for the packages used in your system. If it has not, then you have to create the structure to build a package yourself.

The Octave staff belongs to another question. If that's your real problem, then start a new question, and post the apt commands and output.

1
  • I've seen that I can use the checkinstall utility I was not aware of. I'll follow your advice and I will post another question with the question about octave. Thanks – LuxGiammi Jan 5 '20 at 21:05
1

You can trick the package manager by installing stub "equivalent" packages. The equivs package can help you creating those, its description is:

Circumvent Debian package dependencies

This package provides a tool to create trivial Debian packages. Typically these packages contain only dependency information, but they can also include normal installed files like other packages do.

One use for this is to create a metapackage: a package whose sole purpose is to declare dependencies and conflicts on other packages so that these will be automatically installed, upgraded, or removed.

Another use is to circumvent dependency checking: by letting dpkg think a particular package name and version is installed when it isn't, you can work around bugs in other packages' dependencies. (Please do still file such bugs, though.)

Be warned that you'll be on your own from this point. Hope you had a good reason for choosing this route instead of installing software from packages (preferably backports but even ones created by checkinstall).

2
  • I was not aware of the checkinstall utility. I tried it with a program and I managed to make a package out of compiled code, install it and my package manager sees it. One question though: does the package manager now know that the software is installed so that if I install a software (via the usual apt install) that depends on the software I've manually compiled it does not get installed again, just like using the equivs package you told me about in your answer? Thank you. – LuxGiammi Jan 5 '20 at 21:03
  • If you named your package the same as the official one it substitutes, it will satisfy the same dependencies. Of course, versioned dependencies have version constraints as well. – Ferenc Wágner Jan 6 '20 at 6:09
0

I had a similar issue, and as it took me a while to figure it out, I thought I'd drop my solution here.

It's a script you can call with a list of package-names, it builds installable .deb package files.

When finished (it takes seconds or less), you can install the packages with "dpkg -i *.deb"

#!/bin/bash

# default version ('high' to supercede further updates)
VERSION=99.99-99.99
# debian-version, urgency, date
RELEASE="experimental; urgency=low\n\n  * Initial Release\n\n -- Dummy <dummy@example.com>  Thu,  31 Dec 2099 00:00:00 +0000\n"

# iterate over command-line arguments
for PKGNAME do

    # check for existing package, to borrow the control file
    echo -n "\n${PKGNAME} : exists in dpkg ? "
    grep -m 1 "^Package: ${PKGNAME}$" /var/lib/dpkg/status \
        && {
            echo " .. YES .. try use dpkg version of control file"
            grep -A 2000 "^Package: ${PKGNAME}$" /var/lib/dpkg/status | \
                sed "s|^\(Package:\)|~\1|" | tr '\n~' '^\n' | \
                head -n 2 | tr '^' '\n' | grep "[^ ]" \
                    > ${PKGNAME}.ctl

        # remove borrowed control-file if none found
        find . -maxdepth 1 -type f -name ${PKGNAME}.ctl -size 0 -delete || \
            echo " .. (but failed)"
        }

    # if we didn't successfully borrow a control-file, fake it to make it
    [ -f  ${PKGNAME}.ctl ] || \
        {
            echo " .. NO .. use template (/usr/share/equivs/template*)"
            equivs-control ${PKGNAME}.ctl
            sed -i "s/^Package:.*/Package: ${PKGNAME}/" ${PKGNAME}.ctl
            sed -i "s/.*Changelog:.*/Changelog: dummychangelog/" ${PKGNAME}.ctl
            echo -e "${PKGNAME} (${VERSION}) ${RELEASE}"  > dummychangelog
        }

    # now, with a control-file, build a deb file
    [ -f  ${PKGNAME}.ctl ] && \
        {
            sed -i "s/^Version:.*/Version: ${VERSION}/" ${PKGNAME}.ctl
            equivs-build ${PKGNAME}.ctl 2>&1 >  ${PKGNAME}.ctl.log
            # cleanup if we succeeded
            ls -l ${PKGNAME}*.deb && { rm dummychangelog ${PKGNAME}.ctl.log ${PKGNAME}.ctl 2>/dev/null ; }
        }
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.