How to build a beta package for Atom that can be installed simultaneously to the stable package?

Hi,

I would like to create a spec file for Atom’s beta releases (it does not need to be OBS-compatible, just want to be able to build this package locally), that builds a package that does not conflict with the package built by my atom.spec file (for stable releases). The official beta package of Atom can be installed simultaneously on the same machine as the official stable package is installed so I know it can be done. Presently I have this atom-beta.spec file (it is meant to be building the Atom 1.6.0-beta3 package, in case this is unclear):


Name:           atom-beta
Version:        1.6.0
Release:        3
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        v%{version}-beta%{release}.tar.gz
Source1:        atom-beta.desktop
BuildRequires:  git-core
BuildRequires:  hicolor-icon-theme
BuildRequires:  npm
BuildRequires:  nodejs-packaging
BuildRequires:  libgnome-keyring-devel
BuildRequires:  python-setuptools
BuildRequires:  update-desktop-files
# MANUAL BEGIN
Requires:       nodejs
Requires:       python-http-parser
# MANUAL END
BuildRoot:      %{_tmppath}/atom-%{version}-beta%{release}-build


%description
Atom is a text editor that's modern, approachable, yet hackable to the core
- a tool you can customize to do anything but also use productively without
ever touching a config file.


This is the beta release of Atom.


%prep
%setup -q


%build
# Hardened package
export CFLAGS="%{optflags} -fPIC -pie"
export CXXFLAGS="%{optflags} -fPIC -pie"
until ./script/build 2>&1; do :; done


%install
script/grunt install --install-dir "%{buildroot}%{_prefix}"
# copy over icons in sizes that most desktop environments like
for i in 1024 512 256 128 64 48 32 24 16; do
    install -Dm 0644 /tmp/atom-build/icons/${i}.png \
      %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
install -Dm 0644 %{S:1} %{buildroot}%{_datadir}/applications/%{name}.desktop
%suse_update_desktop_file %{name}


%post
%desktop_database_post
%icon_theme_cache_post


%postun
%desktop_database_postun
%icon_theme_cache_postun


%files
%defattr(-,root,root,-)
%doc CONTRIBUTING.md README.md docs/
%{license} LICENSE.md
%{_bindir}/%{name}
%{_bindir}/apm-beta
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%exclude %{_datadir}/%{name}/libgcrypt.so.*
%exclude %{_datadir}/%{name}/libnotify.so.*


%changelog

unfortunately every time I attempt to build it with

rpmbuild -ba atom-beta.spec

it returns the error:


Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.nBVwV4
+ umask 022
+ cd /home/makerpm/rpmbuild/BUILD
+ cd /home/makerpm/rpmbuild/BUILD
+ rm -rf atom-beta-1.6.0
+ /usr/bin/gzip -dc /home/makerpm/rpmbuild/SOURCES/v1.6.0-beta3.tar.gz
+ /bin/tar -xf -
+ STATUS=0
+ '' 0 -ne 0 ']'
+ cd atom-beta-1.6.0
/var/tmp/rpm-tmp.nBVwV4: line 34: cd: atom-beta-1.6.0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.nBVwV4 (%prep)




RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.nBVwV4 (%prep)

Thanks for your time,
Brenton

%setup -q -n whatever-top-level-directory-your-archive-has

I made that adjustment and now I am getting this error message:


