Linux: How to Build RPMs without root access
Question: I'm trying to build a RedHat package (RPM), but I don't have root access to /usr/src/redhat. Is there a way that I can build an RPM without having root access?
Answer: There is a simple trick to building an RPM without having root access. You can build it in your home directory. To do this, place a file in your home directory called .rpmmacros.
The contents of the .rpmmacros is: (You will need to replace jsmith and Joe Smith with your own information.)
%_topdir /home/jsmith/rpm %_tmppath /home/jsmith/rpm/tmp %_signature gpg %_gpg_name Joe Smith %_gpg_path ~/.gnupg %distribution RedHat Linux 9 %vendor RedHat
Next, you need to create a file called .rpmrc also in your home directory.
The contents of the .rpmrc file is:
buildarchtranslate: i386: i386 buildarchtranslate: i486: i386 buildarchtranslate: i586: i386 buildarchtranslate: i686: i386 buildarchtranslate: athlon: i386
Finally, you will need to create the directory structure that the RPM system requires.
To do this, execute the following commands:
mkdir ~/rpm mkdir ~/rpm/BUILD mkdir ~/rpm/RPMS mkdir ~/rpm/RPMS/athlon mkdir ~/rpm/RPMS/i386 mkdir ~/rpm/RPMS/i486 mkdir ~/rpm/RPMS/i586 mkdir ~/rpm/RPMS/i686 mkdir ~/rpm/RPMS/noarch mkdir ~/rpm/SOURCES mkdir ~/rpm/SPECS mkdir ~/rpm/SRPMS mkdir ~/rpm/tmp
These commands will create a directory tree in your home directory.
Now, when you need to build an RPM, the system will use the rpm directory instead of the usual /usr/src/redhat directory.
Advertisements