Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to be able to create an RPM that will install python 2.7.1 along with sqlite 3.7.3, MySQL-Python-1.2.3 on a CentOS 5.5 x86_64 host(s) in a directory (e.g. /opt/python2.7). Once that's done, I want to be able to alias the new python binary in .bash_profile so that my developers can begin using it.
I understand 2.7.1 can't be installed on a CentOS host but I've done the above using a shell script successfully. If you search hard enough, I posted my script on line
However, I need to create the RPM for political reasons. Besides placing the source file(s) in the SOURCES directory, what do I need to do in the spec to be able to successfully create an RPM installer?
Please be gentle with me. I've been drinking the Windows cool-aid for most of my IT career so, this is one of my first attempts of becoming a better DevOps Admin.
I want to (..) create an RPM that will install python 2.7.1 along with sqlite 3.7.3, MySQL-Python-1.2.3 on a CentOS 5.5 x86_64 host(s) in a directory (e.g. /opt/python2.7).
If you intend to create a package containing all three pieces of SW then you are likely to break Centos' package management. That may not sound like a problem right now but down the line it will be (I have just enough RPM packageing-fu knowledge to be dangerous). So as long as you intend to create separate packages for python-2.7.1, sqlite-3.7.3 and MySQL-Python-1.2.3 it should work (shoehorning or not) and you would still maintain a certain degree of compatibility.
Quote:
Originally Posted by wills
I want to be able to alias the new python binary in .bash_profile so that my developers can begin using it.
Patching all current unprivileged users shell profiles and /etc/skel/.* (or modifying /etc/bash.*) may provide "interesting" results so I really would suggest this to be done outside of the RPM.
Quote:
Originally Posted by wills
I posted my script on line
CYP post the URI here?
Quote:
Originally Posted by wills
Besides placing the source file(s) in the SOURCES directory, what do I need to do in the spec to be able to successfully create an RPM installer?
Package creation should be done as unprivileged user to maintain integrity of your workstation (you don't build on production hosts, right?). RPM Package creation ('man rpmbuild') is driven by a .spec file which handles the package meta data, installation and any pre and post-installation scripting. Really not that hard. If you post your script to install python-2.7.1 (preferably in BB code tags) and the name of the tarball to use I'll transmogrify it into a .spec file and explain all of the regular chicken-passing, drawing veves with Penn oil, calling of Loa and such :-]
# Don't build debuginfo packages:
%define debug_packages %{nil}
%define debug_package %{nil}
# Package name:
%define name python
# Version:
%define ver 2.7.1
# Release:
%define rel 1
# RPM meta data:
Name: %{name}
Summary: %{name}
Version: %{ver}
Release: %{rel}
License: GPL
Group: Development/Languages
Source0: http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
BuildRequires: gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make
Provides: %{name}
URL: http://www.python.org
BuildRoot: %{_tmppath}/%{name}-%{version}
#
%description
Python is an interpreted, interactive, object-oriented programming
language often compared to Tcl, Perl, Scheme or Java. Python includes
modules, classes, exceptions, very high level dynamic data types and
dynamic typing. Python supports interfaces to many system calls and
libraries, as well as to various windowing systems (X11, Motif, Tk,
Mac and MFC).
Programmers can write new built-in modules for Python in C or C++.
Python can be used as an extension language for applications that need
a programmable interface. This package contains most of the standard
Python modules, as well as modules for interfacing to the Tix widget
set for Tk and RPM.
Note that documentation for Python is provided in the python-docs
package.
# Here we start building the package:
# This preps dir $RPM_BUILD_DIR/%{name}-%{version}.%{release}/.
%prep
# or %setup if a tarball
%setup
%build
%configure --prefix=/opt/python2.7.1 --with-threads --enable-shared
make
%install
make DESTDIR=$RPM_BUILD_ROOT install
# Pre-%files stage inventory
find $RPM_BUILD_ROOT -not -type d -printf "%%%attr(%%m,root,root) %%p\n" | sed -e "s|$RPM_BUILD_ROOT||g" > %{_tmppath}/%{name}_contents.txt
%clean
[ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}" ] && rm -rf $RPM_BUILD_ROOT
# Any pre or post installation scripts run from here:
%post
echo "/opt/python2.7.1/lib/" >> /etc/ld.so.conf.d/opt-python2.7.1.conf
ldconfig
ln -sf /opt/python2.7.1/bin/python /usr/bin/python2.7
# Create a separate script that can be sourced on user login and can be removed:
umask 0022
echo "[ `id -u` -ge 500 ] && { \" >> /etc/profile.d/python.sh
echo "alias python='/opt/python2.7.1/bin/python' \" >> /etc/profile.d/python.sh
echo "alias python2.7='/opt/python2.7.1/bin/python' \" >> /etc/profile.d/python.sh
echo "PATH=$PATH:/opt/python2.7/bin; }" >> /etc/profile.d/python.sh
%preun
# Remove regardless of update or uninstall:
[ -e /etc/ld.so.conf.d/opt-python2.7.1.conf ] && rm -f /etc/ld.so.conf.d/opt-python2.7.1.conf
[ -e /etc/profile.d/python.sh ] && rm -f /etc/profile.d/python.sh
%postun
ldconfig
# Auto-fill in the files section. (http://docs.fedoraproject.org/drafts/rpm-guide-en/ch09s05.html)
# This and the changelog entries mark the end of package creation.
#
%files -f %{_tmppath}/%{name}_contents.txt
%changelog
* Tue Mar 08 2011 %{packager}
- Testing, testing, one, two...
4. Run 'rpmbuild -bb /home/wills/redhat/SPECS/python-2.7.1.spec 2>&1 | tee /home/wills/redhat/BUILD/python-2.7.1.tee'.
5. Read back /home/wills/redhat/BUILD/python-2.7.1.tee if there's any errors and post relevant lines here.
Nice! I will usually make every effort to read the docs before posting questions. I know time is precious so, my intention is to not waste yours. That being said, I need to thank you for the help I had create a spec file but my first mistake was to wrap sqlite and MySQL-Python in there, which goes back to your original reply.
I ran rpmbuild, here is what it's complaining about:
bzip2-develsqlite-devel - assuming (not a good word) that this is referring to bzip2-devel but I noticed that in my script as well so, that's a problem that I caused. Removing that particular package allowed me to go further, but not before running into a new error:
Code:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd python-2.7.1
/var/tmp/rpm-tmp.51404: line 37: cd: python-2.7.1: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.51404 (%prep)
? have you killed CentOS 5.5 yet with a second and different version of python ?
i would NOT make that into a rpm
but build and install into /opt from source and install it to /opt/Python-2.7 and leave that folder OUT of the system $PATH
then point any program that needs it to that folder when you build that from source
cent uses python for yum and MOST of Gnome
and changing the version WILL kill yum if you are not VERY VERY careful .
I ran rpmbuild, here is what it's complaining about: bzip2-develsqlite-devel - assuming (not a good word) that this is referring to bzip2-devel but I noticed that in my script as well so, that's a problem that I caused.
My bad: just split "bzip2-develsqlite-devel" into "bzip2-devel sqlite-devel".
Quote:
Originally Posted by wills
Code:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd python-2.7.1
/var/tmp/rpm-tmp.51404: line 37: cd: python-2.7.1: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.51404 (%prep)
(..) So I switched from /home/wills/redhat to /usr/src/redhat but it continues to do the same. I've got some more reading to do now.
No, apparently the tarball expands to "Python-2.7.1" instead of "python-2.7.1". That's just plain *dumb* as developers should know *N{I,U}X are case sensitive. For now I would suggest 'cd ~/redhat/SOURCES && wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz && tar -xzf Python-2.7.1.tgz && mv Python-2.7.1 python-2.7.1 && tar -czf python-2.7.1.tar.gz python-2.7.1' and change the "Source0: http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz" line to read "Source0: python-2.7.1.tgz".
Quote:
Originally Posted by John VV
cent uses python for yum and MOST of Gnome and changing the version WILL kill yum if you are not VERY VERY careful .
Good call, yes, but do note he uses "%configure --prefix=/opt/python2.7.1" already.
[EDIT]Should be %configure --prefix=/opt/python-2.7.1[/EDIT]
It took you more than a decennium to post again so let's not be picky ;-p
Quote:
Originally Posted by kdoswald
Anyone have any ideas?
In no particular order:
- ensure you've got valid and compelling reasons to muck with Python: it's a core system dependency and fscking up means you're SOL.
- please don't compile and package as root: it's an unnecessary risk.
- "/usr/share/man/man1/python2.7.1" may actually be "/usr/share/man/man1/python2.7.1.gz". Check and modify the .spec file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.