Add spec file to build rpm package

master
Justin Zhang 12 years ago
parent 81e873768a
commit e0183531c3
  1. 46
      README.md
  2. 72
      bash-git-prompt.spec

@ -103,4 +103,50 @@ function prompt_callback {
**Enjoy!**
## Alternative RPM Install
This project ships an RPM spec to simplify installation on RHEL and
clones. If you wish to install from RPM, you may first build the RPM
from scratch by following this procedure:
* Clone this repository and tag the release with a version number
````sh
git tag -a -m "Tag release 1.1" 1.1
````
* Run the following command to create a tarball:
````sh
VER1=$(git describe)
# replace dash with underscore to work around
# rpmbuild does not allow dash in version string
VER=${VER1//\-/_}
git archive \
--format tar \
--prefix=bash-git-prompt-${VER}/ \
HEAD \
-- *.sh \
*.py \
*.fish \
README.md \
> bash-git-prompt-${VER}.tar
mkdir -p /tmp/bash-git-prompt-${VER}
sed "s/Version:.*/Version: ${VER}/" \
bash-git-prompt.spec \
> /tmp/bash-git-prompt-${VER}/bash-git-prompt.spec
OLDDIR=$(pwd)
cd /tmp
tar -uf ${OLDDIR}/bash-git-prompt-${VER}.tar \
bash-git-prompt-${VER}/bash-git-prompt.spec
cd ${OLDDIR}
gzip bash-git-prompt-${VER}.tar
mv bash-git-prompt-${VER}.tar.gz bash-git-prompt-${VER}.tgz
````
* Log into an RHEL or clones host and run:
````sh
rpmbuild -ta bash-git-prompt-xxx.tar.gz
````
Then you may publish or install the rpm from "~/rpmbuild/RPMS/noarch".
[blog post]: http://sebastiancelis.com/2009/nov/16/zsh-prompt-git-users/

@ -0,0 +1,72 @@
%global START_TOKEN ### Generated by %{name} rpm package
%global END_TOKEN ### Generated by %{name} rpm package
Name: bash-git-prompt
Version: 1.0
Release: 1%{?dist}
Summary: Informative git prompt for bash and fish
Group: Development/Tools
License: GPL
URL: https://github.com/magicmonty/bash-git-prompt.git
Source0: https://github.com/magicmonty/bash-git-prompt/archive/%{name}-%{version}.tgz
Requires: git
BuildArch: noarch
%description
A bash prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
This package will automatically enable the git prompt for bash after
install. It will disable the prompt accordingly after uninstall.
%prep
%setup -q
%build
%install
rm -rf %{buildroot}
install -d 755 %{buildroot}%{_datadir}/%{name}
install -pm 755 *.sh %{buildroot}%{_datadir}/%{name}
install -pm 755 *.py %{buildroot}%{_datadir}/%{name}
install -pm 755 *.fish %{buildroot}%{_datadir}/%{name}
install -pm 644 README.md %{buildroot}%{_datadir}/%{name}
# never include compiled Python program
rm -fr %{buildroot}%{_datadir}/%{name}/*.pyo
rm -fr %{buildroot}%{_datadir}/%{name}/*.pyc
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_datadir}/%{name}
%post
# enable bash-git-prompt
cat << EOF >> /etc/bashrc
%{START_TOKEN}
if [ -f %{_datadir}/%{name}/gitprompt.sh ]; then
# Set config variables first
GIT_PROMPT_ONLY_IN_REPO=1
source %{_datadir}/%{name}/gitprompt.sh
fi
%{END_TOKEN}
EOF
%postun
# remove bash-git-prompt setup
sed -i -e '/^%{START_TOKEN}/, /^%{END_TOKEN}/{d}' /etc/bashrc
%changelog
* Fri Aug 08 2014 Justin Zhang <schnell18@gmail.com - 1.0.1-1
- Initial version of package
Loading…
Cancel
Save