git-lfs/rpm/INSTALL.md
Chris Darroch d5e0ffc9e5 docker/README.md,rpm/INSTALL.md: update rpm docs
We no longer support either CentOS 5 or 6, per commit
b560b853a6e557195c0c68875218f45c89dce56b of PR #1298 and commit
git-lfs/build-dockers@64a3a9fc4d
of PR git-lfs/build-dockers#3, and commit
git-lfs/build-dockers@898d9b045e
of PR git-lfs/build-dockers#33.

We also now build the Asciidoctor Ruby gem in order to generate
our man pages, rather than using ronn and several other gems,
per commit db9a82132a2bb066876d8ddf06c5255da2f199a4 of PR #5054.

We therefore update the documentation for our RPM package build
utilities and for our Docker container image build utilities to
reflect these changes.
2022-12-28 00:09:59 -08:00

86 lines
2.9 KiB
Markdown

# Building RPMs #
All of the code to build the RPM is stored in a SPECS/git-lfs.spec file. The
source code tarball needs to be put in a SOURCES directory. The BUILD and
BUILDROOT directories are used during the build process. The final RPM ends up
in the RPMS directory and a source-rpm in SRPMS.
In order to expedite installing all dependencies (mainly asciidoctor and golang)
and download any needed files a build_rpms.bsh script is included. This is the
**RECOMMENDED** way to build the rpms. It will install all yum packages in
order to build the rpm.
Simple run:
```
./clean.bsh
./build_rpms.bsh
```
The clean.bsh script removes previous rpms, etc... and removed the source
tar.gz file. Otherwise you might end up creating an rpm with pieces from
different versions.
Practice is to run rpmbuild as non-root user. This prevents inadvertently
installing files in the operating system. The intent is to run build_rpms.bsh
as a non-root user with sudo privileges. If you have a different command for
sudo, set the SUDO environment variable to the other command.
When all is down, install (or distribute) RPMS/git-lfs.rpm
```
yum install RPMS/x86_64/git-lfs*.rpm
```
### Alternative build method ###
If you want to use your own ruby/golang without using the version from
build_rpms.bsh, you will have to disable dependencies on the rpms. It's pretty
easy, just make sure asciidoctor and go are in the path, and run
```
NODEPS=1 ./build_rpms.bsh
```
### Manual build method ###
If you want to use your own ruby/golang without using build_rpms.bsh, it's a
little more complicated. You have to make sure asciidoctor and go are in the path,
and create the build structure, and download/create the tar.gz file used. This
is not recommended, but it is possible.
```
mkdir -p {BUILD,BUILDROOT,SOURCES,RPMS,SRPMS}
#download file to SOURCES/v{version number}.tar.gz
rpmbuild --define "_topdir `pwd`" -bb SPECS/git-lfs.spec --nodeps
#(and optionally)
rpmbuild --define "_topdir `pwd`" -bs SPECS/git-lfs.spec --nodeps
```
### Releases ###
It is no longer necessary to update SPECS/git-lfs.spec every version. As long
as lfs/lfs.go is updated, build_rpms.bsh parses the version number using the
pattern ```s|const Version = "\([0-9.]*\)"|\1|``` and updates
SPECS/git-lfs.spec. The version number is then used to download:
https://github.com/git-lfs/git-lfs/archive/v%{version}.tar.gz
This way when a new version is archived, it will get downloaded and built
against. When developing, it is advantageous to use the currently checked out
version to test against. In order do that, after running ```./clean.bsh```,
set the environment variable BUILD_LOCAL to 1
```
./clean.bsh
BUILD_LOCAL=1 ./build_rpms.bsh
```
### Troubleshooting ###
**Q**) I ran build_rpms.bsh as root and now there are root owned files in the
rpm dir
**A**) That happens. Either run build_rpms.bsh as a user with sudo permissions
or ```chown -R username:groupname rpm``` as root after building.