Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
eepm
Commits
774fea82
Commit
774fea82
authored
Apr 24, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm-assure: implement version checking
parent
9a4c2024
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
20 deletions
+46
-20
epm-assure
bin/epm-assure
+46
-20
No files found.
bin/epm-assure
View file @
774fea82
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2013
, 2014, 2015
Etersoft
# Copyright (C) 2013
-2016
Etersoft
# Copyright (C) 2013
, 2014, 2015
Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2013
-2016
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# 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
# it under the terms of the GNU Affero General Public License as published by
...
@@ -38,48 +38,74 @@ is_dirpath()
...
@@ -38,48 +38,74 @@ is_dirpath()
rhas
"
$1
"
"/"
rhas
"
$1
"
"/"
}
}
__epm_need_update
()
{
local
PACKAGE
=
"
$1
"
local
PACKAGEVERSION
=
"
$2
"
[
-n
"
$PACKAGEVERSION
"
]
||
return
1
load_helper epm-query
is_installed
"
$PACKAGE
"
||
return
0
load_helper epm-print
# epm print version for package N
local
INSTALLEDVERSION
=
$(
query_package_field
"version"
"
$PACKAGE
"
)
# if needed <= installed, return
[
"
$(
compare_version
"
$PACKAGEVERSION
"
"
$INSTALLEDVERSION
"
)
"
-lt
0
]
&&
return
0
return
1
}
__epm_assure_install
()
{
local
PACKAGE
=
"
$1
"
#docmd epm --auto --skip-installed install "$PACKAGE"
docmd epm
--auto
install
"
$PACKAGE
"
}
# Do fast checking for command and install package if the command does not exist
# Do fast checking for command and install package if the command does not exist
# $1 - command name
# $1 - command name
# $2 - package name
# $2 - [package name]
# $3 - [needed package version]
__epm_assure
()
__epm_assure
()
{
{
local
CMD
=
"
$1
"
local
PACKAGE
=
"
$2
"
local
PACKAGEVERSION
=
"
$3
"
[
-n
"
$PACKAGE
"
]
||
PACKAGE
=
"
$1
"
if
is_dirpath
"
$
1
"
;
then
if
is_dirpath
"
$
CMD
"
;
then
if
[
-e
"
$
1
"
]
;
then
if
[
-e
"
$
CMD
"
]
;
then
if
[
-n
"
$verbose
"
]
;
then
if
[
-n
"
$verbose
"
]
;
then
info
"File or directory
$
1
is already exists."
info
"File or directory
$
CMD
is already exists."
epm qf
"
$
1
"
epm qf
"
$
CMD
"
fi
fi
return
0
__epm_need_update
"
$PACKAGE
"
"
$PACKAGEVERSION
"
&&
__epm_assure_install
"
$PACKAGE
"
return
0
fi
fi
[
-n
"
$2
"
]
||
fatal
"You need run with package name param when use with absolute path"
[
-n
"
$2
"
]
||
fatal
"You need run with package name param when use with absolute path"
docmd epm
--auto
--skip-installed
install
"
$2
"
__epm_need_update
"
$PACKAGE
"
"
$PACKAGEVERSION
"
&&
__epm_assure_install
"
$PACKAGE
"
return
return
fi
fi
if
__check_command_in_path
"
$
1
"
>
/dev/null
;
then
if
__check_command_in_path
"
$
CMD
"
>
/dev/null
;
then
if
[
-n
"
$verbose
"
]
;
then
if
[
-n
"
$verbose
"
]
;
then
local
compath
=
"
$(
__check_command_in_path
"
$1
"
)
"
local
compath
=
"
$(
__check_command_in_path
"
$1
"
)
"
info
"Command
$
1
is exists:
$compath
"
info
"Command
$
CMD
is exists:
$compath
"
epm qf
"
$compath
"
epm qf
"
$compath
"
fi
fi
__epm_need_update
"
$PACKAGE
"
"
$PACKAGEVERSION
"
&&
__epm_assure_install
"
$PACKAGE
"
return
0
return
0
fi
fi
# TODO: use package name normalization
# TODO: use package name normalization
info
"Installing appropriate package for
$1
command..."
info
"Installing appropriate package for
$CMD
command..."
__epm_need_update
"
$PACKAGE
"
"
$PACKAGEVERSION
"
&&
__epm_assure_install
"
$PACKAGE
"
local
PACKAGE
=
"
$2
"
[
-n
"
$PACKAGE
"
]
||
PACKAGE
=
"
$1
"
local
PACKAGEVERSION
=
"
$3
"
warning
"TODO: check for PACKAGEVERSION is missed"
docmd epm
--auto
--skip-installed
install
"
$PACKAGE
"
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment