Rpm spec macros and variables

A nice place to read about the macros in rpm specs is https://fedoraproject.org/wiki/Packaging:RPMMacros. You can also run a command similar to rpm -E ‘%{dist}’ to see a variable’s definition.

To use your own variable in a spec, you can use a %define.

%define myvar 3.1415926

To get even fancier, you can do shell commands in a definition.

%define version_num "%( echo %version | tr -d '\.' )"

This takes %{version} which could be 4.51 and sets a variable to “451” for which I had a use.

Advertisements

Set word-read permissions on python libs

In an environment where the default umask is 0077 or similar, the pip utility for installing python libraries can set up new files that cannot be read by all users.

I dropped this script into my ~/bin dir so I can enforce other-read permissions easily on all the python libs. I wrote this script after hours and hours of troubleshooting python libs just to find out it’s an old-school permissions issue.

Wrapper script for ansible to use nsupdate with gsstsig

The ansible module nsupdate is a great module. However, if you have dns zones that only accept kerberos-authenticated secure dynamic updates (gsstsig), you’re out of luck for the time being.

I wrote a shell script as a wrapper around nsupdate -g, and it adds a delimiting character so you can pass in multiple statements if you wish. Check out the code below, or at https://gist.github.com/bgstack15/2d484428c1ba60c0172459d49b7033b0

Load your bash profile even when switching user

If you use a shared application account, for example, ansible, and want your profile to be used even after switching to that user, here is a solution for you. Add this to the destination user ~/.bashrc.

echo "${SSH_CLIENT}" | grep -q '192.168.2.88' && __bp=1
test "$( stat -c '%U' "$( tty 2>/dev/null )" 2>/dev/null )" = "bgstack15" && __bp=1
test "${__bp}" = "1" && test -f /usr/bin/bp && . /usr/bin/bp --noclear

I am using a world-readable copy of my bgstack15 profile, aka bash profile.

Fedora remove duplicate packages from partially-completed dnf update

On my Fedora 27 systems, my system froze up when I was updating all the packages (I suspect I’m having hardware problems).

My system did reboot just fine, but not all ancillary services came up. During my troubleshooting, I discovered that there were multiple versions of packages installed for hundreds of packages.

After some brief Internet searches, I found my solution:

sudo dnf remove --duplicates

Output will resemble:

Last metadata expiration check: 1:14:37 ago on Sat 31 Mar 2018 09:52:43 PM EDT.
Dependencies resolved.
================================================================================
 Package                       Arch   Version            Repository        Size
================================================================================
Reinstalling:
 ImageMagick                   x86_64 1:6.9.9.38-1.fc27  updates-smith122 186 k
     replacing  ImageMagick.x86_64 1:6.9.9.27-1.fc27
 ImageMagick-libs              x86_64 1:6.9.9.38-1.fc27  updates-smith122 2.3 M
     replacing  ImageMagick-libs.x86_64 1:6.9.9.27-1.fc27
 abrt                          x86_64 2.10.7-1.fc27      updates-smith122 525 k
     replacing  abrt.x86_64 2.10.5-1.fc27
 abrt-addon-ccpp               x86_64 2.10.7-1.fc27      updates-smith122 130 k
     replacing  abrt-addon-ccpp.x86_64 2.10.5-1.fc27
 abrt-addon-coredump-helper    x86_64 2.10.7-1.fc27      updates-smith122  40 k
     replacing  abrt-addon-coredump-helper.x86_64 2.10.5-1.fc27
 abrt-addon-kerneloops         x86_64 2.10.7-1.fc27      updates-smith122  54 k
     replacing  abrt-addon-kerneloops.x86_64 2.10.5-1.fc27
 abrt-addon-pstoreoops         x86_64 2.10.7-1.fc27      updates-smith122  32 k
     replacing  abrt-addon-pstoreoops.x86_64 2.10.5-1.fc27

References

Weblinks

  1. https://ask.fedoraproject.org/en/question/95550/how-to-remove-duplicate-packages-installed-with-dnf-on-fedora-24/