Skip to content

Commit

Permalink
Merge branch 'Etersoft:devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderShad authored Oct 27, 2024
2 parents 2b7a132 + 5401995 commit 41f486a
Show file tree
Hide file tree
Showing 49 changed files with 1,505 additions and 478 deletions.
17 changes: 14 additions & 3 deletions bin/distr_info
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ normalize_version3()
echo "$1" | sed -e "s|^\([^.][^.]*\.[^.][^.]*\.[^.][^.]*\)\..*|\1|"
}

is_numeric()
{
echo "$1" | grep -q "^[0-9][0-9]*$"
}


fill_distr_info()
{
Expand Down Expand Up @@ -394,11 +399,17 @@ if distro os-release ; then
#PRETTY_NAME
VENDOR_ID="$ID"
case "$VENDOR_ID" in
ubuntu|reld|rhel|astra|manjaro|redos|msvsphere|alteros)
ubuntu|reld|rhel|astra|manjaro|redos|msvsphere|alteros|rockylinux|almalinux)
;;
*)
# ID_LIKE can be 'rhel centos fedora', use latest word
[ -n "$ID_LIKE" ] && VENDOR_ID="$(echo "$ID_LIKE" | xargs -n1 | tail -n1)"
if [ -n "$ID_LIKE" ] ; then
# ID_LIKE can be 'rhel centos fedora', use first word
VENDOR_ID="$(echo "$ID_LIKE" | xargs -n1 | head -n1)"
# use latest word for versions like Fedora has
if is_numeric "$DISTRIB_RELEASE" && [ "$DISTRIB_RELEASE" -ge 20 ] ; then
VENDOR_ID="$(echo "$ID_LIKE" | xargs -n1 | tail -n1)"
fi
fi
;;
esac
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
Expand Down
21 changes: 19 additions & 2 deletions bin/epm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ load_helper()

local CMD="$SHAREDIR/$1"
# do not use fatal() here, it can be initial state
[ -r "$CMD" ] || { message 'FATAL: Have no $CMD helper file' ; exit 1; }
if [ ! -r "$CMD" ] ; then
message 'FATAL: Have no $CMD helper file'
[ "$1" = "epm-play" ] && message 'Install eepm-play package to use epm play command.'
exit 1
fi
eval "$shieldname=1"
# shellcheck disable=SC1090
. $CMD
Expand Down Expand Up @@ -153,6 +157,7 @@ pkg_options=
quoted_args=
direct_args=
ipfs=
force_overwrite=

eget_backend=$EGET_BACKEND
epm_vardir=/var/lib/eepm
Expand Down Expand Up @@ -466,6 +471,15 @@ check_command()
epm_cmd=play
direct_args=1
;;
create-fake) # HELPCMD: create fake rpm
epm_cmd=create-fake
direct_args=1
;;
desktop)
epm_cmd=desktop
direct_args=1
;;

-V|checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg
;;
Expand Down Expand Up @@ -580,6 +594,9 @@ check_option()
--no-check-certificate)
fatal "--no-check-certificate is a wget option. It is recommended never use it at all. Check the date or upgrade your system."
;;
--force-overwrite) # HELPOPT: force overwrite one package's file with another's file
force_overwrite="--force-overwrite"
;;
-*)
[ -n "$direct_args" ] && return 1
[ -n "$pkg_options" ] && pkg_options="$pkg_options $1" || pkg_options="$1"
Expand Down Expand Up @@ -648,7 +665,7 @@ if [ -n "$quiet" ] ; then
fi

# fill
export EPM_OPTIONS="$nodeps $force $verbose $debug $quiet $interactive $non_interactive $save_only $download_only"
export EPM_OPTIONS="$nodeps $force $verbose $debug $quiet $interactive $non_interactive $save_only $download_only $force_overwrite"

# if input is not console and run script from file, get pkgs from stdin too
if [ ! -n "$inscript" ] && [ -p /dev/stdin ] && [ "$EPMMODE" != "pipe" ] ; then
Expand Down
2 changes: 1 addition & 1 deletion bin/epm-Install
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ epm_Install()
local names="$(echo $pkg_names | filter_out_installed_packages)"
local files="$(echo $pkg_files | filter_out_installed_packages)"

[ -z "$files$names" ] && info "Install: Skip empty install list." && return 22
[ -z "$files$names" ] && info "Install: Empty install list was skipped." && return 22

epm_update || { [ -n "$force" ] || return ; }

Expand Down
9 changes: 5 additions & 4 deletions bin/epm-autoremove
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ Use
epm_autoremove()
{

if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] ; then
epm_autoremove_print_help
return 0
fi

