Making nethserver-fetchmail rpms

v7-alpha2

(Alessio Fattorini) #1

Continuing the discussion from NethServer v7-alpha2:

I’m following the howto, and after

make-rpms nethserver-fetchmail.spec

I obtain

prep-sources [INFO] source0 git archive: nethserver-fetchmail-1.1.5.tar.gz
INFO: mock.py version 1.2.13 starting (python version = 2.7.5)...
Start: init plugins
INFO: selinux enabled
Finish: init plugins
Start: run
INFO: Start(nethserver-fetchmail.spec)  Config(nethserver-6.7-x86_64)
Start: clean chroot
Finish: clean chroot
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
INFO: enabled yum cache
Start: cleaning yum metadata
Finish: cleaning yum metadata
Mock Version: 1.2.13
INFO: Mock Version: 1.2.13
ERROR: Exception(nethserver-fetchmail.spec) Config(nethserver-6.7-x86_64) 0 minutes 0 seconds
INFO: Results and/or logs in: .
INFO: Cleaning up build root ('cleanup_on_failure=True')
Start: clean chroot
Finish: clean chroot
ERROR: [Errno 21] Is a directory: '/etc/localtime'
Traceback (most recent call last):
  File "/usr/sbin/mock", line 833, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 649, in main
    run_command(options, args, config_opts, commands, buildroot, state)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 732, in run_command
    do_buildsrpm(config_opts, commands, buildroot, options, args)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 511, in do_buildsrpm
    cmd=cmd, post=None, clean=clean)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 439, in rebuild_generic
    commands.init(prebuild=not config_opts.get('short_circuit'))
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/backend.py", line 122, in init
    self.buildroot.initialize(**kwargs)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/buildroot.py", line 85, in initialize
    self._init(prebuild=prebuild, do_log=do_log)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/buildroot.py", line 142, in _init
    self._setup_timezone()
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/buildroot.py", line 221, in _setup_timezone
    self._copy_config('localtime')
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 84, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/buildroot.py", line 197, in _copy_config
    shutil.copy2(orig_conf_file, etcdir)
  File "/usr/lib64/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/lib64/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 21] Is a directory: '/etc/localtime'

Any hint?


(Davide Principi) #2

Did you read the “common issues” section ?

http://wiki.nethserver.org/doku.php?id=developer:nethserver_7_kickstart#common_issues


(Alessio Fattorini) #3

Yes, that’s my spec

 [alessio@localhost nethserver-fetchmail]$ cat nethserver-fetchmail.spec
%define fetchmail_home /var/lib/nethserver/fetchmail

Name:		nethserver-fetchmail
Version: 1.1.5
Release: 1%{?dist}
Summary:	NethServer fetchmail
Group:		Networking/Daemons
License:	GPLv2
Source0:	%{name}-%{version}.tar.gz
URL: 		%{url_prefix}/%{name}
BuildArch: 	noarch

BuildRequires:	nethserver-devtools
Requires:	nethserver-mail-server > 1.8.2-1
Requires:	fetchmail

%description
Fetchmail add-on for NethServer

%prep
%setup

%build
%{makedocs}
perl createlinks

%install
rm -rf %{buildroot}
(cd root ; find . -depth -print | cpio -dump %{buildroot})
%{genfilelist} %{buildroot} > %{name}-%{version}-%{release}-filelist
echo "%doc COPYING" >> %{name}-%{version}-%{release}-filelist

%clean 
rm -rf $RPM_BUILD_ROOT

%pre
if ! getent passwd fetchmail >/dev/null; then
   # Add the "fetchmail" user
   useradd -r -U -s /sbin/nologin -d %{fetchmail_home} -c "Fetchmail user" fetchmail

elif ! [ -d %{fetchmail_home} ]; then
   # Stop any running instance:
   service fetchmail status &>/dev/null && service fetchmail stop
   # Create the primary group, if not exists:
   groupadd -f -g `id -u fetchmail` -r fetchmail
   # Fix the home dir path and move the existing DB to the new path:
   usermod -m -d %{fetchmail_home} -g fetchmail fetchmail
   mkdir -m 0750 %{fetchmail_home}
   mv -n /var/run/fetchmail/.fetchids %{fetchmail_home}/.fetchids &>/dev/null
   chown -Rf fetchmail.fetchmail %{fetchmail_home}
fi

exit 0

%files -f %{name}-%{version}-%{release}-filelist
%defattr(-,root,root)
%dir %{_nseventsdir}/%{name}-update

%changelog
* Tue Sep 29 2015 Davide Principi <davide.principi@nethesis.it> - 1.1.5-1
- Make Italian language pack optional - Enhancement #3265 [NethServer]

