How to create a spec file for Atom that is suitable for the OBS?

Hi,

I would like to know how I might write a spec file for Atom that is suitable for the OBS. This may seem like a duplicate of this question, but that question was me looking for any solution that gave me an RPM package locally that I could install. This question is me asking whether and how I can setup an OBS repository that can build Atom, despite the fact that the OBS does not give spec files access to the Internet during the build. See I suspect it might be possible if I provide all the node modules, apm modules and the electron package source code, required for the build of Atom. I have done a Google Search and found a few similar questions to this one, including this issue at Atom’s GitHub repository, but the answers have all been written for people that have an excellent knowledge of both spec files and npm, which I do not have. If it helps here is the spec file I have successfully used to build the latest stable release of Atom (1.5.2), with an Internet connection:


Name:           atom
Version:        1.5.2
Release:        0
Summary:        A hackable text editor for the 21st century
License:        MIT
Group:          Productivity/Publishing/Other
Url:            https://atom.io/
Source0:        v%{version}.tar.gz
Source1:        atom.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}/%{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
install -Dm 0644 %{S:1} %{buildroot}%{_datadir}/applications/atom.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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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 for your time,
Brenton

Hi
The problem is you need to download all the sources it uses to build the various modules etc as there is no internet access (during build time) and modify/patch the build script/process to use those local sources…

Now you could create them as _service files, run these first, then build.

You may find this link useful for a start: https://en.opensuse.org/openSUSE:Packaging_nodejs

On Fri 12 Feb 2016 05:26:02 AM CST, fusion809 wrote:

Hi,

I would like to know how I might write a spec file for Atom that is
suitable for the OBS. This may seem like a duplicate of ‘this question’
(Atom spec file is not building an RPM or SRPM; why? - Open Build Service (OBS) - openSUSE Forums), but that question was me looking for any
solution that gave me an RPM package locally that I could install. This
question is me asking whether and how I can setup an OBS repository that
can build Atom, despite the fact that the OBS does not give spec files
access to the Internet during the build. See I suspect it might be
possible if I provide all the node modules, apm modules and the electron
package source code, required for the build of Atom. I have done a
Google Search and found a few similar questions to this one, including
‘this issue’ (Install atom without internet connection · Issue #3269 · atom/atom · GitHub) at Atom’s GitHub
repository, but the answers have all been written for people that have
an excellent knowledge of both spec files and npm, which I do not have.
If it helps here is the spec file I have successfully used to build the
latest stable release of Atom (1.5.2), with an Internet connection:

Code:

Name: atom
Version: 1.5.2
Release: 0
Summary: A hackable text editor for the 21st century
License: MIT
Group: Productivity/Publishing/Other
Url: https://atom.io/
Source0: v%{version}.tar.gz
Source1: atom.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}/%{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
install -Dm 0644 %{S:1}
%{buildroot}%{_datadir}/applications/atom.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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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 for your time,
Brenton

Hi
I also note on the Packaging ML

there has been work on nodejs packages, so a lot you may need for atom
have already been built, you just need to work on the package.json file
and if not on OBS, then create/submit…?


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 SP1|GNOME 3.10.4|3.12.51-60.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Must admit I have found the discussion so far in this thread confusing as I’m not a Node.js/npm expert, the openSUSE Wiki link wasn’t particularly helpful either as I have little Node.js knowledge. What I tried as a workaround though was I compressed the /home/makerpm/BUILD/atom-1.5.3 directory I got from building Atom with the atom.spec file I’m using to build it locally to atom-1.5.3.tar.gz (as it contains all the needed downloaded files) and used it instead of v%{version}.tar.gz as Source0. The problem is that this failed giving this error:


No live log available: connect: Connection refused

Here is my spec file:


Name:           atom
Version:        1.5.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
Source1:        atom.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}/%{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

%install
cd $RPM_BUILD_DIR/atom-%{version}
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/atom.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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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


After some debuging I managed to (almost) fix it, i.e., fix it, such that no errors are returned when I build it locally with

osc build openSUSE_Tumbleweed

. Here is my current spec file:


Name:           atom
Version:        1.5.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
Source1:        %{name}-build-%{version}.tar.gz
Source2:        atom.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}/%{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
tar -xzf %{S:1} -C $RPM_BUILD_DIR

%install
cd $RPM_BUILD_DIR/atom-%{version}
script/grunt install --install-dir "%{buildroot}%{_prefix}" --build-dir $RPM_BUILD_DIR/atom-build
# 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 $RPM_BUILD_DIR/atom-build/icons/${i}.png \
      %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
install -Dm 0644 %{S:2} %{buildroot}%{_datadir}/applications/atom.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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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


now it is returning this error message:


  408s] ... checking filelist
  408s] atom-1.5.3-5.1.i586.rpm: directories not owned by a package:
  408s]  - /usr/share/icons/hicolor/1024x1024
  408s]  - /usr/share/icons/hicolor/1024x1024/apps
  408s] 
  408s] cloud113 failed "build atom.spec" at Tue Feb 16 12:56:56 UTC 2016.
  408s] 
  408s] ### WATCHDOG MARKER START ###
  411s]   375.261551] sysrq: SysRq : Power Off
  411s]   375.379608] reboot: Power down
  415s] ### WATCHDOG MARKER END ###
  415s] 
  415s] cloud113 failed "build atom.spec" at Tue Feb 16 12:57:04 UTC 2016.

which I suspect will be an easier issue for someone here to help me with than what I was previously asking.

All files/directories that exist in build root must be owned by some package. You need to either find package that owns them and add it to BuildRequires or add directories (as %dir) to file list. In principle, directory can belong to multiple packages and this is not an error as long as attributes are the same everywhere. But the former is probably more clean.

