1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh -x
# It will run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
PRODUCT="$3"
PKG="$4"
SUBGENERIC="$5"
# firstly, pack $PRODUCTDIR if used
. $(dirname $0)/common.sh
flag_python3=''
for i in lib/python3 lib/python2.7 ; do
t=$i
if [ -d $BUILDROOT/usr/$i/dist-packages ] ; then
mv -v $BUILDROOT/usr/$i/dist-packages $BUILDROOT/usr/$t/site-packages
subst "s|/usr/$i/dist-packages|/usr/$t/site-packages|" $SPEC
fi
done
for i in $BUILDROOT/usr/bin/* ; do
[ -L "$i" ] && continue
[ -f "$i" ] || continue
grep -Eq '^#!/usr/bin/python|^#!/usr/bin/env python' $i && flag_python3=1
subst 's|^#!/usr/bin/python$|#!/usr/bin/python3|' $i
subst 's|^#!/usr/bin/env python$|#!/usr/bin/env python3|' $i
done
# check for .py scripts
find $BUILDROOT -name "*.py" | grep -q "\.py$" && flag_python3=1
# can't use subst in find's exec (subst can be as function only)
find $BUILDROOT -name "*.py" -exec sed -i -e '1{/python3/n};1i#!/usr/bin/python3' {} \;
if [ -n "$flag_python3" ] ; then
if [ "$(epm print info -s)" = "alt" ] && [ -z "$EPM_RPMBUILD" ] ; then
epm install --skip-installed rpm-build-python3
subst "1i%add_python3_lib_path /usr" $SPEC
# by some unknown reason there are no packages provide that (https://github.com/Etersoft/eepm/issues/22)
subst "1i%add_python3_req_skip gi.repository.GLib" $SPEC
fi
fi
# hack:
# TODO: check for tarball, detect root dir
#echo $BUILDROOT | grep -q "tar.*tmpdir/" && move_to_opt /liteide
# no auto req/prov by default
set_autoreq no
set_autoprov no
# Set high Epoche to override repository package
subst "s|^\(Name: .*\)$|# Override repository package\nEpoch: 100\n\1|g" $SPEC
[ -d $BUILDROOT/usr/lib/.build-id ] && remove_dir /usr/lib/.build-id || :
# disablle rpmlint (for ROSA)
subst "1i%global _build_pkgcheck_set %nil" $SPEC
subst "1i%global _build_pkgcheck_srpm %nil" $SPEC
# disable /usr/lib/.build-id generating
subst "1i%global _build_id_links none" $SPEC
set_rpm_field()
{
local field="$1"
local value="$2"
if grep -q "^$field:" $SPEC ; then
[ -n "$value" ] || return
subst "s|^$field:.*|$field: $value|" $SPEC
else
[ -n "$value" ] || value="Stub"
subst "1i$field: $value" $SPEC
fi
}
# FIXME: where is a source of the bug with empty Summary?
summary="$(grep "^Summary: " $SPEC | sed -e "s|Summary: ||g" | head -n1)"
[ -n "$summary" ] || set_rpm_field "Summary" "$PRODUCT (fixme: was empty Summary after alien)"
# clean version
subst "s|^\(Version: .*\)~.*|\1|" $SPEC
# add our prefix to release
subst "s|^Release: |Release: epm1.repacked.|" $SPEC
set_rpm_field "Distribution" "EEPM"
# TODO: check the yaml file!!!
if [ -r "$PKG.eepm.yaml" ] ; then
eval $(epm tool yaml $PKG.eepm.yaml | grep -E '(summary|description|upstream_file|upstream_url|url|appname|arch|group|license|version)=' ) #'
# for tarballs fix permissions
chmod $verbose -R a+rX *
[ -n "$version" ] && set_rpm_field "Version" "$version"
set_rpm_field "Group" "$group"
set_rpm_field "License" "$license"
set_rpm_field "URL" "$url"
set_rpm_field "Summary" "$summary"
[ -n "$upstream_file" ] || upstream_file="binary package $PRODUCT"
[ -n "$upstream_url" ] && upstream_file="$upstream_url"
[ -n "$description" ] && subst "s|^\((Converted from a\) \(.*\) \(package.*\)|$description\n(Repacked from $upstream_file with EPM $(epm --short --version))\n\1 \2 \3|" $SPEC
else
subst "s|^\((Converted from a\) \(.*\) \(package.*\)|(Repacked from binary \2 package with EPM $(epm --short --version))\n\1 \2 \3|" $SPEC
fi
# only for rpm
if [ -z "$SUBGENERIC" ] ; then
fix_cpio_bug_links
fi