3f628c22cfcb97ba45fa01b594c17b0cc465b7f8
[catalyst.git] / targets / stage1 / stage1-chroot.sh
1 #!/bin/bash
2
3 source /tmp/chroot-functions.sh
4
5 # We do this first, so we know our package list for --debug
6 export clst_buildpkgs="$(/tmp/build.py)"
7
8 # Setup our environment
9 BOOTSTRAP_USE="$(portageq envvar BOOTSTRAP_USE)"
10 [ -n "${clst_BINDIST}" ] && BOOTSTRAP_USE="${BOOTSTRAP_USE} bindist"
11
12 FEATURES="${clst_myfeatures} nodoc noman noinfo -news"
13
14 ## Sanity check profile
15 if [ -z "${clst_buildpkgs}" ]
16 then
17         echo "Your profile seems to be broken."
18         echo "Could not build a list of build packages."
19         echo "Double check your /etc/portage/make.profile link and the 'packages' files."
20         exit 1
21 fi
22
23 ## Setup seed pkgmgr to ensure latest
24 clst_root_path=/ setup_pkgmgr
25
26 # Update stage3
27 if [ -n "${clst_update_seed}" ]; then
28         if [ "${clst_update_seed}" == "yes" ]; then
29                 echo "Updating seed stage..."
30                 if [ -n "${clst_update_seed_command}" ]; then
31                         clst_root_path=/ run_merge "--buildpkg=n ${clst_update_seed_command}"
32                 else
33                         clst_root_path=/ run_merge "--buildpkg=n --update --deep --newuse --onlydeps gcc"
34                 fi
35         elif [ "${clst_update_seed}" != "no" ]; then
36                 echo "Invalid setting for update_seed: ${clst_update_seed}"
37                 exit 1
38         fi
39 else
40         echo "Skipping seed stage update..."
41 fi
42
43 make_destpath /tmp/stage1root
44
45 ## START BUILD
46 # First, we drop in a known-good baselayout
47 [ -e /etc/portage/make.conf ] && \
48         echo 'USE="${USE} -build"' >> /etc/portage/make.conf
49 run_merge "--oneshot --nodeps sys-apps/baselayout"
50
51 sed -i '/USE="${USE} -build"/d' /etc/portage/make.conf
52
53 # Now, we install our packages
54 [ -e /etc/portage/make.conf ] && \
55         echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" \
56         >> /etc/portage/make.conf
57 run_merge "--oneshot ${clst_buildpkgs}"
58 sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \
59         /etc/portage/make.conf