OK, well, this spec file’s %install and %files sections are basically identical to the atom.spec file I use to build Atom locally, which is running without these errors. The /usr/share/icons/hicolor/1024x1024/ and /usr/share/icons/hicolor/1024x1024/apps directories both belong to the hicolor-icon-theme package, which is listed in BuildRequires. So suffice it to say I am confused… Is there any way you can think of, whereby I find out which directories belong to which packages? Building for openSUSE 42.1 also lists the /usr/share/licenses directory as belonging to another package. The name of said package is something that escapes me too…

On Tue 16 Feb 2016 01:26:01 PM CST, arvidjaar wrote:

All files/directories that exist in build root must be owned by some
package. You need to either find package that owns them and add it to
BuildRequires or add directories (as %dir) to file list. In principle,
directory can belong to multiple packages and this is not an error as
long as attributes are the same everywhere. But the former is probably
more clean.

Hi
There is that, but I would be tempted to drop a 1024x1024 icon… or
is this the start of having 4K screens etc?

Might be worth a bug report to include in hicolor-icons-theme
package…


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 SP1|GNOME 3.10.4|3.12.51-60.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

openSUSE Tumbleweed i586’s build is giving me this build log (after I removed the 1024px hicolor icon that was causing the previous errors)

x86_64 Tumbleweed just failed and gave the same error as i586. Any ideas?

Hi
Add fdupes to build required and then at the last point in the %install add;


%fdupes -s %{buildroot}

Looks like you need to clean up all the git cruft, clean up the python building too;
https://en.opensuse.org/openSUSE:Packaging_Python#Byte_Compiled_Files

Why no %build section?

See how that goes…

Oh also run the local command osc vc to create a changelog as well as add a %changelog section in the spec file.

No build section as it only contained script/build, which is what was downloading the node modules and had already been run in order to create the atom-1.5.3.tar.gz source included. So you think I should add %fdupes -s %{buildroot} to the %install section, what about the %build section what do you think I should add there? The same thing?

Hi
Only run fdupes at install time, just add a %build and add a #note, just a placeholder.

Ah that’s what I thought you may have meant, so I pushed the changes to the OBS and now it is returning this error http://paste2.org/n48C8xft. Here is the spec file, in case you wish to double-check it:


Name:           atom
Version:        1.5.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
Source1:        %{name}-build-%{version}.tar.gz
Source2:        atom.desktop
BuildRequires:  git-core
BuildRequires:  hicolor-icon-theme
BuildRequires:  npm
BuildRequires:  nodejs-packaging
BuildRequires:  libgnome-keyring-devel
BuildRequires:  python-setuptools
BuildRequires:  update-desktop-files
BuildRequires:  fdupes
# 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
tar -xzf %{S:1} -C $RPM_BUILD_DIR


%build


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


%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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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

On Tue 16 Feb 2016 03:16:01 PM CST, fusion809 wrote:

Ah that’s what I thought you may have meant, so I pushed the changes to
the OBS and now it is returning this error Paste2.org - Viewing Paste n48C8xft.
Here is the spec file, in case you wish to double-check it:

Code:

Name: atom
Version: 1.5.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
Source1: %{name}-build-%{version}.tar.gz
Source2: atom.desktop
BuildRequires: git-core
BuildRequires: hicolor-icon-theme
BuildRequires: npm
BuildRequires: nodejs-packaging
BuildRequires: libgnome-keyring-devel
BuildRequires: python-setuptools
BuildRequires: update-desktop-files
BuildRequires: fdupes

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
tar -xzf %{S:1} -C $RPM_BUILD_DIR

%build

%install
cd $RPM_BUILD_DIR/atom-%{version}
script/grunt install --install-dir “%{buildroot}%{_prefix}”
–build-dir $RPM_BUILD_DIR/atom-build # copy over icons in sizes that
most desktop environments like for i in 512 256 128 64 48 32 24 16; do
mkdir -p %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/
install -Dm 0644 $RPM_BUILD_DIR/atom-build/icons/${i}.png
%{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
install -Dm 0644 %{S:2}
%{buildroot}%{_datadir}/applications/atom.desktop
%suse_update_desktop_file %{name} %fdupes -s %{buildroot}

%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}/atom
%{_bindir}/apm
%dir %{_datadir}/atom
%{_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


Hi
It would seem that a lot of your files need for building atom are being
installed as well, you probably need to re-think you building.

Plus by the look you are installing pre-built binaries, that is not
allowed (technically) on OBS, not the open source way and you may get
pinged by the admins or other users… :wink:

Why not build all the package requirements as individual (yes there is
a lot) nodejs packages, then would be added as build requires.

Some may already exist in the nodejs devel project and you can always
push them so everyone can use. Send a forum PM to user MargueriteSu who
is currently involved in the nodejs packaging for pointers/assistance.


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 SP1|GNOME 3.10.4|3.12.51-60.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

I must admit I’m beginning to see how much more difficult package development is on openSUSE as opposed to the platforms I am used to, like Arch Linux and Sabayon. With Arch and Sabayon there’s no issue with using binary packages for package builds, plus there’s none of the issues associated with the OBS like its lack of Internet access. I suppose at least I can still maintain a GitHub repository containing the spec files for building Atom and other problem packages.

Hi
That’s why it’s called 'open’SUSE :wink: Now there are exceptions, hence the non-oss repository for things like this, but since nodejs packages can be built, then to the benefit of all, it’s good form to build from sources…

Now there is nothing stopping you creating your own Build Service instance (it’s available on iso or as a vm) and publishing as you see fit either, lots of folks do this as well as for in-house building there own packages…

Like I indicated, send a PM to Marguerite, I’m sure she would be happy to help point you in the right direction since she was suffering from the same issues…