#11 el7 compat fixes
Closed 5 years ago by clime. Opened 5 years ago by praiskup.
praiskup/rpkg-util el7-fixes  into  master

file modified
+33 -17
@@ -1,3 +1,18 @@ 

+ %if 0%{?fedora} || 0%{?rhel} > 7

+ %global python          python3

+ %global python_pfx      python3

+ %global python_build    %py3_build

+ %global python_install  %py3_install

+ %global rpm_pyparsing   python3-pyparsing

+ %else

+ %global python          python2

+ %global python_pfx      python

+ %global python_build    %py2_build

+ %global python_install  %py2_install

+ %global rpm_pyparsing   pyparsing

+ %endif

+ 

+ 

  # vim: syntax=spec

  Name: {{{ git_name }}}

  Version: {{{ git_version lead=2 }}}
@@ -25,19 +40,19 @@ 

  Summary: RPM packaging utility

  BuildArch: noarch

  

- BuildRequires: python3

- BuildRequires: python3-setuptools

- BuildRequires: python3-devel

- BuildRequires: python3-rpkg

- BuildRequires: python3-mock

- BuildRequires: python3-munch

- BuildRequires: python3-pytest

- BuildRequires: python3-pyparsing

- BuildRequires: python3-configparser

+ BuildRequires: %python

+ BuildRequires: %python-setuptools

+ BuildRequires: %python-devel

+ BuildRequires: %python-rpkg

+ BuildRequires: %python-mock

+ BuildRequires: %python_pfx-munch

+ BuildRequires: %python-pytest

+ BuildRequires: %rpm_pyparsing

+ BuildRequires: %python-configparser

  

- Requires: python3-rpkg

- Requires: python3-pyparsing

- Requires: python3-configparser

+ Requires: %python-rpkg

+ Requires: %rpm_pyparsing

+ Requires: %python-configparser

  

  %description -n rpkg

  This is an RPM packaging utility based on python-rpkg library.
@@ -48,14 +63,14 @@ 

  %setup -q

  

  %check

- FULL=1 ./run_tests.sh

+ FULL=1 PYTHON=%python ./run_tests.sh

  

  %build

- version=%{version} %py3_build

- %{__python3} man/rpkg_man_page.py > rpkg.1

+ version=%{version} %python_build

+ %python man/rpkg_man_page.py > rpkg.1

  

  %install

- %py3_install

+ %python_install

  install -d %{buildroot}%{_mandir}/man1

  install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1

  
@@ -67,7 +82,7 @@ 

  

  %files -n rpkg

  %license LICENSE

- %{python3_sitelib}/*

+ %{expand:%%%{python}_sitelib}/*

  

  %config(noreplace) %{_sysconfdir}/rpkg.conf

  %{_datadir}/bash-completion/completions/rpkg.bash
@@ -75,6 +90,7 @@ 

  %{_bindir}/rpkg

  %{_mandir}/*/*

  

+ 

  %changelog

  {{{ git_changelog }}}

  

file modified
+11 -12
@@ -7,7 +7,10 @@ 

  import git

  import glob

  

- from urllib.parse import urlparse

+ try:

+     from urllib.parse import urlparse

+ except ImportError:

+      from urlparse import urlparse

  

  import pyrpkg

  from pyrpkg.utils import cached_property
@@ -412,18 +415,14 @@ 

          self.load_spec()

  

      def get_tag_message(self, new_tagname, skip_edit=False):

-         tag_pattern = '{}*'.format(self.module_name)

- 

-         tagnames = self.repo.git.tag(

-             '--list', '--sort=-taggerdate:unix', tag_pattern,

-             '--merged').split()

- 

+         tag_pattern = '{}.*'.format(self.module_name)

          last_matching_tagname = None

-         for tagname in tagnames:

-             expr = r'^{}-[^-]+-[^-]+$'.format(self.module_name)

-             if re.match(expr, tagname):

-                 last_matching_tagname = tagname

-                 break

+ 

+         matching_tagnames = utils.list_tags(

+                 self.repo.working_dir,

+                 pattern=tag_pattern)

+         if matching_tagnames:

+             last_matching_tagname = matching_tagnames[-1]

  

          if last_matching_tagname:

              rev_list_expr = '{}..HEAD'.format(

file modified
+3 -3
@@ -204,7 +204,7 @@ 

          print('\n'.join(unused))

  

      def make_source(self):

-         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)

