Puppet not uninstalling package - puppet

I'm trying to uninstall packageA with puppet, however puppet doesn't uninstall.
My package resource looks like this:
package {
'packageA':
ensure => absent,
provider => rpm,
alias => 'packageA',
name => 'packageA',
uninstall_options => ['--nodeps'],
}
Here are the --debug puppet logs for that package:
Debug: /Package[packageA]: Provider rpm does not support features targetable; not managing attribute command
Debug: Executing: '/bin/rpm --version'
Debug: Executing '/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
Debug: Executing: '/bin/rpm -q packageA --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing: '/bin/rpm -q packageA --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n --whatprovides'
Debug: /Package[packageA]: Nothing to manage: no ensure and the resource doesn't exist
I don't see puppet executing rpm -e --nodeps packageA anywhere. Am I missing something?
Please note that if I have rpm -e packageA --nodeps in an exec resource, it uninstalls the package. But I'd like to know what's wrong with the package resource above.
Thanks in advance.

Try this
package { 'packageA':
ensure => absent,
alias => 'packageA-<version or arch>',
uninstall_options => ['--nodeps'],
}
It's good practice not to specify the provider, one of the advantages of Puppet is the abstraction layers, it'll figure out the correct provider for you so your code will run on any OS, you may find Puppet successfully removes this package with yum. Just leave that complexity to Puppet to sort out.
You only need the alias if the package might be known as a different name, a yum info should tell you this or an rpm -qa packageA, that would have been useful to add to the original question.
You generally won't need to specify the name as it defaults to the resource title.
https://puppet.com/docs/puppet/5.5/types/package.html

I don't see puppet executing rpm -e --nodeps packageA anywhere. Am I missing something?
Yes and no and maybe.
Do you see ...
Debug: /Package[packageA]: Nothing to manage: no ensure and the resource doesn't exist
? That's telling you that Package packageA isn't installed in the first place. In that case, Puppet does not need to do anything to make it absent. In particular, it will not execute a rpm -e command for a package that isn't (initially) installed in the first place.
However, that message also says "no ensure". Perhaps that exhibits a bug, but it seems to be telling you that the Package it is applying does not have an ensure attribute expressed, which would mean that the output presented does not go with the code presented. Still, that doesn't change anything in the previous paragraph.

Related

Why doesn't `nix-env -q` find my installed packages? (NixOS channels, profiles and packages)

I recently installed NixOS and I ended up with 3 profiles:
bruno (a user profile),
default (used by root), and
system (used by NixOS).
I found it convenient to use a stable channel for the system profile and an unstable channel for me (bruno profile):
~> nix-channel --list
unstable https://nixos.org/channels/nixos-unstable
~> sudo nix-channel --list
nixos https://nixos.org/channels/nixos-17.09
I have then declaratively installed a few packages through /etc/nixos/configuration.nix:
environment.systemPackages = with pkgs; [
firefox
chromium
htop
# ...
];
And some imperatively: nix-env --install firefox.
Now listing my installed packages, I'd expect to also see the ones provided by the system profile (as they are available in my user profile):
~> htop --version
htop 2.0.2 - (C) 2004-2016 Hisham Muhammad
Released under the GNU GPL.
~> nix-env -q | grep htop
~> nix-env -q | grep firefox
firefox-57.0
Only Firefox is listed. Let's try using the root profile:
~> sudo nix-env -q | grep htop
Same thing, it's actually completely empty.
Maybe using the system profile:
~> sudo nix-env -p /nix/var/nix/profiles/system -q
Still nothing.
Coming from traditional package managers (Debian, Red Hat), I find confusing that Nix being defined as "The Purely Functional Package Manager" does not seem to provide a tool to query packages universally - nix-env is mentioned throughout the manuals and feels like Debian apt's alter ego.
Is there such a tool, or is this a non-problem, that is, people are generally fine with not having a list of all packages present across profiles/environments?
nix-env -q will only report packages that are installed into imperative 'environments', like those created by nix-env -i.
nix-env is a tool for imperative package management that is a thin layer over the otherwise declarative and immutable Nix system. The profiles mechanism provides a means for mutability and nix-env creates manifest.nix in the profile to record the set of packages that are in the environment.
A NixOS system only uses the profiles but does not provide a manifest.nix file. This makes sense, because a NixOS system gets rebuilt from scratch every time, which makes it nicely declarative.
As a consequence nix-env can not query a NixOS profile.
So, nix-env -q queries your imperatively installed user packages. sudo nix-env -q shows those imperatively installed by root, which does not include your NixOS packages, because they are part of your system, declaratively. Pointing nix-env -q -p at your NixOS system gives an empty list, because it's not an environment created by nix-env.
The reason your user can use system commands is not because the system is part of the (Nix) environment in the user profile, but because your (UNIX) environment variables point to both profiles.
$ which firefox
/home/user/.nix-profile/bin/firefox
$ which cp
/run/current-system/sw/bin/cp
$ echo $PATH
[...]
To figure out what is installed on your system, you may run the following commands:
nix-env -q to figure out what is installed in an imperative user environment.
nixos-option environment.systemPackages to query the set of packages that will appear in /run/current-system/sw when your configuration is built and activated. To quote its documentation, "These packages are automatically available to all users."
nix-store -q --requisites /run/current-system ~/.nix-profile the combined closure of dependencies of the current system and your user profile
nix-store -q --references /run/current-system direct dependencies of the current system
See --query section or nix-store --help for more options.