(Davide Principi) #4

The problem is not the .spec. It’s a mock issue

When running make-rpms, mock complains of localtime and prints the following line:
IOError: [Errno 21] Is a directory: '/etc/localtime’
To fix this issue, change your sites-default.cfg:


(Alessio Fattorini) #5

I sorted out the mock problem now I have this:

INFO: Done(nethserver-fetchmail.spec) Config(nethserver-6.7-x86_64) 0 minutes 17 seconds
INFO: Results and/or logs in: .
INFO: Cleaning up build root ('cleanup_on_success=True')
Start: clean chroot
Finish: clean chroot
Finish: run
INFO: mock.py version 1.2.13 starting (python version = 2.7.5)...
Start: init plugins
INFO: selinux disabled
Finish: init plugins
Start: run
. Error: [Errno 2] No such file or directory: 'nethserver-fetchmail-1.1.5-1.ns6.src.rpm\r'

Rpm seems existing, is there any problem into the spec?

$ ll nethserver-fetchmail-1.1.5-1.ns6.src.rpm
-rw-rw-r--. 1 alessio mock 28785 Dec 17 17:18 nethserver-fetchmail-1.1.5-1.ns6.src.rpm

(Davide Principi) #6

Tomorrow I’ll try to reproduce it


(Alessio Fattorini) #7

UHHH I have new fresh rpms! :v: :v ::v: :v:

total 336
-rw-rw-r--. 1 alessio alessio  24099 Dec 17 19:01 build.log
-rw-rw-r--. 1 alessio alessio  35147 Dec 17 17:36 COPYING
-rwxrwxr-x. 1 alessio alessio   1966 Dec 17 17:36 createlinks
-rw-rw-r--. 1 alessio mock     33260 Dec 17 19:01 nethserver-fetchmail-1.1.5-1.ns7.noarch.rpm
-rw-rw-r--. 1 alessio mock     28738 Dec 17 19:00 nethserver-fetchmail-1.1.5-1.ns7.src.rpm
-rw-rw-r--. 1 alessio alessio  23121 Dec 17 18:58 nethserver-fetchmail-1.1.5.tar.gz
-rw-rw-r--. 1 alessio alessio   3849 Dec 17 18:18 nethserver-fetchmail.spec
drwxrwxr-x. 5 alessio alessio     36 Dec 17 17:36 root
-rw-rw-r--. 1 alessio alessio 169451 Dec 17 19:01 root.log
-rw-rw-r--. 1 alessio alessio   3213 Dec 17 19:01 state.log

(Alessio Fattorini) #8

I fixed it using this way and not using your parameter

rm /etc/localtime
ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime

(Giacomo Sanchietti) #9

I just noticed the spec file contains a lot of logic inside the %pre section, and this is so ugly! :smile:
Can we get rid of them?


(Davide Principi) #10

That code is horrible! Who’s the author? Uh that’s me :smile:

This is the full (bug) story

http://dev.nethserver.org/issues/2947

…and, yes we can probably remove it. That if branch migrates the fetchmail home directory, we can assume it has been already run for old installations. What do you think?


(Giacomo Sanchietti) #12

I agree! We can always implement it inside the migration code, if needed.


(Davide Principi) #13

Ok what will be our issue tracking policy for old “migration code”? Open a separate issue or work on the same Pull Request?

In other packages I just removed the “migration code” (DB keys, migration fragments) and pushed directly on v7. So think we can analyze the single case here, then add a commit to a Pull Request that will be merged on v7.


NethServer v7-alpha2
(Filippo Carletti) #14

fetchmail is the only package I’d like to drop. :grinning:


#15

nooo please :slight_smile:
why?


(Filippo Carletti) #16

I’m still looking for a volunteer experimenting with getmail.


Try out NethServer 7 alpha2 ISO!
#17

mhhh seems interesting, i think you found a volunteer with not so much time, but… where do we start?
it seems to have a lot of pro… but what are the cons of leaving fetchmail?


#18

just made a pr for el7 fix… no code clean (it’s better if someone else do it :wink: )
but i’ve one of my newbie question… i’ve left the sysv init script, and in this case it seems to work. But in general, when migrating a package to ns7 it’s better to rewrite the init for systemd or it’s acceptable leave the init script to systemd-sysv-generator ?


(Filippo Carletti) #19

I still do not have a clear opinion.
If the SysV init works, I’d leave it as is.
But writing a systemd unit file is not hard.

Regarding fetchmail, I’d like to drop it completely if getmail proves to be a better alternative.