native-compiling: make-portage-squash

File make-portage-squash, 2.1 kB (added by tomboy64, 3 years ago)

Create portage.squash file automatically

Line 
1#!/bin/bash
2
3OPENMOKO_OVERLAY="/usr/portage/local/layman/openmoko/trunk/openmoko-target/"
4MY_PWD=${PWD}
5
6if [[ -d squash ]]
7then
8  echo "Deleting dir 'squash'..."
9  rm -rf squash || exit 1
10  echo "  done."
11fi
12if [[ -e portage.squashfs ]]
13then
14  echo "Deleting old 'portage.squashfs'..."
15  rm -rf portage.squashfs || exit 1
16  echo "  done."
17fi
18
19echo "Creating dir 'squash'..."
20mkdir squash || exit 1
21echo "  done."
22
23echo "Getting and extracting 'portage-latest.tar.bz2'..."
24wget -O- \
25--progress=bar \
26  http://de-mirror.org/distro/gentoo/snapshots/portage-latest.tar.lzma \
27  | unlzma -c \
28  | tar xp -C squash \
29    || exit 1
30echo "  done."
31
32echo "Preparing Openmoko Overlay..."
33mkdir "${MY_PWD}/squash/tmpOM"
34(cd ${OPENMOKO_OVERLAY} && tar cf - .) | (cd ${MY_PWD}/squash/tmpOM/ && tar xpf -) || exit 1
35echo "  done."
36echo "Sorting categories ..."
37cat "${MY_PWD}/squash/portage/profiles/categories" >> "${MY_PWD}/squash/tmpOM/profiles/categories"
38sort -u -o "${MY_PWD}/squash/tmpOM/profiles/categories" "${MY_PWD}/squash/tmpOM/profiles/categories"
39echo "  done."
40echo "Handling further difficult files ..."
41for i in repo_name embedded arch.list
42do
43  cp -r "${MY_PWD}/squash/portage/profiles/${i}" "${MY_PWD}/squash/tmpOM/profiles/"
44done
45echo "  done."
46echo "Injecting fixed Overlay ..."
47(cd ${MY_PWD}/squash/tmpOM/ && tar cf - .) | (cd ${MY_PWD}/squash/portage/ && tar xpf -) || exit 1
48echo "  done."
49echo "Cleaning up .svn remnants..."
50for i in `find "${MY_PWD}/squash/portage/" -name .svn`
51do
52  rm -rf ${i}
53done
54echo "  done."
55echo "Redigesting portage tree..."
56for i in $(ls ${OPENMOKO_OVERLAY})
57do
58  if [[ -d ${OPENMOKO_OVERLAY}/${i} ]]
59  then for j in $(ls ${OPENMOKO_OVERLAY}/${i})
60    do if [[ -e ${OPENMOKO_OVERLAY}/${i}/${j}/Manifest ]]
61      then
62        dir="squash/portage/${i}/${j}/"
63        ebuild ${dir}/$(ls ${dir} | grep ebuild$ | tail -n1) digest
64      fi
65    done
66  fi
67done
68echo "  done."
69
70cd ${MY_PWD}/squash
71chown -R portage:portage *
72
73echo "Creating squashfs..."
74mksquashfs portage ../portage.squashfs || exit 1
75echo "  done."
76
77chmod a+r,a-wx ../portage.squashfs
78
79echo "Done."