Bug 767593

Summary: Provide native systemd service
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: foghornAssignee: Ryan O'Hara <rohara>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: johannbg, rohara
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foghorn-0.1.5-2.fc17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-27 19:27:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 751869    
Attachments:
Description Flags
Native systemd service file for foghorn
none
foghorn.spec file for version 0.1.5-2 (with scriptlets for SySV to systemd migration) none

Description Jóhann B. Guðmundsson 2011-12-14 13:14:17 UTC
Description of problem:

Let's get the ball rolling on this one...

http://fedoraproject.org/wiki/Features/SysVtoSystemd
https://fedoraproject.org/wiki/Packaging:Guidelines:Systemd
https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Jóhann B. Guðmundsson 2011-12-14 13:15:10 UTC
Created attachment 546721 [details]
Native systemd service file for foghorn

Comment 2 Ryan O'Hara 2012-01-21 00:21:56 UTC
I've added the service file to the upstream git repo and made several changes to the spec file. I believe I have followed the instructions on the web page(s) provided in comment #1, but I'm hitting a problem the the preun scriptlet failing.

[root@rocket-03 ~]# rpm -q foghorn
foghorn-0.1.2-5.fc16.x86_64

[root@rocket-03 ~]# rpm -Uhv foghorn-0.1.5-2.fc16.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:foghorn                ########################################### [100%]
/var/tmp/rpm-tmp.4QXbKA: line 3: syntax error near unexpected token `fi'
/var/tmp/rpm-tmp.4QXbKA: line 3: `fi'
error: %preun(foghorn-0.1.2-5.fc16.x86_64) scriptlet failed, exit status 2
error: foghorn-0.1.2-5.fc16.x86_64: erase failed

[root@rocket-03 ~]# rpm -qa|grep foghorn
foghorn-0.1.5-2.fc16.x86_64
foghorn-0.1.2-5.fc16.x86_64

This does not look good. I attempt to remove both packages:

[root@rocket-03 ~]# rpm -e foghorn-0.1.5-2.fc16.x86_64
[root@rocket-03 ~]# rpm -e foghorn-0.1.2-5.fc16.x86_64
/var/tmp/rpm-tmp.2htt0A: line 3: syntax error near unexpected token `fi'
/var/tmp/rpm-tmp.2htt0A: line 3: `fi'
error: %preun(foghorn-0.1.2-5.fc16.x86_64) scriptlet failed, exit status 2
error: foghorn-0.1.2-5.fc16.x86_64: erase failed

The preun scriptlet in foghorn-0.1.2-5 is as follows:

%preun
if [ "$1" == 0 ] then;
   /sbin/chkconfig --del foghorn
fi

This seems fine to me. The real issue appears to be that the 'rpm -Uhv' command to update foghorn left two instances of foghorn. I'll attach the spec file I'm using for 0.1.5-2 since I've yet to spot the problem.

Comment 3 Ryan O'Hara 2012-01-21 00:23:36 UTC
Created attachment 556639 [details]
foghorn.spec file for version 0.1.5-2 (with scriptlets for SySV to systemd migration)

Comment 4 Ryan O'Hara 2012-01-21 00:28:44 UTC
This is definitely a problem in the existing spec file for the latest build (0.1.2-5.fc16). On a clean F16 system with:

[root@rocket-04 ~]# rpm -q foghorn
foghorn-0.1.2-5.fc16.x86_64
[root@rocket-04 ~]# rpm -e foghorn
/var/tmp/rpm-tmp.oa8Ubc: line 3: syntax error near unexpected token `fi'
/var/tmp/rpm-tmp.oa8Ubc: line 3: `fi'
error: %preun(foghorn-0.1.2-5.fc16.x86_64) scriptlet failed, exit status 2
error: foghorn-0.1.2-5.fc16.x86_64: erase failed

Comment 5 Ryan O'Hara 2012-01-21 00:42:50 UTC
(In reply to comment #4)
> This is definitely a problem in the existing spec file for the latest build
> (0.1.2-5.fc16). On a clean F16 system with:
> 
> [root@rocket-04 ~]# rpm -q foghorn
> foghorn-0.1.2-5.fc16.x86_64
> [root@rocket-04 ~]# rpm -e foghorn
> /var/tmp/rpm-tmp.oa8Ubc: line 3: syntax error near unexpected token `fi'
> /var/tmp/rpm-tmp.oa8Ubc: line 3: `fi'
> error: %preun(foghorn-0.1.2-5.fc16.x86_64) scriptlet failed, exit status 2
> error: foghorn-0.1.2-5.fc16.x86_64: erase failed

The current build (0.1.2-5) definitely has a but in the preun script. The current preun script is:

%preun
if [ "$1" == 0 ] then;
   /sbin/chkconfig --del foghorn
fi

There is a misplaced semicolon. It should be:

%preun
if [ "$1" == 0 ] ; then
   /sbin/chkconfig --del foghorn
fi

The old foghorn can be removed with --noscripts options, and then the new version can be installed cleanly. This probably results in the scriptlets not being fully tested. I'm not sure how to proceed. Can you review the spec file I attached? At least we can get the package fixed in F17. Thanks.

Comment 6 Jóhann B. Guðmundsson 2012-01-22 09:21:57 UTC
I got nothing up my sleeve to fix that preun error. 

I even went ahead and asked on the package list if there was some official way to deal with this but got no replies which indicates there is none other than forcing the user to the terminal and having him manually remove the old package.

Comment 7 Jóhann B. Guðmundsson 2012-01-22 15:55:50 UTC
Note that it might be doable to use a trigger or posttrans to fix it.

Comment 8 Ryan O'Hara 2012-01-23 15:51:01 UTC
(In reply to comment #6)
> I got nothing up my sleeve to fix that preun error. 
> 
> I even went ahead and asked on the package list if there was some official way
> to deal with this but got no replies which indicates there is none other than
> forcing the user to the terminal and having him manually remove the old
> package.

OK. My concern is that the error that exists in the preun scriptlet will cause a package update to fail and the extra scriptlet work being done to convert sysv to systemd will not occur.

Have a look at the spec file attached to this BZ. If it looks ok, I'll push the new spec file and get a new build started.