Creating RPM on Mac - linux

I downloaded one of our application which is bundled as an rpm package. I have to update a specific file inside that rpm package. So I extracted the RPM on my Mac using tar xvf rpm_package.rpm .I updated one file after extraction, is there a simple way I can package this again as an RPM.

Not this way.
You can do that if you have access to src.rpm. Then you can unpack the src.rpm. Alter it (https://rpm-packaging-guide.github.io/#packaging-software is your friend). Run rpmbuild (here is how to get rpmbuild to Mac http://timperrett.com/2014/03/23/enabling-rpmbuild-on-mac-osx/ )

Related

How to get rpm file path in spec file

I want to copy the installed rpm file to some directory during %post. Like
%post
cp rpm_path %_prefix/rpm/
Is there any way to get rpm file path in spec file?
It is not possible.
However, you can achieve it on the DNF level, by using local plugin. Or writing a similar plugin.
https://github.com/rpm-software-management/dnf-plugins-core/blob/master/plugins/local.py

Modify rpm using rpmrebuild

I have a rpm created for dev environment and CONTAINS a configuration file that points to dev. Now I have to create the rpm for another environment for which I need to replace just one file in the SOURCES folder and update the reference in .spec and rebuild it. Issue is that I don't have the .spec file that I used to create the rpm for dev.
So upon searching, came across rpmrebuild and I was able to see the .spec file in the editor.
When I give rpmrebuild command, the spec file opens in the editor.
Here's the small snippet from the file
/root/rpmbuild/SOURCES /root/rpmbuild/SOURCES
%files
%attr(0755, root, root) "/opt/**{replace/with/newfile/path**}"
But updating that that gives me - File not found: /root/.tmp/rpmrebuild.2345/work/root/opt/{path/to/newfile}
I don't know if I have to use rpmrebuild command with any --params in order to replace the file in the SOURCES and its reference in the .spec. There are no other changes to be made.
Please guide.
Note: I am a unix novice
I presume you do not have the src.rpm for this package. If you do, then it's very easy, simply install that with rpm -ihv /path/to/src/rpm as you would do with any RPM file. The contents, unless specified otherwise, will be extracted to ~/rpmbuild. The spec will be under ~/rpmbuild/SPECS, the sources under ~/rpmbuild/SOURCES, etc.
If you do not have the src.rpm but only the RPM itself, install the rpmrebuild package from the EPEL repos and then:
$ rpmrebuild -e -p /path/to/package
It will open the spec in your default editor. Edit it and save the spec wherever you want.
Then, assuming you have all the needed source files (declared in the spec using the SourceN directives), you can call:
$ rpmbuild -bb /path/to/spec
To rebuild the RPM from the edited spec.

RPM Spec file - how to get rpm package location in %pre script

I am working with RPM package manager for about a month now. Currently I want to use rpm -U to upgrade already existing content from previous RPM execution but I need to know the rpm package location on the file system.
The only way I can think of is searching whole file system for rpm name in %pre script but I would really like to avoid that option. Is there any way to get the path of the rpm package (package can be anywhere on the system) as a variable inside the spec file (%pre and %post script). Hope I explained my issue clearly enough.
Any help or proposal is welcome.
There isn't one location (or path) where a package is installed,
so I'm not sure what you are asking.
The files that are installed by a installed rpm package called "foo"
can be displayed with
rpm -ql foo
There is no common prefix on the paths except "/" in general.

Files installed from debian package with dpkg do not belong to root

I created a binary package with this command:
dpkg-deb --build -z9 -Zlzma $(DEB_SRC_DIR) $(DEB_DEST_DIR)
and install it on my Ubuntu 12.04 with this command:
sudo dpkg -i /path/to/package
The contents of the package I think are irrelevant.
Despite the sudo command the files in the installation directory belong to the current user and not to root as I expected.
How can I fix that?
Try to run the dpkg-deb command with fakeroot:
`fakeroot dpkg-deb ...`
(This will only help if the files in the source directory already have the correct ownership, which they probably dont. The problem you're actually trying to solve here, is to create an archive with files in it that belong to user root, which is where fakeroot theoretically helps.)
Let me say though, that what you are doing is not the best way for creating a binary package (far from it).
Instead, create a debian/ directory with dh_make (from the dh-make package), and edit the control file and changelog accordingly. You also need a file debian/install that lists what files you are installing and where they should go. There are various guides on the net (and on Stack Overflow) that explain this process. For example, look at the Debian New Maintainers' Guide.
You can then use dpkg-buildpackage to create a real, standard-conforming Debian package with your files in a reproducible way.
dpkg-deb is a low-level tool for manipulating existing deb files; it's not meant to be used for package creation.

Creating a binary package of a compiled library

I'm running gentoo and have manually compiled and installed the flann library. I need to create a binary package with the extension of .tar.tbz2 that has all the required files. I tried installing into a separate folder and compressing it but it wasn't recognized as an actual package. (Using make install DESTDIR=folder)
My attempt at the file contained usr as a subdirectory.
Additional info: I'm packaging the library as a part of cross-compiling.
Add --prefix=pathtoinstall to ./configure,then execute make and make install and generate tar from pathtoinstall
./configure --prefix=pathtoinstall
make
make install
tar -cjvf flann.tar.bz2 pathtoinstall
you could write an ebuild for your library and use quickpkg to do the binary package.
Advantage: if a dependency breaks, it's rebuilt (emerge #preserved-rebuild / revdep-rebuild)

Resources