Unexpected RPM conflict on %config(noreplace) files - linux

I'm creating my own RPM using rpmbuild.
My RPM contains config files which should never get overridden, even if the RPM contains a new version of these config files.
To archive this, I tagged these with
%config(noreplace) /opt/mypackage/etc/*
in the spec file.
According to the documentation and this site, a locally modified file will never get overridden in this case which is exactly what I want.
However, when doing the following operations:
Install version 1 of the RPM
Change configuration file etc/myconfig
Update package with version 2 of the RPM
I'm getting a conflict:
$ rpm --prefix ~/rpmroot/ -ih dist/mypackage-1.0.1-1.x86_64.rpm
########################################### [100%]
file /home/user/rpmroot/mypackage/etc/myconfig from install of mypackage-1.0.2-1.x86_64 conflicts with file from package mypackage-1.0.1-1.x86_64
Questions:
How can this conflict be explained? (I'd expect that the new version of the config file would be stored as myconfig.rpmnew and the existing remains untouched)
What I am doing wrong?
UPDATE (additional information)
The output of rpm -qcp dist/mypackage-1.0.1-1.x86_64.rpm is:
/opt/mypackage/etc/config1.xml
/opt/mypackage/etc/config2.xml
/opt/mypackage/etc/run.sh
/opt/mypackage/etc/config3.xml
The complete %files section:
%files
%defattr(0444,root,root)
/opt/mypackage/java/*
#dba
%defattr(0444,root,root)
/opt/mypackage/dba/sql/*
%defattr(0555,root,root)
/opt/mypackage/dba/script/*
#srv
%defattr(0555,root,root)
/opt/mypackage/srv/bin/*
/opt/mypackage/srv/lib/*
#etc
%defattr(0664,root,root)
%config(noreplace) /opt/mypackage/etc/*

If this is actually your issue, you may kick yourself ...
I think this may be just because you are "installing" and not "upgrading"
replace -ih with -Uh
I created a test RPM with similar setup, here are the results:
With -ih as you did
$ sudo rpm --prefix ~/rpmroot/ -ih
/home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm
##################################### [100%] file /home/nhed/rpmroot/etc/a from install of ptst-1.1.0-1.x86_64 conflicts
with file from package ptst-1.0.0-1.x86_64 file
/home/nhed/rpmroot/etc/b from install of ptst-1.1.0-1.x86_64 conflicts
with file from package ptst-1.0.0-1.x86_64 file
/home/nhed/rpmroot/etc/c from install of ptst-1.1.0-1.x86_64 conflicts
with file from package ptst-1.0.0-1.x86_64
With -Uh
$ sudo rpm --prefix ~/rpmroot/ -Uh
/home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm
##################################### [100%]
warning: /home/nhed/rpmroot/etc/a created as /home/nhed/rpmroot/etc/a.rpmnew
##################################### [100%]

Related

Issue when installing lablgtk with opam

I'l trying to install a package (https://github.com/SchornacklabSLCU/amfinder) that use opam to install several libraries. However, two libraries failed to install: lablgtk and cairo2-gtk.I tried to install these two directly via opam (opam install labgtk) but got the same error:
User configuration:
~/.profile is already up-to-date.
[NOTE] Make sure that ~/.profile is well sourced in your ~/.bashrc.
[ERROR] There already is an installed switch named 4.08.0
[NOTE] Package camlzip is already installed (current version is 1.11).
[NOTE] Package magic-mime is already installed (current version is 1.2.0).
[NOTE] Package cairo2 is already installed (current version is 0.6.2).
[NOTE] Package odoc is already installed (current version is 2.0.0).
[NOTE] Package dune is already installed (current version is 2.9.1).
The following actions will be performed:
∗ install lablgtk 2.18.11
∗ install cairo2-gtk 0.6.2
===== ∗ 2 =====
Do you want to continue? [Y/n] y
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved cairo2-gtk.0.6.2 (cached)
⬇ retrieved lablgtk.2.18.11 (cached)
[ERROR] The compilation of lablgtk.2.18.11 failed at "./configure --prefix /home/alr/.opam/4.08.0
LABLGLDIR=/home/alr/.opam/4.08.0/lib/lablgl".
#=== ERROR while compiling lablgtk.2.18.11 ====================================#
# context 2.1.1 | linux/x86_64 | ocaml-base-compiler.4.08.0 | https://opam.ocaml.org#03fce048
# path ~/.opam/4.08.0/.opam-switch/build/lablgtk.2.18.11
# command ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix /home/alr/.opam/4.08.0 LABLGLDIR=/home/alr/.opam/4.08.0/lib/lablgl
# exit-code 1
# env-file ~/.opam/log/lablgtk-16902-8d49b3.env
# output-file ~/.opam/log/lablgtk-16902-8d49b3.out
### output ###
# [...]
# checking native dynlink... checking for pkg-config... /home/linuxbrew/.linuxbrew/bin/pkg-config
# checking for GTK+ - version >= 2.0.0...
# *** 'pkg-config --modversion gtk+-2.0' returned 2.24.33, but GTK+ (2.24.32)
# *** was found! If pkg-config was correct, then it is best
# *** to remove the old version of GTK+. You may also be able to fix the error
# *** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
# *** /etc/ld.so.conf. Make sure you have run ldconfig if that is
# *** required on your system.
# *** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH
# *** to point to the correct configuration files
# no
# configure: error: GTK+ is required
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build lablgtk 2.18.11
└─
╶─ No changes have been performed
<><> lablgtk.2.18.11 troubleshooting ><><><><><><><><><><><><><><><><><><><><><>
=> This package requires gtk+ 2.0 development packages installed on your system
File "dune", line 4, characters 29-39:
4 | (libraries lablgtk2 cairo2 cairo2-gtk camlzip magic-mime)
^^^^^^^^^^
Error: Library "cairo2-gtk" not found.
pkg-config --modversion gtk+-2.0returns 2.24.33
echo $LD_LIBRARY_PATHreturns empty path.
echo $PKG_CONFIG_PATHreturns /home/alr/.opam/4.08.0/lib/pkgconfig:
File /etc/ld.so.conf contains the following line: include /etc/ld.so.conf.d/*.conf
I am using WSL2 on Windows10 with Ubuntu18.04. libgtk2.0-dev is already installed.
I guess there is an error in path to library but cannot figure out how to solve it.
Any help would be greatly appreciated.
Thanks

Why are files missing after installation of my rpm?

I build my first rpm package. It is the prescriped way to deploy applications to our distributed SuSE Servers.
The application is build with NodeJs and Typescript.
We have a build step that transcribes the Typescript to Javascript into a dist folder. NPM provides the dependencies in a node_modules folder. Then there are some .env config files, a bash script to start the application called myApplication and a init.d script called myDaemon. These are all packed into a tar.gz file. The structure is the following:
myApplication.tar.gz
|
|--dist
| |
| |-index.js
| |-...
|
|--node_modules
| |
| |-dependency_a
| |-dependency_b
| |-...
|
|--.env
|--.env.production
|--.env.development
|--.env.sample
|--myApplication
|--myDaemon
The rpmbuild unpacks the tar.gz file, creates the needed folders in the build root and copies the files to the correct folders. dist and node_modules go the a folder in /opt. The configuration files to folder in /etc/, the daemon to /etc/init.d and the executable bash script to start the application to /usr/bin. The README is treated as documentation and the logfiles are marked as ghost.
This is the spec file:
%define debug_package %{nil}
# Use other payload algorithm to fix the following error on SuSE: Failed dependencies: rpmlib(FileDigests) <= 4.6.0-1 is needed
%define _binary_filedigest_algorithm 1
# automatically generate requires and provides from package.json
%{?nodejs_find_provides_and_requires}
# filter out any false provides created due to dependencies with native components
%{?nodejs_default_filter}
# name of zip file containing source without .zip extension
%define modname myApplication
Summary: The %{modname} is a nodeJs project
Name: %{modname}
Group: Applications/Server
Version: 0.1
Release: 1
License: None
URL: https://private.git/myApplication
Source0: myApplication.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: x86_64
ExclusiveArch: x86_64
BuildRequires: npm
Requires: nodejs10
AutoReq: no
AutoProv: no
%description
%{Summary}
#Unpack the tar.gz file
%prep
%setup -q -n myApplication
%build
#Code is already build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/myApplication
%{__cp} -r $RPM_BUILD_DIR/myApplication/.env* $RPM_BUILD_ROOT/etc/myApplication
mkdir -p $RPM_BUILD_ROOT/opt/myApplication/dist
%{__cp} -r $RPM_BUILD_DIR/myApplication/dist $RPM_BUILD_ROOT/opt/myApplication/
mkdir -p $RPM_BUILD_ROOT/opt/myApplication/node_modules
%{__cp} -r $RPM_BUILD_DIR/myApplication/node_modules $RPM_BUILD_ROOT/opt/myApplication/
mkdir -p $RPM_BUILD_ROOT/usr/bin
%{__cp} -r $RPM_BUILD_DIR/myApplication/myApplication $RPM_BUILD_ROOT/usr/bin/myApplication
mkdir -p $RPM_BUILD_ROOT/etc/init.d/
%{__cp} -r $RPM_BUILD_DIR/myApplication/myDaemon $RPM_BUILD_ROOT/etc/init.d/myDaemon
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(0755, root, root)
%doc README.md
%dir /etc/myApplication
%config /etc/myApplication/.env
%config /etc/myApplication/.env.production
%config /etc/myApplication/.env.development
/etc/myApplication/.env.sample
/opt/myApplication
/usr/bin/myApplication
/etc/init.d/myDaemon
%ghost /var/log/myApplication.log
%ghost /var/log/myDaemon.log
%changelog
* Wed Sep 29 2021 seism0saurus
- Initial spec file for myApplication
The rpm build with -vv runs fine and lists all dependencies from node_modules. I can also open the rpm with a zip utility and can see all needed dependencies inside the /opt/myApplication/node_modules folder.
But only some of the dependencies in that node_modules folder are installed, when I run zypper install myApplication.rpm. For example dependency_b is missing but dependency_a was installed. I can check that with rpm -V -v --nodeps -p myApplication.rpm. The folders are marked as missing. Here is a part from the output:
.......T /opt/myApplication/node_modules/triple-beam/test.js
missing /opt/myApplication/node_modules/url-parse
missing /opt/myApplication/node_modules/url-parse/LICENSE
missing /opt/myApplication/node_modules/url-parse/README.md
missing /opt/myApplication/node_modules/url-parse/dist
missing /opt/myApplication/node_modules/url-parse/dist/url-parse.js
missing /opt/myApplication/node_modules/url-parse/dist/url-parse.min.js
missing /opt/myApplication/node_modules/url-parse/dist/url-parse.min.js.map
missing /opt/myApplication/node_modules/url-parse/index.js
missing /opt/myApplication/node_modules/url-parse/package.json
........ /opt/myApplication/node_modules/util-deprecate
I usually use Debian/GNU Linux and not SuSE, so I don't have any experience with rpm.
Can someone explain, why the folders and files are not installed, although rpm knows, that they should be installed and shows them as missing?
How can I fix that? Is something wrong with my spec or my approach to package a NodeJs application?
--- EDIT ---
The rpm package works fine inside my Leap 15 containers (rpm 4.14.3). The problems is only on a SLES 11 installation (rpm 4.4.2.3).
So the problems seems to be related with the old version of rpm.
--- EDIT 2 ---
I tweaked the spec by configuring the compression algorithm:
%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio
Now i can install the package correctly with rpm but zypper has still the same problem.
Any thoughts on that?
Kind regards,
seism0saurus
The final solution was to use a different compression algorithm in the spec file and to give the package a new version number, so that zypper doesn't use the old version from cache.
%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

How to convert perl modules into deb packages?

My team is delivering a product that requires some perl modules, and since we deliver a full OS installer (Ubuntu 12.04) we want those modules as .deb packages. I've been able to build some other perl (like Algorithm::LUHN, Env::C, Linux::PID and Config::Properties) by following the instructions here, but having problems with Apache2::SizeLimit
Tried with Apache-SizeLimit-0.96 and Apache-SizeLimit-0.97... and all the methods described in the doc. Also tried in different OSs versions; Ubuntu 14.04.2, Ubuntu 12.04.5 (clean install), all the attempts ended with the same error:
test#test:~$ dh-make-perl --build --cpan Apache::SizeLimit
Going to read '/home/test/.cpan/Metadata'
Database was generated on Thu, 19 Mar 2015 02:17:02 GMT
CPAN: Digest::SHA loaded ok (v5.61)
Checksum for /home/test/.cpan/sources/authors/id/P/PH/PHRED/Apache-SizeLimit-0.97.tar.gz ok
Apache-SizeLimit-0.97/
Apache-SizeLimit-0.97/Changes
Apache-SizeLimit-0.97/INSTALL
Apache-SizeLimit-0.97/lib/
Apache-SizeLimit-0.97/LICENSE
Apache-SizeLimit-0.97/Makefile.PL
Apache-SizeLimit-0.97/MANIFEST
Apache-SizeLimit-0.97/MANIFEST.SKIP
Apache-SizeLimit-0.97/META.json
Apache-SizeLimit-0.97/META.yml
Apache-SizeLimit-0.97/README
Apache-SizeLimit-0.97/t/
Apache-SizeLimit-0.97/t/apache/
Apache-SizeLimit-0.97/t/apache2/
Apache-SizeLimit-0.97/t/pod.t
Apache-SizeLimit-0.97/t/response/
Apache-SizeLimit-0.97/t/response/TestApache/
Apache-SizeLimit-0.97/t/response/TestApache2/
Apache-SizeLimit-0.97/t/response/TestApache2/basic.pm
Apache-SizeLimit-0.97/t/response/TestApache2/check_n_requests2.pm
Apache-SizeLimit-0.97/t/response/TestApache2/deprecated.pm
Apache-SizeLimit-0.97/t/response/TestApache2/zzz_check_n_requests.pm
Apache-SizeLimit-0.97/t/response/TestApache/basic.pm
Apache-SizeLimit-0.97/t/response/TestApache/check_n_requests2.pm
Apache-SizeLimit-0.97/t/response/TestApache/deprecated.pm
Apache-SizeLimit-0.97/t/response/TestApache/zzz_check_n_requests.pm
Apache-SizeLimit-0.97/t/apache2/all.t
Apache-SizeLimit-0.97/t/apache/all.t
Apache-SizeLimit-0.97/lib/Apache/
Apache-SizeLimit-0.97/lib/Apache2/
Apache-SizeLimit-0.97/lib/Apache2/SizeLimit.pm
Apache-SizeLimit-0.97/lib/Apache/SizeLimit/
Apache-SizeLimit-0.97/lib/Apache/SizeLimit.pm
Apache-SizeLimit-0.97/lib/Apache/SizeLimit/Core.pm
CPAN: File::Temp loaded ok (v0.22)
======================================================================
Unpacked tarball already existed, directory renamed to /home/test/Apache-SizeLimit-0.97.13910
======================================================================
Using META.json
Found: Apache2-SizeLimit 0.97 (libapache2-sizelimit-perl arch=all)
cat: /etc/mailname: No such file or directory
No APT contents can be loaded.
Please install 'apt-file' package (at least version 2.5.0) and
run 'apt-file update' as root.
Dependencies not updated.
Using maintainer: test
Found docs: README
cat: /etc/mailname: No such file or directory
Using rules: /usr/share/dh-make-perl/rules.dh7.tiny
cat: /etc/mailname: No such file or directory
make: Entering directory `/home/test/Apache-SizeLimit-0.97'
dh clean
dh_testdir
dh_auto_clean
dh_clean
make: Leaving directory `/home/test/Apache-SizeLimit-0.97'
make: Entering directory `/home/test/Apache-SizeLimit-0.97'
dh build
dh_testdir
dh_auto_configure
Can't find mod_perl installed
The error was: Can't locate mod_perl2.pm in #INC (#INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at Makefile.PL line 147.
dh_auto_configure: perl Makefile.PL INSTALLDIRS=vendor returned exit code 2
make: *** [build] Error 2
make: Leaving directory `/home/test/Apache-SizeLimit-0.97'
Cannot create deb package: 'debian/rules build' failed.
Will appreciate any help on fixing it
Sharing how it was solved. As #grant-mclean answered; I was missing a -dev package: the "apache2-dev" (apache2-threaded-dev).
With it, and skipping tests I was able to build the .deb package.
sudo apt-get install devscripts dh-make-perl libapache2-mod-perl2 libapache2-mod-perl2-dev apache2-threaded-dev
export DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nocheck"
dh-make-perl --build --cpan Apache::SizeLimit
Usually when you're trying to build something on Debian and get a message about something being missing, you need to install a 'dev' package - one that contains things like header files that aren't needed by the runtime.
I'm just guessing, but in your case perhaps you need to install: libapache2-mod-perl2-dev

How to change library-dirs in ghc-pkg

I'm trying to compile haskell ghc from source. I try to configure my cabal config from different folder than /usr/. From the start it always succeed in building any package.
At some point (after installing package cabal-install), I change my config for cabal to include another "library-dirs". Then, something wrong happens (probably because wrong string to be inserted in field "library-dirs" in cabal config). So, I try to reconfigure my cabal config file again (I even delete the config file and try to clean the ghc package cache) and comment field "library-dirs" options but it still fails. I also already tried to remove the cabal package directory (a directory where cabal save the cache about the packages).
This is the output when using "ghc-pkg check" :
Warning: library-dirs: {stripped} doesn't exist or isn't a directory
This is the output right now when I building package using cabal or manually from Setup.hs :
sudo -E cabal --config-file=/opt/haskell/config/config install hashable -O2 --global --flags="-fllvm" --prefix=/opt/haskell 2>error --upgrade-dependencies --reinstall
Resolving dependencies...
Configuring hashable-1.2.1.0...
Building hashable-1.2.1.0...
Failed to install hashable-1.2.1.0
Last 10 lines of the build log ( /{stripped}/hashable-1.2.1.0.log ):
Data/Hashable/Class.hs:100:15: Warning:
Literal 15868100553162883236 is out of the Int range -9223372036854775808..9223372036854775807
[2 of 3] Compiling Data.Hashable.Generic ( Data/Hashable/Generic.hs, dist/build/Data/Hashable/Generic.o )
Data/Hashable/Generic.hs:20:1: Warning:
The import of ‛Bits’ from module ‛Data.Bits’ is redundant
[3 of 3] Compiling Data.Hashable ( Data/Hashable.hs, dist/build/Data/Hashable.o )
/usr/bin/ld: cannot find {stripped}: No such file or directory
collect2: error: ld returned 1 exit status
This is the cabal config file : (any default values are stripped)
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /opt/haskell/cabal
world-file: /opt/haskell/cabal/world
extra-prog-path: /opt/haskell/cabal/bin
build-summary: /opt/haskell/cabal/logs/build.log
remote-build-reporting: anonymous
jobs: $ncpus
install-dirs global
prefix: /opt/haskell/
Can anybody help me or guide me ? Or at least tell me where ghc are actually save the information of "library-dirs" configuration for an uninstalled package ?
cabal -V
cabal-install version 1.18.0.2
using version 1.18.1.3 of the Cabal library
ghc -v
The Glorious Glasgow Haskell Compilation System, version 7.9.20140206
Thank you.
I believe this might be due to the fact that each package contains the full path to the location when it was first created. Look into. .ghc/YOUR_PLATFORM/package.conf.d(for me, it's .ghc/x86_64-darwin-7.6.3/package.conf.d). You'll see a lot of .conf files, and each will contain hardcoded paths:
[...]
import-dirs: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/lib
library-dirs: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/lib
[...]
haddock-interfaces: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/doc/html/pandoc-types.haddock
haddock-html: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/doc/html
You can either manually update the files for the contents to point to the right location or write a script which would do it for you.
Then you need to update the package.cache files (might require a sudo here and there):
pejvan$ ghc-pkg recache
pejvan$ ghc-pkg recache --user
Finally, check that everything is now fine:
pejvan$ ghc-pkg check

How to install libgdal on openSUSE 11.3?

libgdal
linux-y3pi:~ # rpm -Uvh libgdal1-1.8.0-1.59.src.rpm
warning: libgdal1-1.8.0-1.59.src.rpm: Header V4 RSA/SHA1 Signature, key ID 1abd1afb: NOKEY
1:libgdal1 ########################################### [100%]
linux-y3pi:~ #
libgdal-devel
linux-y3pi:~ # rpm -Uvh libgdal-devel-1.8.0-1.59.x86_64.rpm
warning: libgdal-devel-1.8.0-1.59.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 1abd1afb: NOKEY
error: Failed dependencies:
libgdal1 = 1.8.0-1.59 is needed by libgdal-devel-1.8.0-1.59.x86_64
Of course libgdal-devel needs other dependencies too, but why isn't it able to see libgdal.
linux-y3pi:~ # whereis libgdal
libgdal: /usr/local/lib/libgdal.la /usr/local/lib/libgdal.a /usr/local/lib/libgdal.so
Of course, this is not in path:
linux-y3pi:~ # $PATH
bash: /home/anisha/qtsdk-2010.05/qt/bin/:/home/anisha/qtsdk-2010.05/bin:/home/anisha/qtsdk-2010.05/qt/bin:/home/anisha/qtsdk-2010.05/qt/bin/:/home/anisha/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/anisha/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games: No such file or directory
I did: export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH as root, didn't help.
Where do I install this libgdal now?
# rpm -Uvh libgdal1-1.8.0-1.59.src.rpm
The "src" indicates that it's a source RPM. You need to find the binary RPM, specifically (probably) the x86_64 RPM. It will have a similar name, except it will say "x86_64" instead.

Resources