Commit b8401c9e authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to p8 as 1.8.4-alt0.M80P.1 (with rpmbph script)

parents 2b53de67 3be9c684
......@@ -19,6 +19,9 @@
PROGDIR=$(dirname $0)
[ "$PROGDIR" = "." ] && PROGDIR=$(pwd)
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
PROGDIR=""
fi
# will replaced to /usr/share/eepm during install
SHAREDIR=$PROGDIR
......@@ -364,8 +367,8 @@ for opt in "$@" ; do
check_filenames $opt
done
# if input is not console, get pkg from it too
if ! inputisatty ; then
# if input is not console and run script from file, get pkgs from stdin too
if ! inputisatty && [ -n "$PROGDIR" ] ; then
for opt in $(withtimeout 1 cat) ; do
check_filenames $opt
done
......
......@@ -34,7 +34,9 @@ case $PMTYPE in
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts
echo "We will try remove all installed packages which are missed in repositories"
warning "Use with caution!"
local PKGLIST=$(__epm_orphan_altrpm | sed -e "s/\.32bit//g" | grep -v -- "^kernel")
local PKGLIST=$(__epm_orphan_altrpm \
| sed -e "s/\.32bit//g" \
| grep -v -- "^kernel")
docmd epm remove $PKGLIST
;;
apt-dpkg|aptitude-dpkg)
......
......@@ -32,11 +32,11 @@ __epm_autoremove_altrpm()
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -- "$libexclude" | \
grep -E -v -- "-(devel|debuginfo)$" | \
grep -E -v -- "-(util|tool|plugin|daemon)" | \
sed -e "s/\.32bit$//g" | \
grep -E -v -- "^(libsystemd|libreoffice|libnss)" )
pkgs=$(apt-cache list-nodeps | grep -- "$libexclude" \
| grep -E -v -- "-(devel|debuginfo)$" \
| grep -E -v -- "-(util|tool|plugin|daemon)" \
| sed -e "s/\.32bit$//g" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss)" )
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
info "Removing unused python/perl modules..."
......
......@@ -17,8 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
etersoft_updates_site="http://updates.etersoft.ru/pub/Etersoft/Sisyphus/$($DISTRVENDOR -e)/"
download_dir="/tmp"
myinit(){
etersoft_updates_site="http://updates.etersoft.ru/pub/Etersoft/Sisyphus/$($DISTRVENDOR -e)/"
download_dir="/tmp"
}
download_epm(){
download_link=$etersoft_updates_site$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #"
......@@ -27,6 +29,7 @@ download_epm(){
}
epm_epm_install(){
myinit
download_epm || fatal "Error. Check download link: $download_link"
epm i $eepm_package || fatal
rm -fv $eepm_package
......
......@@ -101,7 +101,7 @@ epm_install_names()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get $APTOPTIONS install $@
sudocmd apt-get $APTOPTIONS $noremove install $@
return ;;
aptitude-dpkg)
sudocmd aptitude install $@
......@@ -188,7 +188,7 @@ epm_ni_install_names()
case $PMTYPE in
apt-rpm|apt-dpkg)
export DEBIAN_FRONTEND=noninteractive
sudocmd apt-get -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
sudocmd apt-get -y $noremove --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;;
aptitude-dpkg)
sudocmd aptitde -y install $@
......@@ -256,6 +256,58 @@ __epm_check_if_rpm_already_installed()
LANG=C $SUDO rpm -Uvh $force $nodeps $@ 2>&1 | grep -q "is already installed"
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_deb()
{
local pkg
local debpkgs=""
for pkg in $@ ; do
[ "$(get_package_type "$pkg")" = "deb" ] || return 1
[ -e "$pkg" ] || fatal "Can't read $pkg"
debpkgs="$debpkgs $(realpath $pkg)"
done
[ -n "$debpkgs" ] || return 1
assure_exists alien
local TDIR=$(mktemp -d)
cd $TDIR
for pkg in $debpkgs ; do
showcmd alien -r -k --scripts "$pkg"
# TODO: need check for return status
done
rm -f $TDIR/*
rmdir $TDIR/
return 0
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_rpm()
{
local pkg
local rpmpkgs=""
for pkg in $@ ; do
[ "$(get_package_type "$pkg")" = "rpm" ] || return 1
[ -e "$pkg" ] || fatal "Can't read $pkg"
rpmpkgs="$rpmpkgs $(realpath $pkg)"
done
[ -n "$rpmpkgs" ] || return 1
assure_exists alien
local TDIR=$(mktemp -d)
cd $TDIR
for pkg in $rpmpkgs ; do
showcmd alien -d -k --scripts "$pkg"
# TODO: need check for return status
done
rm -f $TDIR/*
rmdir $TDIR/
return 0
}
epm_install_files()
{
......@@ -267,6 +319,8 @@ epm_install_files()
case $PMTYPE in
apt-rpm)
__epm_check_if_try_install_deb $@ && return
sudocmd rpm -Uvh $force $nodeps $@ && return
local RES=$?
......@@ -277,11 +331,15 @@ epm_install_files()
# use install_names
;;
apt-dpkg|aptitude-dpkg)
# the new version of the conf. file is installed with a .dpkg-dist suffix
if [ -n "$non_interactive" ] ; then
DPKGOPTIONS="--force-confdef --force-confold"
fi
__epm_check_if_try_install_rpm $@ && return
# FIXME: return false in case no install and in case install with broken deps
sudocmd dpkg $DPKGOPTIONS -i $@
local RES=$?
......@@ -296,7 +354,10 @@ epm_install_files()
sudocmd dpkg $DPKGOPTIONS -i $@
return
;;
yum-rpm|dnf-rpm)
__epm_check_if_try_install_deb $@ && return
sudocmd rpm -Uvh $force $nodeps $@ && return
# if run with --nodeps, do not fallback on hi level
......@@ -306,7 +367,9 @@ epm_install_files()
YUMOPTIONS=--nogpgcheck
# use install_names
;;
zypper-rpm)
__epm_check_if_try_install_deb $@ && return
sudocmd rpm -Uvh $force $nodeps $@ && return
local RES=$?
......@@ -318,7 +381,9 @@ epm_install_files()
ZYPPEROPTIONS=$(__use_zypper_no_gpg_checks)
# use install_names
;;
urpm-rpm)
__epm_check_if_try_install_deb $@ && return
sudocmd rpm -Uvh $force $nodeps $@ && return
local RES=$?
......
......@@ -39,7 +39,9 @@ print_binpkgfilelist()
local PKGNAME=$(basename "$2")
find "$PKGDIR" ! -name '*\.src\.rpm' -name '*\.rpm' -execdir \
rpmquery -p --qf='%{sourcerpm}\t%{name}-%{version}-%{release}.%{arch}.rpm\n' "{}" \; \
| grep "^$PKGNAME[[:space:]].*" | cut -f2 | xargs -n1 -I "{}" echo -n "$PKGDIR/{} "
| grep "^$PKGNAME[[:space:]].*" \
| cut -f2 \
| xargs -n1 -I "{}" echo -n "$PKGDIR/{} "
}
# TODO: need try detect more strict
......
......@@ -146,6 +146,16 @@ __epm_query_file()
docmd $CMD $@
}
# hack: dpkg -W will print names for removed packages too (until newest Ubuntu)
__epm_query_dpkg_check()
{
local i
for i in $@ ; do
a= dpkg -s $i >/dev/null 2>/dev/null || return
done
return 0
}
__epm_query_name()
{
local CMD
......@@ -158,7 +168,10 @@ __epm_query_name()
;;
*-dpkg)
#docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
#CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
docmd dpkg-query -W "--showformat=\${Package}-\${Version}\n" $@ || return
__epm_query_dpkg_check $@ || return
return
;;
npackd)
docmd "npackdcl path --package=$@"
......@@ -197,7 +210,10 @@ __epm_query_shortname()
CMD="rpm -q --queryformat %{name}\n"
;;
*-dpkg)
CMD="dpkg-query -W --showformat=\${Package}\n"
#CMD="dpkg-query -W --showformat=\${Package}\n"
docmd dpkg-query -W "--showformat=\${Package}\n" $@ || return
__epm_query_dpkg_check $@ || return
return
;;
npackd)
docmd "npackdcl path --package=$@"
......@@ -228,7 +244,7 @@ __epm_query_shortname()
# check if pkg is installed
is_installed()
{
short=1 pkg_filenames="$@" pkg_names="$@" epm_query >/dev/null 2>/dev/null
__epm_query_shortname $pkg_names >/dev/null 2>/dev/null
# broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
}
......
......@@ -35,15 +35,21 @@ __wcount()
__detect_alt_release_by_repo()
{
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list | \
grep -v "^#" | grep "p[5-9]/branch/" | sed -e "s|.*\(p[5-9]\)/branch.*|\1|g" | sort -u )
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \
| grep "p[5-9]/branch/" \
| sed -e "s|.*\(p[5-9]\)/branch.*|\1|g" \
| sort -u )
if [ $(__wcount $BRD) = "1" ] ; then
echo "$BRD"
return
fi
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list | \
grep -v "^#" | grep "Sisyphus/" | sed -e "s|.*\(Sisyphus\).*|\1|g" | sort -u )
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \
| grep "Sisyphus/" \
| sed -e "s|.*\(Sisyphus\).*|\1|g" \
| sort -u )
if [ $(__wcount $BRD) = "1" ] ; then
echo "$BRD"
return
......@@ -58,8 +64,11 @@ __replace_alt_version_in_repo()
assure_exists apt-repo
#echo "Upgrading $DISTRNAME from $1 to $2 ..."
docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | egrep --color -- "$1"
confirm "Are these correct changes? [y/N]" || fatal "Exiting"
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
# ask and replace only we will have changes
if apt-repo list | egrep -q -- "$1" ; then
confirm "Are these correct changes? [y/N]" || fatal "Exiting"
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi
docmd apt-repo list
}
......@@ -160,6 +169,7 @@ __update_alt_to_next_distro()
*)
warning "Have no idea how to update from $DISTRNAME $DISTRVERSION."
info "Try run f.i. # epm release-upgrade p8 or # epm release-upgrade Sisyphus"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
return 1
esac
}
......
......@@ -19,6 +19,16 @@
load_helper epm-query
__repofix_check_vendor()
{
local i
for i in /etc/apt/vendors.list.d/*.list; do
[ -e "$i" ] || continue
grep -q "^simple-key \"$1\"" $i && return
done
return 1
}
__fix_apt_sources_list()
{
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|p6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
......@@ -31,15 +41,34 @@ __fix_apt_sources_list()
#sed -i -r -e "$SUBST_ALT_RULE" $i
regexp_subst "/^ *#/! $SUBST_ALT_RULE" $i
# add signs
# Sisyphus uses 'alt' vendor key
if __repofix_check_vendor alt ; then
regexp_subst "/ALTLinux\/Sisyphus\//s/^rpm *([fhr])/rpm [alt] \1/" $i
else
warning "Skip set alt vendor key (it misssed)"
fi
# skip branch replacement for ALT Linux Sisyphus
[ "$DISTRVERSION" = "Sisyphus" ] && continue
# add signs for branches
local br
for br in $DISTRVERSION ; do
if ! __repofix_check_vendor $br ; then
warning "Skip set $br vendor key (it misssed)"
continue
fi
regexp_subst "/ALTLinux\/$br\/branch/s/^rpm *([fhr])/rpm [$br] \1/" $i
if is_installed apt-conf-etersoft-common ; then
regexp_subst "/Etersoft\/$br\/branch/s/^rpm *([fhr])/rpm [etersoft] \1/" $i
done
for br in $DISTRVERSION ; do
#if is_installed apt-conf-etersoft-common ; then
if ! __repofix_check_vendor etersoft ; then
warning "Skip set etersoft vendor key (it misssed)"
continue
fi
regexp_subst "/Etersoft\/$br\/branch/s/^rpm *([fhr])/rpm [etersoft] \1/" $i
done
regexp_subst "/ALTLinux\/Sisyphus\//s/^rpm *([fhr])/rpm [alt] \1/" $i
done
}
......
......@@ -261,7 +261,12 @@ set_sudo()
[ $EFFUID = "0" ] && return
# use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo --" && return
if which sudo >/dev/null 2>/dev/null ; then
SUDO="sudo --"
# check for < 1.7 version which do not support --
sudo --help | grep -q " --" || SUDO="sudo"
return
fi
SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
......@@ -389,6 +394,10 @@ get_package_type()
# print options description from HELPCMD/HELPOPT lines in the code
get_help()
{
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
return
fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g")
......
# This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 1.8.3
Version: 1.8.4
Release: alt0.M80P.1
Summary: Etersoft EPM package manager
......@@ -67,9 +67,19 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%changelog
* Mon May 23 2016 Vitaly Lipatov <lav@altlinux.ru> 1.8.3-alt0.M80P.1
* Mon May 30 2016 Vitaly Lipatov <lav@altlinux.ru> 1.8.4-alt0.M80P.1
- backport to ALTLinux p8 (by rpmbph script)
* Mon May 30 2016 Vitaly Lipatov <lav@altlinux.ru> 1.8.4-alt1
- epm install: add initial support for cross install packages (deb/rpm packages on rpm/deb-based hosts)
- install: add --noremove support for apt
- repofix: add check for vendor key if set it
- add check if sudo supports --
- repofix: skip useless Sisyphus replacements
- release_upgrade: skip confirm if there are no changes
- epm-query: add semihack for check removed packages
- epm: add support for run script from stdin
* Mon May 23 2016 Vitaly Lipatov <lav@altlinux.ru> 1.8.3-alt1
- autoorphans: do real removing
- autoremove: add update-kernel version 0.9.9 checking
......
......@@ -41,7 +41,7 @@ get_version()
filter_out()
{
grep -v "^ *load_helper " | sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \
grep -v "^[ ]*load_helper " | sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \
sed -e "s|@VERSION@|$(get_version)|g"
}
......
......@@ -258,7 +258,12 @@ set_sudo()
[ $EFFUID = "0" ] && return
# use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo --" && return
if which sudo >/dev/null 2>/dev/null ; then
SUDO="sudo --"
# check for < 1.7 version which do not support --
sudo --help | grep -q " --" || SUDO="sudo"
return
fi
SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
......@@ -326,7 +331,6 @@ regexp_subst()
assure_exists()
{
load_helper epm-assure
local package="$2"
local textpackage=
[ -n "$package" ] || package="$(__get_package_for_command "$1")"
......@@ -379,6 +383,10 @@ get_package_type()
get_help()
{
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
return
fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g")
......@@ -578,8 +586,6 @@ serv_list()
sudocmd systemctl list-units $@
;;
*)
load_helper serv-list_all
load_helper serv-status
for i in $(serv_list_all) ; do
is_service_running $i >/dev/null && echo $i
done
......@@ -614,8 +620,6 @@ serv_list_startup()
{
case $SERVICETYPE in
*)
load_helper serv-list_all
load_helper serv-status
for i in $(serv_list_all | cut -f 1 -d" " | grep "\.service$") ; do
is_service_autostart >/dev/null $i && echo $i
done
......@@ -1237,7 +1241,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.8.2"
echo "Service manager version 1.8.4"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013, 2016"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment