Fwd: Re: distutils bdist_rpm and %postun section of spec file

Dnia czwartek 17 września 2009 o 23:07:17 A. Cavallo napisał(a):
Hi, as rule of thumb (followed now by all major distros) you should not put any script in %postun, %postinst etc sections.
Regards, Antonio
Hello, I am looking for some advise in creating rpm package using bdist_rpm. I have managed to create post_install part using information http://stackoverflow.com/questions/1321270/how-to-extend-distutils-with-a -s imple-post-install-script Now i would like to add some code to %postun part of spec file to revert changes done by my post_install command. Is there a way to add it in setup.py or do i have to manually edit spec file?
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelines Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py. -- Michał Klich klich.michal@gmail.com michal@michalklich.com http://www.michalklich.com

On Fri, 2009-09-18 at 21:55 +0200, Michał Klich wrote:
Dnia czwartek 17 września 2009 o 23:07:17 A. Cavallo napisał(a):
Hi, as rule of thumb (followed now by all major distros) you should not put any script in %postun, %postinst etc sections.
Regards, Antonio
Hello, I am looking for some advise in creating rpm package using bdist_rpm. I have managed to create post_install part using information http://stackoverflow.com/questions/1321270/how-to-extend-distutils-with-a -s imple-post-install-script Now i would like to add some code to %postun part of spec file to revert changes done by my post_install command. Is there a way to add it in setup.py or do i have to manually edit spec file?
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelines
Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py.
Why is the symlink not simply a part of the rpm payload? That way it would be created on installation and removed on removal. Dave

Dnia piątek 18 września 2009 o 22:00:17 David Malcolm napisał(a):
On Fri, 2009-09-18 at 21:55 +0200, Michał Klich wrote:
Dnia czwartek 17 września 2009 o 23:07:17 A. Cavallo napisał(a):
Hi, as rule of thumb (followed now by all major distros) you should not put any script in %postun, %postinst etc sections.
Regards, Antonio
Hello, I am looking for some advise in creating rpm package using bdist_rpm. I have managed to create post_install part using information http://stackoverflow.com/questions/1321270/how-to-extend-distutils-wi th-a -s imple-post-install-script Now i would like to add some code to %postun part of spec file to revert changes done by my post_install command. Is there a way to add it in setup.py or do i have to manually edit spec file?
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelines
Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py.
Why is the symlink not simply a part of the rpm payload? That way it would be created on installation and removed on removal.
Dave
Symlink is pointing to x86_64 arch file, i would like to have noarch rpm. It is pointing to /usr/bin/consolehelper as application needs to be run with root rights. I might be doing something wrong here but this is my first package. -- Michał Klich klich.michal@gmail.com michal@michalklich.com http://www.michalklich.com

On Fri, 2009-09-18 at 22:22 +0200, Michał Klich wrote:
Dnia piątek 18 września 2009 o 22:00:17 David Malcolm napisał(a):
On Fri, 2009-09-18 at 21:55 +0200, Michał Klich wrote:
Dnia czwartek 17 września 2009 o 23:07:17 A. Cavallo napisał(a):
Hi, as rule of thumb (followed now by all major distros) you should not put any script in %postun, %postinst etc sections.
Regards, Antonio
Hello, I am looking for some advise in creating rpm package using bdist_rpm. I have managed to create post_install part using information http://stackoverflow.com/questions/1321270/how-to-extend-distutils-wi th-a -s imple-post-install-script Now i would like to add some code to %postun part of spec file to revert changes done by my post_install command. Is there a way to add it in setup.py or do i have to manually edit spec file?
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelines
Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py.
Why is the symlink not simply a part of the rpm payload? That way it would be created on installation and removed on removal.
Dave
Symlink is pointing to x86_64 arch file, i would like to have noarch rpm. It is pointing to /usr/bin/consolehelper as application needs to be run with root rights. I might be doing something wrong here but this is my first package.
Although the target (/usr/bin/consolehelper) of the symlink is a compiled binary and thus architecture-specific, the symlink's path and thus the symlink itself is architecture-independent, so it ought to be possible to create a noarch rpm. I can think of a couple of approaches: (i) You can write a generic setup.py script and invoke the "bdist_rpm" command, as you're doing, and have this generate a specfile for your RPM and build it. The specfile is autogenerated. If I'm reading the distutils code correctly this will internally call the "install" command, and scrape the installed payload into a file named "INSTALLED_FILES", which will get referenced in the autogenerated specfile. I believe one can create a symlink from your script to consolehelper using: # caution; untested code! # not sure if I got src/dst the right way around distutils.file_util.copy_file('/usr/bin/consolehelper', '/usr/bin/your_script', link='sym') However, reading the consolehelper manpage, it looks like you may also need to set up files under /etc/pam.d/ (not my area of expertise) (ii) You can write a generic setup.py script, and also write a .spec file. You then create the symlink in the specfile, and add it to the % files section. In Fedora we have a script "rpmdev-newspec" that makes it easy to create new boilerplate .spec files for a setup.py file. The downside to this approach is that you now have a .spec file separate from your setup.py, and have to maintain both. It makes sense in our world where Python is only one of many technologies, and rpm is the native packaging format (for good or ill). Hope this is helpful Dave