+         sys.stderr.write('This function is deprecated and will be removed in a future release.\n')

          self.cmd.sources()

          self.cmd.make_source()

  
@@ -216,7 +216,7 @@ 

              except NotUnpackedException:

                  pass

              else:

-                 print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)

+                 sys.stderr.write('Auto-packing is deprecated and will be removed in a future release.\n')

          return self.cmd.srpm(target=getattr(self.args, 'target', None),

                               bcond_with=getattr(self.args, 'with', []),

                               bcond_without=getattr(self.args, 'without', []))
@@ -298,7 +298,7 @@ 

                              self.args.copr_config)

  

      def is_packed(self):

-         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)

+         sys.stderr.write('This function is deprecated and will be removed in a future release.\n')

          self.cmd.dump_spec_only = True

          ts = rpm.ts()

          try:

file modified
+3 -2
@@ -3,6 +3,7 @@ 

  import pycurl

  import os

  import sys

+ from six.moves.urllib.parse import quote

  

  from pyrpkg.errors import DownloadError

  
@@ -14,7 +15,7 @@ 

              hashtype = self.hashtype

  

          self.log.info("Downloading %s", filename)

-         urled_file = filename.replace(' ', '%20')

+         urled_file = quote(filename)

  

          subs = {'module': module, 'filename': urled_file,

                  'hash': hash, 'hashtype': hashtype}
@@ -49,7 +50,7 @@ 

  

          with open(outfile, 'wb') as f:

              c = pycurl.Curl()

-             c.setopt(pycurl.URL, download_url)

+             c.setopt(pycurl.URL, str(download_url))

              c.setopt(pycurl.HTTPHEADER, ['Pragma:'])

              c.setopt(pycurl.NOPROGRESS, False)

              c.setopt(pycurl.PROGRESSFUNCTION, self.print_progress)

file modified
+6 -4
@@ -1,4 +1,5 @@ 

  import os

+ import sys

  import subprocess

  import tempfile

  import re
@@ -27,11 +28,12 @@ 

                  'VERSION_BUMP': version_bump,

                  'INPUT_PATH': input_path,

                  'ENV_STORE': env_store_name,

+                 'PYTHONPATH': ':'.join(sys.path),

+                 'PYTHON': sys.executable,

              }

              p = subprocess.Popen(cmd, env=env, cwd=cwd,

                                   stderr=subprocess.PIPE,

-                                  stdout=subprocess.PIPE,

-                                  encoding='utf8')

+                                  stdout=subprocess.PIPE)

  

              app_log.debug('> {}'.format(token))

              app_log.debug('> cwd: {}'.format(cwd))
@@ -39,7 +41,7 @@ 

  

              (stdout, stderr) = p.communicate()

  

-             for line in stderr.split('\n'):

+             for line in stderr.decode('utf-8').split('\n'):

                  if not line:

                      continue

  
@@ -64,7 +66,7 @@ 

  

              app_log.debug('---')

              retval += '\n' if retval else ''

-             retval += stdout

+             retval += stdout.decode('utf-8')

  

          return retval

      return invoke

file modified
+37 -20
@@ -37,10 +37,6 @@ 

      sed -e 's|/|-|g' -e 's|-$||'

  }

  

- function filter_tags {

-     grep -E "^$1-[^-]+-[^-]+$"

- }

- 

  function output {

      __cached["${FUNCNAME[1]}"]="$*"

      echo -n "${__cached[${FUNCNAME[1]}]}"
@@ -140,6 +136,26 @@ 

      echo -n "$lead.$bumped_follow"

  }

  

+ 

+ git_list_tags ()

+ {

+     __merged=

+     case "$1" in

+     --merged)

+         __merged=', only_merged=True'

+         shift

+         ;;

+     esac

+ 

+     ${PYTHON-python3} -c "\

+ from rpkglib.utils import list_tags

+ tags = list_tags(pattern='$1-[^-]+-[^-]+$'$__merged)

+ for tag in tags:

+     print(tag)

+ " 2>/dev/null

+ }

+ 

+ 

  function git_version {

      declare name="$(cached git_name)" lead=0 follow= "$@"

  
@@ -157,8 +173,8 @@ 

          log_error "follow cannot contain dots."

          return 1

      fi

-     

-     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged 2> /dev/null | filter_tags "$name")

+ 

+     mapfile -t tags < <(git_list_tags --merged "$name")

  

      if [ ${#tags[@]} -gt 0 ]; then

          latest_tag="${tags[-1]}"
@@ -270,7 +286,7 @@ 

          return 2

      fi

  

-     cmd_stdout="$(git -C "$path" archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"

+     cmd_stdout="$(cd "$path" && git archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"

      cmd_retcode=$?

  

      log_debug "$cmd_stdout"
@@ -293,13 +309,7 @@ 

  function git_changelog {

      declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_wrap=80 "$@"

  

-     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged 2> /dev/null | filter_tags "$name")

- 

-     if [ -n "$header_date_format" ]; then

-         header_date_format_suffix=":format:$header_date_format"

-     else

-         header_date_format_suffix=

-     fi

+     mapfile -t tags < <(git_list_tags --merged "$name")

  

      changelog=

      until_tag_hit=
@@ -309,13 +319,20 @@ 

          fi

          since_tag_hit=1

  

-         data="$(git tag -l "$tag" --format='%(body)')"

+         data="$(git for-each-ref "refs/tags/$tag" --format='%(body)')"

          if [ -z "$data" ]; then

              data="(none)"

          fi

  

+         ref=refs/tags/$tag

+         header_date='%(taggerdate)'

+         if [ -n "$header_date_format" ]; then

+             realdate=$(git for-each-ref "$ref" --format '%(taggerdate:iso8601)')

+             header_date=$(date --date "$realdate" +"$header_date_format")

+         fi

+ 

          verrel="$(echo "$tag" | sed -E -n "s/^$name-([^-]+)(-[^-]+)$/\1\2/p")"

-         header="$(LC_ALL="$header_locale" git tag -l "$tag" --format="* %(taggerdate$header_date_format_suffix) %(taggername) %(taggeremail)") $verrel"

+         header="$(LC_ALL="$header_locale" git for-each-ref "refs/tags/$tag" --format="* $header_date %(taggername) %(taggeremail)") $verrel"

          formatted_data="$(echo "$data" | fold -cs --width="$body_wrap" | sed -E -e 's/(\s+)%([^%])/\1%%\2/g' -e 's/\s*$//')"

  

          if [ -n "$changelog" ]; then
@@ -335,7 +352,7 @@ 

  ############## DIR FUNCTIONS ##############

  

  function git_dir_name {

-     git_name append="-$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)" "$@"

+     git_name append="-$(cd "$(dirname "$INPUT_PATH")" && git rev-parse --show-prefix | name_convert)" "$@"

  }

  

  function git_dir_version {
@@ -343,7 +360,7 @@ 

  }

  

  function git_dir_vcs {

-     git_vcs subtree="$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix)" "$@"

+     git_vcs subtree="$(cd "$(dirname "$INPUT_PATH")" && git rev-parse --show-prefix)" "$@"

  }

  

  function git_dir_pack {
@@ -365,7 +382,7 @@ 

  ############## CURRENT WORKING DIR FUNCTIONS ##############

  

  function git_cwd_name {

-     git_name append="-$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"

+     git_name append="-$(cd "$(pwd)" && git rev-parse --show-prefix | name_convert)" "$@"

  }

  

  function git_cwd_version {
@@ -373,7 +390,7 @@ 

  }

  

  function git_cwd_vcs {

-     git_vcs subtree="$(git -C "$(pwd)" rev-parse --show-prefix)" "$@"

+     git_vcs subtree="$(cd "$(pwd)" && git rev-parse --show-prefix)" "$@"

  }

  

  function git_cwd_pack {

@@ -28,7 +28,11 @@ 

  DIR_NAME=""

  SOURCE_NAME=""

  EXCLUDE_VCS="--exclude-vcs"

- EXCLUDE_VCS_IGNORES="--exclude-vcs-ignores"

+ if tar --help | grep -q -- --exclude-vcs-ignores; then

+     EXCLUDE_VCS_IGNORES="--exclude-vcs-ignores"

+ else

+     EXCLUDE_VCS_IGNORES="--exclude=.gitignore" ## TODO

+ fi

  

  while [ -n "$1" ] ; do

      case "$1" in

file modified
+34 -2
@@ -6,6 +6,7 @@ 

  import textwrap

  import subprocess

  import tempfile

+ import git

  

  from pyrpkg.errors import rpkgError

  
@@ -57,14 +58,14 @@ 

  

  def run_command(cmd, shell=False, env=None, cwd=None):

      try:

-         output = subprocess.check_output(cmd, shell=shell, env=env, cwd=cwd, encoding='utf8')

+         output = subprocess.check_output(cmd, shell=shell, env=env, cwd=cwd)

      except (subprocess.CalledProcessError, OSError) as e:

          raise rpkgError(e)

      except KeyboardInterrupt:

          raise rpkgError('Command is terminated by user.')

      except Exception as e:

          raise rpkgError(e)

-     return output

+     return output.decode('utf-8')

  

  

  def edit(editor, text):
@@ -77,3 +78,34 @@ 

      tmp_f.close()

      os.unlink(tmp_f.name)

      return result

+ 

+ 

+ def list_tags(repo=None, pattern=None, only_merged=False):

+     def sort_tags(tags):

+         return sorted(tags, key=lambda t: t.commit.committed_date)

+ 

+     repo = git.Repo(repo, search_parent_directories=True)

+     tags = repo.tags

+     if pattern:

+         regexp = re.compile(pattern)

+         tags = [t for t in tags if regexp.match(t.name)]

+     if not tags:

+         return []

+ 

+     if not only_merged:

+         return sort_tags(tags)

+ 

+     found_tags = []

+     tagged_hashes = {}

+     for tag in tags:

+         sha = tag.commit.hexsha

+         if sha in tagged_hashes:

+             tagged_hashes[sha].append(tag)

+         else:

+             tagged_hashes[sha] = [tag]

+ 

+     for commit in repo.iter_commits():

+         if commit.hexsha in tagged_hashes:

+             found_tags.extend(tagged_hashes[commit.hexsha])

+ 

+     return sort_tags(found_tags)

file modified
+3 -1
@@ -2,7 +2,9 @@ 

  

  path="${1:-tests}"

  

- PYTHONPATH=.:$PYTHONPATH python3 -m pytest -s $path

+ export PYTHONPATH=".${PYTHONPATH+:$PYTHONPATH}"

+ 

+ ${PYTHON-python3} -m pytest -s $path

  

  if [ -n "$FULL" ] && [ -z "$FULL_OVERRIDE" ]; then

      ./tests/preproc/run.sh

file modified
+3 -3
@@ -22,8 +22,8 @@ 

  }

  

  function head_commit_sub {

-     full_hash=$(git -C "$1" rev-parse HEAD)

-     short_hash=$(git -C "$1" rev-parse --short HEAD)

+     full_hash=$(cd "$1" && git rev-parse HEAD)

+     short_hash=$(cd "$1" && git rev-parse --short HEAD)

      sed -Ei -e "s|(\.git\.[0-9]+)\.[a-zA-Z0-9]+|\1.$short_hash|" -e "s|#\w{40}:|#$full_hash:|" "$2"

  }

  
@@ -36,7 +36,7 @@ 

  

      local out="$(mktemp -d)"

  

-     run "../preproc.py --path $path --input $input --output $out/output $opts | log_filter &> $out/log"

+     run "${PYTHON-python3} ../preproc.py --path $path --input $input --output $out/output $opts | log_filter &> $out/log"

  

      if [ -n "$copy_only" ]; then

          cp "$out/log" "$out/output" .

@@ -7,8 +7,11 @@ 

  

  prepare_input input $repo/input

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -8,18 +8,20 @@ 

  prepare_input ../input $repo/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- 

- git -C $repo remote add origin https://pagure.io/clime/test.git

- git -C $repo add -A

- git -C $repo commit -m 'commit 1'

- touch $repo/foo

- git -C $repo add foo

- git -C $repo commit -m 'commit 2'

- touch $repo/bar

- git -C $repo add bar

- git -C $repo commit -m 'commit 3'

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+   git add -A

+   git commit -m 'commit 1'

+   touch foo

+   git add foo

+   git commit -m 'commit 2'

+   touch bar

+   git add bar

+   git commit -m 'commit 3'

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -8,11 +8,14 @@ 

  prepare_input ../input $repo/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

- git -C $repo add -A

- git -C $repo commit -a -m 'inital_commit'

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+   git add -A

+   git commit -a -m 'inital_commit'

+ )

  

  touch $repo/foo

  

@@ -7,8 +7,11 @@ 

  

  prepare_input ../input $repo/input

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -8,9 +8,12 @@ 

  prepare_input ../input $repo/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -7,8 +7,11 @@ 

  

  prepare_input input $repo/input

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+ )

  

  touch output && cp output $output

  

@@ -9,10 +9,13 @@ 

  echo 1 > $repo/cookie

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo add -A

- git -C $repo commit -m 'commit 1'

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git add -A

+   git commit -m 'commit 1'

+ )

  

  touch output && cp output $output

  

@@ -12,15 +12,18 @@ 

  echo 3 > $repo/subdir2/cookie

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

- git -C $repo add -A

- git -C $repo commit -m 'commit 1'

- git -C $repo tag -a -m 'tag message' test-0.4-1

- git -C $repo tag -a -m 'tag message' test-subdir1-0.4-1

- git -C $repo tag -a -m 'tag message' test-subdir2-0.4-1

- git -C $repo tag -a -m 'tag message' test-subdir3-0.4-1

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+   git add -A

+   git commit -m 'commit 1'

+   git tag -a -m 'tag message' test-0.4-1

+   git tag -a -m 'tag message' test-subdir1-0.4-1

+   git tag -a -m 'tag message' test-subdir2-0.4-1

+   git tag -a -m 'tag message' test-subdir3-0.4-1

+ )

  

  touch output && cp output $output

  

@@ -9,9 +9,13 @@ 

  prepare_input ../input $repo/subdir2/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

+ 

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -8,16 +8,19 @@ 

  prepare_input ../input $repo/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

- git -C $repo add -A

- git -C $repo commit -a -m 'inital_commit'

- git -C $repo tag -a -m 'subject' -m '- message' foo-1.1-1

- git -C $repo tag -a -m 'subject' -m '- message' foo-1.2-1

