Commit 33ac0aee authored by Vitaly Lipatov's avatar Vitaly Lipatov

initial commit

parents
See detailed description in russian at
http://wiki.etersoft.ru/Epm
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# HACK
#ETERBUILDBIN=/usr/bin
# FIXME
#. /usr/share/eterbuild/eterbuild
#load_mod rpm git buildsrpm
. $(dirname $0)/epm-sh-functions
#############################
phelp()
{
echo "$Descr
$Usage
-i|install install packages
"
}
name=${0##*/}
Usage="Usage: $name [-i|install] [package name(s), package files]..."
Descr="$name - etersoft package manager"
verbose=1
epm_cmd=
pkg_files=
pkg_names=
for opt in "$@" ; do
case $opt in
-h|--help|help)
phelp; exit 0
;;
-v|--verbose)
verbose=1
;;
-i|install)
epm_cmd=install
;;
*)
if [ -f "$opt" ] ; then
pkg_files="$pkgfiles $opt"
else
pkg_names="$pkgnames $opt"
fi
;;
esac
done
pkg_files=$(strip_spaces "$pkg_files")
pkg_names=$(strip_spaces "$pkg_names")
echover "pkg_files=$pkg_files"
echover "pkg_names=$pkg_names"
DISTRVENDOR=distr_vendor
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d)
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
set_target_pkg_env
[ -n "$epm_cmd" ] || fatal "Run without command"
epm_cmd_file=$(dirname $0)/epm-$epm_cmd
[ -r "$epm_cmd_file" ] || fatal "Have no $epm_cmd_file command file"
. $epm_cmd_file
eval epm_$epm_cmd
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
get_install_package_command()
{
local DISTRNAME=$1
local INAC=$2
local CMD
local RET=0
case $DISTRNAME in
"ALTLinux"|"Ubuntu"|"Debian"|"PCLinux")
[ -n "$INAC" ] && CMD="apt-get install" || CMD="apt-get -y --force-yes install"
;;
"LinuxXP"|"Fedora"|"ASPLinux"|"CentOS"|"RHEL"|"Scientific")
[ -n "$INAC" ] && CMD="yum install" || CMD="yum -y install"
;;
"Mandriva")
[ -n "$INAC" ] && CMD="urpmi --no-verify-rpm" || CMD="urpmi --auto --no-verify-rpm"
;;
"ROSA")
[ -n "$INAC" ] && CMD="urpmi --no-verify-rpm" || CMD="urpmi --auto --no-verify-rpm"
;;
"SUSE|SLED|SLES")
[ -n "$INAC" ] && CMD="zypper --non-interactive install" || CMD="yes | zypper --non-interactive install"
;;
*)
RET=1
CMD="echo \"Do not known install command for DISTRNAME $DISTRNAME\""
;;
esac
echo $CMD
return $RET
}
epm_install()
{
[ -n "$pkg_files$pkg_names" ] || fatal "Run install without packages"
CMD=$(get_install_package_command $DISTRNAME interactive)
docmd $CMD $pkg_files $pkg_names
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
echover()
{
[ -n "$verbose" ] || return
echo "$*"
}
# Used DISTRNAME
set_target_pkg_env()
{
[ "$($DISTRVENDOR -V)" -ge "20120519" ] || fatal "update rpm-build-altlinux-compat package to get new $DISTRVENDOR command"
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME")
}
# Print command line and run command line
docmd()
{
#SETCOLOR_SUCCESS
echo " \$ $@"
#SETCOLOR_NORMAL
"$@"
}
filter_strip_spaces()
{
# possible use just
#xargs echo
sed -e "s| \+| |g" | \
sed -e "s|^ ||" | sed -e "s| \$||"
}
strip_spaces()
{
echo "$*" | filter_strip_spaces
}
# Print error message and stop the program
fatal()
{
if [ -z "$TEXTDOMAIN" ] ; then
echo "Error in $0: $@" >&2
else
echog "Error in $0: $@" >&2
fi
exit 1
}
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