Boomaga / boomaga

Boomaga provides a virtual printer for CUPS. This can be used for print preview or for print booklets.
Other
182 stars 34 forks source link

SPEC file for building RPM x86_64 #27

Closed XOlegator closed 7 years ago

XOlegator commented 9 years ago

I try to do valid RPM package for Fedora x86_64. There is worked example of SPEC file (but not valid according to the guidelines):

Name:           boomaga
Version:        0.7.0
Release:        1%{?dist}
Summary:        Boomaga is a virtual printer for viewing a document before printing

License:        GPLv2 and LGPLv2+
URL:            http://boomaga.github.io
Source0:        %{name}-%{version}.tar.gz

BuildRequires:  cmake,cups-devel,poppler-devel,poppler-cpp-devel,qt5-qtbase-devel,qt5-qttools-devel,snappy-devel
Requires:       cups

%description
Boomaga (BOOklet MAnager) is a virtual printer for viewing a document before printing it out using the
physical printer.
The program is very simple to work with. Running any program, click “print” and select “Boomaga” to
see in several seconds (CUPS takes some time to respond) the Boomaga window open.
If you print out one more document, it gets added to the previous one, and you can also print them out as one.

%prep
%setup -q

%build
mkdir build
cd build
cmake ..

%make_install

%files
%defattr(0755,root,root,-)
/usr/lib/cups/backend/boomaga
/usr/lib/cups/filter/boomaga_pstopdf
/usr/local/bin/boomaga
/usr/local/lib/boomaga/boomagabackend
/usr/local/lib/boomaga/boomagamerger
/usr/local/share/applications/boomaga.desktop
/usr/local/share/boomaga/translations/boomaga_cs.qm
/usr/local/share/boomaga/translations/boomaga_de.qm
/usr/local/share/boomaga/translations/boomaga_el.qm
/usr/local/share/boomaga/translations/boomaga_fr.qm
/usr/local/share/boomaga/translations/boomaga_it.qm
/usr/local/share/boomaga/translations/boomaga_lt.qm
/usr/local/share/boomaga/translations/boomaga_pl_PL.qm
/usr/local/share/boomaga/translations/boomaga_ru.qm
/usr/local/share/boomaga/translations/boomaga_uz@Latn.qm
/usr/local/share/dbus-1/services/org.boomaga.service
/usr/local/share/icons/hicolor/128x128/apps/boomaga.png
/usr/local/share/icons/hicolor/16x16/apps/boomaga.png
/usr/local/share/icons/hicolor/32x32/apps/boomaga.png
/usr/local/share/icons/hicolor/64x64/apps/boomaga.png
/usr/local/share/mime/packages/boomaga.xml
/usr/share/ppd/boomaga/boomaga.ppd
%attr(0644,root,root)
%doc
/usr/local/share/man/man1/boomaga.1.gz

%changelog
* Mon Jun 22 2015 Oleg
- 

The guidelines (https://fedoraproject.org/wiki/How_to_create_an_RPM_package) said: "You should follow the Filesystem Hierarchy Standard (FHS). Executables go in /usr/bin, global configuration files go in /etc, libraries go into /usr/lib (or /usr/lib64) and so on. Do not install files into /opt or /usr/local." There is valid according to the guidelines - https://fedoraproject.org/wiki/Packaging:Cmake - SPEC file (but it doesn't work for x86_64. See %files section):

Name:           boomaga
Version:        0.7.0
Release:        1%{?dist}
Summary:        Boomaga is a virtual printer for viewing a document before printing

License:        GPLv2 and LGPLv2+
URL:            http://boomaga.github.io
Source0:        %{name}-%{version}.tar.gz

BuildRequires:  cmake,cups-devel,poppler-devel,poppler-cpp-devel,qt5-qtbase-devel,qt5-qttools-devel,snappy-devel
Requires:       cups

%description
Boomaga (BOOklet MAnager) is a virtual printer for viewing a document
before printing it out using the physical printer.
The program is very simple to work with.
Running any program, click “print” and select “Boomaga” to see in several
seconds (CUPS takes some time to respond) the Boomaga window open.
If you print out one more document,
it gets added to the previous one, and you can also print them out as one.

%prep
%setup -q

%build
%cmake .
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}

