[opensuse-packaging] Packaging Questions
Hi All, I have been trying my hands on packaging. I have a few questions related to it. I am trying to build the following package https://build.opensuse.org/package/live_build_log?arch=i586&package=nut&project=home%3Amanugupt1&repository=openSUSE_11.4 Now according to the log, we dont have a folder /usr/local/bin amongst others here. Since the build system does not have a ./configure or anything like that. So a make install should work, but I have been unable to create a folder, so how do I create them. Using simple mkdir does not help. My question is why is this so and how can I avoid such situations in future. Regards Manu -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
First lines of the Makefile:
prefix = /usr/local
libdir = $(prefix)/lib/nut
bindir = $(prefix)/bin
mandir = $(prefix)/man/man1
Patch it, so that:
prefix = /usr
that should do the trick.
2012/5/10 Manu Gupta
Hi All,
I have been trying my hands on packaging. I have a few questions related to it.
I am trying to build the following package https://build.opensuse.org/package/live_build_log?arch=i586&package=nut&project=home%3Amanugupt1&repository=openSUSE_11.4
Now according to the log, we dont have a folder /usr/local/bin amongst others here.
Since the build system does not have a ./configure or anything like that. So a make install should work, but I have been unable to create a folder, so how do I create them.
Using simple mkdir does not help. My question is why is this so and how can I avoid such situations in future.
Regards Manu -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
-- Nelson Marques // I've stopped trying to understand sandwiches with a third piece of bread in the middle... -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 2012-05-10 16:16:53 (+0100), Nelson Marques
First lines of the Makefile:
prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1
Patch it, so that:
prefix = /usr
that should do the trick.
Much easier, overwrite them by passing them to make. Any variable assignment you pass to make will supersede whatever the Makefile sets: ---8<------------------------------------------- %build make %{?_smp_mflags} \ prefix="%{_prefix}" \ mandir="%{_mandir}/man1" %install make \ prefix="%{buildroot}%{_prefix}" \ mandir="%{buildroot}%{_mandir}/man1" %files %defattr(-,root,root) %{_bindir}/nut %{_libdir}/nut %doc %{_mandir}/man1/nut.1* ---8<------------------------------------------- cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
The correct way would be to properly patch the software, maybe
including support for DESTDIR and submit upstream... That sort of
fixes is in my humble opinion 'the way of the slacker'...
Wouldnt it be more benefic for all if this changes would be applied by
upstream? I would suppose so... but what would I know about it ;)
2012/5/10 Pascal Bleser
On 2012-05-10 16:16:53 (+0100), Nelson Marques
wrote: First lines of the Makefile:
prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1
Patch it, so that:
prefix = /usr
that should do the trick.
Much easier, overwrite them by passing them to make. Any variable assignment you pass to make will supersede whatever the Makefile sets: ---8<------------------------------------------- %build make %{?_smp_mflags} \ prefix="%{_prefix}" \ mandir="%{_mandir}/man1"
%install make \ prefix="%{buildroot}%{_prefix}" \ mandir="%{buildroot}%{_mandir}/man1"
%files %defattr(-,root,root) %{_bindir}/nut %{_libdir}/nut %doc %{_mandir}/man1/nut.1* ---8<-------------------------------------------
cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
-- Nelson Marques // I've stopped trying to understand sandwiches with a third piece of bread in the middle... -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 2012-05-10 17:02:19 (+0100), Nelson Marques
The correct way would be to properly patch the software, maybe including support for DESTDIR and submit upstream... That sort of fixes is in my humble opinion 'the way of the slacker'...
Wouldnt it be more benefic for all if this changes would be applied by upstream? I would suppose so... but what would I know about it ;)
A patch for DESTDIR support, yes, definitely, as that is good practice. Something like going from prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1 to this: DESTDIR = prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1 (and obviously use $DESTDIR in the install target) As well as making strip optional. But changing the prefix from /usr/local to /usr is not, in my opinion, something one should push to upstream, as when someone builds from source without any packaging, /usr/local is actually the right spot. But as said, the paths depend on the distribution (e.g. mandir, it's not /usr/share/man everywhere, in the olden days and on some current distributions (eg. slackware if I'm not mistaken), it's /usr/man), and they are properly defined as variables in the Makefile. The purpose of such variables is to be overridden when invoking make. That's precisely what they have been made for (just like there are parameters in configure), so why not use them, why going through the hassle of a patch. For DESTDIR, though, I agree, but using make prefix="%{buildroot}{_prefix}" works too. Depends on how much time you want to spend on packaging it, and your level of experience. [...] cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
Pascal,
Thanks for the corrections and for dedicating some time to elaborate
them. It's important (from my unwanted perspective) that experienced
people like yourself pass on the good procedures for people starting
up.
NM
2012/5/10 Pascal Bleser
On 2012-05-10 17:02:19 (+0100), Nelson Marques
wrote: The correct way would be to properly patch the software, maybe including support for DESTDIR and submit upstream... That sort of fixes is in my humble opinion 'the way of the slacker'...
Wouldnt it be more benefic for all if this changes would be applied by upstream? I would suppose so... but what would I know about it ;)
A patch for DESTDIR support, yes, definitely, as that is good practice.
Something like going from
prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1
to this:
DESTDIR = prefix = /usr/local libdir = $(prefix)/lib/nut bindir = $(prefix)/bin mandir = $(prefix)/man/man1
(and obviously use $DESTDIR in the install target)
As well as making strip optional.
But changing the prefix from /usr/local to /usr is not, in my opinion, something one should push to upstream, as when someone builds from source without any packaging, /usr/local is actually the right spot.
But as said, the paths depend on the distribution (e.g. mandir, it's not /usr/share/man everywhere, in the olden days and on some current distributions (eg. slackware if I'm not mistaken), it's /usr/man), and they are properly defined as variables in the Makefile. The purpose of such variables is to be overridden when invoking make. That's precisely what they have been made for (just like there are parameters in configure), so why not use them, why going through the hassle of a patch.
For DESTDIR, though, I agree, but using make prefix="%{buildroot}{_prefix}" works too. Depends on how much time you want to spend on packaging it, and your level of experience.
[...]
cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
-- Nelson Marques // I've stopped trying to understand sandwiches with a third piece of bread in the middle... -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Quoting Manu Gupta
Hi All,
I have been trying my hands on packaging. I have a few questions related to it.
I am trying to build the following package https://build.opensuse.org/package/live_build_log?arch=i586&package=nut&project=home%3Amanugupt1&repository=openSUSE_11.4
Now according to the log, we dont have a folder /usr/local/bin amongst others here.
/usr/local is meant for application installed 'from the local console' and should not be touched by packages... your package should install to /usr prefix
Since the build system does not have a ./configure or anything like that. So a make install should work, but I have been unable to create a folder, so how do I create them.
Ok, you might not have gotten the simplest example then. You will need to check how (if) you can pass a new prefix to the build system, in order to use /usr only, not /usr/local Additionally, make install needs to 'redirect' all actions to %{DESTDIR} (which points to the buildroot), as you can not write in /usr tree directly...
Using simple mkdir does not help. My question is why is this so and how can I avoid such situations in future.
If your package would have a configure script, you would use %configure, which is a macro passing all kind of default values to it. For any other kind of build system, there are either equivalents, command lines or patches. Dominique -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Thu, May 10, 2012 at 8:50 PM, Dominique Leuenberger a.k.a DimStar
/usr/local is meant for application installed 'from the local console' and should not be touched by packages... your package should install to /usr prefix
Ok.. I got the prefix as Nelson, suggested but that worked for /usr/bin Other directories like /usr/local/lib and /usr/local/man/man1, they give me an error cp nut /usr/bin cp: cannot create regular file '/usr/bin/nut': Permission denied make: [install] Error 1 (ignored) cd /usr/bin; strip nut Nut strip: 'nut': No such file strip: 'Nut': No such file make: [install] Error 1 (ignored) cp raw.data/* /usr/lib/nut cp: target '/usr/lib/nut' is not a directory make: [install] Error 1 (ignored) cp nut.1 /usr/local/man/man1 cp: cannot create regular file '/usr/local/man/man1': No such file or directory make: [install] Error 1 (ignored) chmod a+r /usr/lib/nut/* /usr/local/man/man1/nut.1 chmod: cannot access '/usr/lib/nut/*': No such file or directory chmod: cannot access '/usr/local/man/man1/nut.1': No such file or directory make: [install] Error 1 (ignored) + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-suse Since compilation is sucecessful, I am assuming I have got the dependencies right. However I am unsure on how files and directories are handled. I mean what approach is taken.
Since the build system does not have a ./configure or anything like that. So a make install should work, but I have been unable to create a folder, so how do I create them.
Ok, you might not have gotten the simplest example then. You will need to check how (if) you can pass a new prefix to the build system, in order to use /usr only, not /usr/local
Additionally, make install needs to 'redirect' all actions to %{DESTDIR} (which points to the buildroot), as you can not write in /usr tree directly...
Using simple mkdir does not help. My question is why is this so and how can I avoid such situations in future.
If your package would have a configure script, you would use %configure, which is a macro passing all kind of default values to it.
For any other kind of build system, there are either equivalents, command lines or patches.
Dominique
-- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
-- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 2012-05-10 21:15:14 (+0530), Manu Gupta
On Thu, May 10, 2012 at 8:50 PM, Dominique Leuenberger a.k.a DimStar
wrote: [...] Ok.. I got the prefix as Nelson, suggested but that worked for /usr/bin
Do it as in the mail I've just sent, by passing them to make rather than patching the Makefile.
Other directories like /usr/local/lib and /usr/local/man/man1, they give me an error
cp nut /usr/bin cp: cannot create regular file '/usr/bin/nut': Permission denied
Here you didn't pass %{buildroot}, also see my mail.
make: [install] Error 1 (ignored) cd /usr/bin; strip nut Nut
Okay, that's a nasty one that possibly needs patching. You must not allow the Makefile to do a "strip" on binaries, as that removes all debugging symbols and, hence, we can't create a -debuginfo subpackage. One common trick is to override the command for strip: often, you find something like this in Makefiles: STRIP = strip You can override that when you call make (typically in the %install section with "make install") like this: make STRIP=touch install touch will just update the "last modified" ("mtime") timestamp of the file to "now", completely harmless, and will not run "strip" and, hence, keep the debugging symbols, which is what we want.
strip: 'nut': No such file strip: 'Nut': No such file make: [install] Error 1 (ignored) cp raw.data/* /usr/lib/nut cp: target '/usr/lib/nut' is not a directory
Apparently the Makefile doesn't take care of creating the directories it installs its files in. Based on the email I've just sent prior to this one, use this in the %install section instead: install -d \ "%{buildroot}%{_bindir}" \ "%{buildroot}%{_prefix}/lib/nut" \ "%{buildroot}%{_mandir}/man1" make \ prefix="%{buildroot}%{_prefix}" \ mandir="%{buildroot}%{_mandir}/man1" \ STRIP=touch \ install [...]
Since compilation is sucecessful, I am assuming I have got the dependencies right. However I am unsure on how files and directories are handled. I mean what approach is taken.
You absolutely need to read up on buildroot, it's an essential aspect of building RPMs: http://www.rpm.org/max-rpm/s1-rpm-anywhere-different-build-area.html https://fedoraproject.org/wiki/How_to_create_an_RPM_package (even though they are doing a few things wrong in the latter, ie. do *NOT* do a "rm -rf %{buildroot}" at the beginning of the %build or %install section, it's insecure) [...] PS: no top posting please ;) cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
* Manu Gupta (manugupt1@opensuse.org) [20120510 17:45]:
On Thu, May 10, 2012 at 8:50 PM, Dominique Leuenberger a.k.a DimStar
wrote: /usr/local is meant for application installed 'from the local console' and should not be touched by packages... your package should install to /usr prefix
Ok.. I got the prefix as Nelson, suggested but that worked for /usr/bin
See sr 120626 I just made. It adds support for DESTDIR, passes the right defines and does a few more things resulting in a package with only negligable rpmlint warnings. have fun Philipp -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Phillipp,
Anyway you can approach upstream and suggest inclusion of your patch ?
(I'm suggesting this because this is what Vincent and Dominique always
encouraged us to do, whenever possible, fix stuff upstream).
Thanks for your work,
NM
2012/5/10 Philipp Thomas
* Manu Gupta (manugupt1@opensuse.org) [20120510 17:45]:
On Thu, May 10, 2012 at 8:50 PM, Dominique Leuenberger a.k.a DimStar
wrote: /usr/local is meant for application installed 'from the local console' and should not be touched by packages... your package should install to /usr prefix
Ok.. I got the prefix as Nelson, suggested but that worked for /usr/bin
See sr 120626 I just made. It adds support for DESTDIR, passes the right defines and does a few more things resulting in a package with only negligable rpmlint warnings.
have fun Philipp -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
-- Nelson Marques // I've stopped trying to understand sandwiches with a third piece of bread in the middle... -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
* Nelson Marques (nmo.marques@gmail.com) [20120510 19:16]:
Anyway you can approach upstream and suggest inclusion of your patch ? (I'm suggesting this because this is what Vincent and Dominique always encouraged us to do, whenever possible, fix stuff upstream).
I will try when I'm back from vacation in two weeks. Philipp -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 2012-05-10 11:20:26 (-0400), Dominique Leuenberger a.k.a DimStar
Quoting Manu Gupta
: [...] Additionally, make install needs to 'redirect' all actions to %{DESTDIR} (which points to the buildroot), as you can not write in /usr tree directly...
For the record/archives, it's either "${DESTDIR}" (shell variable) or "%{buildroot}" (rpmbuild variable). When in doubt, use %{buildroot} as it is escaped properly by rpmbuild, regardless of shell globbing or whatever. cheers -- -o) Pascal Bleser /\\ http://opensuse.org -- we haz green _\_v http://fosdem.org -- we haz conf
As a side note, there's already a package called nut (Network UPS
Tools) so you might want to rename yours to something else to avoid
collisions.
--
Later,
Darin
On Thu, May 10, 2012 at 11:13 AM, Manu Gupta
Hi All,
I have been trying my hands on packaging. I have a few questions related to it.
I am trying to build the following package https://build.opensuse.org/package/live_build_log?arch=i586&package=nut&project=home%3Amanugupt1&repository=openSUSE_11.4
Now according to the log, we dont have a folder /usr/local/bin amongst others here.
Since the build system does not have a ./configure or anything like that. So a make install should work, but I have been unable to create a folder, so how do I create them.
Using simple mkdir does not help. My question is why is this so and how can I avoid such situations in future.
Regards Manu -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
-- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (6)
-
Darin Perusich
-
Dominique Leuenberger a.k.a DimStar
-
Manu Gupta
-
Nelson Marques
-
Pascal Bleser
-
Philipp Thomas