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
etersoft
eepm
Commits
8c503144
Commit
8c503144
authored
6 months ago
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm-prescription: use epm-play-common for common functions
parent
d410aa99
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
129 deletions
+177
-129
epm-play
bin/epm-play
+1
-122
epm-play-common
bin/epm-play-common
+145
-0
epm-prescription
bin/epm-prescription
+31
-7
No files found.
bin/epm-play
View file @
8c503144
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
load_helper epm-play-common
__check_installed_app
()
__check_installed_app
()
{
{
...
@@ -48,17 +49,6 @@ __is_app_installed()
...
@@ -48,17 +49,6 @@ __is_app_installed()
return
return
}
}
__run_script
()
{
local
script
=
"
$psdir
/
$1
.sh"
[
-s
"
$script
"
]
||
return
[
-f
"
$script
.rpmnew"
]
&&
warning
'There is .rpmnew file(s) in $psdir dir. The play script can be outdated.'
shift
[
"
$PROGDIR
"
=
"/usr/bin"
]
&&
SCPATH
=
"
$PATH
"
||
SCPATH
=
"
$PROGDIR
:
$PATH
"
(
unset
EPMCURDIR
;
export
PATH
=
$SCPATH
;
$script
"
$@
"
)
return
}
__get_app_package
()
__get_app_package
()
{
{
...
@@ -66,19 +56,6 @@ __get_app_package()
...
@@ -66,19 +56,6 @@ __get_app_package()
}
}
__list_all_app
()
{
cd
$psdir
||
fatal
for
i
in
*
.sh
;
do
local
name
=
${
i
/.sh/
}
[
-n
"
$IGNOREi586
"
]
&&
startwith
"
$name
"
"i586-"
&&
continue
startwith
"
$name
"
"common"
&&
continue
echo
"
$name
"
done
cd
-
>
/dev/null
}
__list_all_packages
()
__list_all_packages
()
{
{
local
name
local
name
...
@@ -147,43 +124,6 @@ __list_installed_packages()
...
@@ -147,43 +124,6 @@ __list_installed_packages()
}
}
# args: script, host arch
__get_app_description
()
{
__run_script
"
$1
"
--description
"
$2
"
2>/dev/null
}
__check_play_script
()
{
local
script
=
"
$psdir
/
$1
.sh"
shift
[
-s
"
$script
"
]
}
__epm_play_run_script
()
{
local
script
=
"
$1
"
shift
local
addopt
addopt
=
"
$dryrun
$non_interactive
"
local
bashopt
=
''
[
-n
"
$debug
"
]
&&
bashopt
=
'-x'
#info "Running $($script --description 2>/dev/null) ..."
[
"
$PROGDIR
"
=
"/usr/bin"
]
&&
SCPATH
=
"
$PATH
"
||
SCPATH
=
"
$PROGDIR
:
$PATH
"
(
export
EPM_OPTIONS
=
"
$EPM_OPTIONS
$addopt
"
export
PATH
=
$SCPATH
;
docmd
$CMDSHELL
$bashopt
$script
"
$@
"
)
}
__epm_play_run
()
{
local
script
=
"
$psdir
/
$1
.sh"
shift
__epm_play_run_script
"
$script
"
"
$@
"
}
__epm_play_list_installed
()
__epm_play_list_installed
()
{
{
local
i
local
i
...
@@ -207,43 +147,6 @@ __epm_play_list_installed()
...
@@ -207,43 +147,6 @@ __epm_play_list_installed()
}
}
__epm_play_list
()
{
local
psdir
=
"
$1
"
local
extra
=
"
$2
"
local
i
local
IGNOREi586
local arch
=
"
$SYSTEMARCH
"
[
"
$arch
"
=
"x86_64"
]
&&
IGNOREi586
=
''
||
IGNOREi586
=
1
if
[
-n
"
$short
"
]
;
then
for
i
in
$(
__list_all_app
)
;
do
local
desc
=
"
$(
__get_app_description
$i
$arch
)
"
[
-n
"
$desc
"
]
||
continue
echo
"
$i
"
if
[
-n
"
$extra
"
]
;
then
for
j
in
$(
__run_script
"
$i
"
"--product-alternatives"
)
;
do
echo
"
$i
=
$j
"
done
fi
done
exit
fi
for
i
in
$(
__list_all_app
)
;
do
local
desc
=
"
$(
__get_app_description
$i
$arch
)
"
[
-n
"
$desc
"
]
||
continue
[
-n
"
$quiet
"
]
||
echo
-n
" "
printf
"%-20s - %s
\n
"
"
$i
"
"
$desc
"
if
[
-n
"
$extra
"
]
;
then
for
j
in
$(
__run_script
"
$i
"
"--product-alternatives"
)
;
do
printf
" %-20s - %s
\n
"
"
$i
=
$j
"
"
$desc
"
done
fi
done
}
epm_play_help
()
epm_play_help
()
{
{
message
'
message
'
...
@@ -269,30 +172,6 @@ Examples:
...
@@ -269,30 +172,6 @@ Examples:
'
'
}
}
__epm_is_shell_script
()
{
local
script
=
"
$1
"
[
-x
"
$script
"
]
&&
rhas
"
$script
"
"
\.
sh$"
&&
head
-n1
"
$script
"
|
grep
-q
"^#!/bin/sh"
}
__epm_play_remove
()
{
local
prescription
for
prescription
in
$*
;
do
if
__epm_is_shell_script
"
$prescription
"
;
then
__epm_play_run_script
$prescription
--remove
continue
fi
if
__check_play_script
"
$prescription
"
;
then
__epm_play_run
$prescription
--remove
__remove_installed_app
"
$prescription
"
else
psdir
=
$prsdir
__check_play_script
"
$prescription
"
||
fatal
'We have no idea how to remove $prescription (checked in $psdir and $prsdir)'
__epm_play_run
"
$prescription
"
--remove
||
fatal
"There was some error during run the script."
fi
done
}
__epm_play_update
()
__epm_play_update
()
...
...
This diff is collapsed.
Click to expand it.
bin/epm-play-common
0 → 100644
View file @
8c503144
#!/bin/sh
#
# Copyright (C) 2015, 2017, 2019, 2020, 2022 Etersoft
# Copyright (C) 2015, 2017, 2019, 2020, 2022 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/>.
#
__run_script
()
{
local
script
=
"
$psdir
/
$1
.sh"
[
-s
"
$script
"
]
||
return
[
-f
"
$script
.rpmnew"
]
&&
warning
'There is .rpmnew file(s) in $psdir dir. The play script can be outdated.'
shift
[
"
$PROGDIR
"
=
"/usr/bin"
]
&&
SCPATH
=
"
$PATH
"
||
SCPATH
=
"
$PROGDIR
:
$PATH
"
(
unset
EPMCURDIR
;
export
PATH
=
$SCPATH
;
$script
"
$@
"
)
return
}
__list_all_app
()
{
cd
$psdir
||
fatal
for
i
in
*
.sh
;
do
local
name
=
${
i
/.sh/
}
[
-n
"
$IGNOREi586
"
]
&&
startwith
"
$name
"
"i586-"
&&
continue
startwith
"
$name
"
"common"
&&
continue
echo
"
$name
"
done
cd
-
>
/dev/null
}
# args: script, host arch
__get_app_description
()
{
__run_script
"
$1
"
--description
"
$2
"
2>/dev/null
}
__check_play_script
()
{
local
script
=
"
$psdir
/
$1
.sh"
shift
[
-s
"
$script
"
]
}
__epm_play_run_script
()
{
local
script
=
"
$1
"
shift
local
addopt
addopt
=
"
$dryrun
$non_interactive
"
local
bashopt
=
''
[
-n
"
$debug
"
]
&&
bashopt
=
'-x'
#info "Running $($script --description 2>/dev/null) ..."
[
"
$PROGDIR
"
=
"/usr/bin"
]
&&
SCPATH
=
"
$PATH
"
||
SCPATH
=
"
$PROGDIR
:
$PATH
"
(
export
EPM_OPTIONS
=
"
$EPM_OPTIONS
$addopt
"
export
PATH
=
$SCPATH
;
docmd
$CMDSHELL
$bashopt
$script
"
$@
"
)
}
__epm_play_run
()
{
local
script
=
"
$psdir
/
$1
.sh"
shift
__epm_play_run_script
"
$script
"
"
$@
"
}
__epm_is_shell_script
()
{
local
script
=
"
$1
"
[
-x
"
$script
"
]
&&
rhas
"
$script
"
"
\.
sh$"
&&
head
-n1
"
$script
"
|
grep
-q
"^#!/bin/sh"
}
__epm_play_remove
()
{
local
prescription
for
prescription
in
$*
;
do
if
__epm_is_shell_script
"
$prescription
"
;
then
__epm_play_run_script
$prescription
--remove
continue
fi
if
__check_play_script
"
$prescription
"
;
then
__epm_play_run
$prescription
--remove
__remove_installed_app
"
$prescription
"
else
psdir
=
$prsdir
__check_play_script
"
$prescription
"
||
fatal
'We have no idea how to remove $prescription (checked in $psdir and $prsdir)'
__epm_play_run
"
$prescription
"
--remove
||
fatal
"There was some error during run the script."
fi
done
}
__epm_play_list
()
{
local
psdir
=
"
$1
"
local
extra
=
"
$2
"
local
i
local
IGNOREi586
local arch
=
"
$SYSTEMARCH
"
[
"
$arch
"
=
"x86_64"
]
&&
IGNOREi586
=
''
||
IGNOREi586
=
1
if
[
-n
"
$short
"
]
;
then
for
i
in
$(
__list_all_app
)
;
do
local
desc
=
"
$(
__get_app_description
$i
$arch
)
"
[
-n
"
$desc
"
]
||
continue
echo
"
$i
"
if
[
-n
"
$extra
"
]
;
then
for
j
in
$(
__run_script
"
$i
"
"--product-alternatives"
)
;
do
echo
"
$i
=
$j
"
done
fi
done
exit
fi
for
i
in
$(
__list_all_app
)
;
do
local
desc
=
"
$(
__get_app_description
$i
$arch
)
"
[
-n
"
$desc
"
]
||
continue
[
-n
"
$quiet
"
]
||
echo
-n
" "
printf
"%-20s - %s
\n
"
"
$i
"
"
$desc
"
if
[
-n
"
$extra
"
]
;
then
for
j
in
$(
__run_script
"
$i
"
"--product-alternatives"
)
;
do
printf
" %-20s - %s
\n
"
"
$i
=
$j
"
"
$desc
"
done
fi
done
}
This diff is collapsed.
Click to expand it.
bin/epm-prescription
View file @
8c503144
...
@@ -17,21 +17,45 @@
...
@@ -17,21 +17,45 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
load_helper epm-play
load_helper epm-play
-common
epm_prescription
()
epm_prescription
_help
()
{
{
local
psdir
=
"
$CONFIGDIR
/prescription.d"
if
[
"
$1
"
=
"-h"
]
||
[
"
$1
"
=
"--help"
]
;
then
message
'
message
'
Options:
Options:
<receipt> - run <receipt>
<receipt> - run <receipt>
--list-all - list all available receipts
--list-all - list all available receipts
'
'
}
epm_prescription
()
{
local
psdir
=
"
$CONFIGDIR
/prescription.d"
while
[
-n
"
$1
"
]
;
do
case
"
$1
"
in
-h
|
--help
)
epm_prescription_help
exit
exit
fi
;;
--remove
)
shift
if
[
-z
"
$1
"
]
;
then
fatal
"run --remove with receipt name"
fi
__epm_play_remove
"
$@
"
exit
;;
-
*
)
fatal
"Unknown option
$1
"
;;
*
)
break
;;
esac
done
if
[
"
$1
"
=
"--list-all"
]
||
[
-z
"
$*
"
]
;
then
if
[
"
$1
"
=
"--list-all"
]
||
[
-z
"
$*
"
]
;
then
[
-n
"
$short
"
]
||
[
-n
"
$quiet
"
]
||
message
"Run with a name of a prescription to run:"
[
-n
"
$short
"
]
||
[
-n
"
$quiet
"
]
||
message
"Run with a name of a prescription to run:"
...
...
This diff is collapsed.
Click to expand it.
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