+ /usr/lib/rpm/check-buildroot
/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64/usr/share/applications/atom.desktop:Exec=/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64/usr/share/atom/atom %U
/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64/usr/share/applications/atom.desktop:Icon=/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64/usr/share/atom/resources/app.asar.unpacked/resources/atom.png
Found '/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64' in installed files; aborting
error: Bad exit status from /var/tmp/rpm-tmp.6yEPBK (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.6yEPBK (%install)

This is my atom-beta.spec file:


Name:           atom-beta
Version:        1.6.0
Release:        3
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        v%{version}-beta%{release}.tar.gz
Source1:        atom-beta.desktop
BuildRequires:  git-core
BuildRequires:  hicolor-icon-theme
BuildRequires:  npm
BuildRequires:  nodejs-packaging
BuildRequires:  libgnome-keyring-devel
BuildRequires:  python-setuptools
BuildRequires:  update-desktop-files
# MANUAL BEGIN
Requires:       nodejs
Requires:       python-http-parser
# MANUAL END
BuildRoot:      %{_tmppath}/atom-%{version}-beta%{release}-build

%description
Atom is a text editor that's modern, approachable, yet hackable to the core
- a tool you can customize to do anything but also use productively without
ever touching a config file.

This is the beta release of Atom.

%prep
%setup -q -n atom-%{version}-beta%{release}

%build
# Hardened package
cd $RPM_BUILD_DIR/atom-%{version}-beta%{release}
export CFLAGS="%{optflags} -fPIC -pie"
export CXXFLAGS="%{optflags} -fPIC -pie"
until ./script/build 2>&1; do :; done

%install
cd $RPM_BUILD_DIR/atom-%{version}-beta%{release}
script/grunt install --install-dir "%{buildroot}%{_prefix}"
# copy over icons in sizes that most desktop environments like
for i in 1024 512 256 128 64 48 32 24 16; do
    install -Dm 0644 /tmp/atom-build/icons/${i}.png \
      %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
install -Dm 0644 %{S:1} %{buildroot}%{_datadir}/applications/%{name}.desktop
%suse_update_desktop_file %{name}

%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root,-)
%doc CONTRIBUTING.md README.md docs/
%{license} LICENSE.md
%{_bindir}/%{name}
%{_bindir}/apm-beta
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%exclude %{_datadir}/%{name}/libgcrypt.so.*
%exclude %{_datadir}/%{name}/libnotify.so.*

%changelog


You need to fix Makefile to strip %{buildroot} from all files or do it manually in %install section. You obviously won’t have
/home/makerpm/rpmbuild/BUILDROOT/atom-beta-1.6.0-3.x86_64/usr/share/atom/atom on target system, it must be /usr/share/atom/atom

OK, just wondering how I would do that. Atom doesn’t have a makefile per se, rather as it builds using Node.js/npm. I tried to fix this error by ditching Source1 (the atom-beta.desktop file) and rather using sed to modify the resources/linux/atom.desktop.in file in it, to fit the format I want for atom-beta.desktop. Here is the error I’m getting:


ERROR: suse_update_desktop_file: unable to find atom-beta.desktop

Usage: suse_update_desktop_file.sh [OPTIONS] <APPLICATION> [CATEGORIES]

 Summary:
       Used to add easily a category to .desktop files according to XDG
       standard. More information is available on
       http://en.opensuse.org/SUSE_Package_Conventions/RPM_Macros
       If you have any questions, please use our mailinglist: 
       opensuse-packaging@opensuse.org
 Options:
       <APPLICATION>             : The name of the desktop file.
                                   Example: use "qbrew" to edit qbrew.desktop
                                   If APPLICATION has multiple desktop files, try the exact path
                                   to the desktop file.
                                   Example: use "%suse_update_desktop_file \
                                   %{buildroot}%{_datadir}/susehelp/meta/%name/%name.desktop"
                                   to edit the susehelp desktop entry file instead.
       -u|--unimportant          : add "NoDisplay=true" to the resulting desktop
                                   file.
       -n|--no-i18n              : Do not prepare the desktop file for translators (obsoletes -t).
                                   (adds X-SuSE-translate=false to the desktop file)
       -i|--install              : Install an existing desktop file in /usr/share/applications/
                                   The to be installed desktop file can be located in:
                                   - RPM_SOURCE_DIR or
                                   - RPM_BUILD_DIR
                                   A referenced icon file (ending *.png; *.xpm) is installed in
                                   /usr/share/pixmaps/ automatically if it is located in one of the 
                                   directories mentioned above (-maxdepth 1).
       -r|--reset                : Reset the "Categories" line in an existing desktop file.
                                   Normally, categories mentioned in an existing desktop file will be
                                   obtained. Additional categories from commandline are added.
       -d|--docid <string>       : Add "X-SuSE-DocTeamID=<string>" to the desktop file.
       -D|--docpath <path>       : Add "DocPath=<path>" to the desktop file - do not guess it
                                   automatically.
       -c|--create <name>        : Create a new desktop file in /usr/share/applications/<name>.desktop .
       -C|--comment <string>     : Use <string> as "Comment=<string>" in desktop file.
       -N|--name <string>        : Use <string> as "Name=<string>" in desktop file.
       -G|--genericname <string> : Use <string> as "GenericName=<string>" in desktop file.

