summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_image_common.sh
blob: 5e0b497c237209e6459000751d22b2983aef279a (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
#!/bin/bash
#
# Copyright (C) 2010 by Marc Kleine-Budde <mkl@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#


#
# ptxd_get_ipkg_files - get full path to ipkgs that should be installed
#
# in:
# - $*				list of selected packages
#
# out:
# - $ptxd_reply_ipkg_files	array of ipkg files
# - $ptxd_reply_perm_files	array of permission files
#
ptxd_get_ipkg_files() {
    # map pkg_label to pkg's ipkg files
    local -a ptxd_reply
    ptxd_do_xpkg_map ${*}

    unset ptxd_reply_ipkg_files ptxd_reply_perm_files

    set -- "${ptxd_reply[@]}"
    while [ ${#} -ne 0 ]; do
	# look in "image_ipkg_repo_dirs" for ipkg files

	# FIXME: add IPKG_ARCH, pkg_version?
	local -a ipkg_files
	ipkg_files="${image_ipkg_repo_dirs[@]/%//${1}_*.ipk}"

	# take first hit
	if ptxd_get_path "${ipkg_files[@]}"; then
	    ptxd_reply_ipkg_files[${#ptxd_reply_ipkg_files[@]}]="${ptxd_reply}"
	    if [ -z "$(ptxd_get_ptxconf PTXCONF_IMAGE_INSTALL_FROM_IPKG_REPOSITORY)" ]; then
		ptxd_reply_perm_files[${#ptxd_reply_perm_files[@]}]="${ptxd_reply%/*/*}/state/${1}.perms"
	    else
		ptxd_reply_perm_files[${#ptxd_reply_perm_files[@]}]="${ptxd_reply%.ipk}.perms"
	    fi
	else
	    ptxd_bailout "\

Unable to find xpkg file for '${1}', this should not happen!
Run first 'ptxdist clean root' then 'ptxdist images' again.
"
	fi

	shift
    done
}
export -f ptxd_get_ipkg_files


#
# initialize variables needed for image creation
#
ptxd_make_image_init() {
    if [ -z "$(ptxd_get_ptxconf PTXCONF_IMAGE_INSTALL_FROM_IPKG_REPOSITORY)" ]; then
	image_ipkg_repo_dirs=( "${ptx_pkg_dir}" )
    else
	image_ipkg_repo_dirs=( "${image_repo_dist_dir}" )
    fi

    if [ -n "${PTXDIST_BASE_PLATFORMDIR}" ]; then
	image_ipkg_repo_dirs[${#image_ipkg_repo_dirs[@]}]="${PTXDIST_BASE_PLATFORMDIR}/packages"
    fi
}
export -f ptxd_make_image_init