diff --git a/.files b/.files index 9be4b08..19977b9 100644 Binary files a/.files and b/.files differ diff --git a/.rev b/.rev index 11a87b9..97d912c 100644 --- a/.rev +++ b/.rev @@ -7,4 +7,12 @@ Add 7zip to Factory 943593 + + 434adbc5ce2840794a6524c33a4851db + 21.07 + + dimstar_suse + + 946078 + diff --git a/7zip.changes b/7zip.changes index 8b77159..41d412c 100644 --- a/7zip.changes +++ b/7zip.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Jan 12 16:45:41 UTC 2022 - Danilo Spinella + +- Replace p7zip with 7zip + * Add p7zip and p7zip.1 + +------------------------------------------------------------------- Mon Jan 3 11:31:10 UTC 2022 - Danilo Spinella - Update to version 21.07: diff --git a/7zip.spec b/7zip.spec index 23994ba..f077354 100644 --- a/7zip.spec +++ b/7zip.spec @@ -1,7 +1,7 @@ # # spec file for package 7zip # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -23,20 +23,28 @@ Release: 0 Summary: File Archivier # CPP/7zip/Compress/LzfseDecoder.cpp is under the BSD-3-Clause # C/Sha1.c and C/Sha256.c are in the public domain -License: LGPL-2.1-or-later AND BSD-3-Clause AND SUSE-Public-Domain +License: BSD-3-Clause AND LGPL-2.1-or-later AND SUSE-Public-Domain Group: Productivity/Archiving/Compression URL: https://www.7-zip.org/ Source: https://www.7-zip.org/a/7z%{stripped_version}-src.tar.xz +Source1: p7zip +Source2: p7zip.1 BuildRequires: dos2unix BuildRequires: gcc BuildRequires: gcc-c++ +Conflicts: p7zip +Conflicts: p7zip-full +Provides: p7zip = %{version} +Provides: p7zip-full = %{version} +Obsoletes: p7zip < %{version} +Obsoletes: p7zip-full < %{version} %description This package contains the 7z command line utility for archiving and extracting various formats. %prep -%__tar xaf %{SOURCE0} +tar xaf %{SOURCE0} dos2unix DOC/*.txt # Remove executable perms from docs chmod -x DOC/*.txt @@ -57,10 +65,24 @@ cd CPP/7zip//Bundles/Alone2 %install install -d -m 755 %{buildroot}%{_bindir} install -Dt %{buildroot}%{_bindir} CPP/7zip/Bundles/Alone2/b/g/7zz +# Create links the executables provided by p7zip +ln -s %{_bindir}/7zz %{buildroot}%{_bindir}/7z +ln -s %{_bindir}/7z %{buildroot}%{_bindir}/7za +ln -s %{_bindir}/7z %{buildroot}%{_bindir}/7zr +# Install p7zip wrapper and its manpage +install -m755 %{SOURCE1} %{buildroot}%{_bindir}/p7zip +install -m644 -Dt %{buildroot}%{_mandir}/man1 %{SOURCE2} +# Remove a mention of the p7zip-rar package that we don't have +sed -i 's/RAR (if the non-free p7zip-rar package is installed)//g' %{buildroot}%{_mandir}/man1/p7zip.1 %files %license DOC/copying.txt DOC/License.txt %doc DOC/readme.txt DOC/7zC.txt DOC/Methods.txt DOC/src-history.txt +%{_bindir}/7z +%{_bindir}/7za +%{_bindir}/7zr %{_bindir}/7zz +%{_bindir}/p7zip +%{_mandir}/man1/p7zip.1%{?ext_man} %changelog diff --git a/p7zip b/p7zip new file mode 100644 index 0000000..de33914 --- /dev/null +++ b/p7zip @@ -0,0 +1,225 @@ +#!/bin/sh +# gzip-like CLI wrapper for p7zip +# version 3.0 +# +# History +# 2.0 : +# - support for -filename, "file name" +# - p7zip file1 file2 ... +# 3.0 : (robert@debian.org, March 2016) +# - use 7za or 7zr, whichever one is available +# - refactor the script for better readability +# - remove `"$?" != 0 ' checks that do not work with `set -e' +# - use stderr for error reporting +# - add support for -c, -f, -k options + +set -e + +# detect 7z program to use +prg7z="`which 7za 2>/dev/null`" || \ + prg7z="`which 7zr 2>/dev/null`" || \ + { echo "$0: cannot find neither 7za nor 7zr command" >&2; exit 1; } + +# global options +f_compress=true +f_keep=false +f_force=false +f_tostdout=false + +usage() +{ + echo "Usage: $0 [options] [--] [ name ... ]" + echo "" + echo "Options:" + echo " -c --stdout --to-stdout output data to stdout" + echo " -d --decompress --uncompress decompress file" + echo " -f --force do not ask questions" + echo " -k --keep keep original file" + echo " -h --help print this help" + echo " -- treat subsequent arguments as file" + echo " names, even if they start with a dash" + echo "" + exit 0 +} + +has_7z_suffix() +{ + case "$1" in + *.7z) + return 0 + ;; + *) + return 1 + ;; + esac; +} + +make_tmp_file() +{ + P7ZIPTMP="${TMP:-/tmp}" + mktemp "${P7ZIPTMP}/p7zip.XXXXXXXX" +} + +check_not_a_tty() +{ + if ! ${f_force} && ${f_compress} && tty <&1 >/dev/null ; then + echo "$0: compressed data not written to a terminal." >&2 + echo "For help, type: $0 -h" >&2 + exit 1 + fi +} + +compress_file() +{ + file="$1" + + if ! ${f_force} && has_7z_suffix "${file}"; then + echo "$0: $file already has the 7z suffix" >&2 + exit 1 + fi + + # compress to stdout via temporary file + if ${f_tostdout}; then + check_not_a_tty + tmp="`make_tmp_file`" + trap "rm -f -- ${tmp}" 0 + rm -f -- "${tmp}" + "${prg7z}" a -si -- "${tmp}" < "${file}" >/dev/null && cat "${tmp}" || \ + { echo "$0: failed to compress data to temporary file" >&2; exit 1; } + rm -f -- "${tmp}" + return 0 + fi + + # compress to a file + if ! ${f_force} && [ -e "${file}.7z" ]; then + echo "$0: destination file ${file}.7z already exists" >&2 + exit 1 + fi + + rm -f -- "${file}.7z" + flags="" + ${f_keep} || flags="$flags -sdel" + ! ${f_force} || flags="$flags -y" + "${prg7z}" a $flags -- "${file}.7z" "${file}" || { rm -f -- "${file}.7z"; exit 1; } +} + + +decompress_file() +{ + file="$1" + + has_7z_suffix "${file}" || { echo "$0: ${file}: unknown suffix" >&2; exit 1; } + + # decompress to stdout + if ${f_tostdout}; then + # The following `| cat' pipe shouldn't be needed, however it is here to + # trick 7z not to complain about writing data to terminal. + "${prg7z}" x -so -- "${file}" | cat || exit 1 + return 0; + fi + + flags="" + ! ${f_force} || flags="$flags -y" + "${prg7z}" x $flags -- "${file}" || exit 1 + + # remove original file unless the archive contains more than one file + if ! ${f_keep} && "${prg7z}" l -- "${file}" 2>/dev/null | grep -q '^1 file,' 2>/dev/null; then + rm -f -- "${file}" + fi +} + +process_file() +{ + file="$1" + + # check if file exists and is readable + [ -r "${file}" ] || { echo "$0: cannot read ${file}" >&2; exit 1; } + + if ${f_compress}; then + compress_file "${file}" + else + decompress_file "${file}" + fi +} + +process_stdin() +{ + check_not_a_tty + + tmp="`make_tmp_file`" + trap "rm -f -- ${tmp}" 0 + + if ${f_compress}; then + + rm -f -- "${tmp}" + "${prg7z}" a -si -- "${tmp}" >/dev/null && cat -- "${tmp}" || exit 1 + + else # decompress + + cat > "${tmp}" + # The following `| cat' pipe shouldn't be needed, however it is here to + # trick 7z not to complain about writing data to terminal. + "${prg7z}" x -so -- "${tmp}" | cat || exit 1 + fi + + rm -f -- "${tmp}" +} + + +## MAIN + + +# files and flags +while [ "$#" != "0" ] ; do + case "$1" in + -c|--stdout|--to-stdout) + f_tostdout=true + ;; + -d|--decompress|--uncompress) + f_compress=false # decompressing + ;; + -f|--force) + f_force=true + ;; + -h|--help) + usage + ;; + -k|--keep) + f_keep=true + ;; + --) + shift + break + ;; + -*) + echo "$0: ignoring unknown option $1" >&2 + ;; + *) + break + ;; + esac + shift +done + + +# make sure they're present, before we screw up +for i in mktemp rm cat tty grep; do + if ! which $i >/dev/null ; then + echo "$0: $i: command not found" >&2 + exit 1 + fi +done + +if [ "$#" = 0 ]; then + # compressing/decompressing using standard I/O + process_stdin + exit 0 +fi + +# only files now +while [ "$#" != "0" ] ; do + process_file "$1" + shift +done + +exit 0 diff --git a/p7zip.1 b/p7zip.1 new file mode 100644 index 0000000..12d7057 --- /dev/null +++ b/p7zip.1 @@ -0,0 +1,79 @@ +.TH p7zip 1 "March 6th, 2016" "7-Zip" +.SH NAME +p7zip \- Wrapper on 7-Zip file archiver with high compression ratio +.SH SYNOPSIS +.B p7zip +.RB [ \-c | \-\-stdout | \-\-to\-stdout ] +.RB [ \-d | \-\-decompress | \-\-uncompress ] +.RB [ \-f | \-\-force ] +.RB [ \-h | \-\-help ] +.RB [ \-k | \-\-keep ] +.RB [ \-\- ] +.RI [ "file ..." ] +.SH DESCRIPTION +7-Zip is a file archiver supporting 7z (that implements LZMA compression algorithm +featuring very high compression ratio), LZMA2, XZ, ZIP, Zip64, CAB, +RAR (if the non-free p7zip-rar package is installed), ARJ, GZIP, BZIP2, TAR, CPIO, RPM, ISO, +most filesystem images and DEB formats. +Compression ratio in the new 7z format is 30-50% better than ratio in ZIP format. +.PP +.B p7zip +is a gzip-like CLI wrapper script for 7-Zip, and handles only the 7z format (the native +format of 7-Zip), internally executing either +.BR 7za (1) +or +.BR 7zr (1) +command. +.PP +With no switches passed in the command line, each given +.I file +argument is compressed into +.IR file.7z , +and then removed. +.PP +With the +.B \-d +switch each passed +.I file +needs to end with the +.I .7z +extension and is decompressed. After the +decompression the original +.I file +is removed unless it contained more than one archived file. +.PP +When used without any +.I file +argument, +.BR p7zip +reads data from the standard input and compresses (or decompresses in case of +.BR \-d ) +it into the standard output. +.SH SWITCHES +.TP +.BR \-c ", " \-\-stdout ", " \-\-to\-stdout +Write output on standard output. +.TP +.BR \-d ", " \-\-decompress ", " \-\-uncompress +Decompress file. +.TP +.BR \-f ", " \-\-force +Skip some checks and force compression or decompression. +.TP +.BR \-h ", " \--help +Print usage. +.TP +.BR \-k ", " \-\-keep +Do not delete input file. +.TP +.B \-\- +Treat all subsequent arguments as file names, even if they start with a dash. +.SH "SEE ALSO" +.BR 7z (1), +.BR 7za (1), +.BR 7zr (1), +.BR bzip2 (1), +.BR gzip (1), +.BR zip (1) +.SH AUTHOR +Written for Debian by Mohammed Adnene Trojette. Updated by Robert Luberda.