case $BASEDISTRNAME in
"alt")
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] ; then
epm_autoremove_print_help
return 0
fi

if [ -z "$direct" ] ; then
[ -n "$1" ] && fatal "Run autoremove without args or with --direct. Check epm autoremove --help to available commands."
Expand Down
15 changes: 15 additions & 0 deletions bin/epm-check
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,26 @@

load_helper epm-check_updated_repo

__epm_check_container_issue_43533()
{
[ "$(epm print info -i)" = "lxc" ] || return
[ -s /etc/rpm/macros.d/container ] && return
info "Adding /sys and /proc owners workaround to /etc/rpm/macros.d/container..."
echo '%_netsharedpath /sys:/proc' | sudocmd tee /etc/rpm/macros.d/container
}


epm_check()
{
update_repo_if_needed
local APTOPTIONS="$(subst_option non_interactive -y)"
local DNFOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose --verbose) "

case $BASEDISTRNAME in
"alt")
__epm_check_container_issue_43533
esac

case $PMTYPE in
apt-rpm)
#sudocmd apt-get check || exit
Expand Down
159 changes: 159 additions & 0 deletions bin/epm-create-fake
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#!/bin/sh
#
# Copyright (C) 2017-2018, 2020 Etersoft
# Copyright (C) 2017-2018, 2020 Vitaly Lipatov <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

load_helper epm-assure
load_helper epm-repack-rpm


__create_spec() {

echo "%{!?fake_name: %global fake_name $NAME}" >> "$1"
echo "%{!?fake_version: %global fake_version $VERSION}" >> "$1"
echo "%{!?fake_release: %global fake_release $RELEASE}" >> "$1"
if [ -n "$REQUIRES" ]; then
echo "%{!?fake_requires: %global fake_requires $REQUIRES}" >> "$1"
fi
if [ -n "$PROVIDES" ]; then
echo "%{!?fake_provides: %global fake_provides $PROVIDES}" >> "$1"
fi

cat <<EOF >> "$1"
%define _rpmdir $PWD
Name: fake-%{fake_name}
Version: %{fake_version}
Release: %{fake_release}
License: CC0
Group: Other
Summary: Faked provides package
%if "%{?fake_provides}" != ""
Provides: %{fake_provides}
%endif
Provides: %{fake_name}
%if "%{?fake_requires}" != ""
Requires: %{fake_requires}
%endif
BuildArch: noarch
%description
This package is empty. It has been created to put fake entry in rpmdb.
%files
#intentionaly empty
%changelog
#intentionaly empty
EOF
}


__epm_create-fake_help()
{
message '
epm create-fake - create package with fake provides and requires. Use follow params:
--install - auto install fake package
--version=* - set package version (by default version is 0)
--release=* - set package release (by default release is 0)
--requires=* - set package requires
--provides=* - set package provides (by default package provide only it self)
Examples:
# epm create-fake --install python-somepackage
# epm create-fake --install --provides="python3dist(somepackage)" python-somepackage
# epm create-fake --install --requires=python3 --requires=python3-module python-somepackage
'
return
}

epm_create-fake()
{

VERSION=0
RELEASE=0
REQUIRES=""

for i in "$@"; do
case $i in
--version=*)
VERSION="${i#*=}"
shift # past argument
;;
--release=*)
RELEASE="${i#*=}"
shift # past argument
;;
--requires=*)
REQUIRES+=" ${i#*=}"
shift # past argument
;;
--provides=*)
PROVIDES+=" ${i#*=}"
shift # past argument
;;
--help|-h)
__epm_create-fake_help
return
;;
*)
# unknown option
;;
esac
done

NAME=$1

if [ -z "$NAME" ]; then
fatal "Error: You have to specify PACKAGE_NAME"
fi

# will set RPMBUILD
__assure_exists_rpmbuild

HOME="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
remove_on_exit $HOME
export HOME
__create_rpmmacros

tmpbuilddir=$HOME/$(basename $NAME).tmpdir
mkdir $tmpbuilddir

cd $tmpbuilddir/ || fatal

SPECFILE=${PWD}/${NAME}.spec
__create_spec "$SPECFILE"

showcmd $RPMBUILD -bb $SPECFILE
if [ -n "$verbose" ] ; then
a='' $RPMBUILD -bb $SPECFILE || fatal
else
a='' $RPMBUILD -bb $SPECFILE >/dev/null || fatal
fi

repacked_rpm="$(realpath "$tmpbuilddir/noarch/*.rpm")"
remove_on_exit "$repacked_rpm"

if [ -n "$install" ] ; then
epm install "$repacked_rpm"
fi
}
Loading

0 comments on commit 41f486a

Please sign in to comment.