[Mageia-dev] [soft-commits] [4584] (systemd_unit_exists) factorize

Colin Guthrie mageia at colin.guthr.ie
Wed May 23 20:38:09 CEST 2012


'Twas brillig, and Thierry Vignaud at 23/05/12 19:29 did gyre and gimble:
> On 23 May 2012 20:25,  <root at mageia.org> wrote:
>> Revision 4584 Author tv Date 2012-05-23 20:25:15 +0200 (Wed, 23 May 2012)
>>
>> Log Message
>>
>> (systemd_unit_exists) factorize
>>
>> Modified Paths
>>
>> drakx/trunk/perl-install/services.pm
>>
>> Modified: drakx/trunk/perl-install/services.pm
>> ===================================================================
>> --- drakx/trunk/perl-install/services.pm	2012-05-23 18:02:37 UTC (rev 4583)
>> +++ drakx/trunk/perl-install/services.pm	2012-05-23 18:25:15 UTC (rev 4584)
>> @@ -433,7 +433,7 @@
>>          if (my ($name, $l) = m!^(\S+)\s+(0:(on|off).*)!) {
>>              # If we expect to use systemd (i.e. installer) only show those
>>              # sysvinit scripts which are not masked by a native systemd
>> unit.
>> -            my $has_systemd_unit = (-e "$::prefix/lib/systemd/system/$name.service" or -l "$::prefix/lib/systemd/system/$name.service");
>> +            my $has_systemd_unit = systemd_unit_exists($name);
>>              if (!$has_systemd || !$has_systemd_unit) {
>>                  if ($::isInstall) {
>>                      $on_off = $l =~ /\d+:on/g;
>> @@ -466,12 +466,14 @@
>>
>>
>>
>> +sub systemd_unit_exists {
>> +    my ($name) = @_;
>> +    -e "$::prefix/lib/systemd/system/$name.service" or -l "$::prefix/lib/systemd/system/$name.service";
>> +}
>>
>> -
>> -
>>  sub service_exists {
>>      my ($service) = @_;
>> -    -x "$::prefix/etc/rc.d/init.d/$service" or -e "$::prefix/lib/systemd/system/$service.service" or -l "$::prefix/lib/systemd/system/$service.service";
>> +    -x "$::prefix/etc/rc.d/init.d/$service" or systemd_unit_exists($service);
>>  }
> 
> BTW Colin your test is redundant. -e returns true for symlinks too
> (unless target doesn't exist in which case we don't care much anyway...)

NAK. No it's not redundant it's very important. The symlinks *will* be
broken when run via the installer due to the $::prefix as they will
point to "non-existent" paths in /lib/systemd/ (not to
/mnt/lib/systemd...) so I treat any symlink that exists (even if it
points to an invalid unit) as "valid" here.

I think I even said as much in a comment or the commit log that it's
important :)

Col


-- 

Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the Mageia-dev mailing list