introduce spec file and related build scripts
The repository now contains a Vagrantfile for running the testing script against an RPM package created locally using `make rpm`. To run this test use `make vagrant-test`. setup.py was also modified to adhere to packaging guidelines and not to install system-level executables. The lincense is now included in the Python package using the MANIFEST.in file.
This commit is contained in:
parent
c5ec09a230
commit
3c19420b3e
7 changed files with 141 additions and 11 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.rpm
|
||||
*.tar.gz
|
||||
*.egg-info
|
||||
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
|
@ -0,0 +1 @@
|
|||
include LICENSE
|
||||
39
Makefile
Normal file
39
Makefile
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
PACKAGE_NAME=osbuild
|
||||
VERSION=1
|
||||
|
||||
sdist:
|
||||
python3 setup.py sdist
|
||||
find `pwd`/dist -name '*.tar.gz' -printf '%f\n' -exec mv {} . \;
|
||||
|
||||
tarball:
|
||||
git archive --prefix=osbuild-$(VERSION)/ --format=tar.gz HEAD > $(VERSION).tar.gz
|
||||
|
||||
srpm: $(PACKAGE_NAME).spec tarball
|
||||
/usr/bin/rpmbuild -bs \
|
||||
--define "_sourcedir $(CURDIR)" \
|
||||
--define "_srcrpmdir $(CURDIR)" \
|
||||
$(PACKAGE_NAME).spec
|
||||
|
||||
rpm: $(PACKAGE_NAME).spec tarball
|
||||
mkdir -p "`pwd`/output"
|
||||
mkdir -p "`pwd`/rpmbuild"
|
||||
/usr/bin/rpmbuild -bb \
|
||||
--define "_sourcedir `pwd`" \
|
||||
--define "_specdir `pwd`" \
|
||||
--define "_builddir `pwd`/rpmbuild" \
|
||||
--define "_srcrpmdir `pwd`" \
|
||||
--define "_rpmdir `pwd`/output" \
|
||||
--define "_buildrootdir `pwd`/build" \
|
||||
$(PACKAGE_NAME).spec
|
||||
find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
|
||||
rm -r "`pwd`/rpmbuild"
|
||||
rm -r "`pwd`/output"
|
||||
rm -r "`pwd`/build"
|
||||
|
||||
copy-rpms-to-test:
|
||||
cp *.rpm test/
|
||||
|
||||
vagrant-test: rpm copy-rpms-to-test
|
||||
- $(MAKE) -C test up
|
||||
- $(MAKE) -C test install-deps
|
||||
$(MAKE) -C test run-tests-remotely
|
||||
76
osbuild.spec
Normal file
76
osbuild.spec
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
%global pypi_name osbuild
|
||||
|
||||
Name: %{pypi_name}
|
||||
Version: 1
|
||||
Release: 1%{?dist}
|
||||
License: ASL 2.0
|
||||
|
||||
URL: https://github.com/larskarlitski/osbuild
|
||||
|
||||
Source0: https://github.com/larskarlitski/%{pypi_name}/archive/%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
Summary: A build system for OS images
|
||||
|
||||
BuildRequires: python3-devel
|
||||
|
||||
Requires: bash
|
||||
Requires: coreutils
|
||||
Requires: dnf
|
||||
Requires: e2fsprogs
|
||||
Requires: glibc
|
||||
Requires: policycoreutils
|
||||
Requires: qemu-img
|
||||
Requires: systemd
|
||||
Requires: systemd-container
|
||||
Requires: tar
|
||||
Requires: util-linux
|
||||
Requires: python3-%{pypi_name}
|
||||
|
||||
%{?python_enable_dependency_generator}
|
||||
|
||||
%description
|
||||
A build system for OS images
|
||||
|
||||
%package -n python3-%{pypi_name}
|
||||
Summary: %{summary}
|
||||
%{?python_provide:%python_provide python3-%{pypi_name}}
|
||||
|
||||
%description -n python3-%{pypi_name}
|
||||
A build system for OS images
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version}
|
||||
|
||||
%build
|
||||
%py3_build
|
||||
|
||||
%install
|
||||
%py3_install
|
||||
|
||||
mkdir -p %{buildroot}%{_libexecdir}/%{pypi_name}/stages
|
||||
install -p -m 0755 stages/* %{buildroot}%{_libexecdir}/%{pypi_name}/stages/
|
||||
|
||||
mkdir -p %{buildroot}%{_libexecdir}/%{pypi_name}/assemblers
|
||||
install -p -m 0755 assemblers/* %{buildroot}%{_libexecdir}/%{pypi_name}/assemblers/
|
||||
|
||||
install -p -m 0755 osbuild-run %{buildroot}%{_libexecdir}/%{pypi_name}/
|
||||
|
||||
%check
|
||||
exit 0
|
||||
# We have some integration tests, but those require running a VM, so that would
|
||||
# be an overkill for RPM check script.
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%{_bindir}/osbuild
|
||||
%{_libexecdir}/%{pypi_name}
|
||||
|
||||
%files -n python3-%{pypi_name}
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%{python3_sitelib}/%{pypi_name}-*.egg-info/
|
||||
%{python3_sitelib}/%{pypi_name}/
|
||||
|
||||
%changelog
|
||||
* Wed Jul 17 2019 Martin Sehnoutka <msehnout@redhat.com> - 1-1
|
||||
- Initial package
|
||||
6
setup.py
6
setup.py
|
|
@ -6,12 +6,8 @@ setuptools.setup(
|
|||
version="1",
|
||||
description="A build system for OS images",
|
||||
packages=["osbuild"],
|
||||
license='Apache-2.0',
|
||||
entry_points={
|
||||
"console_scripts": ["osbuild = osbuild.__main__:main"]
|
||||
},
|
||||
data_files=[
|
||||
("/usr/lib/osbuild", ["osbuild-run"]),
|
||||
("/usr/lib/osbuild/stages", glob.glob("./stages/*")),
|
||||
("/usr/lib/osbuild/assemblers", glob.glob("./assemblers/*"))
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
base:
|
||||
$(OSBUILD) --input $(BASE_INPUT) --output $(BASE_OUTPUT) 1-create-base.json
|
||||
up:
|
||||
vagrant up
|
||||
|
||||
web:
|
||||
$(OSBUILD) --input $(BASE_OUTPUT) --output $(WEB_OUTPUT) 2-configure-web-server.json
|
||||
install-deps:
|
||||
vagrant provision
|
||||
|
||||
qcow2:
|
||||
$(OSBUILD) --input $(WEB_OUTPUT) --output $(QCOW2_OUTPUT) 3-compose-qcow2.json
|
||||
run-tests-remotely:
|
||||
vagrant ssh -c 'pushd /vagrant; sudo python3 run-tests.py'
|
||||
|
|
|
|||
15
test/Vagrantfile
vendored
Normal file
15
test/Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
$script = <<-SCRIPT
|
||||
sudo dnf install qemu-system-x86 /vagrant/osbuild*.rpm -y
|
||||
SCRIPT
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "fedora/30-cloud-base"
|
||||
config.vm.box_version = "30.20190425.0"
|
||||
config.vm.provider "libvirt" do |v|
|
||||
v.memory = 4096
|
||||
end
|
||||
config.vm.provision "shell", inline: $script
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue