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
d9b86caa
Commit
d9b86caa
authored
Jan 31, 2018
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add repack command and move all repack code to a separate module
parent
ba3b1451
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
197 additions
and
150 deletions
+197
-150
epm
bin/epm
+5
-2
epm-install
bin/epm-install
+4
-148
epm-repack
bin/epm-repack
+188
-0
No files found.
bin/epm
View file @
d9b86caa
#!/bin/sh
#
# Copyright (C) 2012-201
6
Etersoft
# Copyright (C) 2012-201
6
Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-201
8
Etersoft
# Copyright (C) 2012-201
8
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
...
...
@@ -299,6 +299,9 @@ check_command()
print
)
# HELPCMD: print various info, run epm print help for details
epm_cmd
=
print
;;
repack
)
# HELPCMD: repack rpm to local compatibility
epm_cmd
=
repack
;;
-V
|
checkpkg|integrity
)
# HELPCMD: check package file integrity (checksum)
epm_cmd
=
checkpkg
;;
...
...
bin/epm-install
View file @
d9b86caa
#!/bin/sh
#
# Copyright (C) 2012-201
7
Etersoft
# Copyright (C) 2012-201
7
Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-201
8
Etersoft
# Copyright (C) 2012-201
8
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,7 @@
load_helper epm-sh-altlinux
load_helper epm-query
load_helper epm-assure
load_helper epm-repack
load_helper epm-check_updated_repo
load_helper epm-sh-warmup
...
...
@@ -289,149 +290,6 @@ __epm_check_if_rpm_already_installed()
LANG
=
C
$SUDO
rpm
-Uvh
$force
$nodeps
$@
2>&1 |
grep
-q
"is already installed"
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_deb
()
{
local
pkg
local
debpkgs
=
""
for
pkg
in
$@
;
do
[
"
$(
get_package_type
"
$pkg
"
)
"
=
"deb"
]
||
return
1
[
-e
"
$pkg
"
]
||
fatal
"Can't read
$pkg
"
debpkgs
=
"
$debpkgs
$(
realpath
$pkg
)
"
done
[
-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
local
RPMCONVERTED
=
$(
grep
"rpm generated"
$RC_STDOUT
|
sed
-e
"s| generated||g"
)
clean_store_output
docmd epm
install
$force
$nodeps
$RPMCONVERTED
done
rm
-f
$TDIR
/
*
rmdir
$TDIR
/
return
0
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_rpm
()
{
local
pkg
local
rpmpkgs
=
""
for
pkg
in
$@
;
do
[
"
$(
get_package_type
"
$pkg
"
)
"
=
"rpm"
]
||
return
1
[
-e
"
$pkg
"
]
||
fatal
"Can't read
$pkg
"
rpmpkgs
=
"
$rpmpkgs
$(
realpath
$pkg
)
"
done
[
-n
"
$rpmpkgs
"
]
||
return
1
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
"
local
DEBCONVERTED
=
$(
grep
"deb generated"
$RC_STDOUT
|
sed
-e
"s| generated||g"
)
clean_store_output
docmd epm
install
$force
$nodeps
$DEBCONVERTED
done
rm
-f
$TDIR
/
*
rmdir
$TDIR
/
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
...
...
@@ -462,8 +320,6 @@ epm_install_files()
apt-rpm
)
__epm_check_if_try_install_deb
$@
&&
return
# 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
...
...
@@ -692,7 +548,7 @@ epm_install()
return
fi
if
[
-n
"
$direct
"
]
||
[
-n
"
$repack
"
]
;
then
if
[
-n
"
$direct
"
]
&&
[
-z
"
$repack
"
]
;
then
__handle_direct_install
fi
...
...
bin/epm-repack
0 → 100644
View file @
d9b86caa
#!/bin/sh
#
# Copyright (C) 2017-2018 Etersoft
# Copyright (C) 2017-2018 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/>.
#
load_helper epm-sh-altlinux
load_helper epm-assure
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_deb
()
{
local
pkg
local
debpkgs
=
""
for
pkg
in
$@
;
do
[
"
$(
get_package_type
"
$pkg
"
)
"
=
"deb"
]
||
return
1
[
-e
"
$pkg
"
]
||
fatal
"Can't read
$pkg
"
debpkgs
=
"
$debpkgs
$(
realpath
$pkg
)
"
done
[
-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
local
RPMCONVERTED
=
$(
grep
"rpm generated"
$RC_STDOUT
|
sed
-e
"s| generated||g"
)
clean_store_output
docmd epm
install
$force
$nodeps
$RPMCONVERTED
done
rm
-f
$TDIR
/
*
rmdir
$TDIR
/
return
0
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_rpm
()
{
local
pkg
local
rpmpkgs
=
""
for
pkg
in
$@
;
do
[
"
$(
get_package_type
"
$pkg
"
)
"
=
"rpm"
]
||
return
1
[
-e
"
$pkg
"
]
||
fatal
"Can't read
$pkg
"
rpmpkgs
=
"
$rpmpkgs
$(
realpath
$pkg
)
"
done
[
-n
"
$rpmpkgs
"
]
||
return
1
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
"
local
DEBCONVERTED
=
$(
grep
"deb generated"
$RC_STDOUT
|
sed
-e
"s| generated||g"
)
clean_store_output
docmd epm
install
$force
$nodeps
$DEBCONVERTED
done
rm
-f
$TDIR
/
*
rmdir
$TDIR
/
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
()
{
assure_distr ALTLinux
"install --repack"
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
}
epm_repack
()
{
# 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
fi
[
-z
"
$pkg_files
"
]
&&
info
"Skip empty repack list"
&&
return
22
__epm_repack_rpm
$pkg_files
||
fatal
cp
-v
$repacked_rpms
.
# 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
}
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