Atom spec file is not building an RPM or SRPM; why?

Hi,

I have borrowed an Atom spec file from Fedora’s COPR and tried to modify it to better fit openSUSE, here it is:


# https://copr.fedoraproject.org/coprs/helber/atom
%{?nodejs_find_provides_and_requires}
%global debug_package %{nil}
%global _hardened_build 1
%global __requires_exclude (libnode)
%global npm_ver 2.7.6
%global project atom
%global repo %{project}


# commit
%global _commit 164201e7bba5681594ac80ef1430c3afd9b58911
%global _shortcommit %(c=%{_commit}; echo ${c:0:7})


Name:    atom
Version: 1.4.3
Release: 1
Summary: A hackable text editor for the 21st century


Group:   Applications/Editors
License: MIT
URL:     https://atom.io/
Source0: https://github.com/atom/atom/archive/v%{version}.tar.gz


BuildRequires: npm
BuildRequires: nodejs-packaging
BuildRequires: libgnome-keyring-devel
BuildRequires: python-setuptools
BuildRequires: git-core
Requires:      nodejs
Requires:      http-parser


%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.


Visit https://atom.io to learn more.


%prep
%setup -q


%build
# Hardened package
export CFLAGS="%{optflags} -fPIC -pie"
export CXXFLAGS="%{optflags} -fPIC -pie"
## Upgrade npm
# Install new npm to INSTALL_PREFIX for build package
npm config set registry="http://registry.npmjs.org/"
npm config set ca ""
npm config set strict-ssl false
npm install -g --ca=null --prefix %{buildroot}%{_prefix} npm@%{npm_ver}
# Export PATH to new npm version
export PATH="%{buildroot}%{_bindir}:$PATH"
until ./script/build 2>&1; do :; done


%install
script/grunt install --install-dir "%{buildroot}%{_prefix}"
%{__sed} -i -e 's|=.*atom|=atom|g' -e 's|atom.png|atom|g' \
    %{buildroot}%{_datadir}/applications/atom.desktop


# copy over icons in sizes that most desktop environments like
for i in 1024 512 256 128 64 48 32 24 16; do
    install -D -m 0644 /tmp/atom-build/icons/${i}.png \
      %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done


%post
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null ||:
/usr/bin/update-desktop-database -q ||:


%postun
if  $1 -eq 0 ]; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null ||:
    /usr/bin/gtk-update-icon-cache -f -t -q %{_datadir}/icons/hicolor ||:
fi
/usr/bin/update-desktop-database -q ||:


%posttrans
/usr/bin/gtk-update-icon-cache -f -t -q %{_datadir}/icons/hicolor ||:


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

I followed the RPM build instructions at the Fedora Wiki as I was told to by the openSUSE Wiki. Then I ran:

rpmbuild -ba atom.spec

from /home/makerpm/rpmbuild/SPECS as the makerpm user (I logged in as makerpm by running su - makerpm). To my surprise, while I saw no error messages (the output so great in size that it could not fit in the 1,000 lines kept in memory by Konsole) no RPM or SRPM packages were built in /home/makerpm/rpmbuild/RPMS or /home/makerpm/rpmbuild/SRPMS, respectively. So I am here to ask why. I am new to openSUSE (sort of, I’ve been running it in VirtualBox VMs for several months now, but never run it on my physical machine until yesterday when I installed it on my hard drive, replacing Arch Linux, which I had only installed about a fortnight earlier, as I had experienced issues with it I failed to resolve), and I am hoping that this distro will be a keeper.

Thanks for your time,
Brenton

Hi
There should be a build log somewhere (not sure why you have a specific user to build rpms, build as user, install as root) or increase the amount of lines kept, I would have to guess it’s an error somewhere.

Else look at using OBS for building…

That Fedora Wiki’s guide to building RPMs is what told me to build as the makerpm user, http://fedoraproject.org/wiki/How_to_create_an_RPM_package, and it is referred to by the article I linked earlier at the openSUSE Wiki. Not sure why it is being linked to by the openSUSE Wiki, if there are superior methods to build RPM packages on openSUSE. Can’t find a build log, I ran:

find . -name "*.log"

from /home/makerpm/rpmbuild and it returned:

./BUILD/atom-1.4.3/build/node_modules/grunt/node_modules/grunt-legacy-log/node_modules/underscore.string/libpeerconnection.log
./BUILD/atom-1.4.3/build/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log
./BUILD/atom-1.4.3/node_modules/roaster/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log

