File nodejs2rpm-licensefile.patch of Package nodejs2rpm

diff -Pdpru nodejs2rpm-1.0.0.orig/nodejs2rpm.py nodejs2rpm-1.0.0/nodejs2rpm.py
--- nodejs2rpm-1.0.0.orig/nodejs2rpm.py	2017-12-28 14:42:46.000000000 +0100
+++ nodejs2rpm-1.0.0/nodejs2rpm.py	2018-01-09 11:06:34.226436453 +0100
@@ -54,8 +54,24 @@ def getREADME(tar_file):
     tar.close()
     return docfile
 
+def getLICENSE(tar_file):
 
-def fillSPEC(template_file, sub_dict, docfile, output_file):
+    print "Using tarfile: " + tar_file
+    if not tarfile.is_tarfile(tar_file):
+        print "Invalid tar file!"
+        sys.exit(1)
+
+    tar = tarfile.open(tar_file, "r:gz")
+    licensefile = "none"
+    for tarinfo in tar:
+        if (tarinfo.isreg()) and (re.search('.*license$', tarinfo.name, re.I) is not None):
+            print "Found LICENSE - " + os.path.basename(tarinfo.name)
+            licensefile = os.path.basename(tarinfo.name)
+    tar.close()
+    return licensefile
+
+
+def fillSPEC(template_file, sub_dict, docfile, licensefile, output_file):
 
 
     # Initialize the Jinja environment
@@ -214,6 +230,9 @@ out.close()
 # get the README file from the tar
 docfile = getREADME(tarball)
 
+# get the LICENSE file from the tar
+licensefile = getLICENSE(tarball)
+
 # map the strings to the values to be substituted
 sub_dict = {
     '__VERSION__': meta_latest,
@@ -224,12 +243,13 @@ sub_dict = {
     '__BASENAME__': meta_name,
     '__REQUIRES__': meta_dependencies,
     '__DOC__': docfile,
+    '__LICENSEF__': licensefile,
     '__BOILERPLATE__': boilerplate,
     # the metadata does not have a detailed description
     '__DESCRIPTION__': meta_desc }
 
 # substitute the variables in the SPEC template
-fillSPEC(options.templatefile, sub_dict, docfile, output)
+fillSPEC(options.templatefile, sub_dict, docfile, licensefiel, output)
 
 # create the changes file if requested
 fillChanges(options.email, options.changelog, output)
diff -Pdpru nodejs2rpm-1.0.0.orig/templates/default.spec nodejs2rpm-1.0.0/templates/default.spec
--- nodejs2rpm-1.0.0.orig/templates/default.spec	2017-12-28 14:42:46.000000000 +0100
+++ nodejs2rpm-1.0.0/templates/default.spec	2018-01-09 11:20:08.034984568 +0100
@@ -52,8 +52,10 @@ mv -f package.json \
 cp -prf * \
         %{buildroot}%{nodejs_modulesdir}/%{base_name}
 
+%if ! 0%{?suse_version}
 %clean
 rm -rf $RPM_BUILD_ROOT
+%endif
 
 %post 
 
@@ -77,6 +79,9 @@ fi
 %dir %{nodejs_modulesdir}
 %{nodejs_modulesdir}/%{base_name}/*
 %dir %{nodejs_modulesdir}/%{base_name}
+{%- if __LICENSEF__ != "none" %}
+%license {{ __LICENSEF__ }}
+{%- endif %}
 {%- if __DOC__ != "none" %}
 %doc {{ __DOC__ }}
 {%- endif %}
openSUSE Build Service is sponsored by