Commit 65d6bae9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to p8 as 3.4.0-alt1.M80P.2 (with rpmbph script)

parents d35fa63b 035e692a
......@@ -2,6 +2,9 @@
epme вызывает apt-get remove для пакетов, которых нет при удалении через rpm
yum versionlock - сравнить/обобщить
https://itfb.com.ua/kak-zablokirovat-obnovlenie-odnogo-iz-paketov-ili-ispolzuem-yum-versionlock/
apt-mark (для работы autoremove and autoorphans) - помечать то, что удалять не следует
apt-mark hold unhold showhold auto manual showauto showmanual
......
#!/bin/sh
# 2007-2019 (c) Vitaly Lipatov <lav@etersoft.ru>
# 2007-2019 (c) Etersoft
# 2007-2019 Public domain
# 2007-2020 (c) Vitaly Lipatov <lav@etersoft.ru>
# 2007-2020 (c) Etersoft
# 2007-2020 Public domain
# You can set ROOTDIR to root system dir
#ROOTDIR=
PROGVERSION="20201010"
# TODO: check /etc/system-release
# Check for DISTRO specific file in /etc
......@@ -121,11 +123,14 @@ if distro altlinux-release ; then
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 "ALT .*9.[0-9]" ; then DISTRIB_RELEASE="p9"
elif has "ALT p9 " ; then DISTRIB_RELEASE="p9"
elif has "ALT 8 SP " ; then DISTRIB_RELEASE="c8"
elif has "ALT 9 SP " ; then DISTRIB_RELEASE="c9"
elif has "ALT c8 " ; then DISTRIB_RELEASE="c8"
elif has "ALT c8.1 " ; then DISTRIB_RELEASE="c8.1"
elif has "ALT c8.2 " ; then DISTRIB_RELEASE="c8.2"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "ALT .*9.[0-9]" ; then DISTRIB_RELEASE="p9"
elif has "ALT p9.* p9 " ; then DISTRIB_RELEASE="p9"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
......@@ -287,7 +292,7 @@ elif distro os-release ; 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")
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
......@@ -398,6 +403,25 @@ esac
echo "$DIST_ARCH"
}
get_distro_arch()
{
local arch="$(get_arch)"
case "$(pkgtype)" in
rpm)
:
;;
deb)
case $arch in
'i586')
arch='i386' ;;
'x86_64')
arch='amd64' ;;
esac
;;
esac
echo "$arch"
}
get_bit_size()
{
local DIST_BIT
......@@ -430,8 +454,9 @@ echo "$DIST_BIT"
}
# TODO: check before calc
get_memory_size() {
local detected=0
get_memory_size()
{
local detected=""
local DIST_OS="$(get_base_os_name)"
case "$DIST_OS" in
macosx)
......@@ -443,9 +468,14 @@ get_memory_size() {
linux)
[ -r /proc/meminfo ] && detected=$((`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`/1024))
;;
solaris)
detected=$(prtconf | grep Memory | sed -e "s|Memory size: \([0-9][0-9]*\) Megabyte.*|\1|")
;;
# *)
# fatal "Unsupported OS $DIST_OS"
esac
# Exit codes only support values between 0 and 255. So use stdout.
[ -n "$detected" ] || detected=0
echo $detected
}
......@@ -454,6 +484,32 @@ print_name_version()
[ -n "$DISTRIB_RELEASE" ] && echo $DISTRIB_ID/$DISTRIB_RELEASE || echo $DISTRIB_ID
}
get_core_count()
{
local detected=""
local DIST_OS="$(get_base_os_name)"
case "$DIST_OS" in
macos|freebsd)
detected=$(sysctl hw.ncpu | awk '{print $2}')
;;
linux)
detected=$(grep -c "^processor" /proc/cpuinfo)
;;
solaris)
detected=$(prtconf | grep -c 'cpu[^s]')
;;
aix)
detected=$(lsdev -Cc processor -S A | wc -l)
;;
# *)
# fatal "Unsupported OS $DIST_OS"
esac
[ -n "$detected" ] || detected=0
echo $detected
}
get_virt()
{
local VIRT
......@@ -499,29 +555,34 @@ print_pretty_name()
print_total_info()
{
cat <<EOF
distro_info total information (run with -h to get help):
distro_info v$PROGVERSION : Copyright © 2007-2020 Etersoft
==== Total system information:
Pretty distro name (--pretty): $(print_pretty_name)
Distro name and version (-e): $(print_name_version)
Packaging system (-p): $(pkgtype)
Running service manager (-y): $(get_service_manager)
Virtualization (-i): $(get_virt)
CPU Cores (-c): $(get_core_count)
CPU Architecture (-a): $(get_arch)
CPU norm register size (-b): $(get_bit_size)
System memory size (MB) (-m): $(get_memory_size)
Base OS name (-o): $(get_base_os_name)
Build system distro name (-s): $(pkgvendor)
Build system vendor name (-n): $(rpmvendor)
(run with -h to get help)
EOF
}
case $1 in
-h)
echo "distro_info - distro name and version detection"
echo "distro_info v$PROGVERSION - distro information retriever"
echo "Usage: distro_info [options] [args]"
echo "Options:"
echo " -a - print hardware architecture"
echo " -a - print hardware architecture (--distro-arch for distro depended name)"
echo " -b - print size of arch bit (32/64)"
echo " -c - print number of CPU cores"
echo " -d - print distro name"
echo " -e - print full name of distro with version"
echo " -i - print virtualization type"
......@@ -547,6 +608,12 @@ case $1 in
--pretty)
print_pretty_name
;;
--distro-arch)
# override DISTRIB_ID
test -n "$2" && DISTRIB_ID="$2"
get_distro_arch
exit 0
;;
-d)
echo $DISTRIB_ID
;;
......@@ -556,6 +623,9 @@ case $1 in
-b)
get_bit_size
;;
-c)
get_core_count
;;
-i)
get_virt
;;
......@@ -584,7 +654,7 @@ case $1 in
get_service_manager
;;
-V)
echo "20191121"
echo "$PROGVERSION"
exit 0
;;
-e)
......
......@@ -256,10 +256,10 @@ check_command()
repolist|sl|rl|listrepo|repo-list) # HELPCMD: print repo list
epm_cmd=repolist
;;
repofix) # HELPCMD: fix paths in sources lists (ALT Linux only)
repofix) # HELPCMD: <mirror>: fix paths in sources lists (ALT Linux only). use repofix etersoft/yandex/basealt for rewrite URL to the specified server
epm_cmd=repofix
;;
removerepo|rr) # HELPCMD: remove package repo
removerepo|rr) # HELPCMD: remove package repo (shortcut for epm repo remove)
epm_cmd=removerepo
;;
repo) # HELPCMD: manipulate with repository list (run epm repo --help to help)
......@@ -268,7 +268,7 @@ check_command()
full-upgrade) # HELPCMD: update all system packages and kernel
epm_cmd=full_upgrade
;;
release-upgrade|upgrade-release|upgrade-system) # HELPCMD: update whole system to the release in arg (default: next (latest) release)
release-upgrade|upgrade-release|upgrade-system|release-switch) # HELPCMD: upgrade/switch whole system to the release in arg (default: next (latest) release)
epm_cmd=release_upgrade
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version
......@@ -409,18 +409,27 @@ check_option()
return 0
}
has_space()
{
[ -n "$2" ]
}
check_filenames()
{
local opt
for opt in "$@" ; do
# files can be with full path or have extension via .
if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then
has_space $opt && warning "There are space(s) in filename '$opt', it is not supported. Skipped" && continue
pkg_files="$pkg_files $opt"
elif [ -d "$opt" ] ; then
has_space $opt && warning "There are space(s) in directory path '$opt', it is not supported. Skipped" && continue
pkg_dirs="$pkg_dirs $opt"
elif echo "$opt" | grep -q "://" ; then
elif echo "$opt" | grep -q "^[fhtps]*://" ; then
has_space $opt && warning "There are space(s) in URL '$opt', it is not supported. Skipped" && continue
pkg_urls="$pkg_urls $opt"
else
has_space $opt && warning "There are space(s) in package name '$opt', it is not supported. Skipped" && continue
pkg_names="$pkg_names $opt"
fi
quoted_args="$quoted_args \"$opt\""
......
......@@ -40,51 +40,80 @@ __epm_addrepo_rhel()
return 0
}
__epm_addrepo_etersoft_addon()
{
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold || fatal
# TODO: ignore only error code 22 (skipped) || fatal
local pb="$DISTRVERSION/branch"
[ "$DISTRVERSION" = "Sisyphus" ] && pb="$DISTRVERSION"
# FIXME
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
# TODO: use apt-repo add ?
echo "" | sudocmd tee -a /etc/apt/sources.list
echo "# added with eepm addrepo etersoft" | sudocmd tee -a /etc/apt/sources.list
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/$DISTRARCH addon" | sudocmd tee -a /etc/apt/sources.list
if [ "$DISTRARCH" = "x86_64" ] ; then
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/x86_64-i586 addon" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/noarch addon" | sudocmd tee -a /etc/apt/sources.list
}
__epm_addrepo_altlinux()
{
local repo="$@"
local repo="$*"
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
[ -n "$branch" ] || fatal "Empty DISTRVERSION"
if [ -z "$repo" ] || [ "$repo" == "--help" ] ; then
info "Add branch repo. Use follow params:"
sudocmd apt-repo $dryrun add branch
echo "etersoft - for LINUX@Etersoft repo"
echo "basealt - for BaseALT repo"
echo "yandex - for BaseALT repo mirror on yandex (recommended)"
echo "<task number> - add task repo"
echo "archive 2018/02/09 - for archive from that date"
echo "autoimports - for BaseALT autoimports repo"
return
fi
case "$1" in
etersoft)
info "add Etersoft's addon repo"
load_helper epm-query
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold
# TODO: ignore only error code 22 (skipped) || fatal
local branch="$DISTRVERSION/branch"
[ "$DISTRVERSION" = "Sisyphus" ] && branch="$DISTRVERSION"
# FIXME
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
# TODO: func?
local arch=$(uname -m)
[ "$arch" = "i686" ] && arch="i586"
# TODO: use apt-repo add ?
echo "" | sudocmd tee -a /etc/apt/sources.list
echo "# added with eepm addrepo etersoft" | sudocmd tee -a /etc/apt/sources.list
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$branch/$arch addon" | sudocmd tee -a /etc/apt/sources.list
if [ "$arch" = "x86_64" ] ; then
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$branch/$arch-i586 addon" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$branch/noarch addon" | sudocmd tee -a /etc/apt/sources.list
repo="$DISTRVERSION"
assure_exists apt-repo
__epm_addrepo_etersoft_addon
a='' apt-repo add $branch
epm repofix etersoft
return 0
;;
basealt|altlinux)
# TODO: setrepo?
assure_exists apt-repo
a='' apt-repo add $branch
return 0
;;
yandex)
assure_exists apt-repo
a='' apt-repo add $branch
epm repofix yandex
return 0
;;
autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
repo="autoimports.$branch"
;;
archive)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
datestr="$2"
echo "$datestr" | grep -Eq "^20[0-2][0-9]/[01][0-9]/[0-3][0-9]$" || fatal "use follow date format: 2017/12/31"
# TODO: func?
local arch=$(uname -m)
[ "$arch" = "i686" ] && arch="i586"
echo "" | sudocmd tee -a /etc/apt/sources.list
local distrversion="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
local rpmsign='[alt]'
[ "$distrversion" != "sisyphus" ] && rpmsign="[$distrversion]"
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/$arch classic" | sudocmd tee -a /etc/apt/sources.list
if [ "$arch" = "x86_64" ] ; then
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/$arch-i586 classic" | sudocmd tee -a /etc/apt/sources.list
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/$DISTRARCH classic" | sudocmd tee -a /etc/apt/sources.list
if [ "$DISTRARCH" = "x86_64" ] ; then
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/x86_64-i586 classic" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/noarch classic" | sudocmd tee -a /etc/apt/sources.list
return 0
......@@ -98,18 +127,64 @@ __epm_addrepo_altlinux()
return
fi
if [ -z "$repo" ] ; then
info "Add branch repo. Use follow params:"
sudocmd apt-repo $dryrun add branch
echo "etersoft - for LINUX@Etersoft repo"
echo "archive 2018/02/09 - for archive from that date"
sudocmd apt-repo $dryrun add "$repo"
}
# TODO: add repo addkey command
__epm_addkey_deb()
{
local url="$1"
local fingerprint="$2"
if [ -z "$fingerprint" ] ; then
assure_exists curl
showcmd "curl -fsSL '$url' | sudo apt-key add -"
a= curl -fsSL "$url" | $SUDO apt-key add -
return
fi
sudocmd apt-key adv --keyserver "$url" --recv "$fingerprint"
}
__epm_addrepo_deb()
{
assure_exists apt-add-repository software-properties-common
local ad="$($DISTRVENDOR --distro-arch)"
# TODO: move to distro_info
local nd="$(lsb_release -cs)"
local repo="$*"
if [ -z "$repo" ] || [ "$repo" = "--help" ]; then
info "Add repo. You can use follow params:"
echo " docker - add official docker repo"
echo " ppa:<user>/<ppa-name> - add PPA repo"
echo " distribution component name"
echo " full sources list line"
echo " URL version component"
return
fi
# TODO: add other mirror (mirror.yandex.ru)
# TODO: apt-repo supports archive
sudocmd apt-repo $dryrun add "$repo"
# keywords
case "$1" in
docker)
__epm_addkey_deb https://download.docker.com/linux/$PKGVENDOR/gpg "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
repo="https://download.docker.com/linux/$PKGVENDOR $nd stable"
;;
esac
# if started from url, use heroistic
if echo "$repo" | egrep -q "^https?://" ; then
repo="deb [arch=$ad] $repo"
fi
if echo "$repo" | grep -q "https://" ; then
assure_exists /usr/share/doc/apt-transport-https apt-transport-https
assure_exists /usr/sbin/update-ca-certificates ca-certificates
fi
# FIXME: quotes in showcmd/sudocmd
showcmd apt-add-repository "$repo"
$SUDO apt-add-repository "$repo"
info "Check file /etc/apt/sources.list if needed"
}
epm_addrepo()
......@@ -118,6 +193,7 @@ local repo="$*"
case $DISTRNAME in
ALTLinux)
# Note! Don't use quotes here
__epm_addrepo_altlinux $repo
return
;;
......@@ -125,12 +201,8 @@ esac
case $PMTYPE in
apt-dpkg)
assure_exists apt-add-repository software-properties-common
if echo "$repo" | grep -q "https://" ; then
assure_exists apt-transport-https
fi
sudocmd apt-add-repository "$repo"
info "Check file /etc/apt/sources.list if needed"
# Note! Don't use quotes here
__epm_addrepo_deb $repo
;;
aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list (TODO)"
......
......@@ -22,22 +22,6 @@ __check_command_in_path()
PATH=$PATH:/sbin:/usr/sbin which "$1" 2>/dev/null
}
# copied from strings
# CHECKME: the same like estrlist has ?
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas()
{
echo "$1" | grep -E -q -- "$2"
}
# copied from strings
is_dirpath()
{
[ "$1" = "." ] && return $?
rhas "$1" "/"
}
__epm_need_update()
{
local PACKAGE="$1"
......
......@@ -51,11 +51,12 @@ epm_dedup()
{
case "$DISTRNAME" in
"ALTLinux")
assure_exists /usr/share/apt/scripts apt-scripts
if [ -f /usr/share/apt/scripts/dedup.lua ] ; then
info "Check for duplicates via apt-get dedup from apt-scripts"
assure_exists /usr/share/apt/scripts/dedup.lua apt-scripts
if [ -z "$direct" ] && [ -f /usr/share/apt/scripts/dedup.lua ] ; then
info "Check for duplicates via apt-get dedup from apt-scripts (also you can use internal EPM dedup implementation with --direct option)"
sudocmd apt-get dedup
else
info "You can use dedup from apt-scripts package"
try_fix_apt_rpm_dupls
fi
;;
......
......@@ -63,6 +63,7 @@ __epm_removerepo_alt()
__epm_removerepo_alt_grepremove " repo/$1/"
;;
*)
# TODO: if return empty for whole line, use grep
sudocmd apt-repo $dryrun rm "$*"
;;
esac
......@@ -82,7 +83,8 @@ esac;
case $PMTYPE in
apt-dpkg)
assure_exists apt-add-repository software-properties-common
sudocmd apt-add-repository --remove "$@"
showcmd apt-add-repository --remove "$*"
$SUDO apt-add-repository --remove "$*"
info "Check file /etc/apt/sources.list if needed"
;;
aptitude-dpkg)
......
......@@ -91,6 +91,7 @@ __fix_spec()
{
local buildroot="$1"
local spec="$2"
local pkgname="$3"
local i
# drop forbidded paths
......@@ -111,8 +112,11 @@ __fix_spec()
# subst 's|^\("'$i'"\)$|\1|' $spec
fi
done
# FIXME: where is a source of the bug with empty Summary?
subst "s|Summary: *$|Summary: $pkgname (was empty Summary after alien)|" $spec
subst "s|^Release: |Release: alt1.repacked.with.epm.|" $spec
subst "s|^\((Converted from a rpm package.*\)|(Repacked from binary rpm with epm $EPMVERSION)\n\1|" $spec
subst "s|^\((Converted from a\) \(.*\) \(package.*\)|(Repacked from binary \2 package with epm $EPMVERSION)\n\1 \2 \3|" $spec
#" hack for highlight
}
......@@ -160,7 +164,7 @@ __epm_repack_rpm()
local abspkg
repacked_rpms=''
for pkg in $* ; do
local tmpbuilddir=$HOME/repack-$(basename $pkg)
local tmpbuilddir=$HOME/$(basename $pkg).tmpdir
mkdir $tmpbuilddir
abspkg="$(realpath $pkg)"
info ""
......@@ -168,6 +172,7 @@ __epm_repack_rpm()
# alien failed with spaced names
# alpkg=$abspkg
alpkg=$(basename $pkg)
# don't use abs package path: copy package to temp dir and use there
cp -v $pkg $tmpbuilddir/../$alpkg
cd $tmpbuilddir || fatal
docmd fakeroot alien --generate --to-rpm $verbose $scripts "../$alpkg" || fatal
......@@ -180,8 +185,8 @@ __epm_repack_rpm()
[ -s "$spec" ] || fatal "can't find spec"
mv $spec $tmpbuilddir || fatal
spec="$tmpbuilddir/$(basename "$spec")"
__fix_spec $tmpbuilddir/$subdir $spec
local pkgname="$(grep "^Name: " $spec | sed -e "s|Name: ||g" | head -n1)"
__fix_spec $tmpbuilddir/$subdir $spec $pkgname
__apply_fix_code $pkgname $tmpbuilddir/$subdir $spec
# TODO: we need these dirs to be created
to_remove_pkg_dirs="$to_remove_pkg_dirs $HOME/RPM/BUILD $HOME/RPM"
......@@ -191,8 +196,9 @@ __epm_repack_rpm()
else
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal
fi
mv $tmpbuilddir/../*.rpm $tmpbuilddir/
local repacked_rpm="$(realpath $tmpbuilddir/*.rpm)"
# remove copy of source binary package (don't mix with generated)
rm -f $tmpbuilddir/../$alpkg
local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)"
if [ -s "$repacked_rpm" ] ; then
repacked_rpms="$repacked_rpms $repacked_rpm"
to_remove_pkg_files="$to_remove_pkg_files $repacked_rpm"
......@@ -201,7 +207,6 @@ __epm_repack_rpm()
fi
cd - >/dev/null
rm -rf $tmpbuilddir/$subdir/
#rm -rf $tmpbuilddir/../*.rpm
rm -rf $spec
done
......
......@@ -26,7 +26,7 @@ epm_repo()
shift
case $CMD in
"-h"|"--help"|help) # HELPCMD: help
get_help HELPCMD epm-repo
get_help HELPCMD $SHAREDIR/epm-repo
;;
""|list) # HELPCMD: list packages
load_helper epm-repolist
......@@ -36,7 +36,15 @@ epm_repo()
load_helper epm-repofix
epm_repofix "$@"
;;
clean) # HELPCMD: remove temp. repos
change) # HELPCMD: <mirror>: switch sources to the mirror (supports etersoft/yandex/basealt): rewrite URL to the specified server
load_helper epm-repofix
epm_repofix "$@"
;;
set) # HELPCMD: <mirror>: remove all existing sources and add mirror for the branch
epm repo rm all
epm addrepo "$@"
;;
clean) # HELPCMD: remove temp. repos (tasks and CD-ROMs)
# TODO: check for ALT
sudocmd apt-repo $dryrun clean
;;
......
......@@ -29,12 +29,27 @@ __repofix_check_vendor()
return 1
}
__repofix_filter_vendor()
{
local br="$1"
br="$(echo "$br" | sed -e "s|\..*||")"
case $br in
c8)
br="cert8"
;;
c9)
br="cert9"
;;
esac
echo "$br"
}
# source-list vendor path
# example: /etc/apt/source.list p7 ALTLinux\/Sisyphus
__try_fix_apt_source_list()
{
local list="$1"
local br="$2"
local br="$(__repofix_filter_vendor "$2")"
local path="$3"
if grep -q -e "^[^#].*$path" $list ; then
if __repofix_check_vendor $br ; then
......@@ -49,8 +64,8 @@ __try_fix_apt_source_list()
__fix_alt_sources_list()
{
# for beauty spaces
local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9][/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9]\.?[0-9]?[/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local i
assure_root
for i in "$@" ; do
......@@ -78,8 +93,26 @@ __subst_with_etersoft_url()
{
local NURL="http://download.etersoft.ru/pub ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.yandex.ru altlinux|$NURL|"
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|"
}
__subst_with_yandex_url()
{
local NURL="http://mirror.yandex.ru altlinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
}
__subst_with_basealt_url()
{
local NURL="http://ftp.basealt.ru/pub/distributions ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
}
__fix_repo_to_etersoft()
......@@ -87,11 +120,35 @@ __fix_repo_to_etersoft()
local NN
a="" apt-repo list | grep -v debuginfo | grep -v etersoft | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_etersoft_url "$nn")"
[ "$NN" = "$nn" ] && continue
epm removerepo "$nn"
epm addrepo "$NN"
done
}
__fix_repo_to_yandex()
{
local NN
a="" apt-repo list | grep -v debuginfo | grep -v mirror\.yandex | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_yandex_url "$nn")"
[ "$NN" = "$nn" ] && continue
epm removerepo "$nn"
epm addrepo "$NN"
done
}
__fix_repo_to_basealt()
{
local NN
a="" apt-repo list | grep -v debuginfo | grep -v ftp.basealt | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_basealt_url "$nn")"
[ "$NN" = "$nn" ] && continue
epm removerepo "$nn"
epm addrepo "$NN"
done
}
epm_repofix()
{
......@@ -102,10 +159,19 @@ case $DISTRNAME in
[ -n "$quiet" ] || docmd apt-repo list
__fix_alt_sources_list /etc/apt/sources.list
__fix_alt_sources_list /etc/apt/sources.list.d/*.list
# TODO: move to repo change
if [ "$pkg_filenames" = "etersoft" ] ; then
__fix_repo_to_etersoft /etc/apt/sources.list
__fix_repo_to_etersoft /etc/apt/sources.list.d/*.list
fi
if [ "$pkg_filenames" = "yandex" ] ; then
__fix_repo_to_yandex /etc/apt/sources.list
__fix_repo_to_yandex /etc/apt/sources.list.d/*.list
fi
if [ "$pkg_filenames" = "basealt" ] ; then
__fix_repo_to_basealt /etc/apt/sources.list
__fix_repo_to_basealt /etc/apt/sources.list.d/*.list
fi
docmd apt-repo list
return
;;
......
......@@ -125,12 +125,15 @@ tasknumber()
# todo: improve apt-repo
get_task_arepo_packages()
{
local res
epm assure apt-repo
epm assure curl
info "TODO: please, improve apt-repo to support arepo (i586-) packages for apt-repo list task"
showcmd "curl -s -f http://git.altlinux.org/tasks/$tn/plan/arepo-add-x86_64-i586 | cut -f1"
a='' curl -s -f http://git.altlinux.org/tasks/$tn/plan/arepo-add-x86_64-i586 2>/dev/null | cut -f1
# TODO: retrieve one time
res="$(a='' curl -s -f http://git.altlinux.org/tasks/$tn/plan/arepo-add-x86_64-i586 2>/dev/null)" || { warning "There is a download error for x86_64-i586 arepo." ; return ; }
echo "$res" | cut -f1
}
# use assure apt-repo before
......@@ -140,6 +143,7 @@ get_task_packages()
local tn
for tn in $(tasknumber "$@") ; do
showcmd apt-repo list task "$tn"
a='' apt-repo list task "$tn" >/dev/null || continue
a='' apt-repo list task "$tn"
[ "$arch" = "x86_64" ] && get_task_arepo_packages "$tn"
done
......
......@@ -181,6 +181,21 @@ isnumber()
echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$"
}
# copied from strings
# CHECKME: the same like estrlist has ?
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas()
{
echo "$1" | grep -E -q -- "$2"
}
# copied from strings
is_dirpath()
{
[ "$1" = "." ] && return $?
rhas "$1" "/"
}
filter_strip_spaces()
{
# possible use just
......@@ -452,7 +467,9 @@ get_help()
return
fi
local F="$0"
[ -n "$2" ] && F="$(dirname $0)/$2"
if [ -n "$2" ] ; then
is_dirpath "$2" && F="$2" || F="$(dirname $0)/$2"
fi
cat "$F" | grep -- "# $1" | while read -r n ; do
if echo "$n" | grep -q "# $1: PART: " ; then
......@@ -461,7 +478,7 @@ get_help()
continue
fi
echo "$n" | grep -q "^ *#" && continue
opt="$(echo $n | sed -e "s|) # $1:.*||g")" #"
opt="$(echo $n | sed -e "s|) # $1:.*||g" -e 's|"||g' -e 's@^|@@')" #"
desc="$(echo $n | sed -e "s|.*) # $1:||g")" #"
printf " %-20s %s\n" $opt "$desc"
done
......@@ -480,6 +497,11 @@ set_pm_type()
# Fill for use: PMTYPE, DISTRNAME, DISTRVERSION, PKGFORMAT, PKGVENDOR, RPMVENDOR
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d) || fatal "Can't get distro name."
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
if [ -z "$DISTRARCH" ] ; then
DISTRARCH=$($DISTRVENDOR -a)
# TODO: translate func
[ "$DISTRARCH" = "x86" ] && DISTRARCH="i586"
fi
set_target_pkg_env
# override package manager detection result
......
......@@ -20,6 +20,8 @@
is_warmup_allowed()
{
local MEM
# disable warming up until set EPM_WARNUP in /etc/eepm/eepm.conf
[ -n "$EPM_WARMUP" ] || return 1
MEM="$($DISTRVENDOR -m)"
# disable warm if have no enough memory
[ "$MEM" -le 1024 ] && return 1
......
......@@ -200,6 +200,10 @@ check_command()
serv_cmd=list_startup
withoutservicename=1
;;
list-failed|--failed) # HELPCMD: list services failed on startup
serv_cmd=list_failed
withoutservicename=1
;;
on|enable) # HELPCMD: add service to run on startup and start it now
serv_cmd=enable
;;
......
#!/bin/sh
#
# Copyright (C) 2020 Etersoft
# Copyright (C) 2020 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
# 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/>.
#
serv_list_failed()
{
case $SERVICETYPE in
# service-chkconfig|service-upstart)
# # service --status-all for Ubuntu/Fedora
# #sudocmd chkconfig --list | cut -f1
# ;;
# service-initd|service-update)
# sudocmd ls -1 /etc/init.d/* | sed -e "s|/etc/init.d/||g" | grep -v README
# ;;
systemd)
sudocmd systemctl --failed
;;
*)
load_helper serv-list_startup
load_helper serv-status
for i in $(serv_list_startup | cut -f 1 -d" ") ; do
is_service_running >/dev/null $i && continue
echo ; echo $i
serv_status $i
done
;;
esac
}
......@@ -19,6 +19,8 @@
serv_list_startup()
{
load_helper serv-list_all
load_helper serv-status
case $SERVICETYPE in
# service-chkconfig|service-upstart)
# # service --status-all for Ubuntu/Fedora
......@@ -27,16 +29,18 @@ serv_list_startup()
# service-initd|service-update)
# sudocmd ls -1 /etc/init.d/* | sed -e "s|/etc/init.d/||g" | grep -v README
# ;;
# systemd)
# sudocmd systemctl list-unit-files
# ;;
*)
load_helper serv-list_all
load_helper serv-status
systemd)
#sudocmd systemctl list-unit-files
# TODO: native command? implement --short for list (only names)
for i in $(serv_list_all | cut -f 1 -d" " | grep "\.service$") ; do
is_service_autostart >/dev/null $i && echo $i
done
;;
*)
for i in $(serv_list_all | cut -f 1 -d" ") ; do
is_service_autostart >/dev/null $i && echo $i
done
;;
esac
}
......@@ -44,7 +44,7 @@ fatal()
filter_glob()
{
# translate glob to regexp
grep "^$(echo "$1" | sed -e "s|\*|.*|g" -e "s|\?|.|g")$"
grep "^$(echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g")$"
}
......@@ -105,7 +105,7 @@ fi
get_urls()
{
$WGET -O- $URL | \
grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
grep -i -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
}
if [ -n "$LISTONLY" ] ; then
......
# This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 3.3.3
Release: alt0.M80P.1
Version: 3.4.0
Release: alt1.M80P.2
Summary: Etersoft EPM package manager
......@@ -25,7 +25,7 @@ Provides: upm
%if %_vendor == "alt"
# FIXHERE: Replace with target platform package manager
Requires: apt rpm
Requires: distro_info >= 1.1
Requires: distro_info >= 1.6
%endif
%description
......@@ -37,6 +37,21 @@ with various distros.
See detailed description here: http://wiki.etersoft.ru/EPM
%package repack
Summary: Etersoft EPM package manager (repack requirements)
Group: System/Configuration/Packaging
Requires: %name = %EVR
Requires: fakeroot alien rpm-build dpkg
%description repack
This package has requirements needed for using epm repack on ALT
(repack rpm packages and repack/install deb packages).
See https://bugzilla.altlinux.org/show_bug.cgi?id=34308 for
a discussion about extra requirements.
Requires: fakeroot alien rpm-build dpkg
%prep
%setup
......@@ -105,10 +120,40 @@ rm -f %buildroot%_bindir/distr_info
%_sysconfdir/bash_completion.d/serv
%_sysconfdir/bash_completion.d/cerv
%if %_vendor == "alt"
%files repack
%endif
%changelog
* Sun Oct 11 2020 Vitaly Lipatov <lav@altlinux.ru> 3.3.3-alt0.M80P.1
* Thu Oct 22 2020 Vitaly Lipatov <lav@altlinux.ru> 3.4.0-alt1.M80P.2
- backport to ALTLinux p8 (by rpmbph script)
* Wed Oct 21 2020 Vitaly Lipatov <lav@altlinux.ru> 3.4.0-alt2
- add epm-repack subpackage (just a static requirements)
* Mon Oct 19 2020 Vitaly Lipatov <lav@altlinux.ru> 3.4.0-alt1
- serv-list_startup: temp. fix for non systemd systems
- serv: add list-failed command
- epm-repack: add workaround for empty Summary
- add repack support for dialog-ee-x deb package
- epm: disable warming up by default
- epm addrepo/removerepo: fix repo manipulating on deb systems
- epm-addrepo: initial implementation of addkey for deb
* Mon Oct 19 2020 Vitaly Lipatov <lav@altlinux.ru> 3.3.5-alt1
- epm-repo: fix set
- epm-release_upgrade: big rewrite, add support for downgrade to с8
- epm-release_upgrade: allow two params: from and to
* Fri Oct 16 2020 Vitaly Lipatov <lav@altlinux.ru> 3.3.4-alt1
- epm: skip all args with spaces (we don't support it)
- epm-dedup: add --direct support to use epm internal implementation
- epm-repofix: add support for yandex and basealt
- epm-addrepo: add support for basealt and yandex repo sites
- epm-release_upgrade: replace etersoft-gpgkeys with alt-gpgkeys if we have not LINUX@Etersoft repo
- epm-repo: add set command implemented via clean & change
- epm-repack: don't intersect with source rpm package
* Sun Oct 11 2020 Vitaly Lipatov <lav@altlinux.ru> 3.3.3-alt1
- fix typo in get_task_packages
......
#!/bin/sh -x
# It will be run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
# https://bugzilla.altlinux.org/show_bug.cgi?id=39099
subst '1i%filter_from_requires /^.opt.Dialog$/d' $SPEC
#!/bin/sh -x
# It will be run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
LIBPATH="$(cd $BUILDROOT ; echo opt/gcc-*/lib64)"
# find provides there
subst "1i%set_findprov_lib_path /$LIBPATH" $SPEC
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