summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_image_prepare_work_dir.sh
blob: 055494e0284bebac9c75608eb832906ab29fa153 (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
#!/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_make_image_extract_ipkg_files - extract ipkg for later image generation
#
# in:
# - $image_work_dir		directory where ipkg are extracted
# - $image_permissions		name of file that should contain all permissions
# - $image_pkgs_selected_target	space seperated list of selected
#				packages
# - $PTXDIST_IPKG_ARCH_STRING	ARCH variable for ipkg files
# - $PTXCONF_IPKG_IPKG_CONF_URL	the URL to use in /etc/ipkg.conf
#
# out:
# - $image_permissions		file containing all permissions
#
ptxd_make_image_extract_ipkg_files() {
    # FIXME: consolidate "ptxd_install_setup_src"
    local src="/etc/ipkg.conf"
    local ipkg_conf="${PTXDIST_TEMPDIR}/${FUNCNAME}_ipkg.conf"
    local -a list ptxd_reply
    list=( \
	"${PTXDIST_WORKSPACE}/projectroot${PTXDIST_PLATFORMSUFFIX}${src}" \
	"${PTXDIST_WORKSPACE}/projectroot${src}${PTXDIST_PLATFORMSUFFIX}" \
	"${PTXDIST_WORKSPACE}/projectroot${src}" \
	"${PTXDIST_TOPDIR}/generic${src}" \
	)

    if ! ptxd_get_path "${list[@]}"; then
	local IFS="
"
	ptxd_bailout "
unable to find '${src}'

These location have been searched:
${list[*]}
"
    fi

    rm -rf "${image_work_dir}" &&
    mkdir -p "${image_work_dir}" &&

    ARCH="${PTXDIST_IPKG_ARCH_STRING}" \
    SRC="${PTXCONF_IPKG_IPKG_CONF_URL}" \
	ptxd_replace_magic "${ptxd_reply}" > "${ipkg_conf}" &&

    DESTDIR="${image_work_dir}" \
	fakeroot -- ipkg-cl -f "${ipkg_conf}" -o "${image_work_dir}" \
	install "${ptxd_reply_ipkg_files[@]}" &&
    if ! cat "${ptxd_reply_perm_files[@]}" > "${image_permissions}"; then
	echo "${PTXDIST_LOG_PROMPT}error: failed read permission files" >&2
	return 1
    fi

    return
}
export -f ptxd_make_image_extract_ipkg_files


ptxd_make_image_prepare_work_dir() {
    ptxd_make_image_init &&
    ptxd_get_ipkg_files &&
    ptxd_make_image_extract_ipkg_files
}
export -f ptxd_make_image_prepare_work_dir