generic.sh 3.4 KB
Newer Older
1 2 3 4
#!/bin/sh -x
# It will run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"
5
PRODUCT="$3"
6
PKG="$4"
7
SUBGENERIC="$5"
8

9
# firstly, pack $PRODUCTDIR if used
10
. $(dirname $0)/common.sh
11

12 13
flag_python3=''

14 15 16 17 18 19 20
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
21 22

for i in $BUILDROOT/usr/bin/* ; do
23
    [ -L "$i" ] && continue
24
    [ -f "$i" ] || continue
25
    grep -Eq '^#!/usr/bin/python|^#!/usr/bin/env python' $i && flag_python3=1
26
    subst 's|^#!/usr/bin/python$|#!/usr/bin/python3|' $i
27
    subst 's|^#!/usr/bin/env python$|#!/usr/bin/env python3|' $i
28 29 30 31
done

# check for .py scripts
find $BUILDROOT -name "*.py" | grep -q "\.py$" && flag_python3=1
32 33
# 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' {} \;
34 35

if [ -n "$flag_python3" ] ; then
36
    if [ "$(epm print info -s)" = "alt" ] && [ -z "$EPM_RPMBUILD" ] ; then
37
        epm install --skip-installed rpm-build-python3
38 39 40
        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
41
    fi
42
fi
43

44 45 46 47
# hack:
# TODO: check for tarball, detect root dir
#echo $BUILDROOT | grep -q "tar.*tmpdir/" && move_to_opt /liteide

48 49 50 51
# no auto req/prov by default
set_autoreq no
set_autoprov no

52
# Set high Epoche to override repository package
53
subst "s|^\(Name: .*\)$|# Override repository package\nEpoch: 100\n\1|g" $SPEC
54 55

[ -d $BUILDROOT/usr/lib/.build-id ] && remove_dir /usr/lib/.build-id || :
56 57 58 59 60

# disablle rpmlint (for ROSA)
subst "1i%global _build_pkgcheck_set %nil" $SPEC
subst "1i%global _build_pkgcheck_srpm %nil" $SPEC

61 62 63 64
set_rpm_field()
{
    local field="$1"
    local value="$2"
65
    if grep -q "^$field:" $SPEC ; then
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        [ -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?
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
81
set_rpm_field "Distribution" "EEPM"
82 83


84
if [ -r "$PKG.eepm.yaml" ] ; then
85
    eval $(epm tool yaml $PKG.eepm.yaml | grep -E '(summary|description|upstream_file|upstream_url|url|appname|arches|group|license|version)=' ) #'
86 87 88
    # for tarballs fix permissions
    chmod $verbose -R a+rX *

89
    [ -n "$version" ] && set_rpm_field "Version" "$version"
90 91 92 93 94 95 96 97
    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 --short --version))\n\1 \2 \3|" $SPEC
else
98
    subst "s|^\((Converted from a\) \(.*\) \(package.*\)|(Repacked from binary \2 package with $(epm --short --version))\n\1 \2 \3|" $SPEC
99
fi
100

101 102 103 104
# only for rpm
if [ -z "$SUBGENERIC" ] ; then
    fix_cpio_bug_links
fi