Skip to content

Instantly share code, notes, and snippets.

@ttys3
Forked from ruario/example-spec-files.md
Created February 11, 2020 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttys3/10b1a8c34e0637c6c7c8502d78edf698 to your computer and use it in GitHub Desktop.
Save ttys3/10b1a8c34e0637c6c7c8502d78edf698 to your computer and use it in GitHub Desktop.
Example rpm .spec files for recent versions of Opera.

The following are some example .spec files I created to demonstrate how to deal with a more recent libudev version and the different naming of libcrypto on Fedora, via the use of compatibility symlinks. I do this in post install for maximum compatibility as the resultant rpms could also be used on systems where libudev and libcrypto naming matches what Opera expects.

To fetch all the .spec files:

git clone https://gist.github.com/f0183807a9f708067475.git

Place the version of Opera you wish to repackage in your sources directory (usually ~/rpmbuild/SOURCES). Tweak the Version field in the .spec file(s).

To repackage Opera stable:

rpmbuild -bb opera-stable.spec

To repackage Opera beta:

rpmbuild -bb opera-beta.spec

To repackage Opera developer:

rpmbuild -bb opera-developer.spec

Note: I have only done limited testing on the most recent versions of Fedora, OpenSUSE, PCLinuxOS and Mageia.

%define appname %{name}
%define debug_package %{nil}
Summary: Fast and secure web browser
Name: opera-beta
Version: 29.0.1795.21
Release: 0
Group: Applications/Internet
License: Proprietary
URL: http://www.opera.com/browser
Source0: http://get.geo.opera.com/pub/%{name}/%{version}/linux/%{name}_%{version}_amd64.deb
Source1: opera-rpmlintrc
Vendor: Opera Software ASA
Packager: ruario
%description
Opera is a fast, secure and user-friendly web browser. It
includes web developer tools, news aggregation, and the ability
to compress data via Opera Turbo on congested networks.
%prep
%setup -T -c
%build
%install
# Not needed on Fedora but it is on some other distros
mkdir -p "%{buildroot}"
# Unpack the deb, correcting the lib directory and removing debian directories
ar p %{SOURCE0} data.tar.xz | tar -xJf- -C %{buildroot} \
--transform="s,/usr/lib/.*-linux-gnu,%{_libdir}," \
--exclude="./usr/share/lintian" \
--exclude="./usr/share/menu"
# Fix the location of the doc directory on OpenSUSE
%if 0%{?suse_version}
mkdir -p "%{buildroot}/%{_defaultdocdir}"
mv "%{buildroot}/usr/share/doc/%{name}" "%{buildroot}/%{_defaultdocdir}/%{name}" 2>/dev/null ||:
%endif
# Set the correct permissions on the sandbox
chmod 4755 %{buildroot}%{_libdir}/%{appname}/opera_sandbox
# Correct the symlink due to changed lib directory
ln -fs %{_libdir}/%{appname}/%{appname} %{buildroot}%{_bindir}/%{appname}
%post
# Setup icons
touch -c /usr/share/icons/hicolor
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -tq /usr/share/icons/hicolor 2>/dev/null ||:
fi
# Setup desktop file
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database -q /usr/share/applications 2>/dev/null ||:
fi
%postun
# Remove compatibility symlinks
if [ -e "%{_libdir}/%{appname}/lib/libudev.so.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libudev.so.0
fi
if [ -e "%{_libdir}/%{appname}/lib/libcrypto.so.1.0.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libcrypto.so.1.0.0
fi
# Remove directories left behind due to compatibility symlinks
if [ -d "%{_libdir}/%{appname}/lib" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}/lib
fi
if [ -d "%{_libdir}/%{appname}" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}
fi
%clean
rm -rf %{buildroot}
%files
%{_defaultdocdir}/%{name}
%{_bindir}/%{appname}
%{_libdir}/%{appname}
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%define appname %{name}
%define debug_package %{nil}
Summary: Fast and secure web browser
Name: opera-developer
Version: 29.0.1795.14
Release: 0
Group: Applications/Internet
License: Proprietary
URL: http://www.opera.com/browser
Source0: http://get.geo.opera.com/pub/%{name}/%{version}/linux/%{name}_%{version}_amd64.deb
Source1: opera-rpmlintrc
Vendor: Opera Software ASA
Packager: ruario
%description
Opera is a fast, secure and user-friendly web browser. It
includes web developer tools, news aggregation, and the ability
to compress data via Opera Turbo on congested networks.
%prep
%setup -T -c
%build
%install
# Not needed on Fedora but it is on some other distros
mkdir -p "%{buildroot}"
# Unpack the deb, correcting the lib directory and removing debian directories
ar p %{SOURCE0} data.tar.xz | tar -xJf- -C %{buildroot} \
--transform="s,/usr/lib/.*-linux-gnu,%{_libdir}," \
--exclude="./usr/share/lintian" \
--exclude="./usr/share/menu"
# Fix the location of the doc directory on OpenSUSE
%if 0%{?suse_version}
mkdir -p "%{buildroot}/%{_defaultdocdir}"
mv "%{buildroot}/usr/share/doc/%{name}" "%{buildroot}/%{_defaultdocdir}/%{name}" 2>/dev/null ||:
%endif
# Set the correct permissions on the sandbox
chmod 4755 %{buildroot}%{_libdir}/%{appname}/opera_sandbox
# Correct the symlink due to changed lib directory
ln -fs %{_libdir}/%{appname}/%{appname} %{buildroot}%{_bindir}/%{appname}
%post
# Setup icons
touch -c /usr/share/icons/hicolor
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -tq /usr/share/icons/hicolor 2>/dev/null ||:
fi
# Setup desktop file
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database -q /usr/share/applications 2>/dev/null ||:
fi
%postun
# Remove compatibility symlinks
if [ -e "%{_libdir}/%{appname}/lib/libudev.so.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libudev.so.0
fi
if [ -e "%{_libdir}/%{appname}/lib/libcrypto.so.1.0.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libcrypto.so.1.0.0
fi
# Remove directories left behind due to compatibility symlinks
if [ -d "%{_libdir}/%{appname}/lib" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}/lib
fi
if [ -d "%{_libdir}/%{appname}" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}
fi
%clean
rm -rf %{buildroot}
%files
%{_defaultdocdir}/%{name}
%{_bindir}/%{appname}
%{_libdir}/%{appname}
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%define appname opera
%define debug_package %{nil}
Summary: Fast and secure web browser
Name: opera-stable
Version: 28.0.1750.48
Release: 0
Group: Applications/Internet
License: Proprietary
URL: http://www.opera.com/browser
Source0: http://get.geo.opera.com/pub/%{appname}/desktop/%{version}/linux/%{name}_%{version}_amd64.deb
Source1: opera-rpmlintrc
Vendor: Opera Software ASA
Packager: ruario
%description
Opera is a fast, secure and user-friendly web browser. It
includes web developer tools, news aggregation, and the ability
to compress data via Opera Turbo on congested networks.
%prep
%setup -T -c
%build
%install
# Not needed on Fedora but it is on some other distros
mkdir -p "%{buildroot}"
# Unpack the deb, correcting the lib directory and removing debian directories
ar p %{SOURCE0} data.tar.xz | tar -xJf- -C %{buildroot} \
--transform="s,/usr/lib/.*-linux-gnu,%{_libdir}," \
--exclude="./usr/share/lintian" \
--exclude="./usr/share/menu"
# Fix the location of the doc directory on OpenSUSE
%if 0%{?suse_version}
mkdir -p "%{buildroot}/%{_defaultdocdir}"
mv "%{buildroot}/usr/share/doc/%{name}" "%{buildroot}/%{_defaultdocdir}/%{name}" 2>/dev/null ||:
%endif
# Set the correct permissions on the sandbox
chmod 4755 %{buildroot}%{_libdir}/%{appname}/opera_sandbox
# Correct the symlink due to changed lib directory
ln -fs %{_libdir}/%{appname}/%{appname} %{buildroot}%{_bindir}/%{appname}
%post
# Setup icons
touch -c /usr/share/icons/hicolor
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -tq /usr/share/icons/hicolor 2>/dev/null ||:
fi
# Setup desktop file
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database -q /usr/share/applications 2>/dev/null ||:
fi
%postun
# Remove compatibility symlinks
if [ -e "%{_libdir}/%{appname}/lib/libudev.so.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libudev.so.0
fi
if [ -e "%{_libdir}/%{appname}/lib/libcrypto.so.1.0.0" ]; then
rm -f %{_libdir}/%{appname}/lib/libcrypto.so.1.0.0
fi
# Remove directories left behind due to compatibility symlinks
if [ -d "%{_libdir}/%{appname}/lib" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}/lib
fi
if [ -d "%{_libdir}/%{appname}" ]; then
rmdir --ignore-fail-on-non-empty %{_libdir}/%{appname}
fi
%clean
rm -rf %{buildroot}
%files
%{_defaultdocdir}/%{name}
%{_bindir}/%{appname}
%{_libdir}/%{appname}
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment