Hello community, here is the log from the commit of package unar for openSUSE:Factory checked in at 2018-02-24 16:38:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/unar (Old) and /work/SRC/openSUSE:Factory/.unar.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "unar" Sat Feb 24 16:38:59 2018 rev:3 rq:579544 version:1.10.1 Changes: -------- --- /work/SRC/openSUSE:Factory/unar/unar.changes 2017-01-25 23:33:55.299032540 +0100 +++ /work/SRC/openSUSE:Factory/.unar.new/unar.changes 2018-02-24 16:38:59.682280449 +0100 @@ -1,0 +2,9 @@ +Fri Feb 23 11:17:32 UTC 2018 - [email protected] + +- add unrar_wrapper.py (https://github.com/openSUSE/unrar_wrapper) + that provides the basic backwards compatibility with unrar + [fate#323896] +- unar now obsoletes non-free unrar +- run spec-cleaner + +------------------------------------------------------------------- New: ---- unrar_wrapper.py ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ unar.spec ++++++ --- /var/tmp/diff_new_pack.YfRYSX/_old 2018-02-24 16:39:00.506250796 +0100 +++ /var/tmp/diff_new_pack.YfRYSX/_new 2018-02-24 16:39:00.510250652 +0100 @@ -1,7 +1,7 @@ # # spec file for package unar # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,7 @@ Url: http://unarchiver.c3.cx/commandline Source0: http://unarchiver.c3.cx/downloads/%{name}%{version}_src.zip Source1: %{name}.changes +Source2: unrar_wrapper.py # PATCH-FIX-OPENSUSE use-system-wavpack.patch Patch0: use-system-wavpack.patch # PATCH-FIX-UPSTREAM document-undocumented-options.patch (lp#1393321) @@ -38,7 +39,8 @@ BuildRequires: unzip BuildRequires: wavpack-devel BuildRequires: zlib-devel -BuildRoot: %{_tmppath}/%{name}-%{version}-build +Provides: unrar = 5.5.8.0.1 +Obsoletes: unrar <= 5.5.8 %description The Unarchiver is originally a Mac OS X application. This package @@ -77,8 +79,12 @@ install -m644 Extra/lsar.bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/lsar install -m644 Extra/unar.bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/unar +# Provide unrar-unar compatibility wrapper (fate#323896) +install -d -m755 %{buildroot}/%{_datadir}/%{name}/ +install -m755 %{SOURCE2} %{buildroot}/%{_datadir}/%{name}/ +ln -s %{_datadir}/%{name}/unrar_wrapper.py %{buildroot}/%{_bindir}/unrar + %files -%defattr(-,root,root,-) %doc License.txt README.md %{_bindir}/lsar %{_bindir}/unar @@ -86,5 +92,8 @@ %{_mandir}/man1/unar.1%{ext_man} %{_sysconfdir}/bash_completion.d/lsar %{_sysconfdir}/bash_completion.d/unar +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/unrar_wrapper.py +%{_bindir}/unrar %changelog ++++++ unrar_wrapper.py ++++++ #!/usr/bin/python3 """ UnRAR wrapper is a wrapper python script that transforms the basic UnRAR commands to unar and lsar calling in order to provide a backwards compatibility. It supports only a subset of the UnRAR commands and options: Supported commands: l[t[a],b], t, v[t[a],b], x. Supported options: -o+, -o-, -or, -p Other: files, @listfiles and path_to_extract (only for unar) Return codes: 0 (success), 1 (error), 2 (invalid argument) """ import argparse import subprocess import sys def parse_args(): """Create a parser and parse UnRAR synopsis. The UnRAR synopsis is as follows: unrar command [option1] [optionN] archive [files...] [@list-files...] [path_to_extract/] Support the following commands: l[t[a],b], t, v[t[a],b], x. Support the following options: -o+, -o-, -or, -p Args: Returns: A namespace class that holds parsed arguments Raises: """ parser = argparse.ArgumentParser(description="Transforms the basic UnRAR " "commands to unar and lsar " "calling in order to provide " "a backwards compatibility") parser.add_argument('command', choices=['l', 'lt', 'lta', 'lb', 't', 'v', 'vt', 'vta', 'vb', 'x'], help="UnRAR command") parser.add_argument('-o', dest='overwrite', choices=['+', '-', 'r'], help="'-o+' Set the overwrite mode, '-o-' Unset the " "overwrite mode,'-or' Rename files automatically") parser.add_argument('-p', dest='password', help='-p[password] Set password.') parser.add_argument('archive', help='The path to the archive') parser.add_argument('rest', nargs='*', help="[files...] [@list-files...] [path_to_extract/]") args = parser.parse_args() return args def transform_syntax(args): """Transform UnRAR command and options to the Unarchiver syntax. Args: args: A namespace class that holds parsed UnRAR arguments Returns: A tuple (commands, options) with a string and a list that hold Unarchiver command and options Raises: """ opts = [] if args.command == 'x': command = 'unar' # '-o+' means force-overwrite if args.overwrite == '+': opts.append('-f') # '-o-' means force-skip elif args.overwrite == '-': opts.append('-s') # '-or' means force-rename elif args.overwrite == 'r': opts.append('-r') else: command = 'lsar' if (args.command == 'lb' or args.command == 'vb'): # 'lb' and 'vb'are translated to plain 'lsar' command pass elif (args.command == 'l' or args.command == 'v'): opts.append('-l') elif (args.command == 'lt' or args.command == 'lta' or args.command == 'vt' or args.command == 'vta'): opts.append('-L') elif args.command == 't': opts.append('-t') # '-p' option makes sense for all commands if args.password: opts.append('-p') opts.append(args.password) return command, opts def transform_list_files(list_files): """Return the content of the files given as a list. If any of the files doesn't exist then the program is terminated. Args: list_files: a list of paths to the files Returns: A list of concatenated content of the files given as list_files Raises: """ files = [] for f in list_files: try: with open(f, "r") as stream: for line in stream: # Remove trailing newline files.append(line.rstrip()) except IOError: print("Cannot open {}\nNo such file or directory".format(f), file=sys.stderr) sys.exit(1) return files def process_rest(rest): """Split the argument to [files], [@list-files] and [path_to_extract/]. All of these parts are optional. Args: rest: a list of strings with the paths to files, @list-files and path_to_extract/ Returns: A tuple (files, list_files, path) - files: a list of files, that should be processed - @list-files: a list of text files that contain a list of files that should be processed - path_to_extract/: a string with a directory to write the contents of the archive to Raises: """ if not rest: return None, None, None # UnRAR considers every item ending with '/' as a path. # If multiple paths are present, only the last one is used. files = [] list_files = [] path = None for item in rest: if item.endswith('/'): path = item elif item.startswith('@'): list_files.append(item[1:]) else: files.append(item) return files, list_files, path def main(): args = parse_args() # Translate UnRAR command and options to the Unarchiver syntax command, options = transform_syntax(args) files = [] if args.rest and command == 'lsar': # files, @list_files and path are not supported for lsar print("Warning: [files...], [@list_files...] and [path_to_extract/] " "are not supported for listing and testing. These parameters are " "ignored.", file=sys.stderr) if command == 'unar': # Add '-D' option by default in order to simulate default UnRAR # behaviour (never create a new containing directory if there is more # than one top-level file or folder) options.append("-D") if args.rest: files, list_files, path = process_rest(args.rest) # unar can't process @list_files as is -> transform it to files if list_files: files = files + transform_list_files(list_files) # Transform path to unar syntax ("-o DIRECTORY") if path: options.extend(["-o", path]) # Call Unarchiver rc = subprocess.call([command] + options + [args.archive] + files) return rc if __name__ == "__main__": return_code = main() sys.exit(return_code)