not sure which log I should look at, that’s if any of these logs is the build log you mean I should look at. Guessing https://en.opensuse.org/openSUSE:Build_Service_Tutorial is what I should follow in order to try using the OBS method?

Oh and if https://en.opensuse.org/openSUSE:Build_Service_Tutorial is the guide I should follow then, well I need some help. I have an ~/.oscrc file:


su-wrapper = sudo

I also have the lines:


fusion809    ALL = NOPASSWD: /usr/bin/build
fusion809    ALL = NOPASSWD: /usr/bin/osc

in my /etc/sudoers file, yet running:


cd ~/OBS
osc checkout home:fusion809

returns:


Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in <module>
    r = babysitter.run(osccli)
  File "/usr/lib/python2.7/site-packages/osc/babysitter.py", line 61, in run
    return prg.main(argv)
  File "/usr/lib/python2.7/site-packages/osc/cmdln.py", line 335, in main
    self.postoptparse()
  File "/usr/lib/python2.7/site-packages/osc/commandline.py", line 136, in postoptparse
    override_verbose = self.options.verbose)
  File "/usr/lib/python2.7/site-packages/osc/conf.py", line 796, in get_config
    cp = get_configParser(conffile)
  File "/usr/lib/python2.7/site-packages/osc/conf.py", line 612, in get_configParser
    get_configParser.cp.read(conffile)
  File "/usr/lib64/python2.7/ConfigParser.py", line 305, in read
    self._read(fp, filename)
  File "/usr/lib/python2.7/site-packages/osc/OscConfigParser.py", line 281, in _read
    raise configparser.MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: /home/fusion809/.oscrc, line: 1
'su-wrapper = sudo
'

Nvm, I merely needed to delete ~/.oscrc (the line that the openSUSE Wiki article told me to add is what was generating this error, so I edit the openSUSE Wiki accordingly) and re-run

osc checkout home:fusion809

.

Now I am getting the error:


Error: "/home/fusion809/OBS/home:fusion809" is not an osc package working copy.

from running:

osc up home:fusion809

, after running

osc meta pkg -e home:fusion809 atom

, filling in the title, description and name of the package. If it is relevant here is the .xml file generated by this osc meta command:


<package name="atom" project="home:fusion809">
 <title>atom</title>
 <description>Atom is a free and open-source text editor written in web languages such as CSS, HTML and JS. It is designed to be as customizable as it can be, while still being approachable to new users.</description>
</package>

Hi
Since it needs internet access to grab stuff, you need to build locally, you won’t be able to use OBS…

When building openSUSE rpms, we use a few different tools/macros, try with the following spec file;


Name:           atom
Version:        1.4.3
Release:        0
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        %{name}-%{version}.tar.gz
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}/%{name}-%{version}-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.

%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
%suse_update_desktop_file %{name}

%post
%desktop_database_post

%postun
%desktop_database_postun

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

%changelog


Thanks, you’ve been very helpful. I experienced an error but it seemed to have been caused by errors in copying the spec file across from this forum.

Hi
Try this version then;
http://paste.opensuse.org/view/raw/2e57057f

Thanks again, I managed to copy it across, but now errors are being encountered at the %install stage:


+ QA_CHECK_RPATHS=1
+ case "${QA_CHECK_RPATHS:-}" in
+ /usr/lib/rpm/check-rpaths
+ /usr/lib/rpm/check-buildroot
/home/makerpm/rpmbuild/BUILDROOT/atom-1.4.3-0.x86_64/usr/share/applications/atom.desktop:Exec=/home/makerpm/rpmbuild/BUILDROOT/atom-1.4.3-0.x86_64/usr/share/atom/atom %U
/home/makerpm/rpmbuild/BUILDROOT/atom-1.4.3-0.x86_64/usr/share/applications/atom.desktop:Icon=/home/makerpm/rpmbuild/BUILDROOT/atom-1.4.3-0.x86_64/usr/share/atom/resources/app.asar.unpacked/resources/atom.png
Found '/home/makerpm/rpmbuild/BUILDROOT/atom-1.4.3-0.x86_64' in installed files; aborting
error: Bad exit status from /var/tmp/rpm-tmp.kTwfWa (%install)




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

guessing this indicates that some of %{_sed} command will need to be run in the %prep stage on the atom.desktop file to make it suitable for the RPM.

