Commit 9bbb2b73 authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents 37ab677a 4472df44
......@@ -33,7 +33,7 @@ rpmvendor()
[ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return
[ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return
[ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return
echo "$DISTRIB_ID" | tr "A-Z" "a-z"
echo "$DISTRIB_ID" | tr "[:lower:]"
}
# Translate DISTRIB_ID name to package manner (like in the package release name)
......@@ -46,7 +46,7 @@ pkgvendor()
# Print pkgtype (need DISTRIB_ID var)
pkgtype()
{
case `pkgvendor` in
case $(pkgvendor) in
freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;;
......@@ -86,9 +86,9 @@ DISTRIB_CODENAME=""
# Default with LSB
if distro lsb-release ; then
DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID`
DISTRIB_RELEASE=`cat $DISTROFILE | get_var DISTRIB_RELEASE`
DISTRIB_CODENAME=`cat $DISTROFILE | get_var DISTRIB_CODENAME`
DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
fi
# ALT Linux based
......@@ -96,6 +96,7 @@ if distro altlinux-release ; then
DISTRIB_ID="ALTLinux"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux t7." ; then DISTRIB_RELEASE="t7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
......@@ -120,8 +121,8 @@ if distro altlinux-release ; then
elif distro gentoo-release ; then
DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
DISTRIB_RELEASE=`basename $MAKEPROFILE`
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=`basename $(dirname $MAKEPROFILE)`
DISTRIB_RELEASE=$(basename $MAKEPROFILE)
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)")
# Slackware based
elif distro mopslinux-version ; then
......@@ -134,19 +135,22 @@ elif distro mopslinux-version ; then
fi
elif distro slackware-version ; then
DISTRIB_ID="Slackware"
DISTRIB_RELEASE="$(grep -Eo [0-9]+\.[0-9]+ $DISTROFILE)"
DISTRIB_RELEASE="$(grep -Eo '[0-9]+\.[0-9]+' $DISTROFILE)"
elif distro os-release && which apk 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="$ID"
DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which tce-ab 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="TinyCoreLinux"
DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which xbps-query 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live"
......@@ -269,32 +273,32 @@ elif distro SuSe-release || distro SuSE-release ; then
fi
# fixme: can we detect by some file?
elif [ `uname` = "FreeBSD" ] ; then
elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD"
UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g")
# fixme: can we detect by some file?
elif [ `uname` = "SunOS" ] ; then
elif [ "$(uname)" = "SunOS" ] ; then
DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file?
elif [ `uname -s 2>/dev/null` = "Darwin" ] ; then
elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
elif [ "$(uname)" = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
elif [ "$(uname)" = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then
elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all"
......
......@@ -33,6 +33,7 @@ load_helper()
local CMD="$SHAREDIR/$1"
# do not use fatal() here, it can be initial state
[ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
# shellcheck disable=SC1090
. $CMD
}
......
......@@ -46,7 +46,7 @@ case $DISTRNAME in
;;
autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "A-Z" "a-z")"
repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
esac
assure_exists apt-repo
......
......@@ -28,7 +28,7 @@ __check_command_in_path()
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas()
{
echo "$1" | egrep -q -- "$2"
echo "$1" | grep -E -q -- "$2"
}
# copied from strings
......@@ -122,5 +122,6 @@ epm_assure()
[ -n "$pkg_filenames" ] || fatal "Assure: Missing params. Check $0 --help for info."
# use helper func for extract separate params
# shellcheck disable=SC2046
__epm_assure $(eval echo $quoted_args)
}
......@@ -118,6 +118,7 @@ case $PMTYPE in
yum-rpm)
# cleanup orphanes?
while true ; do
# shellcheck disable=SC2046
docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes)
# FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-")
......
......@@ -44,6 +44,9 @@ case $PMTYPE in
docmd rpm -Va --nofiles --nodigest
;;
dnf-rpm)
sudocmd dnf check
;;
emerge)
sudocmd revdep-rebuild
;;
......
......@@ -58,11 +58,11 @@ update_repo_if_needed()
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi
cd /
cd / || fatal
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update
pkg_filenames='' epm_update
fi
cd - >/dev/null
cd - >/dev/null || fatal
}
......@@ -26,5 +26,5 @@ epm_epm_install(){
# FIXME: some way to get latest package
local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #"
pkg_names= pkg_files= pkg_urls=$download_link epm_install
pkg_names='' pkg_files='' pkg_urls="$download_link" epm_install
}
......@@ -55,13 +55,24 @@ __epm_filelist_remote()
case $PMTYPE in
apt-rpm)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach __alt_local_content_filelist $@
docmd_foreach __alt_local_content_filelist "$@"
;;
apt-dpkg)
assure_exists apt-file || return
# if sudo requires a password, skip autoupdate
sudo -n true 2>/dev/null && sudocmd apt-file update || info "sudo requires a password, skip apt-file update"
docmd_foreach __deb_local_content_filelist $@
if sudo -n true 2>/dev/null ; then
sudocmd apt-file update
else
info "sudo requires a password, skip apt-file update"
fi
docmd_foreach __deb_local_content_filelist "$@"
;;
yum-rpm)
assure_exists yum-utils || return
docmd repoquery -q -l "$@"
;;
dnf-rpm)
assure_exists dnf-plugins-core || return
docmd dnf repoquery -l "$@"
;;
*)
fatal "Query filelist for non installed packages is not implemented yet."
......@@ -156,6 +167,7 @@ epm_filelist()
__epm_filelist_file $pkg_files || return
# shellcheck disable=SC2046
__epm_filelist_name $(print_name $pkg_names) || return
}
......@@ -37,6 +37,7 @@ filter_out_installed_packages()
# sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g'
# ;;
*)
# shellcheck disable=SC2013
for i in $(cat) ; do
is_installed $i || echo $i
done
......@@ -146,14 +147,14 @@ epm_install_names()
return ;;
homebrew)
# FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@
SUDO='' __separate_sudocmd "brew install" "brew upgrade" "$@"
return ;;
ipkg)
[ -n "$force" ] && force=-force-depends
sudocmd ipkg $force install $@
return ;;
nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@
__separate_sudocmd "nix-env --install" "nix-env --upgrade" "$@"
return ;;
apk)
sudocmd apk add $@
......@@ -221,7 +222,7 @@ epm_ni_install_names()
return ;;
npackd)
# npackdcl update --package=<package> (remove old and install new)
sudocmd npackdcl add --package=$@
sudocmd npackdcl add --package="$*"
return ;;
chocolatey)
docmd chocolatey install $@
......@@ -243,7 +244,7 @@ epm_ni_install_names()
return ;;
homebrew)
# FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@
SUDO='' __separate_sudocmd "brew install" "brew upgrade" $@
return ;;
#android)
# sudocmd pm install $@
......@@ -279,7 +280,7 @@ __epm_check_if_try_install_deb()
assure_exists alien
local TDIR=$(mktemp -d)
cd $TDIR
cd $TDIR || fatal
for pkg in $debpkgs ; do
# TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k --scripts "$pkg" || fatal
......@@ -309,7 +310,7 @@ __epm_check_if_try_install_rpm()
assure_exists fakeroot
local TDIR=$(mktemp -d)
cd $TDIR
cd $TDIR || fatal
for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
......@@ -472,48 +473,48 @@ epm_print_install_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@"
echo "rpm -Uvh --force $nodeps $*"
;;
apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@"
echo "dpkg -i $*"
;;
pkgsrc)
echo "pkg_add $@"
echo "pkg_add $*"
;;
pkgng)
echo "pkg add $@"
echo "pkg add $*"
;;
emerge)
# need be placed in /usr/portage/packages/somewhere
echo "emerge --usepkg $@"
echo "emerge --usepkg $*"
;;
pacman)
echo "pacman -U --noconfirm --force $nodeps $@"
echo "pacman -U --noconfirm --force $nodeps $*"
;;
slackpkg)
echo "/sbin/installpkg $@"
echo "/sbin/installpkg $*"
;;
npackd)
echo "npackdcl add --package=$@"
echo "npackdcl add --package=$*"
;;
ipkg)
echo "ipkg install $@"
echo "ipkg install $*"
;;
android)
echo "pm install $@"
echo "pm install $*"
;;
aptcyg)
echo "apt-cyg install $@"
echo "apt-cyg install $*"
;;
tce)
echo "tce-load -wi $@"
echo "tce-load -wi $*"
;;
xbps)
echo "xbps-install -y $@"
echo "xbps-install -y $*"
;;
homebrew)
# FIXME: sudo and quote
echo "brew install $@"
echo "brew install $*"
;;
*)
......
......@@ -25,7 +25,7 @@ __repack_rpm_base()
cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal
# mask dependencies with a=
a='' db_dump Packages.BACKUP | a= db_load Packages || fatal
a='' db_dump Packages.BACKUP | a='' db_load Packages || fatal
rm Packages.BACKUP
}
......
......@@ -222,6 +222,8 @@ epm_print()
{
[ -n "$pkg_filenames" ] || fatal "Missed args. Use epm print help for get help."
__epm_print "$(eval echo $quoted_args)"
# Note! do not quote args below (see eterbug #11863)
# shellcheck disable=SC2046
__epm_print $(eval echo $quoted_args)
}
......@@ -33,7 +33,7 @@ epm_programs()
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find $DESKTOPDIR -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u"
find $DESKTOPDIR -type f -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u
showcmd "find $DESKTOPDIR -type f -print0 -name "*.desktop" | xargs -0 $0 -qf --quiet --short | sort -u"
find $DESKTOPDIR -type f -print0 -name "*.desktop" | \
xargs -0 $0 -qf --quiet --short | sort -u
}
......@@ -22,7 +22,7 @@ load_helper epm-print
epm_provides_files()
{
local pkg_files="$@"
local pkg_files="$*"
[ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)"
......@@ -46,7 +46,7 @@ epm_provides_files()
epm_provides_names()
{
local pkg_names="$@"
local pkg_names="$*"
local CMD
[ -n "$pkg_names" ] || return
......@@ -106,5 +106,6 @@ epm_provides()
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files $pkg_files
# shellcheck disable=SC2046
epm_provides_names $(print_name $pkg_names)
}
......@@ -180,7 +180,7 @@ __epm_query_name()
return
;;
npackd)
docmd "npackdcl path --package=$@"
docmd "npackdcl path --package=$1"
return
;;
conary)
......@@ -226,7 +226,7 @@ __epm_query_shortname()
return
;;
npackd)
docmd "npackdcl path --package=$@"
docmd "npackdcl path --package=$1"
return
;;
conary)
......@@ -270,7 +270,7 @@ separate_installed()
{
pkg_installed=
pkg_noninstalled=
for i in $* ; do
for i in "$@" ; do
is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i"
done
}
......@@ -282,8 +282,10 @@ epm_query()
__epm_query_file $pkg_files || return
if [ -n "$short" ] ; then
# shellcheck disable=SC2046
__epm_query_shortname $(print_name $pkg_names) || return
else
# shellcheck disable=SC2046
__epm_query_name $(print_name $pkg_names) || return
fi
}
......@@ -63,7 +63,7 @@ __do_query_real_file()
dpkg_print_name_version()
{
local ver i
for i in $* ; do
for i in "$@" ; do
ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g")
if [ -z "$ver" ] ; then
echo "$i"
......@@ -82,8 +82,8 @@ __do_query()
CMD="rpm -qf"
;;
*-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
showcmd dpkg -S "$1"
dpkg_print_name_version "$(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")"
return ;;
yum-rpm|dnf-rpm|urpm-rpm)
CMD="rpm -qf"
......@@ -138,8 +138,8 @@ __do_short_query()
CMD="rpm -qf --queryformat %{NAME}\n"
;;
NOapt-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")
showcmd dpkg -S "$1"
dpkg_print_name_version "$(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")"
return ;;
NOemerge)
assure_exists equery
......
......@@ -22,7 +22,7 @@ load_helper epm-search
__epm_query_package()
{
pkg_filenames="$@" quoted_args="$@" quiet=1 epm_query_package
pkg_filenames="$*" quoted_args="$*" quiet=1 epm_query_package
}
epm_query_package()
......
#!/bin/sh
#
# Copyright (C) 2013, 2016 Etersoft
# Copyright (C) 2013, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2013, 2016, 2017 Etersoft
# Copyright (C) 2013, 2016, 2017 Vitaly Lipatov <lav@etersoft.ru>
#
# 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
......@@ -37,10 +37,10 @@ __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" \
| grep "[tp][5-9]/branch/" \
| sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \
| sort -u )
if [ $(__wcount $BRD) = "1" ] ; then
if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD"
return
fi
......@@ -50,7 +50,7 @@ __detect_alt_release_by_repo()
| grep "Sisyphus/" \
| sed -e "s|.*\(Sisyphus\).*|\1|g" \
| sort -u )
if [ $(__wcount $BRD) = "1" ] ; then
if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD"
return
fi
......@@ -63,9 +63,9 @@ __replace_alt_version_in_repo()
local i
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"
docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | grep -E --color -- "$1"
# ask and replace only we will have changes
if a='' apt-repo list | egrep -q -- "$1" ; then
if a='' apt-repo list | grep -E -q -- "$1" ; then
confirm "Are these correct changes? [y/N]" || fatal "Exiting"
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi
......@@ -77,7 +77,7 @@ __alt_repofix()
load_helper epm-repofix
showcmd epm repofix
quiet=1 pkg_filenames='' epm_repofix >/dev/null
__replace_text_in_alt_repo "/^ *#/! s!\[p[6-9]\]![updates]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[[tp][6-9]\]![updates]!g"
}
get_fix_release_pkg()
......@@ -90,25 +90,26 @@ get_fix_release_pkg()
__update_to_the_distro()
{
local TO="$1"
__alt_repofix
case "$1" in
case "$TO" in
p7)
docmd epm update || fatal
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p7) || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![p7]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
p8)
docmd epm update || fatal
if ! docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p8) ; then
if ! docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" ; then
# Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1
docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p8) || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
fi
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![p8]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal
......@@ -126,48 +127,53 @@ __update_to_the_distro()
__update_alt_to_next_distro()
{
local FROMTO=$(echo "$*" | sed -e "s| | to |")
local TO=""
local FROM="$1"
info
case "$*" in
"p6"|"p6 p7")
info "Upgrade $DISTRNAME from p6 to p7 ..."
"p6"|"p6 p7"|"t6 p7")
TO="p7"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
__replace_alt_version_in_repo p6/branch/ p7/branch/
__update_to_the_distro p7
__replace_alt_version_in_repo "$FROM/branch/" "$TO/branch/"
__update_to_the_distro "$TO"
docmd epm update-kernel
info "Done."
info "Run epm release-upgrade again for update to p8"
;;
"p7"|"p7 p8")
info "Upgrade $DISTRNAME from p7 to p8 ..."
docmd epm install apt-conf-branch $(get_fix_release_pkg p7) || fatal
__replace_alt_version_in_repo p7/branch/ p8/branch/
__update_to_the_distro p8
"p7"|"p7 p8"|"t7 p8")
TO="p8"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
docmd epm update-kernel || fatal
info "Done."
;;
"Sisyphus p8")
info "Downgrade $DISTRNAME from Sisyphus to p8 ..."
TO="p8"
info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
__replace_alt_version_in_repo Sisyphus/ p8/branch/
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![p8]!g"
__update_to_the_distro p8
__replace_alt_version_in_repo "$FROM/" "$FROM/branch/"
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
info "Done."
;;
"p8 Sisyphus")
info "Upgrade $DISTRNAME from p8 to Sisyphus ..."
TO="Sisyphus"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
docmd epm upgrade || fatal
__replace_alt_version_in_repo p8/branch/ Sisyphus/
__replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![alt]!g"
__update_to_the_distro Sisyphus
__update_to_the_distro $TO
docmd epm update-kernel || fatal
info "Done."
;;
*)
warning "Have no idea how to update from $DISTRNAME $DISTRVERSION."
warning "Have no idea how to update from $DISTRNAME $FROM to $DISTRNAME $TO."
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
......
......@@ -29,6 +29,7 @@ epm_remove_low()
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg|aptitude-dpkg)
# shellcheck disable=SC2046
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
return ;;
pkgsrc)
......@@ -102,7 +103,7 @@ epm_remove_names()
sudocmd conary erase $@
return ;;
npackd)
sudocmd npackdcl remove --package=$@
sudocmd npackdcl remove --package=$1
return ;;
nix)
sudocmd nix-env --uninstall $@
......@@ -132,6 +133,7 @@ epm_remove_names()
sudocmd xbps remove -R $@
return ;;
ipkg)
# shellcheck disable=SC2046
sudocmd ipkg $(subst_option force -force-depends) remove $@
return ;;
*)
......@@ -185,34 +187,34 @@ epm_print_remove_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@"
echo "rpm -ev $nodeps $*"
;;
apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@"
echo "dpkg -P $*"
;;
pkgsrc)
echo "pkg_delete -r $@"
echo "pkg_delete -r $*"
;;
pkgng)
echo "pkg delete -R $@"
echo "pkg delete -R $*"
;;
pacman)
echo "pacman -R $@"
echo "pacman -R $*"
;;
emerge)
echo "emerge --unmerge $@"
echo "emerge --unmerge $*"
;;
slackpkg)
echo "/sbin/removepkg $@"
echo "/sbin/removepkg $*"
;;
ipkg)
echo "ipkg remove $@"
echo "ipkg remove $*"
;;
aptcyg)
echo "apt-cyg remove $@"
echo "apt-cyg remove $*"
;;
xbps)
echo "xbps remove -y $@"
echo "xbps remove -y $*"
;;
*)
fatal "Have no suitable appropriate remove command for $PMTYPE"
......
......@@ -27,7 +27,7 @@ case $DISTRNAME in
autoimports)
info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "A-Z" "a-z")"
repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
;;
esac
......
......@@ -49,7 +49,7 @@ __try_fix_apt_source_list()
__fix_apt_sources_list()
{
# for beauty spaces
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'
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local i
assure_root
for i in "$@" ; do
......
......@@ -22,7 +22,7 @@ load_helper epm-print
epm_requires_files()
{
local pkg_files="$@"
local pkg_files="$*"
[ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)"
......@@ -128,5 +128,6 @@ epm_requires()
{
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files $pkg_files
# shellcheck disable=SC2046
epm_requires_names $(print_name $pkg_names)
}
......@@ -90,7 +90,7 @@ case $PMTYPE in
CMD="xbps-query -Ro"
;;
aptcyg)
docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g")
docmd apt-cyg searchall "$(echo " $pkg_filenames" | sed -e "s| /| |g")"
return
;;
*)
......
......@@ -38,7 +38,7 @@ get_local_alt_mirror_path()
__local_ercat()
{
local i
for i in $* ; do
for i in "$@" ; do
case "$i" in
*.xz)
a='' xzcat $i
......@@ -106,7 +106,7 @@ get_local_alt_contents_index()
local LOCALPATH
epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read URL ARCH other ; do
epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read -r URL ARCH other ; do
LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH")
download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 || continue
echo "$LOCALPATH/contents_index*"
......
......@@ -48,7 +48,7 @@ check_tty()
# egrep from busybox may not --color
# egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then
if grep -E --help 2>&1 | grep -q -- "--color" ; then
export EGREPCOLOR="--color"
fi
......@@ -89,7 +89,7 @@ echover()
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
/bin/echo -n "$*"
}
......@@ -109,7 +109,7 @@ showcmd()
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
echo " $PROMTSIG $*"
restore_color
fi >&2
}
......@@ -117,7 +117,7 @@ showcmd()
# Print command line and run command line
docmd()
{
showcmd "$@$EXTRA_SHOWDOCMD"
showcmd "$*$EXTRA_SHOWDOCMD"
#FIXME
$@
}
......@@ -137,7 +137,7 @@ docmd_foreach()
# Print command line and run command line with SUDO
sudocmd()
{
showcmd "$SUDO $@"
showcmd "$SUDO $*"
$SUDO $@
}
......@@ -170,11 +170,10 @@ get_firstarg()
get_lastarg()
{
local lastarg
eval lastarg=\${$#}
eval "lastarg=\${$#}"
echon "$lastarg"
}
filter_strip_spaces()
{
# possible use just
......@@ -202,7 +201,7 @@ store_output()
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp)
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
return "$(cat $CMDSTATUS)"
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS
......@@ -230,7 +229,7 @@ epm()
fatal()
{
if [ -z "$TEXTDOMAIN" ] ; then
echo "Error: $@" >&2
echo "Error: $*" >&2
# else
# echog "Error in $0: $@" >&2
fi
......@@ -241,7 +240,7 @@ fatal()
warning()
{
if [ -z "$TEXTDOMAIN" ] ; then
echo "Warning: $@" >&2
echo "Warning: $*" >&2
# else
# echog "Error in $0: $@" >&2
fi
......@@ -254,9 +253,9 @@ info()
# print message to stderr if stderr forwarded to (a file)
if isatty2 ; then
isatty || return 0
echo "$@"
echo "$*"
else
echo "$@" >&2
echo "$*" >&2
fi
}
......@@ -270,7 +269,7 @@ set_sudo()
return
fi
EFFUID=`id -u`
EFFUID=$(id -u)
# do not need sudo
[ $EFFUID = "0" ] && return
......@@ -414,7 +413,7 @@ get_help()
return
fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
grep -v -- "^#" $0 | grep -- "# $1" | while read -r n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g")
printf " %-20s %s\n" $opt "$desc"
......@@ -525,5 +524,6 @@ is_active_systemd()
a='' mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return
# some hack
# shellcheck disable=SC2009
ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
}
......@@ -145,7 +145,11 @@ epm_simulate()
_epm_do_simulate $filenames
local RES=$?
if [ -z "$quiet" ] ; then
[ "$RES" = 0 ] && info "Simulate result: $filenames package(s) CAN BE installed" || info "Simulate result: There are PROBLEMS with install some package(s)"
if [ "$RES" = 0 ] ; then
info "Simulate result: $filenames package(s) CAN BE installed"
else
info "Simulate result: There are PROBLEMS with install some package(s)"
fi
fi
return $RES
}
......
......@@ -35,7 +35,7 @@ get_pao_var()
{
local FIELD="$1"
#grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g'
$SHAREDIR/tools_json -b | egrep "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
$SHAREDIR/tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
return 0
}
......
......@@ -94,6 +94,7 @@ epm_upgrade()
CMD="guix package -u"
;;
aptcyg)
# shellcheck disable=SC2046
docmd_foreach "epm install" $(short=1 epm packages)
return
;;
......
......@@ -70,7 +70,7 @@ create_fake_files()
DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES"
print_files | while read line ; do
print_files | while read -r line ; do
touch $DIRALLFILES/$(basename "$line")
done
}
......
......@@ -5,6 +5,11 @@
EXCL=-eSC2086,SC2039,SC2034,SC2068,SC2155
# TODO:
# SC2154: pkg_filenames is referenced but not assigned.
# SC2002: Useless cat.
EXCL="$EXCL,SC2154,SC2002"
if [ -n "$1" ] ; then
shellcheck $EXCL "$1"
exit
......
# This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 2.0.8
Version: 2.1.0
Release: alt0.M80P.1
Summary: Etersoft EPM package manager
......@@ -68,9 +68,19 @@ chmod a+x %buildroot%_datadir/%name/tools_*
%_sysconfdir/bash_completion.d/cerv
%changelog
* Thu Jun 15 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.8-alt0.M80P.1
* Sun Jul 23 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.0-alt0.M80P.1
- backport to ALTLinux p8 (by rpmbph script)
* Sat Jul 22 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.0-alt1
- fix quotes (eterbug #11863)
- make shellcheck happy
- check_code.sh: skip global vars
* Fri Jul 21 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.9-alt1
- epm-filelist: add support with yum and dnf
- imlrement check for dnf via dnf check
- add support for ALT Linux t7
* Thu Jun 15 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.8-alt1
- make shellcheck more happy
- improve epm query
......
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