Skip to content

Commit

Permalink
(SIMP-306) Working Documentation RPMs
Browse files Browse the repository at this point in the history
* RPMs build on both EL6 and EL7 mock spaces
* Updated ALL tables to be in list-table format
  * The PDF build takes quite a while
* Moved the LogStash SVG to PNG format since the PDF can't handle SVG

SIMP-306 #close #comment OMG MoAr Hackery

Change-Id: I501d933b510542020b616a0421db5676a68bb883
  • Loading branch information
trevor-vaughan committed Aug 12, 2015
1 parent d13c4b1 commit da954e8
Show file tree
Hide file tree
Showing 29 changed files with 3,232 additions and 6,233 deletions.
46 changes: 44 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@
require 'simp/rake'

class DocPkg < Simp::Rake::Pkg
# We need to inject the SCL Python repos for RHEL6 here if necessary
def mock_pre_check(chroot, *args)
mock_cmd = super(chroot, *args)

rh_version = %x(#{mock_cmd} -r #{chroot} -q --chroot 'cat /etc/redhat-release | cut -f3 -d" " | cut -f1 -d"."').chomp

# This is super fragile
if rh_version.to_i == 6
python_repo = 'rhscl-python27-epel-6-x86_64'

puts "NOTICE: You can ignore any errors relating to RPM commands that don't result in failure"
%x(#{mock_cmd} -q -r #{chroot} --chroot 'rpmdb --rebuilddb')
sh %(#{mock_cmd} -q -r #{chroot} --chroot 'rpm --quiet -q yum') do |ok,res|
unless ok
%x(#{mock_cmd} -q -r #{chroot} --install yum)
end
end

sh %(#{mock_cmd} -q -r #{chroot} --chroot 'rpm --quiet -q #{python_repo}') do |ok,res|
unless ok
%x(#{mock_cmd} -q -r #{chroot} --install 'https://www.softwarecollections.org/en/scls/rhscl/python27/epel-6-x86_64/download/#{python_repo}.noarch.rpm')
end
end

sh %(#{mock_cmd} -q -r #{chroot} --chroot 'rpm --quiet -q python27') do |ok,res|
unless ok
# Fun Fact: Mock (sometimes) adds its default repos to /etc/yum/yum.conf and ignores anything in yum.repos.d
puts %x(#{mock_cmd} -q -r #{chroot} --chroot 'cat /etc/yum.repos.d/#{python_repo}.repo >> /etc/yum/yum.conf && yum install -qy python27')
end
end
end

mock_cmd
end

def define_clean
task :clean do
find_erb_files.each do |erb|
Expand Down Expand Up @@ -36,6 +71,7 @@ end
DocPkg.new( File.dirname( __FILE__ ) ) do |t|
# Not sure this is right
t.clean_list << "#{t.base_dir}/html"
t.clean_list << "#{t.base_dir}/html-single"
t.clean_list << "#{t.base_dir}/pdf"
t.clean_list << "#{t.base_dir}/sphinx_cache"

Expand All @@ -48,7 +84,6 @@ DocPkg.new( File.dirname( __FILE__ ) ) do |t|
end
end


namespace :docs do
desc 'build HTML docs'
task :html do
Expand All @@ -61,12 +96,19 @@ namespace :docs do
%x(#{cmd} > /dev/null)
end


desc 'build HTML docs (single page)'
task :singlehtml do
extra_args = ''
cmd = "sphinx-build -E -n #{extra_args} -b singlehtml -d sphinx_cache docs html-single"
puts "== #{cmd}"
%x(#{cmd} > /dev/null)
end

desc 'build PDF docs (SLOW)'
task :pdf do
extra_args = ''
cmd = "sphinx-build -E -n #{extra_args} -b pdf -d sphinx_cache docs pdf"
puts "== #{cmd}"
%x(#{cmd} > /dev/null)
end
end
64 changes: 41 additions & 23 deletions build/simp-doc.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
%if 0%{?el6}
%define simp_major_version 4
%else
%define simp_major_version 5
%endif

Summary: SIMP Documentation
Name: simp-doc
Expand All @@ -10,54 +14,68 @@ Source: %{name}-%{version}-%{release}.tar.gz
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Buildarch: noarch
Requires: links
BuildRequires: sphinx >= 1.2
BuildRequires: python-sphinx >= 0
Prefix: /usr/share/doc/simp-%{version}
%if 0%{?el6}
BuildRequires: scl-utils
BuildRequires: python27
%endif
BuildRequires: python-pip
BuildRequires: python-virtualenv

%description
Documentation for SIMP %{version}-%{release}

You can access the documentation on a text-based system using the
command 'simp doc'. Alternatively, a PDF is provided in
%{prefix}/pdf
command 'simp doc'.

Alternatively, you can read the docs at https://simp.readthedocs.org

%prep
%setup
%setup -q

%build
sphinx-build -n -t simp_%{simp_major_version} -b html -d sphinx_cache docs html
# We need the latest version of sphinx and rst2pdf
# Make sure we play nice with our neighbors...

%if 0%{?el6}
# We can't use the normal SCL commands in mock so we do this manually!
source /opt/rh/python27/enable
%endif

virtualenv venv
source venv/bin/activate
pip install --upgrade sphinx
pip install --upgrade rst2pdf

sphinx-build -E -n -t simp_%{simp_major_version} -b html -d sphinx_cache docs html
sphinx-build -E -n -t simp_%{simp_major_version} -b singlehtml -d sphinx_cache docs html-single
sphinx-build -E -n -t simp_%{simp_major_version} -b pdf -d sphinx_cache docs pdf

%install
mkdir -p %{buildroot}%{prefix}
src_dirs="changelogs Changelog*.rst ldifs html"
for dir in $src_dirs; do
if [ -e $dir ]; then
cp -r $dir %{buildroot}%{prefix}
fi
done
if [ ! -d changelogs ]; then
mkdir changelogs
fi

# Publican Material
mkdir -p %{buildroot}%{prefix}/html
cp -r "html/" %{buildroot}%{prefix}/html/
cp -r "html-single/" %{buildroot}%{prefix}/html-single/
mv pdf/SIMP_Documentation.pdf pdf/SIMP-%{version}-%{release}.pdf

chmod -R u=rwX,g=rX,o=rX %{buildroot}%{prefix}
%install
# Just the Docs...

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%docdir %{prefix}
%{prefix}
%defattr(0644,root,root,0755)
%doc Changelog.rst html html-single pdf ldifs

%post
# Post install stuff

%postun
# Post uninstall stuff

%changelog
* Tue Aug 11 2015 Trevor Vaughan <tvaughan@onyxpoint.com> - 5.1.0-Beta2
- Updated the spec file to properly build the docs.

%changelog
* Fri Jul 31 2015 Judy Johnson <judy.johnson@onyxpoint.com> - 5.1.0-Beta2
- Converted docs from Publican to ReStructured Text.
Expand Down

0 comments on commit da954e8

Please sign in to comment.