There is tee, there is script. You must capture build log to be able to fix build problems.

no RPM or SRPM packages were built in /home/makerpm/rpmbuild/RPMS or /home/makerpm/rpmbuild/SRPMS, respectively.

What is the value of _topdir (rpm --eval %_topdir)?

rpmbuild does not leave any build logs, all messages go to standard output (may be stderr).

_topdir is /home/makerpm/rpmbuild.

I am now rebuilding this package and capturing the logs, if that helps, the process usually takes half an hour to an hour, so please bare with me.

Hi
Ahh it’s adding the buildroot into the desktop file, so in the %prep section add;


sed -i 's/<%= installDir %>/\/usr/g' resources/linux/atom.desktop.in 
sed -i 's/<%= iconPath %>/atom/g' resources/linux/atom.desktop.in

It failed too, I’m afraid. I captured the output using:


rpmbuild -ba atom.spec > output.txt 2> errors.txt

output.txt is here (http://paste2.org/AdznFUtd) and errors.txt is here (http://paste2.org/W2008MeL). If there’s a better way to capture the output please tell me, I’m only using this method as it is the only one I know that gets all the output.

Hi
Updated spec file to fix the errors, plus your one isn’t building anything;
http://paste.opensuse.org/view/raw/ff8391e8

or use;


wget -O atom.spec http://paste.opensuse.org/view/download/ff8391e8

Ah, there’s an error in this atom.spec file, namely this line (line #29):


sed -i

I say so as building this spec file gives a sed usage message (i.e., the manual entry that indicates how to use sed).

Ahh my bad;
http://paste.opensuse.org/view/raw/c379d90f

or;


wget -O atom.spec http://paste.opensuse.org/view/download/c379d90f

Just built locally on a Leap test machine, all good, just use zypper to install the rpm :wink:

It worked perfectly, thanks a million! Thanks to you, I have found this forum far more newbie-friendly than the Arch forums, so thanks.

Hi
Your welcome :slight_smile: We are a pretty friendly bunch here :wink:

I’m guessing the earlier errors you were having would have been related to the npm building, not sure why they need to build…

Hi malcomlewis, I’m afraid this issue has returned. Here is the spec file I was originally using:


Name:           atom
Version:        1.5.1
Release:        0
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        %{name}-%{version}.tar.gz
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}/%{name}-%{version}-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.


%prep
%setup -q
sed -i -e 's/<%= appName %>/Atom/g' \
      -e "s/<%= description %>/%{description}/g" \
      -e 's/<%= installDir %>/\/usr/g' \
      -e 's|/usr/share/<%= appFileName %>/atom %U|/usr/bin/atom %U|g' \
      -e 's/<%= iconPath %>/atom/g' \
      -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;|g' \
      resources/linux/atom.desktop.in


%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
%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 README.md docs/
%{license} LICENSE.md
%{_bindir}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_datadir}/atom/*
%{_datadir}/applications/atom.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%exclude %{_datadir}/%{name}/libgcrypt.so.*
%exclude %{_datadir}/%{name}/libnotify.so.*


%changelog

it returns this error:


WARNING: '/usr/lib/rpm/brp-desktop.data/suse-screensavers.menu' does not exist
WARNING: '/usr/lib/rpm/brp-desktop.data/applications-kmenuedit.menu' does not exist
WARNING: '/usr/lib/rpm/brp-desktop.data/custom.menu' does not exist
ERROR: No sufficient Category definition: /home/makerpm/rpmbuild/BUILDROOT/atom-1.5.1-0.x86_64//usr/share/applications/atom.desktop 
Errors in installed desktop file detected. Please refer to http://en.opensuse.org/SUSE_Package_Conventions/RPM_Macros
error: Bad exit status from /var/tmp/rpm-tmp.MngPiD (%install)

now removing

%suse_update_desktop_file %{name}

from this spec file doesn’t fix it. The desktop file generated by the sed line is perfectly except the

-e "s/<%= description %>/%{description}/g" \

is not being parsed the way I was hoping it would (i.e., with <%= description %> being replaced with the description provided under %description in the spec file).

Thanks for your time, I really do appreciate it. I have read http://en.opensuse.org/SUSE_Package_Conventions/RPM_Macros but it didn’t help me as my desktop file is fine as it is (the %suse_update_desktop_file macro seems to make modifications to the desktop file), except for this sed issue.