summaryrefslogtreecommitdiffstats
path: root/scripts/make_deb.sh
blob: a89c7ca4950be113904c533e08f16fd09e3f3e67 (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
#!/bin/bash -x

main() {
    while getopts "d:s:" opt; do
	case "${opt}" in
	    d)
		local deb="${OPTARG}"
		;;
	    s)
		local src="${OPTARG}"
	esac
    done

    if [ -z "${deb}" -o -z "${src}" ]; then
	exit 1
    fi

    local ifs_orig="${IFS}"
    IFS="_"
    set -- ${deb}
    IFS="${ifs_orig}"

    local package="${1##*/}"
    local inst="${1%${package}}"
    local version="${2}"
    local arch="${3%%.deb}"

    local prefix="opt/${src##*/opt/}"
    local destdir="${src%${prefix}}"
    local debian_tmp="${inst}/${package}-temp"
    if [ -e "${debian_tmp}" ]; then
	rm -rf "${debian_tmp}"
    fi

    mkdir -p "${debian_tmp}/DEBIAN"

    cat <<EOF > "${debian_tmp}/DEBIAN/control"
Package: ${package}
Version: ${version}
Priority: optional
Architecture: ${arch}
Essential: no
Maintainer: Pengutronix <ptxdist@pengutronix.de>
Description: ${package}
EOF
#Depends: autoconf, automake, libtool, flex, bison, gcc, g++, python-dev, libncurses5-dev, gawk, pkg-config, make, diff, patch, quilt
    # copy data
    tar -C "${destdir}" -c "${prefix}" | tar -C "${debian_tmp}" -x

    # make a deb out of it
    echo dpkg -b "${debian_tmp}" "${deb}" | fakeroot

    exit 1
    rm -rf "${debian_tmp}"
}


main "${@}"
exit $?