%files
%defattr(755,root,root,-)
%{_libdir}/cups/backend/boomaga
%defattr(-,root,root,-)
%{_libdir}/cups/filter/boomaga_pstopdf
%{_bindir}/boomaga
%{_libdir}/boomaga/boomagabackend
%{_libdir}/boomaga/boomagamerger
%{_datadir}/applications/boomaga.desktop
%{_datadir}/boomaga/translations/*
%{_datadir}/dbus-1/services/org.boomaga.service
%{_datadir}/icons/hicolor/*
%{_datadir}/mime/packages/boomaga.xml
%{_datadir}/ppd/boomaga/boomaga.ppd

%doc COPYING GPL LGPL README.md
%{_mandir}/man1/boomaga.1.gz

%changelog
* Mon Jun 22 2015 Oleg Ekhlakov <subspam@mail.ru> 0.7.0-1.fc21.R
- Initial version of the package

It is aborted with an error:

error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/cups/backend/boomaga error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/cups/filter/boomaga_pstopdf error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/boomaga/boomagabackend error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/boomaga/boomagamerger

As far as I understood, %{_libdir} should be /usr/lib for x32 only and %{_libdir} should be /usr/lib64 for x86_64 only. The guidelines said: "Unfortunately, many programs do not follow the FHS by default. In particular, architecture-independent libraries get placed in /usr/lib instead of /usr/share. The former is for architecture-dependent libraries, while the latter is for architecture-independent libraries, which means that systems with different CPU architectures can share /usr/share. There are many exceptions in Fedora (such as Python and Perl), but Fedora applies this rule more strictly than some distributions. rpmlint will generally complain if you put anything other than ELF files into /usr/lib." It seems that in the project need to change the location of the files (for the x86_64 architecture), but I don't know how to do it correctly: /usr/lib/cups/backend/boomaga -> /usr/lib64/cups/backend/boomaga /usr/lib/cups/filter/boomaga_pstopdf -> /usr/lib64/cups/filter/boomaga_pstopdf /usr/lib/boomaga/boomagabackend -> /usr/lib64/boomaga/boomagabackend /usr/lib/boomaga/boomagamerger -> /usr/lib64/boomaga/boomagamerger

dglent commented 9 years ago

Because they are in /etc/lib Take the example in the spec of Mageia: https://svnweb.mageia.org/packages/cauldron/boomaga/current/SPECS/boomaga.spec?view=markup

----- Mail original -----

De: "Oleg" notifications@github.com À: "Boomaga/boomaga" boomaga@noreply.github.com Envoyé: Lundi 29 Juin 2015 15:52:19 Objet: [boomaga] SPEC file for building RPM x86_64 (#27)

I try to do valid RPM package for Fedora x86_64. There is worked example of SPEC file (but not valid according to the guidelines): Name: boomaga Version: 0.7.0 Release: 1%{ ? dist} Summary: Boomaga is a virtual printer for viewing a document before printing

License: GPLv2 and LGPLv2+ URL: http://boomaga.github.io Source0: %{name}-%{version}.tar.gz

BuildRequires: cmake,cups-devel,poppler-devel,poppler-cpp-devel,qt5-qtbase-devel,qt5-qttools-devel,snappy-devel Requires: cups

%description Boomaga (BOOklet MAnager) is a virtual printer for viewing a document before printing it out using the physical printer. The program is very simple to work with. Running any program, click “print” and select “Boomaga ” to see in several seconds (CUPS takes some time to respond) the Boomaga window open. If you print out one more document, it gets added to the previous one, and you can also print them out as one.

%prep %setup -q

%build mkdir build cd build cmake ..

%make_install

%files %defattr(0755,root,root,-) /usr/lib/cups/backend/boomaga /usr/lib/cups/filter/boomaga_pstopdf /usr/local/bin/boomaga /usr/local/lib/boomaga/boomagabackend /usr/local/lib/boomaga/boomagamerger /usr/local/share/applications/boomaga.desktop /usr/local/share/boomaga/translations/boomaga_cs.qm /usr/local/share/boomaga/translations/boomaga_de.qm /usr/local/share/boomaga/translations/boomaga_el.qm /usr/local/share/boomaga/translations/boomaga_fr.qm /usr/local/share/boomaga/translations/boomaga_it.qm /usr/local/share/boomaga/translations/boomaga_lt.qm /usr/local/share/boomaga/translations/boomaga_pl_PL.qm /usr/local/share/boomaga/translations/boomaga_ru.qm /usr/local/share/boomaga/translations/boomaga_uz@Latn.qm /usr/local/share/dbus-1/services/org.boomaga.service /usr/local/share/icons/hicolor/128x128/apps/boomaga.png /usr/local/share/icons/hicolor/16x16/apps/boomaga.png /usr/local/share/icons/hicolor/32x32/apps/boomaga.png /usr/local/share/icons/hicolor/64x64/apps/boomaga.png /usr/local/share/mime/packages/boomaga.xml /usr/share/ppd/boomaga/boomaga.ppd %attr(0644,root,root) %doc /usr/local/share/man/man1/boomaga.1.gz

%changelog * Mon Jun 22 2015 Oleg

The guidelines ( https://fedoraproject.org/wiki/How_to_create_an_RPM_package ) said: " You should follow the Filesystem Hierarchy Standard (FHS). Executables go in /usr/bin, global configuration files go in /etc, libraries go into /usr/lib (or /usr/lib64) and so on. Do not install files into /opt or /usr/local. " There is valid according to the guidelines - https://fedoraproject.org/wiki/Packaging:Cmake - SPEC file (but it doesn't work for x86_64. See %files section): Name: boomaga Version: 0.7.0 Release: 1%{ ? dist} Summary: Boomaga is a virtual printer for viewing a document before printing

License: GPLv2 and LGPLv2+ URL: http://boomaga.github.io Source0: %{name}-%{version}.tar.gz

BuildRequires: cmake,cups-devel,poppler-devel,poppler-cpp-devel,qt5-qtbase-devel,qt5-qttools-devel,snappy-devel Requires: cups

%description Boomaga (BOOklet MAnager) is a virtual printer for viewing a document before printing it out using the physical printer. The program is very simple to work with. Running any program, click “print” and select “Boomaga ” to see in several seconds (CUPS takes some time to respond) the Boomaga window open. If you print out one more document, it gets added to the previous one, and you can also print them out as one.

%prep %setup -q

%build %cmake . make %{ ? _smp_mflags}

%install make install DESTDIR=%{buildroot}

%files %defattr(755,root,root,-) %{_libdir}/cups/backend/boomaga %defattr(-,root,root,-) %{_libdir}/cups/filter/boomaga_pstopdf %{_bindir}/boomaga %{_libdir}/boomaga/boomagabackend %{_libdir}/boomaga/boomagamerger %{_datadir}/applications/boomaga.desktop %{_datadir}/boomaga/translations/ %{_datadir}/dbus-1/services/org.boomaga.service %{_datadir}/icons/hicolor/ \ %{_datadir}/mime/packages/boomaga.xml %{_datadir}/ppd/boomaga/boomaga.ppd

%doc COPYING GPL LGPL README.md %{_mandir}/man1/boomaga.1.gz

%changelog * Mon Jun 22 2015 Oleg Ekhlakov < subspam@mail.ru > 0.7.0-1.fc21.R

  • Initial version of the package It is aborted with an error:

    error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/cups/backend/boomaga

error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/cups/filter/boomaga_pstopdf

error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/boomaga/boomagabackend

error: File not found: /home/oleg/rpmbuild/BUILDROOT/boomaga-0.7.0-1.fc21.R.x86_64/usr/lib64/boomaga/boomagamerger

As far as I understood, %{_libdir} should be /usr/lib for x32 only and %{_libdir} should be /usr/lib64 for x86_64 only. The guidelines said: " Unfortunately, many programs do not follow the FHS by default. In particular, architecture-independent libraries get placed in /usr/lib instead of /usr/share. The former is for architecture-dependent libraries, while the latter is for architecture-independent libraries, which means that systems with different CPU architectures can share /usr/share. There are many exceptions in Fedora (such as Python and Perl), but Fedora applies this rule more strictly than some distributions. rpmlint will generally complain if you put anything other than ELF files into /usr/lib. " It seems that in the project need to change the location of the files (for the x86_64 architecture), but I don't know how to do it correctly : /usr/lib/cups/backend/boomaga -> /usr/lib64/cups/backend/boomaga /usr/lib/cups/filter/boomaga_pstopdf -> /usr/lib64/cups/filter/boomaga_pstopdf /usr/lib/boomaga/boomagabackend -> /usr/lib64/boomaga/boomagabackend /usr/lib/boomaga/boomagamerger -> /usr/lib64/boomaga/boomagamerger — Reply to this email directly or view it on GitHub .

Dimitrios Glentadakis

XOlegator commented 9 years ago

dglent, thanks for your reply! I tried your version of _%{prefix}/lib instead of _%{libdir}. As my first option, it is compiled, but not valid:

[oleg@o ~]$ rpmlint ~/rpmbuild/SPEC/boomaga.spec ~/rpmbuild/SRPMS/boomaga* ~/rpmbuild/RPMS//boomaga (none): E: no installed packages by name /home/oleg/rpmbuild/SPEC/boomaga.spec boomaga.src: W: name-repeated-in-summary C Boomaga boomaga.src:39: E: hardcoded-library-path in %{_prefix}/lib/cups/backend/%{name} boomaga.src:43: E: hardcoded-library-path in %{_prefix}/lib/cups/filter/boomaga_pstopdf boomaga.src:47: E: hardcoded-library-path in %{_prefix}/lib/%{name}/boomagabackend boomaga.src:50: E: hardcoded-library-path in %{_prefix}/lib/%{name}/boomagamerger boomaga.src: W: invalid-url Source0: boomaga-0.7.0.tar.gz boomaga.x86_64: W: name-repeated-in-summary C Boomaga 3 packages and 0 specfiles checked; 4 errors, 10 warnings.

[oleg@o ~]$ rpmlint -I hardcoded-library-path hardcoded-library-path: A library path is hardcoded to one of the following paths: /lib, /usr/lib. It should be replaced by something like /%{_lib} or %{_libdir}.

I think the correct option to use _%{libdir}, but this requires correction of the source code of the program. Option _%{libdir} should work for 32-bit arch (/usr/lib) and for 64-bit arch (/usr/lib64).

dglent commented 9 years ago

Yes, i don't know if there is a specific reason for the path: /etc/lib ???

----- Mail original -----

De: "Oleg" notifications@github.com À: "Boomaga/boomaga" boomaga@noreply.github.com Cc: "Dimitrios Glentadakis" dglent@free.fr Envoyé: Mardi 30 Juin 2015 10:00:06 Objet: Re: [boomaga] SPEC file for building RPM x86_64 (#27)

dglent, thanks for your reply! I tried your version of %{_prefix}/lib instead of %{_libdir} . As my first option, it is compiled, but not valid:

[oleg@o ~]$ rpmlint ~/rpmbuild/SPEC/boomaga.spec ~/rpmbuild/SRPMS/boomaga* ~/rpmbuild/RPMS/ /boomaga

(none): E: no installed packages by name /home/oleg/rpmbuild/SPEC/boomaga.spec

boomaga.src: W: name-repeated-in-summary C Boomaga

boomaga.src:39: E: hardcoded-library-path in %{_prefix}/lib/cups/backend/%{name}

boomaga.src:43: E: hardcoded-library-path in %{_prefix}/lib/cups/filter/boomaga_pstopdf

boomaga.src:47: E: hardcoded-library-path in %{_prefix}/lib/%{name}/boomagabackend

boomaga.src:50: E: hardcoded-library-path in %{_prefix}/lib/%{name}/boomagamerger

boomaga.src: W: invalid-url Source0: boomaga-0.7.0.tar.gz

boomaga.x86_64: W: name-repeated-in-summary C Boomaga

3 packages and 0 specfiles checked; 4 errors, 10 warnings.

[oleg@o ~]$ rpmlint -I hardcoded-library-path

hardcoded-library-path:

A library path is hardcoded to one of the following paths: /lib, /usr/lib. It

should be replaced by something like /%{_lib} or %{_libdir}.

I think the correct option to use %{_libdir} , but this requires correction of the source code of the program. Option %{_libdir} should work for 32-bit arch (/usr/lib) and for 64-bit arch (/usr/lib64). — Reply to this email directly or view it on GitHub .

Dimitrios Glentadakis

XOlegator commented 9 years ago

dglent, with your help (your SPEC), I completed my SPEC. Now it is all valid and worked.

Name:           boomaga
Version:        0.7.1
Release:        1%{?dist}
Summary:        A virtual printer for viewing a document before printing
License:        GPLv2 and LGPLv2+
URL:            http://boomaga.github.io
Source0:        %{name}-%{version}.tar.gz

BuildRequires:  cmake,cups-devel,poppler-devel,poppler-cpp-devel,qt5-qtbase-devel,qt5-qttools-devel,snappy-devel
Requires:       cups,snappy

%description
Boomaga (BOOklet MAnager) is a virtual printer for viewing a document
before printing it out using the physical printer.
The program is very simple to work with.
Running any program, click “print” and select “Boomaga” to see in several
seconds (CUPS takes some time to respond) the Boomaga window open.
If you print out one more document,
it gets added to the previous one, and you can also print them out as one,
and you can also print them out as one.
Regardless of whether your printer supports duplex printing or not,
you would be able to easily print on both sides of the sheet.
If your printer does not support duplex printing,
point this out in the settings, and Booklet would ask you to turn
over the pages half way through printing your document.
The program can also help you get your documents prepared a bit
before printing. At this stage Boomaga makes it possible to:
* Paste several documents together.
* Print several pages on one sheet.
* 1, 2, 4, 8 pages per sheet
* Booklet. Folding the sheets in two, you’ll get a book.

%prep
%setup -q

%build
%ifarch x86_64
  %cmake -DLIB_SUFFIX=64 -DCUPS_BACKEND_DIR=%{_libdir}/cups/backend -DCUPS_FILTER_DIR=%{_libdir}/cups/filter .
%else
  %cmake -DCUPS_BACKEND_DIR=%{_libdir}/cups/backend -DCUPS_FILTER_DIR=%{_libdir}/cups/filter .
%endif
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}

%__mkdir -p %{buildroot}%{_datadir}/%{name}/scripts
%__install -m 755 scripts/installPrinter.sh %{buildroot}%{_datadir}/%{name}/scripts/
chmod +x %{buildroot}%{_datadir}/%{name}/scripts/installPrinter.sh

# Add translation lang tags
(cd %{buildroot} && find . -name '*.qm') | %__sed -e 's|^.||' | sed -e \
's:\(.*/translations/boomaga_\)\([a-z_A-Z]\+\)\(.*qm$\):%lang(\2) \1\2\3:'\
>> %{name}.lang

