Commit 90a2322c authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents b05e3737 5f4f9268
......@@ -360,9 +360,12 @@ local DIST_ARCH
# Resolve the architecture
DIST_ARCH=`uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"`
case "$DIST_ARCH" in
'amd64' | 'ia32' | 'i386' | 'i486' | 'i586' | 'i686' | 'x86_64')
'ia32' | 'i386' | 'i486' | 'i586' | 'i686')
DIST_ARCH="x86"
;;
'amd64' | 'x86_64')
DIST_ARCH="x86_64"
;;
'ia64' | 'ia-64')
DIST_ARCH="ia64"
;;
......@@ -490,7 +493,7 @@ case $1 in
exit 0
;;
-V)
echo "20161212"
echo "20171010"
exit 0
;;
*)
......
......@@ -74,13 +74,15 @@ print_version()
Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager"
EPMVERSION=@VERSION@
verbose=
quiet=
nodeps=
noremove=
dryrun=
force=
repack=
scripts=
short=
direct=
sort=
......@@ -94,6 +96,10 @@ pkg_names=
pkg_urls=
quoted_args=
# load system wide config
[ -f /etc/eepm/eepm.conf ] && . /etc/eepm/eepm.conf
case $PROGNAME in
epmi)
epm_cmd=install
......@@ -204,7 +210,7 @@ check_command()
provides|prov) # HELPCMD: print package provides
epm_cmd=provides
;;
whatdepends|wd|rdepends) # HELPCMD: print packages dependences on that
whatdepends|wd) # HELPCMD: print packages dependences on that
epm_cmd=whatdepends
;;
whatprovides) # HELPCMD: print packages provides that target
......@@ -233,7 +239,7 @@ check_command()
addrepo|ar) # HELPCMD: add package repo
epm_cmd=addrepo
;;
repolist|sl|rl|listrepo) # HELPCMD: print repo list
repolist|sl|rl|listrepo|repo) # HELPCMD: print repo list
epm_cmd=repolist
;;
repofix) # HELPCMD: fix paths in sources lists (ALT Linux only)
......@@ -345,6 +351,12 @@ check_option()
--direct) # HELPOPT: direct install package file from ftp (not via hilevel repository manager)
direct="--direct"
;;
--repack) # HELPOPT: repack rpm package(s) before install
repack="--repack"
;;
--scripts) # HELPOPT: include scripts in repacked rpm package(s) (see --repack or repacking when foreign package is installed)
scripts="--scripts"
;;
--sort) # HELPOPT: sort output, f.i. --sort=size (supported only for packages command)
# TODO: how to read arg?
sort="$1"
......
......@@ -153,7 +153,7 @@ __epm_print_url_alt_check()
echo
echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime"
__epm_print_url_alt "$1" | while read url ; do
curl -s --head $url >$tm || { echo "$url: missed" ; continue ; }
a='' curl -s --head $url >$tm || { echo "$url: missed" ; continue ; }
local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g")
local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g")
local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g")
......
......@@ -22,7 +22,7 @@ load_helper epm-install
__epm_korinf_site() {
local archprefix=""
[ "$($DISTRVENDOR -b)" = "64" ] && archprefix="x86_64/"
[ "$($DISTRVENDOR -a)" = "x86_64" ] && archprefix="x86_64/"
local aftername="-"
[ "$($DISTRVENDOR -p)" = "deb" ] && aftername="_"
echo "http://updates.etersoft.ru/pub/Korinf/$archprefix$($DISTRVENDOR -e)"
......
......@@ -23,15 +23,32 @@ load_helper epm-assure
load_helper epm-check_updated_repo
load_helper epm-sh-warmup
__fast_hack_for_filter_out_installed_rpm()
{
LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' |
sed -e 's|^.*package \(.*\) is not installed.*|\1|g'
}
# TODO: use when run install with epm --skip-installed install
filter_out_installed_packages()
{
[ -z "$skip_installed" ] && cat && return
case $PKGFORMAT in
"rpm")
LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' |
sed -e 's|^.*package \(.*\) is not installed.*|\1|g'
case $PMTYPE in
yum-rpm|dnf-rpm)
if [ "$($DISTRVENDOR -a)" = "x86_64" ] ; then
# shellcheck disable=SC2013
for i in $(cat) ; do
is_installed "$(__print_with_arch_suffix $i .x86_64)" && continue
is_installed "$(__print_with_arch_suffix $i .noarch)" && continue
is_installed $i || echo $i
done
else
__fast_hack_for_filter_out_installed_rpm
fi
;;
*-rpm)
__fast_hack_for_filter_out_installed_rpm
;;
# dpkg -l lists some non ii status (un, etc)
#"deb")
......@@ -285,15 +302,18 @@ __epm_check_if_try_install_deb()
[ -n "$debpkgs" ] || return 1
assure_exists alien
assure_exists dpkg
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
local TDIR=$(mktemp -d)
cd $TDIR || fatal
for pkg in $debpkgs ; do
# TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k --scripts "$pkg" || fatal
showcmd_store_output alien -r -k $scripts "$pkg" || fatal
local RPMCONVERTED=$(grep "rpm generated" $RC_STDOUT | sed -e "s| generated||g")
clean_store_output
epm install $RPMCONVERTED
docmd epm install $force $nodeps $RPMCONVERTED
done
rm -f $TDIR/*
rmdir $TDIR/
......@@ -315,14 +335,15 @@ __epm_check_if_try_install_rpm()
assure_exists alien
assure_exists fakeroot
assure_exists rpm
local TDIR=$(mktemp -d)
cd $TDIR || fatal
for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
showcmd_store_output fakeroot alien -d -k $scripts "$pkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
clean_store_output
epm install $DEBCONVERTED
docmd epm install $force $nodeps $DEBCONVERTED
done
rm -f $TDIR/*
rmdir $TDIR/
......@@ -330,6 +351,87 @@ __epm_check_if_try_install_rpm()
return 0
}
# args: buildroot spec
__fix_spec()
{
local buildroot="$1"
local spec="$2"
local i
for i in $(grep '^"/' $spec | sed -e 's|^"\(.*\)"$|\1|') ; do
#' hack for highlight
# add %dir to dir in list
if [ -d "$buildroot$i" ] ; then
subst 's|^\("'$i'"\)$|%dir \1|' $spec
fi
done
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
#" hack for highlight
}
__apply_fix_code()
{
local repackcode="/etc/eepm/repack.d/$1.sh"
[ -x "$repackcode" ] || return
shift
docmd $repackcode "$1" "$2" || warning "There was errors with $repackcode script"
}
# will fill repacked_rpms var
__epm_repack_rpm()
{
[ "$DISTRNAME" = "ALTLinux" ] || fatal "install --repack supported only for ALT Linux distros"
assure_exists fakeroot || fatal
assure_exists alien || fatal
assure_exists rpmbuild rpm-build || fatal
local pkg
local tmpbuilddir=$(mktemp -d)/repack
mkdir $tmpbuilddir
local abspkg
repacked_rpms=''
for pkg in $* ; do
abspkg=$(realpath $pkg)
info "Repacking $abspkg to local rpm format ..."
cd $tmpbuilddir || fatal
docmd fakeroot alien --generate --to-rpm $verbose $scripts $abspkg || fatal
local subdir="$(echo *)"
[ -d "$subdir" ] || fatal "can't find subdir"
# detect spec and move to prev dir
local spec="$(echo $tmpbuilddir/$subdir/*.spec)"
[ -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)"
__apply_fix_code $pkgname $tmpbuilddir/$subdir $spec
showcmd fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec
if [ -n "$verbose" ] ; then
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec || fatal
else
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal
fi
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"
else
warning "Can't find converted rpm for source binary $pkg package"
fi
cd - >/dev/null
rm -rf $tmpbuilddir/$subdir/
#rm -rf $tmpbuilddir/../*.rpm
rm -rf $spec
done
rmdir $tmpbuilddir
#rmdir $tmpbuilddir/..
true
}
__handle_direct_install()
{
case "$DISTRNAME" in
......@@ -360,7 +462,9 @@ epm_install_files()
apt-rpm)
__epm_check_if_try_install_deb $@ && return
# do not use low-level for install by file path
# TODO: add --repack support, will force repack rpm
# do not using low-level for install by file path (FIXME: reasons?)
if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then
sudocmd rpm -Uvh $force $nodeps $@ && return
local RES=$?
......@@ -587,11 +691,11 @@ epm_install()
return
fi
if [ -n "$direct" ] ; then
if [ -n "$direct" ] || [ -n "$repack" ] ; then
__handle_direct_install
fi
# if possible, it will put pkg_urls into pkg_files or pkg_names
# if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
if [ -n "$pkg_urls" ] ; then
load_helper epm-download
__handle_pkg_urls_to_install
......@@ -603,6 +707,7 @@ epm_install()
warmup_lowbase
local names="$(echo $pkg_names | filter_out_installed_packages)"
#local names="$(echo $pkg_names | exp_with_arch_suffix | filter_out_installed_packages)"
local files="$(echo $pkg_files | filter_out_installed_packages)"
# can be empty only after skip installed
......@@ -618,12 +723,22 @@ epm_install()
fi
epm_install_names $names || return
# repack binary files
if [ -n "$repack" ] ; then
__epm_repack_rpm $files || fatal
files="$repacked_rpms"
fi
epm_install_files $files
local RETVAL=$?
# TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
fi
return $RETVAL
}
#!/bin/sh
#
# Copyright (C) 2012, 2013, 2015, 2016 Etersoft
# Copyright (C) 2012, 2013, 2015, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013, 2015-2017 Etersoft
# Copyright (C) 2012, 2013, 2015-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
......@@ -20,6 +20,44 @@
load_helper epm-packages
load_helper epm-print
# pkg suffix
__print_with_arch_suffix()
{
local pkg="$1"
local suffix="$2"
# do not change if some suffix already exists
echo "$pkg" | grep -q "(x86-32)$" && echo "$pkg" | sed -e "s|(x86-32)$|.i686|" && return
echo "$pkg" | grep "\.x86_64$" && return
echo "$pkg" | grep "\.noarch$" && return
echo "$pkg" | grep "\.i[56]86$" && return
echo "$pkg$suffix"
}
# add suffix .x86_64 if we have 64 arch
exp_with_arch_suffix()
{
local suffix
[ "$($DISTRVENDOR -a)" = "x86_64" ] || { cat ; return ; }
# TODO: it is ok for ALT rpm to remove with this suffix
# TODO: separate install and remove?
case $PMTYPE in
yum-rpm|dnf-rpm)
suffix=".x86_64"
;;
*)
cat
return
;;
esac
# TODO: use estrlist or some function to do it
local pkg
for pkg in $(cat) ; do
__print_with_arch_suffix $pkg $suffix
done
}
_get_grep_exp()
{
......
......@@ -250,10 +250,14 @@ epm_remove()
return
fi
# TODO: fix pkg_names override
# get full package name(s) from the package file(s)
[ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)"
pkg_files=''
[ -n "$pkg_names" ] || fatal "Remove: missing package(s) name."
# TODO: remove only according current arch (if x86_64)
#pkg_names="$(echo $pkg_names | exp_with_arch_suffix)"
if [ -n "$dryrun" ] ; then
info "Packages for removing:"
......
......@@ -31,9 +31,7 @@ epm_whatdepends()
# by package name
case $PMTYPE in
apt-rpm)
#CMD="apt-cache whatdepends"
# more quiet
CMD="apt-cache rdepends"
CMD="apt-cache whatdepends"
;;
apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends"
......
......@@ -20,6 +20,7 @@
# List running services
serv_list()
{
info "Running services:"
case $SERVICETYPE in
# service-chkconfig)
# ;;
......@@ -33,9 +34,11 @@ serv_list()
sudocmd systemctl list-units $@
;;
*)
# hack to improve list speed
[ "$UID" = 0 ] || { sudocmd $PROGDIR/serv --quiet list ; return ; }
load_helper serv-list_all
load_helper serv-status
for i in $(serv_list_all) ; do
for i in $(quiet=1 serv_list_all) ; do
is_service_running $i >/dev/null && echo $i
done
;;
......
......@@ -23,7 +23,7 @@ serv_list_all()
case $SERVICETYPE in
service-chkconfig|service-upstart)
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig --list | cut -f1
sudocmd chkconfig --list | cut -f1 | grep -v "^$" | grep -v "xinetd:$"
if [ -n "$ANYSERVICE" ] ; then
sudocmd anyservice --quiet list
......
#!/bin/sh
#
# Copyright (C) 2012, 2013, 2016 Etersoft
# Copyright (C) 2012, 2013, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013, 2016, 2017 Etersoft
# Copyright (C) 2012, 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
......@@ -21,23 +21,27 @@
is_service_running()
{
local SERVICE="$1"
local OUTPUT
# TODO: real status can be checked only with grep output
case $SERVICETYPE in
service-chkconfig|service-upstart)
if is_anyservice $1 ; then
$SUDO anyservice $1 status >/dev/null
return
OUTPUT="$($SUDO anyservice $1 status 2>/dev/null)" || return 1
echo "$OUTPUT" | grep -q "is stopped" && return 1
return 0
fi
$SUDO service $1 status >/dev/null
OUTPUT="$($SUDO service $1 status 2>/dev/null)" || return 1
echo "$OUTPUT" | grep -q "is stopped" && return 1
return 0
;;
service-initd|service-update)
$SUDO $INITDIR/$1 status >/dev/null
$SUDO $INITDIR/$1 status >/dev/null 2>/dev/null
;;
systemd)
$SUDO systemctl status $1 >/dev/null
$SUDO systemctl status $1 >/dev/null 2>/dev/null
;;
runit)
$SUDO sv status "$SERVICE" >/dev/null
$SUDO sv status "$SERVICE" >/dev/null 2>/dev/null
;;
*)
fatal "Have no suitable command for $SERVICETYPE"
......
# This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 2.3.2
Version: 2.4.0
Release: alt0.M80P.1
Summary: Etersoft EPM package manager
......@@ -46,6 +46,19 @@ See detailed description here: http://wiki.etersoft.ru/EPM
#install -m 0755 packed/epm.sh %buildroot/%_datadir/%name/epm-packed.sh
#install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
mkdir -p %buildroot%_sysconfdir/eepm/
cat <<EOF >%buildroot%_sysconfdir/eepm/eepm.conf
# EEPM config (will insource in epm shell script)
# Not known variable yet
#verbose=--verbose
#quiet==--quiet
EOF
mkdir -p %buildroot%_sysconfdir/eepm/repack.d/
cp repack.d/*.sh %buildroot%_sysconfdir/eepm/repack.d/
chmod 0755 %buildroot%_sysconfdir/eepm/repack.d/*.sh
mkdir -p %buildroot%_sysconfdir/bash_completion.d/
install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/serv
ln -s serv %buildroot%_sysconfdir/bash_completion.d/cerv
......@@ -61,6 +74,10 @@ rm -f %buildroot%_datadir/%name/tools_eget
%files
%doc README TODO LICENSE
%dir %_sysconfdir/eepm/
%dir %_sysconfdir/eepm/repack.d/
%config(noreplace) %_sysconfdir/eepm/eepm.conf
%config(noreplace) %_sysconfdir/eepm/repack.d/*.sh
%_bindir/epm*
%_bindir/eepm
%_bindir/upm
......@@ -73,9 +90,38 @@ rm -f %buildroot%_datadir/%name/tools_eget
%_sysconfdir/bash_completion.d/cerv
%changelog
* Fri Dec 01 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.2-alt0.M80P.1
* Sun Dec 10 2017 Vitaly Lipatov <lav@altlinux.ru> 2.4.0-alt0.M80P.1
- backport to ALTLinux p8 (by rpmbph script)
* Sun Dec 10 2017 Vitaly Lipatov <lav@altlinux.ru> 2.4.0-alt1
- epm: add /etc/eepm/eepm.conf support
- epm install: add --repack support (binary rpm repacking before install)
- add --scripts support to repack foreign packages with alien
- epm-install: add /etc/eepm/repack.d/PKGNAME.sh support during repacking
- add mssql-server, skypeforlinux rules
- revert "epm whatdepends: use rdepends": miss many dependencies
* Sat Dec 09 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.6-alt1
- drop arch suffix adding (we can't distinct between arch/noarch)
- improve --skip-installed on x86_64 Fedora based: check for noarch too
* Thu Dec 07 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.5-alt1
- serv-status: mask stderr in is_service_running
- epm-query: fix list package by package
- serv list-all: cleanup output
- serv list: improve speed with run sudo once
- serv status: improve running state detection
- query: replace (x86-32) with .i686 for rpm/dnf
* Wed Dec 06 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.4-alt1
- apply prefix only if there are no other prefix
* Tue Dec 05 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.3-alt1
- add repo alias for repolist
- epm-install: add options support during cross install
- distr_info: distinct between x86 and x86_64 for -a
- epm install: expand package names with arch before isinstalled checking (eterbug #12332)
* Fri Dec 01 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.2-alt1
- fix --auto remove for dnf
- release_upgrade: do not update rpm apt when downgraded from Sisyphus
......
#!/bin/sh
# Place shell code here
# It will run with two args: buildroot spec
# Name this script like package name
BUILDROOT="$1"
SPEC="$2"
#!/bin/sh -x
# It will run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
subst "s|^\(Name: .*\)$|# FIXME: due libcrypto.so.10(libcrypto.so.10)(64bit) autoreqs\nAutoReq:yes,nolib\n# Converted from original package requires\nRequires:libssl pbzip2 bzip2 gdb python-base libnuma libkrb5 libsss_nss_idmap\n\1|g" $SPEC
#!/bin/sh -x
# It will run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
# move binaries from /usr/share/PKGNAME to _libdir/PKGNAME
LIBDIR=$(rpmbuild --eval %_libdir 2>/dev/null)
mkdir -p $BUILDROOT$LIBDIR/
mv $BUILDROOT/usr/share/skypeforlinux/ $BUILDROOT$LIBDIR/
subst "s|/usr/share/skypeforlinux|$LIBDIR/skypeforlinux|g" $SPEC
subst "s|^SKYPE_PATH=.*|SKYPE_PATH=$LIBDIR/skypeforlinux/skypeforlinux|" $BUILDROOT/usr/bin/skypeforlinux
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