Symlink is pointing to x86_64 arch file, i would like to have noarch rpm. It is pointing to /usr/bin/consolehelper as application needs to be run with root rights. I might be doing something wrong here but this is my first package.
Although the target (/usr/bin/consolehelper) of the symlink is a compiled binary and thus architecture-specific, the symlink's path and thus the symlink itself is architecture-independent, so it ought to be possible to create a noarch rpm.
Is it this relevant? In a typical system there're quite few packages: why bother to this level of detail?
I can think of a couple of approaches: (i) You can write a generic setup.py script and invoke the "bdist_rpm" command, as you're doing, and have this generate a specfile for your RPM and build it. The specfile is autogenerated.
If I'm reading the distutils code correctly this will internally call the "install" command, and scrape the installed payload into a file named "INSTALLED_FILES", which will get referenced in the autogenerated specfile.
This solution never really worked for me: if I remember it didn't handle the directories properly (at rpm uninstall it tries to rmdir /usr/bin =: ).
However, reading the consolehelper manpage, it looks like you may also need to set up files under /etc/pam.d/ (not my area of expertise)
(ii) You can write a generic setup.py script, and also write a .spec file. You then create the symlink in the specfile, and add it to the % files section. In Fedora we have a script "rpmdev-newspec" that makes
Cool I wish know this before: is available to the public?
it easy to create new boilerplate .spec files for a setup.py file.
Agree, it looks the old way of bdist_rpm hasn't quite catched up with rpm packaging recently.
The downside to this approach is that you now have a .spec file separate from your setup.py, and have to maintain both. It makes sense in our world where Python is only one of many technologies, and rpm is the native packaging format (for good or ill).
It is not a big burden: I can easily manages several packages at once on my python distro (http://pyvm.sourceforge.net). If I can recommend I'd go for the SuSE build service: this will make easier to experiment the "hands off" build a real rpm. Regards, Antonio

Dnia niedziela 20 września 2009 o 12:30:15 A. Cavallo napisał(a):
Symlink is pointing to x86_64 arch file, i would like to have noarch rpm. It is pointing to /usr/bin/consolehelper as application needs to be run with root rights. I might be doing something wrong here but this is my first package.
Although the target (/usr/bin/consolehelper) of the symlink is a compiled binary and thus architecture-specific, the symlink's path and thus the symlink itself is architecture-independent, so it ought to be possible to create a noarch rpm.
Is it this relevant? In a typical system there're quite few packages: why bother to this level of detail?
For sake of space and having two packages i prefer to have it noarch.
However, reading the consolehelper manpage, it looks like you may also need to set up files under /etc/pam.d/ (not my area of expertise)
(ii) You can write a generic setup.py script, and also write a .spec file. You then create the symlink in the specfile, and add it to the % files section. In Fedora we have a script "rpmdev-newspec" that makes
Cool I wish know this before: is available to the public?
Pakcege is called rpmdevtools, but this is in Fedora it may be different in other distro.
it easy to create new boilerplate .spec files for a setup.py file.
Agree, it looks the old way of bdist_rpm hasn't quite catched up with rpm packaging recently.
The downside to this approach is that you now have a .spec file separate from your setup.py, and have to maintain both. It makes sense in our world where Python is only one of many technologies, and rpm is the native packaging format (for good or ill).
It is not a big burden: I can easily manages several packages at once on my python distro (http://pyvm.sourceforge.net).
If I can recommend I'd go for the SuSE build service: this will make easier to experiment the "hands off" build a real rpm.
Looks promising, i will try that. Thanks
Regards, Antonio
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
-- Michał Klich klich.michal@gmail.com michal@michalklich.com http://www.michalklich.com

Dnia piątek 18 września 2009 o 23:43:08 David Malcolm napisał(a):
On Fri, 2009-09-18 at 22:22 +0200, Michał Klich wrote:
Dnia piątek 18 września 2009 o 22:00:17 David Malcolm napisał(a):
On Fri, 2009-09-18 at 21:55 +0200, Michał Klich wrote:
Dnia czwartek 17 września 2009 o 23:07:17 A. Cavallo napisał(a):
Hi, as rule of thumb (followed now by all major distros) you should not put any script in %postun, %postinst etc sections.
Regards, Antonio
Hello, I am looking for some advise in creating rpm package using bdist_rpm. I have managed to create post_install part using information http://stackoverflow.com/questions/1321270/how-to-extend-distutil s-wi th-a -s imple-post-install-script Now i would like to add some code to %postun part of spec file to revert changes done by my post_install command. Is there a way to add it in setup.py or do i have to manually edit spec file?
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelin es
Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py.
Why is the symlink not simply a part of the rpm payload? That way it would be created on installation and removed on removal.
Dave
Symlink is pointing to x86_64 arch file, i would like to have noarch rpm. It is pointing to /usr/bin/consolehelper as application needs to be run with root rights. I might be doing something wrong here but this is my first package.
Although the target (/usr/bin/consolehelper) of the symlink is a compiled binary and thus architecture-specific, the symlink's path and thus the symlink itself is architecture-independent, so it ought to be possible to create a noarch rpm.
I can think of a couple of approaches: (i) You can write a generic setup.py script and invoke the "bdist_rpm" command, as you're doing, and have this generate a specfile for your RPM and build it. The specfile is autogenerated.
If I'm reading the distutils code correctly this will internally call the "install" command, and scrape the installed payload into a file named "INSTALLED_FILES", which will get referenced in the autogenerated specfile.
I believe one can create a symlink from your script to consolehelper using: # caution; untested code! # not sure if I got src/dst the right way around distutils.file_util.copy_file('/usr/bin/consolehelper', '/usr/bin/your_script', link='sym')
However, reading the consolehelper manpage, it looks like you may also need to set up files under /etc/pam.d/ (not my area of expertise)
(ii) You can write a generic setup.py script, and also write a .spec file. You then create the symlink in the specfile, and add it to the % files section. In Fedora we have a script "rpmdev-newspec" that makes it easy to create new boilerplate .spec files for a setup.py file. The downside to this approach is that you now have a .spec file separate from your setup.py, and have to maintain both. It makes sense in our world where Python is only one of many technologies, and rpm is the native packaging format (for good or ill).
Hope this is helpful Dave
Thank you much, yes it is helpful i managed to write copy_file and write_file, which i also need to create files necessery for consolehelper. Thank you again. I have not tried second solution you provided. But, there is always but. For some reason write_file put chars in seperate lines and i have no idea how to make him create file as i want to. Which is ok for now as files are included in data_files argument of setup(). Second but is a major one. I admit i am newbie and please forgive my incompetence. I put copy_file and write_file instructions into setup.py but not into setup(). I guess that is my problem. At this point when i run python setup.py install it creates necessery link but bdist_rpm does not include it. As far as i can understand its because copy_file and write_file are not arguments of setup(). How should i include them in setup.py? I appreciate all your help. -- Michał Klich klich.michal@gmail.com michal@michalklich.com http://www.michalklich.com

It is not mentioned in Fedora guidelines http://fedoraproject.org/wiki/Packaging/Guidelines#Packaging_Guidelines
Neither is explicitly said on any other linux distro: it is experience coming from building rpms that span across distros and releases. If you type rpm -qa --scripts on a running (failrly recent) rpm based distro you'll notice how little scripting is going on: mostly on core packages where the target is well defined.
Ok, how would you handle creating symlink in setup.py? and removing it of course when uninstalling rpm. That is my goal. I managed to create symlink with setup.py but can not find any option for removing, which is i think correct as there is no uninstall option for setup.py.
That's the scope foe the %file description, unless you're not creating an sdk/library in which case other rules apply. And yes none of these "rules" are documented (as far I know): it is just experience. Regards, Antonio
participants (3)
-
A. Cavallo
-
David Malcolm
-
Michał Klich