[packages/vagrant/binary] create vagrant-guest package

glen glen at pld-linux.org
Sun Mar 24 13:03:09 CET 2013


commit d927829708231c67d1cdae3e3748ec01a918d40f
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Mar 24 14:02:19 2013 +0200

    create vagrant-guest package
    
    it is to be installed to base vm.
    it is accessed by insecure vagrant private key and should have sudo
    rights to do administrative jobs

 vagrant.spec | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 3 deletions(-)
---
diff --git a/vagrant.spec b/vagrant.spec
index de5933c..5ce5195 100644
--- a/vagrant.spec
+++ b/vagrant.spec
@@ -1,7 +1,11 @@
+#
+# Conditional build:
+%bcond_without	vagrant	# build vagrant package
+
 Summary:	Provisioning and deployment of virtual instances
 Name:		vagrant
 Version:	1.1.2
-Release:	0.4
+Release:	0.6
 License:	MIT
 Group:		Applications/Emulators
 URL:		http://vagrantup.com/
@@ -9,6 +13,7 @@ Source0:	http://files.vagrantup.com/packages/67bd4d30f7dbefa7c0abc643599f0244986
 # Source0-md5:	83093a71588f97a9eb69fa7fe07418b9
 Source1:	http://files.vagrantup.com/packages/67bd4d30f7dbefa7c0abc643599f0244986c38c8/vagrant_x86_64.rpm?/%{name}-%{version}.x86_64.rpm
 # Source1-md5:	3efa3ac73988c565e6b3236da6867557
+BuildRequires:	bash
 BuildRequires:	pkgconfig
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpm-utils
@@ -20,6 +25,8 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %define		_appdir	%{_libdir}/%{name}
 
+%define		vg_home	/home/vagrant
+
 %define		_enable_debug_packages		0
 %define		no_install_post_strip		1
 %define		no_install_post_check_so	1
@@ -38,6 +45,33 @@ environments by making it easier to do so than not to. Additionally,
 work is ongoing to have Vagrant run identically on every major
 consumer OS platform (Linux, Mac OS X, and Windows).
 
+%package guest
+Summary:	Vagrant guest
+Group:		Development/Building
+Requires(postun):	/usr/sbin/userdel
+Requires(pre):	/bin/id
+Requires(pre):	/usr/bin/getgid
+Requires(pre):	/usr/sbin/groupadd
+Requires(pre):	/usr/sbin/useradd
+Requires:	openssh-server
+Provides:	group(vagrant)
+Provides:	user(vagrant)
+%if "%{_rpmversion}" >= "5"
+BuildArch:	noarch
+%endif
+
+%description guest
+This is the package to be installed in Vagrant guest.
+
+WARNING: This package installs insecure keypair to vagant user. Do not
+install this package in a box that is accessible others but you.
+
+These keys are the "insecure" public/private keypair we offer to base
+box creators for use in their base boxes so that vagrant installations
+can automatically SSH into the boxes.
+
+See: <https://github.com/mitchellh/vagrant/tree/master/keys/>.
+
 %package doc
 Summary:	Documentation for %{name}
 Group:		Documentation
@@ -60,7 +94,6 @@ SOURCE=%{S:1}
 
 V=$(rpm -qp --nodigest --nosignature --qf '%{V}' $SOURCE)
 test "$V" = "%{version}"
-
 rpm2cpio $SOURCE | cpio -i -d
 
 mv opt/vagrant/* .
@@ -69,20 +102,44 @@ grep -rl /tmp/vagrant-temp embedded | xargs sed -i -e 's,/tmp/vagrant-temp,%{_ap
 
 %install
 rm -rf $RPM_BUILD_ROOT
+%if %{with vagrant}
 install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}}
-
 cp -a bin embedded $RPM_BUILD_ROOT%{_appdir}
 ln -s %{_appdir}/bin/%{name} $RPM_BUILD_ROOT%{_bindir}
+%endif
+
+# guest
+install -d $RPM_BUILD_ROOT%{vg_home}/.ssh
+cp -a /etc/skel/.bash*  $RPM_BUILD_ROOT%{vg_home}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%pre guest
+# FIXME: register user in uid_gid.db.txt
+%groupadd -g 2000 vagrant
+%useradd -u 2000 -g vagrant -G wheel -c "Vagrant user" -s /bin/bash -d %{vg_home} vagrant
+
+%postun guest
+if [ "$1" = "0" ]; then
+	%userremove vagrant
+	%groupremove vagrant
+fi
+
+%if %{with vagrant}
 %files
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/vagrant
 
 %defattr(-,root,root,-)
 %{_appdir}
+%endif
+
+%files guest
+%defattr(644,root,root,755)
+%dir %attr(750,vagrant,vagrant) %{vg_home}
+%dir %attr(700,vagrant,vagrant) %{vg_home}/.ssh
+%dir %attr(640,vagrant,vagrant) %{vg_home}/.bash*
 
 %if 0
 %files doc
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/vagrant.git/commitdiff/d927829708231c67d1cdae3e3748ec01a918d40f



More information about the pld-cvs-commit mailing list