3
# Copyright (C) 2017-2018, 2020 Etersoft
4
# Copyright (C) 2017-2018, 2020 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
load_helper epm-sh-altlinux
24
[ -n "$EPM_REPACK_SCRIPTS_DIR" ] || EPM_REPACK_SCRIPTS_DIR="$CONFIGDIR/repack.d"
26
__epm_have_repack_rule()
28
# skip repacking on non ALT systems
29
[ "$BASEDISTRNAME" = "alt" ] || return 1
33
# skip for packages built with repack
34
epm_status_repacked "$i" && return 1
36
# FIXME: use real way (for any archive)
37
local pkgname="$(epm print name for package "$i")"
38
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$pkgname.sh"
39
[ -s "$repackcode" ] || return 1
44
__epm_check_if_needed_repack()
46
__epm_have_repack_rule "$@" || return
47
local pkgname="$(epm print name for package "$1")"
48
warning "There is repack rule for '$pkgname' package. It is better install this package via 'epm install --repack' or 'epm play'."
52
# fills split_replaced_pkgs with packages of that type
53
__epm_split_by_pkg_type()
58
split_replaced_pkgs=''
61
[ "$(get_package_type "$pkg")" = "$type" ] || return 1
62
[ -e "$pkg" ] || fatal "Can't read $pkg"
63
split_replaced_pkgs="$split_replaced_pkgs $pkg"
66
[ -n "$split_replaced_pkgs" ]
73
local alf="$CONFIGDIR/repackstoplist.list"
74
[ -s "$alf" ] || return 1
75
[ -n "$pkg" ] || return 1
76
grep -E -q "^$1$" $alf
82
# alpkg - resulted package file name in the current dir
83
# SUBGENERIC - name of generic file's extension
84
__prepare_source_package()
88
alpkg=$(basename $pkg)
90
# TODO: use func for get name from deb pkg
91
# TODO: epm print name from deb package
92
# TODO: use stoplist only for deb?
93
[ -z "$force" ] && __check_stoplist $(echo $alpkg | sed -e "s|_.*||") && fatal "Please use official package instead of $alpkg repacking (It is not recommended to use --force to skip this checking."
97
if rhas "$alpkg" "\.(rpm|deb)$" ; then
98
# skip packing for supported directly: rpm and deb
102
# convert tarballs to tar (for alien)
105
# they will fill $returntarname
106
if rhas "$alpkg" "\.AppImage$" ; then
107
__epm_pack_run_handler generic-appimage "$pkg"
108
SUBGENERIC='appimage'
109
elif rhas "$alpkg" "\.snap$" ; then
110
__epm_pack_run_handler generic-snap "$pkg"
113
__epm_pack_run_handler generic-tar "$pkg"
117
# it is possible there are a few files, we don't support it
118
[ -s "$returntarname" ] || fatal "Can't read result from pack: '$returntarname' is not a readable file."
120
alpkg=$(basename $returntarname)
121
# FIXME: looks like a hack with current dir
122
if [ "$(pwd)" != "$(dirname "$returntarname")" ] ; then
123
cp $verbose $returntarname $alpkg
124
[ -r "$returntarname.eepm.yaml" ] && cp $verbose $returntarname.eepm.yaml $alpkg.eepm.yaml
130
# FIXME: Нужно как-то обеспечить непродолжение выполнения.
138
load_helper epm-repack-rpm
139
__epm_repack_to_rpm "$@" || return
142
# FIXME: only one package in $@ is supported
143
#local pkgname="$(epm print name from "$@")"
144
#__set_version_pkgname "$1"
145
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$PKGNAME.sh"
146
if [ -x "$repackcode" ] ; then
147
load_helper epm-repack-rpm
148
load_helper epm-repack-deb
149
__epm_repack_to_rpm "$@" || return
150
[ -n "$repacked_pkgs" ] || return
151
__epm_repack_to_deb $repacked_pkgs
153
load_helper epm-repack-deb
154
__epm_repack_to_deb "$@" || return
158
fatal "$PKGFORMAT is not supported for repack yet"
165
__epm_repack_if_needed()
167
# return 1 if there is a package in host package format
168
__epm_split_by_pkg_type $PKGFORMAT "$@" && return 1
176
# if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
177
if [ -n "$pkg_urls" ] ; then
178
load_helper epm-download
179
__handle_pkg_urls_to_install
182
[ -n "$pkg_names" ] && warning "Can't find $pkg_names files"
183
[ -z "$pkg_files" ] && info "Skip empty repack list" && return 22
185
if __epm_repack $pkg_files && [ -n "$repacked_pkgs" ] ; then
186
if [ -n "$install" ] ; then
187
epm install $repacked_pkgs
191
cp $repacked_pkgs "$EPMCURDIR"
192
if [ -z "$quiet" ] ; then
194
echo "Adapted packages:"
195
for i in $repacked_pkgs ; do
196
echo " $EPMCURDIR/$(basename "$i")"