- git -C $repo tag -a -m 'subject' -m '- message that should be %very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.3-1

- git -C $repo tag -a -m 'subject' -m '- message' foo-1.4-1

- git -C $repo tag -a -m 'subject' -m '- message' foo-1.5-1

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+   git add -A

+   git commit -a -m 'inital_commit'

+   git tag -a -m 'subject' -m '- message' foo-1.1-1

+   git tag -a -m 'subject' -m '- message' foo-1.2-1

+   git tag -a -m 'subject' -m '- message that should be %very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.3-1

+   git tag -a -m 'subject' -m '- message' foo-1.4-1

+   git tag -a -m 'subject' -m '- message' foo-1.5-1

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

@@ -8,15 +8,18 @@ 

  prepare_input ../input $repo/input

  

  git init $repo

- git -C $repo config user.email "clime@redhat.com"

- git -C $repo config user.name "clime"

- git -C $repo remote add origin https://pagure.io/clime/test.git

- git -C $repo add -A

- git -C $repo commit -a -m 'inital_commit'

- git -C $repo tag -a -m 'subject' -m '- message.' foo-0.1-1

- touch $repo/foo

- git -C $repo add foo

- git -C $repo commit -m 'commit after tag'

+ (

+   cd "$repo"

+   git config user.email "clime@redhat.com"

+   git config user.name "clime"

+   git remote add origin https://pagure.io/clime/test.git

+   git add -A

+   git commit -a -m 'inital_commit'

+   git tag -a -m 'subject' -m '- message.' foo-0.1-1

+   touch foo

+   git add foo

+   git commit -m 'commit after tag'

+ )

  

  touch output && cp output $output

  wtree_sub $repo $output

file modified
+1 -2
@@ -11,8 +11,7 @@ 

  

  from .spec_templates import SPEC_TEMPLATE

  

- from unittest import mock

- from unittest.mock import MagicMock

+ import mock

  

  from . import base

  

file modified
+6 -3
@@ -13,9 +13,12 @@ 

  

  from pyrpkg.errors import rpkgError

  

- from unittest import mock

- from unittest.mock import MagicMock

- from io import StringIO