+ exit 1
error: Bad exit status from /var/tmp/rpm-tmp.z6qE3S (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.z6qE3S (%install)


while here is my atom-beta.spec file:


Name:           atom-beta
Version:        1.6.0
Release:        3
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        v%{version}-beta%{release}.tar.gz
Source1:        atom-beta.desktop
BuildRequires:  git-core
BuildRequires:  hicolor-icon-theme
BuildRequires:  npm
BuildRequires:  nodejs-packaging
BuildRequires:  libgnome-keyring-devel
BuildRequires:  python-setuptools
BuildRequires:  update-desktop-files
# MANUAL BEGIN
Requires:       nodejs
Requires:       python-http-parser
# MANUAL END
BuildRoot:      %{_tmppath}/atom-%{version}-beta%{release}-build

%description
Atom is a text editor that's modern, approachable, yet hackable to the core
- a tool you can customize to do anything but also use productively without
ever touching a config file.

This is the beta release of Atom.

%prep
%setup -q -n atom-%{version}-beta%{release}
sed -e "s/<%= description %>/$pkgdesc/" \
      -e "s|<%= appName %>|Atom Beta|"\
      -e "s|<%= installDir %>/share/<%= appFileName %>|/usr/bin|"\
      -e "s|<%= iconPath %>|atom-beta|"\
      -e "s|GNOME;||" \
      -e "s|Development;||" \
      -e "s|text/plain;|application/javascript;application/json;application/postscript;application/x-csh;application/x-desktop;application/x-httpd-eruby;application/x-httpd-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/x-latex;application/x-msdos-program;application/x-ruby;application/x-sh;application/x-shellscript;application/x-sql;application/x-tcl;application/x-tex;application/xhtml+xml;application/xml;application/xml-dtd;application/xslt+xml;text/css;text/csv;text/html;text/plain;text/xml;text/xml-dtd;text/x-asm;text/x-bibtex;text/x-boo;text/x-c++;text/x-c++hdr;text/x-c++src;text/x-c;text/x-chdr;text/x-csh;text/x-csrc;text/x-dsrc;text/x-diff;text/x-eiffel;text/x-fortran;text/x-go;text/x-haskell;text/x-java;text/x-java-source;text/x-lua;text/x-makefile;text/x-markdown;text/x-objc;text/x-pascal;text/x-perl;text/x-php;text/x-python;text/x-ruby;text/x-scala;text/x-scheme;text/x-sh;text/x-tcl;text/x-tex;text/x-vala;text/yaml;|" \
      resources/linux/atom.desktop.in > resources/linux/%{name}.desktop

%build
# Hardened package
cd $RPM_BUILD_DIR/atom-%{version}-beta%{release}
export CFLAGS="%{optflags} -fPIC -pie"
export CXXFLAGS="%{optflags} -fPIC -pie"
until ./script/build 2>&1; do :; done

%install
cd $RPM_BUILD_DIR/atom-%{version}-beta%{release}
script/grunt install --install-dir "%{buildroot}%{_prefix}"
# copy over icons in sizes that most desktop environments like
for i in 1024 512 256 128 64 48 32 24 16; do
    install -Dm 0644 /tmp/atom-build/icons/${i}.png \
      %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
%suse_update_desktop_file %{name}.desktop

%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root,-)
%doc CONTRIBUTING.md README.md docs/
%{license} LICENSE.md
%{_bindir}/%{name}
%{_bindir}/apm-beta
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%exclude %{_datadir}/%{name}/libgcrypt.so.*
%exclude %{_datadir}/%{name}/libnotify.so.*

%changelog


Your usage of %suse_update_desktop_file is not documented. Seeing that it complains, it is most likely wrong. See https://en.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros#.25suse_update_desktop_file for description.