repackage an rpm from an installed rpm

On linux can we repackage a installed rpm if so how.I remember that the a rpm can be generated from the installed binaries
rpm -??? > my.rpm
Also the later i.e, the newer rpm should work on a different machine
There is also rpmrebuild
http://rpmrebuild.sourceforge.net
Actually there is a simple but "tricky" way; it is just : rpm -e --repackage package-name
It will output the RPM in /var/spool/repackage/.
Example:
# rpm -e --repackage samba3x-client
# file /var/spool/repackage/samba3x-client-3.5.4-0.83.el5_7.2.i386.rpm
/var/spool/repackage/samba3x-client-3.5.4-0.83.el5_7.2.i386.rpm: RPM v3 bin i386 samba3x-client-3.5.4-0.83.el5_7
Why tricky? Because it actually remove the program prior packaging it, just so you know.
This is possible, but not with the rpm command. I wrote a perl script that does this; it crafts a spec file based on the outputs of rpm -q and does a "build" which just copies the installed files from the system.
You can find it here: https://github.com/cormander/rogue-beret-tools/blob/master/scripts/rpm-repack
Usage example, re-packaging the mailx rpm:
Query it:
$ rpm -ql mailx
/bin/mail
/etc/mail.rc
/usr/bin/Mail
/usr/lib/mail.help
/usr/lib/mail.tildehelp
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz
Repack it:
$ ./rpm-repack -p mailx
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.9773
+ umask 022
+ cd /usr/src/redhat/BUILD
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: mailx-8.1.1-44.2.2
Provides: mailx
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.3.4) libc.so.6(GLIBC_2.4) rtld(GNU_HASH)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/tlkN4yrYEi
Wrote: ~/rpmbuild/RPMS/i386/mailx-8.1.1-44.2.2.i386.rpm
Query the newly built package:
$ rpm -qpl ~/rpmbuild/RPMS/i386/mailx-8.1.1-44.2.2.i386.rpm
/bin/mail
/etc/mail.rc
/usr/bin/Mail
/usr/lib/mail.help
/usr/lib/mail.tildehelp
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz
The code isn't at all elegant, but functional. It does copy a lot of the rpm info (everything from rpm -qi and most of the scripts), but it isn't by any means comprehensive. Also, it can't copy the GPG signature, nor will it have the same checksums as the original RPM file.
NOTE: This is not a "proper" way to build and distribute RPM packages, and was mainly written for troubleshooting and educational purposes.
I think that most rpm based distributions how have official package rpmrebuild (or in the almost official 3'rd party repos like epel, rpmfusion ... etc). I think nowadays this would be your best option for repackaging installed packages.

Can cabal not un-install packages?

cabal help shows thers isnot "uninstall" option.
then what's the best way to uninstall the packages installed by cabal ?
% cabal update
% cabal install mighttpd2
mighttpd2 is installed successfully. However the ghc-pkg cannot find & unregister it:
% ghc-pkg list | grep -i might
% ghc-pkg unregister mighttpd2
ghc-pkg: cannot find package mighttpd2
Sincerely!
>find .cabal | grep -i mighttp
.cabal/share/doc/mighttpd2-2.3.3
.cabal/share/doc/mighttpd2-2.3.3/LICENSE
.cabal/share/mighttpd2-2.3.3
.cabal/share/mighttpd2-2.3.3/sample.conf
.cabal/share/mighttpd2-2.3.3/sample.route
.cabal/packages/hackage.haskell.org/mighttpd2
.cabal/packages/hackage.haskell.org/mighttpd2/2.3.3
.cabal/packages/hackage.haskell.org/mighttpd2/2.3.3/mighttpd2-2.3.3.tar.gz
>ghc-pkg list | grep -i package\.conf
/usr/local/lib/ghc-7.0.3/package.conf.d:
/home/sw2wolf/.ghc/i386-freebsd-7.0.3/package.conf.d:
So ".cabal/packages/hackage.haskell.org" cannot be seen by ghc-pkg.
you might not have the Cabal path as part of your GHC path.
step 1
First, try to find out what your GHC package path is,
ghc-pkg list
# displays stuff like "/home/username/.../package.conf.d"
then, make sure the one Cabal is writing to is active. For me, Cabal adds packages to
/home/username/.ghc/x86_64-linux-7.0.4/package.conf.d
step 2
If there is no such directory on your system, see what Cabal's writing.
strace -f -o trace.txt cabal install mighttpd2
grep "package\.cache" trace.txt
then add the package path to this system environment variable
export GHC_PACKAGE_PATH=NEWPATH:/usr/local/lib/ghc-7.0.3/package.conf.d
try again, if it doesn't work proceed to step 3
step 3
look in that directory and see if there's a file like
mighthttpd2-version-LONGHASHCODE.conf
if it's there, then you probably need to recache
ghc-pkg recache --user
The GHC package system is not used for executables, and the mighttpd2 package only builds executables. To uninstall it, simply remove the two executables (mighty and mkindex) and the two data files (sample.conf and sample.route) listed in the package's cabal file. You can find which directories these files were installed to by perusing cabal's config file in ~/.cabal/config.

Displaying information on non-installed RPM package?

I googled for this, but couldn't find how to query a non-installed RPM file for its information:
# rpm -qa blackfin-jtag-tools-09r1.1-2.i386.rpm
#
# rpm -qi blackfin-jtag-tools-09r1.1-2.i386.rpm
package blackfin-jtag-tools-09r1.1-2.i386.rpm is not installed
#
# rpm -q blackfin-jtag-tools-09r1.1-2.i386.rpm
package blackfin-jtag-tools-09r1.1-2.i386.rpm is not installed
#
# rpm --info blackfin-jtag-tools-09r1.1-2.i386.rpm
RPM version 4.8.0
Copyright (C) 1998-2002 - Red Hat, Inc.
This program may be freely redistributed under the terms of the GNU GPL
Usage: rpm [-aKfgpWHqVcdilsKiv?] [-a|--all] [-f|--file] [-g|--group] [-p|--package] [-W|--ftswalk] [--pkgid] [--hdrid] [--fileid]
[--specfile] [--triggeredby] [--whatrequires] [--whatprovides] [--nomanifest] [-c|--configfiles] [-d|--docfiles]
[--dump] [-l|--list] [--queryformat=QUERYFORMAT] [-s|--state] [--nofiledigest] [--nomd5] [--nofiles] [--nodeps]
[...]
Is there a command to read information out of non-installed RPM file?
rpm -qip foo.rpm
#crazyscot did answer the question. Thanks.
Additionally, I found that specific querytags can also be leveraged this way, which wasn't obvious from reading the man page.
So, for example, I found I can do the following:
rpm -qp --queryformat '%{ARCH}\n' foo.rpm
or, even:
xyz="ARCH"; rpm -qp --qf %{${xyz}} foo.rpm; echo ""
This works nicely for RPM's that are not installed, and leveraging the available querytags in the installed rpm
Here is more information about tags
When rpm is not-installed then (this will list the complete info, plus the list of contents in the package);
rpm -qipl <rpm_name.rpm>
When rpm is installed then;
rpm -qi <rpm_name.rpm>
For more on rpm-queries.
For more on handy-queries.
Use rpm -qip:
rpm -qip package_path1 [package_path2 ...]
-q - query the package
-p - get the package name from arguments
It shows the following info:
Name
Version
Release
Architecture
Install Date
Group
Size
License
Signature
Source RPM
Build Date
Build Host
Relocations
Packager
Vendor
URL
Summary
Description
The man page doesn't talk about the -i option in -q context. However, rpm -qp file doesn't produce the right output.
less <rpm_name.rpm>
Displays all that I need, same as 'rpm -qlpv'.
Very good resource: https://blog.packagecloud.io/eng/2015/10/13/inspect-extract-contents-rpm-packages/ .
Related - Display Infos For Installed Package :
rpm -qi InstalledPackageName
there are lot of -i option used in above answers , best way to check :
For one rpms,
rpm -qlp <rpm-name>.rpm
For all rpms , search for your file with grep :
rpm -qpl *.rpm|grep <string or file name>

trying to install hs-ffmpeg haskell package fails to find libdc1394

doing "cabal install hs-ffmpeg" fails like this:
checking for faacEncGetVersion in -lfaac... no
checking for zlibVersion in -lz... yes
checking for libdc1394... configure: error: Package requirements (libdc1394) were not met:
No package 'libdc1394' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables libdc1394_CFLAGS
and libdc1394_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
cabal: Error: some packages failed to install:
hs-ffmpeg-0.3.4 failed during the configure step. The exception was:
exit: ExitFailure 1
I have libdc1394-22 and libdc1394-22-dev installed on Ubuntu 9.10 Karmic Koala.
I'm thinking that the dependency needs to be updated to reflect the new package that supercedes libdc1394, but I'm not sure how to do that.
hs-ffmpeg's configure script is looking for a libdc1394.pc. For some reason, Ubuntu ships a libdc1394-2.pc instead.
Edit hs-ffmpeg's configure.ac to use the "correct" name and then run autoreconf, and it should work.
Something like mkdir -p ~/.pc; ln -s /usr/lib/pkgconfig/libdc1394-2.pc ~/.pc/libdc1394.pc; export PKG_CONFIG_PATH+=:~/.pc may work too.

Resources