%pre
# Start cups if is stopped
if [ "$(systemctl is-active cups.service)" != "active" ]; then
  systemctl start cups
  sleep 2
fi

%post
# Install the printer to cups backends
if [ $1 = 1 ]; then
  sh %{_datadir}/%{name}/scripts/installPrinter.sh
fi

%preun
# Uninstall the printer
lpadmin -x "Boomaga"

%files
%defattr(755,root,root,-)
%{_libdir}/cups/backend/%{name}
%defattr(-,root,root,-)
%{_libdir}/cups/filter/boomaga_pstopdf
%{_bindir}/%{name}
%{_libdir}/%{name}/boomagabackend
%{_libdir}/%{name}/boomagamerger
%{_datadir}/applications/boomaga.desktop
%{_datadir}/%{name}/translations/*
%{_datadir}/dbus-1/services/org.boomaga.service
%{_datadir}/icons/hicolor/*
%{_datadir}/mime/packages/boomaga.xml
%{_datadir}/ppd/%{name}/boomaga.ppd
%{_datadir}/%{name}/scripts/installPrinter.sh

%doc COPYING GPL LGPL README.md
%{_mandir}/man1/boomaga.1.gz

%changelog
* Tue Jun 30 2015 Oleg Ekhlakov <subspam@mail.ru> 0.7.1-1.fc21.R
- Initial version of the package

All the magic is hidden in the assignment settings:

%ifarch x86_64 %cmake -DLIB_SUFFIX=64 -DCUPS_BACKEND_DIR=%{_libdir}/cups/backend -DCUPS_FILTER_DIR=%{_libdir}/cups/filter . %else %cmake -DCUPS_BACKEND_DIR=%{_libdir}/cups/backend -DCUPS_FILTER_DIR=%{_libdir}/cups/filter . %endif

But some little change in source code I have to do: in /CMakeLists.txt line 82:

set(NONGUI_DIR ${CMAKE_INSTALL_PREFIX}/lib/boomaga)

change to

set(NONGUI_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/boomaga)

in /gui/pdfmerger/CMakeLists.txt line 72:

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION lib/boomaga/)

change to

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION lib${LIB_SUFFIX}/boomaga/)

I have successfully packaged RPM for the basic architecture x86_64:

rpmbuild -ba ~/rpmbuild/SPECS/boomaga.spec

and for x86:

rpmbuild -ba --target=x86 ~/rpmbuild/SPECS/boomaga.spec

[oleg@o ~]$ rpmlint ~/rpmbuild/SPEC/boomaga.spec ~/rpmbuild/SRPMS/boomaga* ~/rpmbuild/RPMS//boomaga (none): E: no installed packages by name /home/oleg/rpmbuild/SPEC/boomaga.spec boomaga.src: W: invalid-url Source0: boomaga-0.7.1.tar.gz 5 packages and 0 specfiles checked; 0 errors, 1 warnings.

I'll try to make a patch to upstream

dglent commented 9 years ago

Super Oleg, i will change the path at the next version for Mageia too !

Την Τρίτη, 30 Ιουνίου 2015 4:00:58 Μ.Μ. CEST, Oleg γράψατε:

dglent, with your help (your SPEC), I completed my SPEC. Now it is all valid and worked.

SokoloffA commented 9 years ago

Sorry for silence. I am on vacation, and have no computer.

среда, 1 июля 2015 г. пользователь Dimitrios Glentadakis написал:

Super Oleg, i will change the path at the next version for Mageia too !

Την Τρίτη, 30 Ιουνίου 2015 4:00:58 Μ.Μ. CEST, Oleg γράψατε:

dglent, with your help (your SPEC), I completed my SPEC. Now it is all valid and worked.

— Reply to this email directly or view it on GitHub https://github.com/Boomaga/boomaga/issues/27#issuecomment-117414336.

Best regards, Alexander.

SokoloffA commented 9 years ago

Hi all! I'm not a guru in RPM-specs, in 2013 I wrote spec for ROSA-linux, and guys from rosa team was made some changes. Let's write one universal RPM-spec.

SokoloffA commented 7 years ago

No response for long time. Closing. Feel free to reopen if you are still facing this issue. And Fedora have official RPM for boomaga.