summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_image_prepare_work_dir.sh
blob: d8f7b1d31827ec3dacda55c5f50ee44c8476d6c3 (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
#!/bin/bash
#
# Copyright (C) 2010 by Marc Kleine-Budde <mkl@pengutronix.de>
#               2011 by George McCollister <george.mccollister@gmail.com>
#
# 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
#
# out:
# - $image_permissions		file containing all permissions
#
ptxd_make_image_extract_xpkg_files() {
    # FIXME: consolidate "ptxd_install_setup_src"
    local src="/etc/ipkg.conf"
    local xpkg_conf="${PTXDIST_TEMPDIR}/${FUNCNAME}_xpkg.conf"
    local -a list ptxd_reply
    if ptxd_get_ptxconf "PTXCONF_HOST_PACKAGE_MANAGEMENT_OPKG" > /dev/null; then
	echo "option force_postinstall 1" > "${xpkg_conf}"
	src="/etc/opkg/opkg.conf"
    else
	src="/etc/ipkg.conf"
    fi
    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="" \
	ptxd_replace_magic "${ptxd_reply}" >> "${xpkg_conf}" &&

    DESTDIR="${image_work_dir}" \
	fakeroot -- ${image_xpkg_type}-cl -f "${xpkg_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_xpkg_files


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