aboutsummaryrefslogtreecommitdiffstats
path: root/freebsd.makefile.sh
blob: 4a1c23aab97b90a1c871372a467289d21cc1d78e (plain) (blame)
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
#!/bin/sh

gen_list () {
    exec 4< "${ports_file}"

    while read -r pkg_name pkg_ports 0<&4; do
        echo "    ${pkg_name}>=0:"'${PORTSDIR}'"/${pkg_ports} \\"
    done

    exec 4<&-
}

makefile_in_file="$1"
: ${makefile_in_file:="freebsd.makefile.in"}

ports_file="$2"
: ${ports_file:="freebsd.ports"}

exec 3< "${makefile_in_file}"

saveIFS="${IFS}"
lineIFS="$(printf "\n")"
IFS="${lineIFS}"

while read -r makefile_line 0<&3; do
    case "${makefile_line}" in
        "PORTVERSION="*)
            printf "PORTVERSION=\t%s\n" "`date '+%Y.%m.%d'`"
            ;;
        "RUN_DEPENDS+="*)
            echo 'RUN_DEPENDS+= \'
            IFS="${saveIFS}"
            gen_list
            IFS="${lineIFS}"
            ;;
        *)
            echo "${makefile_line}"
            ;;
    esac
done

exec 3<&-