Hello. I’m wondering why apt search
on OSMC is looking like this:
And not like this:
It looks like OSMC is actually using apt-cache
instead of apt
. Could someone explain this situation?
Hello. I’m wondering why apt search
on OSMC is looking like this:
And not like this:
It looks like OSMC is actually using apt-cache
instead of apt
. Could someone explain this situation?
You are correct. /usr/bin/apt is a shell script that is part of the package base-files-osmc.
osmc@osmc-4k:~$ file /usr/bin/apt
/usr/bin/apt: Bourne-Again shell script, ASCII text executable
osmc@osmc-4k:~$ file /usr/bin/apt-cache
/usr/bin/apt-cache: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=c0bb304a153a88eb8671a5fc395808e737fabc31, stripped
osmc@osmc-4k:~$ dpkg -S /usr/bin/apt
diversion by base-files-osmc from: /usr/bin/apt
diversion by base-files-osmc to: /usr/bin/apt-real
base-files-osmc, apt: /usr/bin/apt
The answer as to why is one for @sam_nazarko, but it’s probably to do with ensuring that people run full-upgrades, rather than upgrades.
Yea i actually know that. I also know that “vanilla” apt
is renamed to apt-real
.
However running apt-real search
produces the same output as shown on first picture.
Also the script apt
doesn’t really do much. It should not have any impact on other commands than upgrade.
Happy to accept a PR on this.
apt can vary from distribution to distribution. It’d help if you told us what distribution you are using when you see the other results. It may also be influenced by apt.conf.d.
Sam
You originally said:
But that’s not the case:
osmc@osmc-4k:~$ ls -l /usr/bin/apt-cache /usr/bin/apt-real
-rwxr-xr-x 1 root root 54872 Sep 13 2017 /usr/bin/apt-cache
-rwxr-xr-x 1 root root 9732 Sep 13 2017 /usr/bin/apt-real
osmc@osmc-4k:~$ apt-real --help
apt 1.4.8 (armhf)
Usage: apt [options] command
apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialized APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use by default.
Most used commands:
list - list packages based on package names
search - search in package descriptions
show - show package details
install - install packages
remove - remove packages
autoremove - Remove automatically all unused packages
update - update list of available packages
upgrade - upgrade the system by installing/upgrading packages
full-upgrade - upgrade the system by removing/installing/upgrading packages
edit-sources - edit the source information file
See apt(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
This APT has Super Cow Powers.
osmc@osmc-4k:~$ apt-cache --help
apt 1.4.8 (armhf)
Usage: apt-cache [options] command
apt-cache [options] show pkg1 [pkg2 ...]
apt-cache queries and displays available information about installed
and installable packages. It works exclusively on the data acquired
into the local cache via the 'update' command of e.g. apt-get. The
displayed information may therefore be outdated if the last update was
too long ago, but in exchange apt-cache works independently of the
availability of the configured sources (e.g. offline).
Most used commands:
showsrc - Show source records
search - Search the package list for a regex pattern
depends - Show raw dependency information for a package
rdepends - Show reverse dependency information for a package
show - Show a readable record for the package
pkgnames - List the names of all packages in the system
policy - Show policy settings
See apt-cache(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
osmc@osmc-4k:~$ apt-cache list coreutils
E: Invalid operation list
osmc@osmc-4k:~$ apt-real list coreutils
Listing... Done
coreutils/stable,now 8.26-3 armhf [installed]
So apt-real
and apt-cache
are two separate binaries with some overlapping functions.
As to why apt-real search
is producing an output similar as apt-cache search
, I have no idea. Perhaps Sam will be able to enlighten us.
@sam_nazarko second picture is from raspbian, but the same output is produced also in vanilla debian an ubuntu.
I would happily produce a PR, but for now i don’t know the cause of this situation. Need to investigate it more. I’ll try to compare configs for the beginning.
@dillthedog yup i noticed it too, which makes things even more strange.
EDIT: Okay, i found the cause. I copied the apt-real
binary to home directory and renamed it to simply apt
. Ran it from there and the output produced is like on second picture. So it seems like apt itself is changing output according to binary name.
How about we change the content of file 104-add-osmc-bin.sh
from:
export PATH="$PATH:/usr/osmc/bin"
to:
export PATH="/usr/osmc/bin:$PATH"
Then we can install the apt
script into /usr/osmc/bin
with the original apt
binary living as usual in /usr/bin
. This way, when user invokes apt
from command line, it should call the script as /usr/osmc/bin
is present earlier than /usr/bin
in $PATH.
Also the apt script must be tweaked to point REAL_APT to /usr/bin/apt
.
EDIT2: Just checked the above solution on my installation and can confirm it’s working as expected.
If you run apt-config dump | less
you’ll see all the APT configuration settings. Somewhere in that output you’ll see a block of settings for Binary::apt
:
Binary::apt "";
Binary::apt::APT "";
Binary::apt::APT::Color "1";
Binary::apt::APT::Cache "";
Binary::apt::APT::Cache::Show "";
Binary::apt::APT::Cache::Show::Version "2";
Binary::apt::APT::Cache::AllVersions "0";
Binary::apt::APT::Cache::ShowVirtuals "1";
Binary::apt::APT::Cache::Search "";
Binary::apt::APT::Cache::Search::Version "2";
Binary::apt::APT::Cache::ShowDependencyType "1";
Binary::apt::APT::Cache::ShowVersion "1";
Binary::apt::APT::Get "";
Binary::apt::APT::Get::Upgrade-Allow-New "1";
Binary::apt::APT::Cmd "";
Binary::apt::APT::Cmd::Show-Update-Stats "1";
Binary::apt::APT::Keep-Downloaded-Packages "0";
Binary::apt::DPkg "";
Binary::apt::DPkg::Progress-Fancy "1";
Since the binary is now called apt-real, those settings are not used and I assume that APT must default to some fall-back values.
If you create a file /etc/apt/apt.conf.d/99-apt-real
containing settings for Binary::apt-real
, you’ll then see the expected behaviour:
Binary::apt-real "";
Binary::apt-real::APT "";
Binary::apt-real::APT::Color "1";
Binary::apt-real::APT::Cache "";
Binary::apt-real::APT::Cache::Show "";
Binary::apt-real::APT::Cache::Show::Version "2";
Binary::apt-real::APT::Cache::AllVersions "0";
Binary::apt-real::APT::Cache::ShowVirtuals "1";
Binary::apt-real::APT::Cache::Search "";
Binary::apt-real::APT::Cache::Search::Version "2";
Binary::apt-real::APT::Cache::ShowDependencyType "1";
Binary::apt-real::APT::Cache::ShowVersion "1";
Binary::apt-real::APT::Get "";
Binary::apt-real::APT::Get::Upgrade-Allow-New "1";
Binary::apt-real::APT::Cmd "";
Binary::apt-real::APT::Cmd::Show-Update-Stats "1";
Binary::apt-real::APT::Keep-Downloaded-Packages "0";
Binary::apt-real::DPkg "";
Binary::apt-real::DPkg::Progress-Fancy "1";
In my very limited tests so far, I haven’t found any adverse effects.
Does the same issue exist with apt-get or only with apt ?
There is:
Binary::apt-get "";
Binary::apt-get::Acquire "";
Binary::apt-get::Acquire::AllowInsecureRepositories "1";
but it’s less extensive.