summaryrefslogtreecommitdiff
path: root/pcr/initify
diff options
context:
space:
mode:
Diffstat (limited to 'pcr/initify')
-rw-r--r--pcr/initify/PKGBUILD9
-rw-r--r--pcr/initify/trim_path_from_service_name.patch25
-rw-r--r--pcr/initify/validate_args.patch41
3 files changed, 60 insertions, 15 deletions
diff --git a/pcr/initify/PKGBUILD b/pcr/initify/PKGBUILD
index 9911bb15a..317208098 100644
--- a/pcr/initify/PKGBUILD
+++ b/pcr/initify/PKGBUILD
@@ -5,7 +5,7 @@
pkgname=initify
_gitver=f9ccbb147924a2371a1ae5a925c1be6858cca5fa
pkgver=0.0.0.pre.${_gitver:0:7}
-pkgrel=1
+pkgrel=3
pkgdesc="Convert systemd services to OpenRC init-scripts"
arch=(any)
url=https://github.com/goose121/initify/
@@ -16,18 +16,21 @@ depends=(perl)
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/goose121/${pkgname}/archive/${_gitver}.tar.gz)
source+=(trim_path_from_service_name.patch
validate_args.patch)
+
sha256sums=('24709e6f243247a83826b662d6e8431eca223ef5aaccf75a09d5dbf7dde81539')
-sha256sums+=('3ec2d0a9c582c80d708a36bdf35b40f024d8f676d4fbca05e2274a22f1f42f4b'
- '77b06164a52846adfd48d314a18b3aadf10373cc5c6040f97e65b20538d0150d')
+sha256sums+=('e105a8d8e7074050fa192ea139382c75a5cafda83275376dd6cd21779a80ca5d'
+ 'b82a63fda947af397f8d60ad4049d3aba279817360f4acaeb3e684278016a711')
prepare()
{
cd "${srcdir}"/${pkgname}-${_gitver}/
+ # https://github.com/goose121/initify/issues/2
echo "applying trim_path_from_service_name.patch"
patch -p1 < "${srcdir}"/trim_path_from_service_name.patch
+ # https://github.com/goose121/initify/issues/2
echo "applying validate_args.patch"
patch -p1 < "${srcdir}"/validate_args.patch
}
diff --git a/pcr/initify/trim_path_from_service_name.patch b/pcr/initify/trim_path_from_service_name.patch
index dea81a249..f1aef74bd 100644
--- a/pcr/initify/trim_path_from_service_name.patch
+++ b/pcr/initify/trim_path_from_service_name.patch
@@ -1,13 +1,32 @@
diff --git a/initify.pl b/initify.pl
-index 7cec3d2..3accde8 100755
+index 7cec3d2..3d8b1bd 100755
--- a/initify.pl
+++ b/initify.pl
-@@ -14,7 +14,7 @@ my @cmds_start = ();
+@@ -14,7 +14,8 @@ my @cmds_start = ();
my @cmds_stop = ();
my $pidfile = "";
my $desc = "";
-(my $service=$ARGV[0])=~s/\.service//;
-+(my $service=$ARGV[0])=~s|(.*/)?([^/.]*)\.service|$2|;
++(my $service = $ARGV[0]) =~ s/\.service//;
++(my $svc_name = $ARGV[0]) =~ s|(.*/)?([^/.]*)\.service|$2|;
my %opt;
GetOptions(\%opt,
+@@ -23,7 +24,7 @@ GetOptions(\%opt,
+
+ pod2usage() if ($opt{help});
+
+-$service = $opt{name} if (length $opt{name});
++$svc_name = $opt{name} if (length $opt{name});
+
+ while(<>) {
+ #s/\s*|\s*$//g; # Trim whitespace
+@@ -77,7 +78,7 @@ command=$cmd_path[0]
+ command_args="$cmd_argl[0]"
+ pidfile=$pidfile
+
+-name="$service"
++name="$svc_name"
+ description="$desc"
+ EOF
+
diff --git a/pcr/initify/validate_args.patch b/pcr/initify/validate_args.patch
index 515bff05f..447478268 100644
--- a/pcr/initify/validate_args.patch
+++ b/pcr/initify/validate_args.patch
@@ -1,16 +1,39 @@
diff --git a/initify.pl b/initify.pl
-index 7cec3d2..acbfad3 100755
+index 3d8b1bd..fbfbce8 100755
--- a/initify.pl
+++ b/initify.pl
-@@ -9,6 +9,11 @@ use feature "switch";
- use Getopt::Long;
- use Pod::Usage;
+@@ -14,18 +14,31 @@ my @cmds_start = ();
+ my @cmds_stop = ();
+ my $pidfile = "";
+ my $desc = "";
+-(my $service = $ARGV[0]) =~ s/\.service//;
+-(my $svc_name = $ARGV[0]) =~ s|(.*/)?([^/.]*)\.service|$2|;
+
++# parse CLI args
+ my %opt;
+ GetOptions(\%opt,
+ "name=s",
+ "help|?") || pod2usage(2);
+-
+ pod2usage() if ($opt{help});
+
++# get systemd service source file, and target service name
++(my $service = $ARGV[0])=~s/\.service//;
++(my $svc_name = $ARGV[0])=~s|(.*/)?([^/.]*)\.service|$2|;
+ $svc_name = $opt{name} if (length $opt{name});
-+unless (-e $ARGV[0]) {
-+ print "can not find service file: '$ARGV[0]' - quitting\n";
++# sanity checks
++my $USAGE = "Usage: initify [options] some-systemd.service";
++unless ($ARGV[0] =~ /(.*\/)?([^\/.]*)\.service/) {
++ print "no *.service file specified - quitting\n$USAGE\n";
++ exit;
++}
++unless (-e "$ARGV[0]") {
++ print "can not find *.service file: '$ARGV[0]' - quitting\n$USAGE\n";
+ exit;
+}
+
- my $type = "simple";
- my @cmds_start = ();
- my @cmds_stop = ();
++# begin
+ while(<>) {
+ #s/\s*|\s*$//g; # Trim whitespace
+ if (m/^Type\s*=\s*(.*)/) {