+ import mock

+ from mock import MagicMock

+ try:

+     from StringIO import StringIO

+ except:

+     from io import StringIO

  

  from . import base

  

file modified
+1 -2
@@ -2,8 +2,7 @@ 

  

  from rpkglib import utils

  

- from unittest import mock

- from unittest.mock import MagicMock

+ import mock

  

  from . import base

  

This is fixing issues on several fronts:

On RHEL7 is:
* no python3 support:
- io.StringIO behaves badly
- no unittests.mock
- no print(.., file=...)

  • old git <= v2
  • no '-C' option
  • non-working 'git tag --list --format='%(taggerdate:format:..)'
  • git tag --list --sort=... doesn't work

  • old GNU tar

  • missing --exclude-vcs-ignores option

rebased onto ee63012

5 years ago

rebased onto 3177c1e

5 years ago

rebased onto 9a5e74d

5 years ago

Thank you but I decided not to include rpkg in el7 especially for the lack of --merged option. Can you give some motivation for this PR? Quickly looking at the code, the --merged is handled in a very hacky manner that would be horrible to maintain. Also the macro part should be independent of python. --exclude-vcs-ignores for git_pack is not implemented correctly. The changes are very extensive and currently we don't have overall regression tests to make this works for all the cases. Anyway, the main problem is lack of --merged for the old Git in EPEL7. That's why decision was made not to include rpkg there. Unless, there is a good motivation and good way to fix the implementation, I think the decision should be kept.

Can you give some motivation for this PR?

Some Copr builders in Internal Copr are long-term running boxes in not really stable cloud -- so I need them to run on EL7, otherwise I'd have to upgrade fedora all the time. Upgrading fedora has huge risk that something get's broken, and I won't be able to fix that without support...

Quickly looking at the code, the --merged is handled in a very hacky manner

Uh uh, even though it's not exceptionally hacky compared to all the other code (I've spent many hours getting it working, because I was convinced that you'd refuse to do it..), so please suggest better style :-)

--exclude-vcs-ignores for git_pack is not implemented correctly.

Good catch ;) there's TODO for it; nor in GNU tar (pretty new stuff); I'd vote to not use that at all and only implement it in rpkg-util; otherwise you won't ever know when that functionality changes.


I have expected your reaction (I won't merge, while you don't say what/how to fix); so I have other proposal, what about to not depend in copr-rpmbuild on rpkg-util at all?

Some Copr builders in Internal Copr are long-term running boxes in not really stable cloud -- so > I need them to run on EL7, otherwise I'd have to upgrade fedora all the time. Upgrading fedora > has huge risk that something get's broken, and I won't be able to fix that without support...

I understand the limitation...I would suggest to wait it out for a next EPEL release, however, instead of bending the existing tooling now. Alternatively, you could try upgrading Git and tar on the builders if you don't mind being dependent on copr package. I was actually able to install and "use" Git (I just tried git --version actually) from https://copr.fedorainfracloud.org/coprs/g/git-maint/git/ on CentOS7 so I recommend taking look at it. That could be a very nice solution. I haven't look for a newer tar though.

Ok, forget about that. I'll fork this "tool" which you refuse to accept patches for.

Please document why you refuse to porting this tool against the EPEL 7, thanks, #12.

Thanks for the discussion and the constructive approach.

Pull-Request has been closed by clime

5 years ago

Added pull request summary:

Making a dedicated copr with required version of tar and git is a better approach to get rpkg-util working on EPEL7 because it doesn't require very significant changes in the current code-base that can't even be properly tested at the moment. Also the proposed implementation is incomplete with respect to git_pack macro with very difficult implementation bits left and the implementation of --merged switch for Git is very hacky and can't really be accepted as a proper solution.

Making a dedicated copr with required version of tar and git is a better approach to get rpkg-util working on EPEL7 because it doesn't require very significant changes

Huh?

in the current code-base that can't even be properly tested at the moment.

This is nonsense. Please provide el7 version, and let people report the bugs.

Also the proposed implementation is incomplete with respect to git_pack macro with very difficult implementation bits left

Be concrete and constructive, before you close pull requests. Thanks!

and the implementation of --merged switch for Git is very hacky and can't really be accepted as a proper solution.

Please define how that is hacky, and how that should be implemented.