summaryrefslogtreecommitdiffstats
path: root/packages/fedora
blob: cf50a2a89a66c86ae64838d6978a120944804548 (plain)
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
#!/bin/bash
#-- make sure we know how to handle the distro
#   Each file needs to define a function called get_source that will
#   be passed the working directory and a package name, and that must
#   return the full absolute path to the source tree.
#
#   A similar remove_source function must also be defined (same parameters)
#   that just removes everything created in the working directory for this
#   package.
#

get_source() {
        pwd=$(pwd)
        workdir="$1"
        pkg="$2"

        #-- set up the proper environment
        cd "$workdir"
        [ ! -d $pkg ] && mkdir $pkg
        cd $pkg
        [ ! -d rpmbuild ] && mkdir rpmbuild
        for ii in BUILD SOURCES SPECS SRPMS
        do
                [ ! -d rpmbuild/$ii ] && mkdir rpmbuild/$ii
        done
        rpmhome="$workdir/$pkg"

        #-- fetch the bits from fedpkg
        if [ -d $pkg ]
        then
                res=$(cd $pkg; fedpkg pull >/dev/null 2>&1)
        else
                res=$(fedpkg clone -a $pkg >/dev/null 2>&1)
        fi
        if [ ! -d $pkg ]
        then
                echo ""
                cd $pwd
                exit 1
        fi

        #-- get the srpm made
        cd $pkg
        res=$(fedpkg srpm >/dev/null 2>&1)
        fname=$(ls -1 *.src.rpm | head -1)
        if [ -z "$fname" ]
        then
                echo ""
                cd $pwd
                exit 1
        fi

        #-- unpack the srpm
        srpm=$(ls -1 | grep .src.rpm | head -1)
        res=$(HOME=$rpmhome rpm -i $srpm >/dev/null 2>&1)

        #-- unpack the source and apply the patches
        cd $rpmhome/rpmbuild/SPECS
        res=$(HOME=$rpmhome rpmbuild --nodeps -bp ${pkg}.spec >/dev/null 2>&1)

        #-- all done.  as you were.  and report the path.
        path=$(ls $rpmhome/rpmbuild/BUILD | grep $pkg | head -1)
        if [ ! -z $path ]
        then
                echo $rpmhome/rpmbuild/BUILD/$path
        else
                echo ""
        fi
        cd $pwd
}

remove_source () {
        pwd=$(pwd)
        workdir="$1"
        pkg="$2"

        cd "$workdir"
        rm -rf $pkg >/dev/null 2>&1

        cd $pwd
}