Permalink
Browse files

Make RPM's from the Makefile

These are useful for actual RPM's for a COPR or similar, and probably
need tweaks to go upstream. Having said that, patches are welcome!
1 parent ef16c73 commit 8ee3fdab7451bb30b56e42c4586e4304b5805faf @purpleidea committed Jul 7, 2015
Showing with 183 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +134 −2 Makefile
  3. +5 −1 bin/omv.sh
  4. +43 −0 oh-my-vagrant.spec.in
View
@@ -2,3 +2,4 @@ oh-my-vagrant-documentation.pdf
screencasts/
old/
tmp/
+rpmbuild/
View
136 Makefile
@@ -15,14 +15,146 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-.PHONY: all docs
+.PHONY: all docs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms
.SILENT:
-all: docs
+# version of the program
+VERSION := $(shell git tag | sort -r --version-sort | head -1)
+RELEASE = 1
+SPEC = rpmbuild/SPECS/oh-my-vagrant.spec
+SOURCE = rpmbuild/SOURCES/oh-my-vagrant-$(VERSION).tar.bz2
+SRPM = rpmbuild/SRPMS/oh-my-vagrant-$(VERSION)-$(RELEASE).src.rpm
+RPM = rpmbuild/RPMS/oh-my-vagrant-$(VERSION)-$(RELEASE).rpm
+SERVER = 'dl.fedoraproject.org'
+REMOTE_PATH = 'pub/oh-my-vagrant'
+
+all: docs rpm
+
+#
+# aliases
+#
+# TODO: does making an rpm depend on making a .srpm first ?
+rpm: $(SRPM) $(RPM)
+ # do nothing
+
+srpm: $(SRPM)
+ # do nothing
+
+spec: $(SPEC)
+ # do nothing
+
+tar: $(SOURCE)
+ # do nothing
+
+rpmbuild/SOURCES/: tar
+rpmbuild/SRPMS/: srpm
+rpmbuild/RPMS/: rpm
+
+upload: upload-sources upload-srpms upload-rpms
+ # do nothing
docs: oh-my-vagrant-documentation.pdf
oh-my-vagrant-documentation.pdf: DOCUMENTATION.md
pandoc DOCUMENTATION.md -o 'oh-my-vagrant-documentation.pdf'
+#
+# rpmbuild
+#
+$(RPM): $(SPEC) $(SOURCE)
+ @echo Running rpmbuild -bb...
+ rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bb $(SPEC) && \
+ mv rpmbuild/RPMS/noarch/oh-my-vagrant-$(VERSION)-$(RELEASE).*.rpm $(RPM)
+
+$(SRPM): $(SPEC) $(SOURCE)
+ @echo Running rpmbuild -bs...
+ rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bs $(SPEC)
+ # renaming is not needed because we aren't using the dist variable
+ #mv rpmbuild/SRPMS/oh-my-vagrant-$(VERSION)-$(RELEASE).*.src.rpm $(SRPM)
+
+#
+# spec
+#
+$(SPEC): rpmbuild/ oh-my-vagrant.spec.in
+ @echo Running templater...
+ #cat oh-my-vagrant.spec.in > $(SPEC)
+ sed -e s/__VERSION__/$(VERSION)/ -e s/__RELEASE__/$(RELEASE)/ < oh-my-vagrant.spec.in > $(SPEC)
+ # append a changelog to the .spec file
+ git log --format="* %cd %aN <%aE>%n- (%h) %s%d%n" --date=local | sed -r 's/[0-9]+:[0-9]+:[0-9]+ //' >> $(SPEC)
+
+#
+# archive
+#
+$(SOURCE): rpmbuild/
+ @echo Running git archive...
+ # use HEAD if tag doesn't exist yet, so that development is easier...
+ git archive --prefix=oh-my-vagrant-$(VERSION)/ -o $(SOURCE) $(VERSION) 2> /dev/null || (echo 'Warning: $(VERSION) does not exist.' && git archive --prefix=oh-my-vagrant-$(VERSION)/ -o $(SOURCE) HEAD)
+ # TODO: if git archive had a --submodules flag this would easier!
+ @echo Running git archive submodules...
+ # i thought i would need --ignore-zeros, but it doesn't seem necessary!
+ p=`pwd` && (echo .; git submodule foreach) | while read entering path; do \
+ temp="$${path%\'}"; \
+ temp="$${temp#\'}"; \
+ path=$$temp; \
+ [ "$$path" = "" ] && continue; \
+ (cd $$path && git archive --prefix=oh-my-vagrant-$(VERSION)/$$path/ HEAD > $$p/rpmbuild/tmp.tar && tar --concatenate --file=$$p/$(SOURCE) $$p/rpmbuild/tmp.tar && rm $$p/rpmbuild/tmp.tar); \
+ done
+
+# TODO: ensure that each sub directory exists
+rpmbuild/:
+ mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
+
+#
+# sha256sum
+#
+rpmbuild/SOURCES/SHA256SUMS: rpmbuild/SOURCES/ $(SOURCE)
+ @echo Running SOURCES sha256sum...
+ cd rpmbuild/SOURCES/ && sha256sum *.tar.bz2 > SHA256SUMS; cd -
+
+rpmbuild/SRPMS/SHA256SUMS: rpmbuild/SRPMS/ $(SRPM)
+ @echo Running SRPMS sha256sum...
+ cd rpmbuild/SRPMS/ && sha256sum *src.rpm > SHA256SUMS; cd -
+
+rpmbuild/RPMS/SHA256SUMS: rpmbuild/RPMS/ $(RPM)
+ @echo Running RPMS sha256sum...
+ cd rpmbuild/RPMS/ && sha256sum *.rpm > SHA256SUMS; cd -
+
+#
+# gpg
+#
+rpmbuild/SOURCES/SHA256SUMS.asc: rpmbuild/SOURCES/SHA256SUMS
+ @echo Running SOURCES gpg...
+ # the --yes forces an overwrite of the SHA256SUMS.asc if necessary
+ gpg2 --yes --clearsign rpmbuild/SOURCES/SHA256SUMS
+
+rpmbuild/SRPMS/SHA256SUMS.asc: rpmbuild/SRPMS/SHA256SUMS
+ @echo Running SRPMS gpg...
+ gpg2 --yes --clearsign rpmbuild/SRPMS/SHA256SUMS
+
+rpmbuild/RPMS/SHA256SUMS.asc: rpmbuild/RPMS/SHA256SUMS
+ @echo Running RPMS gpg...
+ gpg2 --yes --clearsign rpmbuild/RPMS/SHA256SUMS
+
+#
+# upload
+#
+# upload to public server
+upload-sources: rpmbuild/SOURCES/ rpmbuild/SOURCES/SHA256SUMS rpmbuild/SOURCES/SHA256SUMS.asc
+ if [ "`cat rpmbuild/SOURCES/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/SOURCES/ && cat SHA256SUMS'`" ]; then \
+ echo Running SOURCES upload...; \
+ rsync -avz rpmbuild/SOURCES/ $(SERVER):$(REMOTE_PATH)/SOURCES/; \
+ fi
+
+upload-srpms: rpmbuild/SRPMS/ rpmbuild/SRPMS/SHA256SUMS rpmbuild/SRPMS/SHA256SUMS.asc
+ if [ "`cat rpmbuild/SRPMS/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/SRPMS/ && cat SHA256SUMS'`" ]; then \
+ echo Running SRPMS upload...; \
+ rsync -avz rpmbuild/SRPMS/ $(SERVER):$(REMOTE_PATH)/SRPMS/; \
+ fi
+
+upload-rpms: rpmbuild/RPMS/ rpmbuild/RPMS/SHA256SUMS rpmbuild/RPMS/SHA256SUMS.asc
+ if [ "`cat rpmbuild/RPMS/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/RPMS/ && cat SHA256SUMS'`" ]; then \
+ echo Running RPMS upload...; \
+ rsync -avz --prune-empty-dirs rpmbuild/RPMS/ $(SERVER):$(REMOTE_PATH)/RPMS/; \
+ fi
+
# vim: ts=8
View
@@ -17,7 +17,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-vagrantdir="$HOME/code/oh-my-vagrant/vagrant/" # this should be set at install
+vagrantdir="/usr/share/oh-my-vagrant/" # this should be set at install
+if [ "$OHMYVAGRANT_DIR" != "" ]; then
+ vagrantdir="$OHMYVAGRANT_DIR" # use user provided dir instead
+fi
+vagrantdir="$vagrantdir""vagrant/" # append vagrant/ path postfix!
projectdir="`pwd`" # default to where we are
args=$@
View
@@ -0,0 +1,43 @@
+%global project_version __VERSION__
+
+Name: oh-my-vagrant
+Version: __VERSION__
+#Release: __RELEASE__%{?dist} # use this to make dist specific builds
+Release: __RELEASE__
+Summary: An easy to use dev environment for using vagrant with puppet, docker and more!
+License: AGPLv3+
+URL: https://github.com/purpleidea/oh-my-vagrant
+Source0: https://dl.fedoraproject.org/pub/alt/purpleidea/oh-my-vagrant/SOURCES/oh-my-vagrant-%{project_version}.tar.bz2
+BuildArch: noarch
+
+Requires: vagrant >= 1.6.5
+Requires: vagrant-libvirt >= 0.0.24
+
+%description
+An easy to use dev environment for using vagrant with puppet, docker and more!
+
+%prep
+%setup -c -q -T -D -a 0
+
+%build
+
+%install
+rm -rf %{buildroot}
+# _datadir is typically /usr/share/
+install -d -m 0755 %{buildroot}/%{_datadir}/oh-my-vagrant/
+cp -r oh-my-vagrant-%{project_version}/* %{buildroot}/%{_datadir}/oh-my-vagrant/
+
+mkdir -p %{buildroot}/%{_bindir}
+install -m 0755 oh-my-vagrant-%{project_version}/bin/omv.sh %{buildroot}/%{_bindir}/omv
+
+mkdir -p %{buildroot}%{_sysconfdir}/profile.d
+install oh-my-vagrant-%{project_version}/extras/vagrant.bashrc -m 0755 %{buildroot}%{_sysconfdir}/profile.d/oh-my-vagrant.sh
+
+%files
+%dir %{_sysconfdir}/profile.d
+%attr(0755, root, root) %{_sysconfdir}/profile.d/oh-my-vagrant.sh
+%{_datadir}/oh-my-vagrant/*
+%{_bindir}/omv
+
+# this changelog is auto-generated by git log
+%changelog

0 comments on commit 8ee3fda

Please sign in to comment.