kameleon-builder 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/.editorconfig +0 -0
  2. data/.env +63 -15
  3. data/.gitignore +1 -0
  4. data/README.rst +4 -2
  5. data/Vagrantfile +13 -52
  6. data/bin/kameleon +5 -0
  7. data/completion/_kameleon.zsh +18 -0
  8. data/completion/kameleon.bash +13 -0
  9. data/completion/kameleon.fish +10 -0
  10. data/contrib/polipo_env.sh +2 -0
  11. data/contrib/steps/export/save_as_g5k.yaml +63 -0
  12. data/contrib/steps/setup/add_to_sudoers.yaml +5 -0
  13. data/docs/Makefile +10 -6
  14. data/docs/README.md +17 -0
  15. data/docs/source/_static/kameleon-logo.png +0 -0
  16. data/docs/source/_static/kameleon-logo.xcf +0 -0
  17. data/docs/source/_static/kameleon-long.png +0 -0
  18. data/docs/source/aliases.rst +4 -2
  19. data/docs/source/checkpoint.rst +2 -0
  20. data/docs/source/commands.rst +4 -3
  21. data/docs/source/conf.py +15 -7
  22. data/docs/source/context.rst +7 -4
  23. data/docs/source/faq.rst +39 -1
  24. data/docs/source/getting_started.rst +227 -1
  25. data/docs/source/grid5000_tutorial.rst +110 -0
  26. data/docs/source/index.rst +7 -2
  27. data/docs/source/installation.rst +12 -4
  28. data/docs/source/persistent_cache.rst +34 -0
  29. data/docs/source/recipe.rst +23 -16
  30. data/docs/source/use_cases.rst +93 -0
  31. data/docs/source/workspace.rst +2 -0
  32. data/kameleon-builder.gemspec +7 -1
  33. data/lib/kameleon.rb +3 -6
  34. data/lib/kameleon/cli.rb +104 -50
  35. data/lib/kameleon/compat.rb +39 -0
  36. data/lib/kameleon/context.rb +43 -13
  37. data/lib/kameleon/engine.rb +118 -77
  38. data/lib/kameleon/environment.rb +3 -5
  39. data/lib/kameleon/error.rb +15 -9
  40. data/lib/kameleon/logger.rb +7 -4
  41. data/lib/kameleon/persistent_cache.rb +139 -0
  42. data/lib/kameleon/recipe.rb +200 -81
  43. data/lib/kameleon/shell.rb +51 -16
  44. data/omnibus/.gitignore +11 -0
  45. data/omnibus/.kitchen.yml +25 -0
  46. data/omnibus/Berksfile +9 -0
  47. data/omnibus/Berksfile.lock +25 -0
  48. data/omnibus/Gemfile +12 -0
  49. data/omnibus/README.md +94 -0
  50. data/omnibus/config/projects/kameleon.rb +23 -0
  51. data/omnibus/config/software/kameleon.rb +24 -0
  52. data/omnibus/config/software/polipo.rb +30 -0
  53. data/omnibus/config/software/ruby.rb +158 -0
  54. data/omnibus/files/mac_dmg/Resources/background.png +0 -0
  55. data/omnibus/files/mac_dmg/Resources/icon.png +0 -0
  56. data/omnibus/files/mac_pkg/Resources/background.png +0 -0
  57. data/omnibus/files/mac_pkg/Resources/license.html +1 -0
  58. data/omnibus/files/mac_pkg/Resources/welcome.html +9 -0
  59. data/omnibus/omnibus.rb +27 -0
  60. data/omnibus/package-scripts/kameleon/makeselfinst +27 -0
  61. data/omnibus/package-scripts/kameleon/postrm +9 -0
  62. data/templates/archlinux-desktop.yaml +25 -0
  63. data/templates/archlinux.yaml +106 -0
  64. data/templates/debian-testing.yaml +25 -0
  65. data/templates/debian7-desktop.yaml +25 -0
  66. data/templates/{debian-wheezy-docker.yaml → debian7-docker.yaml} +30 -16
  67. data/templates/debian7-g5k.yaml +97 -0
  68. data/templates/debian7-oar-dev.yaml +51 -0
  69. data/templates/debian7.yaml +128 -0
  70. data/templates/extend.erb +23 -0
  71. data/templates/fedora-rawhide.yaml +30 -0
  72. data/templates/fedora20-desktop.yaml +21 -0
  73. data/templates/fedora20.yaml +105 -0
  74. data/templates/{debian-wheezy-chroot.yaml → old-debian7.yaml} +51 -38
  75. data/templates/{aliases → steps/aliases}/defaults.yaml +37 -12
  76. data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +219 -0
  77. data/templates/steps/bootstrap/archlinux/install_bootloader.yaml +46 -0
  78. data/templates/steps/bootstrap/archlinux/populate_disk.yaml +39 -0
  79. data/templates/steps/bootstrap/debian/debootstrap.yaml +18 -10
  80. data/templates/steps/bootstrap/debian/debootstrap_arm.yaml +31 -0
  81. data/templates/steps/bootstrap/fedora/liveos_bootstrap.yaml +123 -0
  82. data/templates/steps/bootstrap/g5k_reserv.yaml +70 -0
  83. data/templates/steps/bootstrap/initialize_disk_chroot.yaml +84 -0
  84. data/templates/steps/bootstrap/initialize_disk_qemu.yaml +72 -0
  85. data/templates/steps/bootstrap/install_bootloader.yaml +42 -0
  86. data/templates/steps/bootstrap/prepare_chroot.yaml +126 -0
  87. data/templates/steps/bootstrap/prepare_docker.yaml +19 -8
  88. data/templates/steps/bootstrap/prepare_qemu.yaml +47 -0
  89. data/templates/steps/bootstrap/start_chroot.yaml +11 -2
  90. data/templates/steps/bootstrap/start_docker.yaml +2 -2
  91. data/templates/steps/bootstrap/start_qemu.yaml +75 -0
  92. data/templates/steps/bootstrap/ubuntu/debootstrap.yaml +27 -0
  93. data/templates/steps/breakpoint.yaml +2 -0
  94. data/templates/{checkpoints → steps/checkpoints}/docker.yaml +0 -0
  95. data/templates/steps/checkpoints/qcow2.yaml +38 -0
  96. data/templates/steps/checkpoints/qemu.yaml +39 -0
  97. data/templates/steps/export/clean_appliance.yaml +7 -1
  98. data/templates/steps/export/compact_qcow_img.yaml +12 -0
  99. data/templates/steps/export/save_appliance.yaml +58 -0
  100. data/templates/steps/export/save_appliance_from_g5k.yaml +47 -0
  101. data/templates/steps/export/save_vagrant_box.yaml +29 -0
  102. data/templates/steps/setup/archlinux/configure_keyboard.yaml +9 -0
  103. data/templates/steps/setup/archlinux/configure_network.yaml +9 -0
  104. data/templates/steps/setup/archlinux/configure_ruby.yaml +7 -0
  105. data/templates/steps/setup/archlinux/configure_system.yaml +20 -0
  106. data/templates/steps/setup/archlinux/install_dev_tools.yaml +18 -0
  107. data/templates/steps/setup/archlinux/install_gnome.yaml +27 -0
  108. data/templates/steps/setup/archlinux/install_software.yaml +9 -0
  109. data/templates/steps/setup/archlinux/install_yaourt.yaml +29 -0
  110. data/templates/steps/setup/autologin.yaml +16 -0
  111. data/templates/steps/setup/create_group.yaml +12 -0
  112. data/templates/steps/setup/create_user.yaml +9 -10
  113. data/templates/steps/setup/debian/configure_apt.yaml +65 -0
  114. data/templates/steps/setup/debian/configure_kernel.yaml +18 -0
  115. data/templates/steps/setup/debian/{keyboard_config.yaml → configure_keyboard.yaml} +1 -1
  116. data/templates/steps/setup/debian/{network_config.yaml → configure_network.yaml} +0 -0
  117. data/templates/steps/setup/debian/{system_config.yaml → configure_system.yaml} +0 -0
  118. data/templates/steps/setup/debian/install_gnome.yaml +13 -0
  119. data/templates/steps/setup/debian/install_kde.yaml +13 -0
  120. data/templates/steps/setup/debian/install_software.yaml +2 -0
  121. data/templates/steps/setup/debian/oar/oar_debian_config_frontend.yaml +8 -0
  122. data/templates/steps/setup/debian/oar/oar_debian_config_node.yaml +5 -0
  123. data/templates/steps/setup/debian/oar/oar_debian_config_server.yaml +5 -0
  124. data/templates/steps/setup/debian/oar/oar_prereq_install.yaml +16 -0
  125. data/templates/steps/setup/debian/setup_vagrant_box.yaml +52 -0
  126. data/templates/steps/setup/debian/upgrade_system.yaml +15 -0
  127. data/templates/steps/setup/fedora/configure_network.yaml +30 -0
  128. data/templates/steps/setup/fedora/configure_system.yaml +59 -0
  129. data/templates/steps/setup/fedora/install_software.yaml +3 -0
  130. data/templates/steps/setup/fedora/update_system.yaml +10 -0
  131. data/templates/steps/setup/oar/oar_config_devel.yaml +21 -0
  132. data/templates/steps/setup/oar/oar_config_frontend.yaml +38 -0
  133. data/templates/steps/setup/oar/oar_config_node.yaml +4 -0
  134. data/templates/steps/setup/oar/oar_config_server.yaml +25 -0
  135. data/templates/steps/setup/oar/oar_config_system.yaml +34 -0
  136. data/templates/steps/setup/oar/oar_devel_prereq_install.yaml +5 -0
  137. data/templates/steps/setup/oar/oar_git_install.yaml +21 -0
  138. data/templates/steps/setup/ubuntu/configure_apt.yaml +67 -0
  139. data/templates/ubuntu-12.04-desktop.yaml +25 -0
  140. data/templates/ubuntu-12.04.yaml +128 -0
  141. data/templates/ubuntu-14.04-desktop.yaml +27 -0
  142. data/templates/ubuntu-14.04.yaml +25 -0
  143. data/templates/vagrant-debian7.yaml +31 -0
  144. data/version.txt +1 -1
  145. metadata +155 -28
  146. checksums.yaml +0 -7
  147. data/templates/checkpoints/qcow2.yaml +0 -44
  148. data/templates/fedora-docker.yaml +0 -96
  149. data/templates/steps/bootstrap/fedora/docker_bootstrap.yaml +0 -25
  150. data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +0 -22
  151. data/templates/steps/bootstrap/prepare_appliance_with_nbd.yaml +0 -93
  152. data/templates/steps/export/build_appliance_from_docker.yaml +0 -105
  153. data/templates/steps/export/save_appliance_from_nbd.yaml +0 -54
  154. data/templates/steps/setup/debian/kernel_install.yaml +0 -20
  155. data/templates/steps/setup/debian/software_install.yaml +0 -15
  156. data/templates/steps/setup/fedora/kernel_install.yaml +0 -27
  157. data/templates/steps/setup/fedora/software_install.yaml +0 -10
@@ -1,31 +1,44 @@
1
1
  write_local:
2
2
  - exec_local: |
3
3
  mkdir -p $(dirname @1);
4
- cat >@1 <<<"@2"
4
+ cat >@1 <<EOF
5
+ @2
6
+ EOF
5
7
 
6
8
  write_in:
7
9
  - exec_in: |
8
10
  mkdir -p $(dirname @1);
9
- cat >@1 <<<"@2"
11
+ cat >@1 <<EOF
12
+ @2
13
+ EOF
10
14
 
11
15
  write_out:
12
16
  - exec_out: |
13
17
  mkdir -p $(dirname @1);
14
- cat >@1 <<<"@2"
18
+ cat >@1 <<EOF
19
+ @2
20
+ EOF
15
21
 
16
22
  append_local:
17
23
  - exec_local: |
18
24
  mkdir -p $(dirname @1);
19
- cat >>@1 <<<"@2"
25
+ cat >>@1 <<EOF
26
+ @2
27
+ EOF
28
+
20
29
  append_in:
21
30
  - exec_in: |
22
31
  mkdir -p $(dirname @1);
23
- cat >>@1 <<<"@2"
32
+ cat >>@1 <<EOF
33
+ @2
34
+ EOF
24
35
 
25
36
  append_out:
26
37
  - exec_out: |
27
38
  mkdir -p $(dirname @1);
28
- cat >>@1 <<<"@2"
39
+ cat >@1 <<EOF
40
+ @2
41
+ EOF
29
42
 
30
43
  local2out:
31
44
  - exec_out: |
@@ -66,18 +79,30 @@ in2out:
66
79
 
67
80
  check_cmd_out:
68
81
  - on_bootstrap_init:
69
- - rescue:
82
+ - rescue:
70
83
  - exec_out: command -V @1 2> /dev/null
71
- - breakpoint: "@1 is missing"
84
+ - breakpoint: "@1 is missing from out_context"
72
85
 
73
86
  check_cmd_local:
74
87
  - on_bootstrap_init:
75
- - rescue:
88
+ - rescue:
76
89
  - exec_local: command -V @1 2> /dev/null
77
- - breakpoint: "@1 is missing"
90
+ - breakpoint: "@1 is missing from local_context"
78
91
 
79
92
  check_cmd_in:
80
93
  - on_bootstrap_init:
81
- - rescue:
94
+ - rescue:
82
95
  - exec_in: command -V @1 2> /dev/null
83
- - breakpoint: "@1 is missing"
96
+ - breakpoint: "@1 is missing from in_context"
97
+
98
+ umount_out:
99
+ - exec_out: |
100
+ echo "try umount @1..." ; mountpoint -q "@1" && umount -f -l "@1" || true
101
+
102
+ umount_local:
103
+ - exec_local: |
104
+ echo "try umount @1..." ; mountpoint -q "@1" && umount -f -l "@1" || true
105
+
106
+ umount_in:
107
+ - exec_in: |
108
+ echo "try umount @1..." ; mountpoint -q "@1" && umount -f -l "@1" || true
@@ -0,0 +1,219 @@
1
+ # Arch-bootstrap
2
+ #
3
+ # Call the arch-bootstrap.sh script to bootstrap an archlinux distro from
4
+ # any GNU system
5
+
6
+ # You can choose any group from https://www.archlinux.org/groups/
7
+ # It's recommended to use 'base' (default) or 'base-devel' (with dev tools)
8
+
9
+ - pkg_group: base
10
+
11
+ - enable_cache: true
12
+
13
+ - import_script:
14
+ - exec_out: |
15
+ cat > $$kameleon_cwd/arch-bootstrap.sh <<'EOF'
16
+ #!/bin/bash
17
+ #
18
+ # arch-bootstrap: Bootstrap a base Arch Linux system using any GNU distribution.
19
+ #
20
+ # Dependencies: bash >= 4, coreutils, wget, sed, gawk, tar, gzip, chroot, xz.
21
+ # Project: https://github.com/tokland/arch-bootstrap
22
+ #
23
+ # Install:
24
+ #
25
+ # # install -m 755 arch-bootstrap.sh /usr/local/bin/arch-bootstrap
26
+ #
27
+ # Some examples:
28
+ #
29
+ # # arch-bootstrap destination
30
+ # # arch-bootstrap -a x86_64 -r ftp://ftp.archlinux.org destination-x86_64
31
+ #
32
+ # And then you can chroot to the destination directory (root/root):
33
+ #
34
+ # # chroot destination
35
+
36
+ set -e -u -o pipefail
37
+
38
+ # Packages needed by pacman (see get-pacman-dependencies.sh)
39
+ PACMAN_PACKAGES=(
40
+ acl archlinux-keyring attr bzip2 curl expat glibc gpgme libarchive
41
+ libassuan libgpg-error libssh2 lzo2 openssl pacman pacman-mirrorlist xz
42
+ zlib krb5 e2fsprogs keyutils openssh
43
+ )
44
+ BASIC_PACKAGES=(${PACMAN_PACKAGES[*]} filesystem)
45
+ EXTRA_PACKAGES=(
46
+ $$pkg_group haveged syslinux
47
+ )
48
+ DEFAULT_REPO_URL="http://mirrors.kernel.org/archlinux"
49
+ DEFAULT_ARCH=`uname -m`
50
+
51
+ # Output to standard error
52
+ stderr() { echo "$@" >&2; }
53
+
54
+ # Output debug message to standard error
55
+ debug() { echo "--- $@"; }
56
+
57
+ # Extract href attribute from HTML link
58
+ extract_href() { sed -n '/<a / s/^.*<a [^>]*href="\([^\"]*\)".*$/\1/p'; }
59
+
60
+ # Simple wrapper around wget
61
+ fetch() { wget -c --passive-ftp --quiet "$@"; }
62
+
63
+ # Extract FILEPATH gz/xz archive to DEST directory
64
+ uncompress() {
65
+ local FILEPATH=$1 DEST=$2
66
+
67
+ case "$FILEPATH" in
68
+ *.gz) tar xzf "$FILEPATH" -C "$DEST";;
69
+ *.xz) xz -dc "$FILEPATH" | tar x -C "$DEST";;
70
+ *) debug "Error: unknown package format: $FILEPATH"
71
+ return 1;;
72
+ esac
73
+ }
74
+
75
+ ###
76
+
77
+ configure_pacman() {
78
+ local DEST=$1 ARCH=$2
79
+ debug "configure DNS and pacman"
80
+ cp "/etc/resolv.conf" "$DEST/etc/resolv.conf"
81
+ echo "Server = $REPO_URL/\$repo/os/$ARCH" >> "$DEST/etc/pacman.d/mirrorlist"
82
+ }
83
+
84
+ configure_minimal_system() {
85
+ local DEST=$1
86
+
87
+ mkdir -p "$DEST/dev"
88
+ echo "root:x:0:0:root:/root:/bin/bash" > "$DEST/etc/passwd"
89
+ echo 'root:$1$GT9AUpJe$oXANVIjIzcnmOpY07iaGi/:14657::::::' > "$DEST/etc/shadow"
90
+ touch "$DEST/etc/group"
91
+ echo "bootstrap" > "$DEST/etc/hostname"
92
+
93
+ test -e "$DEST/etc/mtab" || echo "rootfs / rootfs rw 0 0" > "$DEST/etc/mtab"
94
+ test -e "$DEST/dev/null" || mknod "$DEST/dev/null" c 1 3
95
+ test -e "$DEST/dev/random" || mknod -m 0644 "$DEST/dev/random" c 1 8
96
+ test -e "$DEST/dev/urandom" || mknod -m 0644 "$DEST/dev/urandom" c 1 9
97
+
98
+ sed -i "s/^[[:space:]]*\(CheckSpace\)/# \1/" "$DEST/etc/pacman.conf"
99
+ sed -i "s/^[[:space:]]*SigLevel[[:space:]]*=.*$/SigLevel = Never/" "$DEST/etc/pacman.conf"
100
+ }
101
+
102
+ fetch_packages_list() {
103
+ local REPO=$1
104
+
105
+ debug "fetch packages list: $REPO/"
106
+ # Force trailing '/' needed by FTP servers.
107
+ fetch -O - "$REPO/" | extract_href | awk -F"/" '{print $NF}' | sort -rn ||
108
+ { debug "Error: cannot fetch packages list: $REPO"; return 1; }
109
+ }
110
+
111
+ install_pacman_packages() {
112
+ local BASIC_PACKAGES=$1 DEST=$2 LIST=$3 PACKDIR=$4
113
+ debug "pacman package and dependencies: $BASIC_PACKAGES"
114
+
115
+ for PACKAGE in $BASIC_PACKAGES; do
116
+ local FILE=$(echo "$LIST" | grep -m1 "^$PACKAGE-[[:digit:]].*\(\.gz\|\.xz\)$")
117
+ test "$FILE" || { debug "Error: cannot find package: $PACKAGE"; return 1; }
118
+ local FILEPATH="$PACKDIR/$FILE"
119
+
120
+ debug "download package: $REPO/$FILE"
121
+ fetch -O "$FILEPATH" "$REPO/$FILE"
122
+ debug "uncompress package: $FILEPATH"
123
+ uncompress "$FILEPATH" "$DEST"
124
+ done
125
+ }
126
+
127
+ install_packages() {
128
+ local ARCH=$1 DEST=$2 PACKAGES=$3
129
+ debug "install packages: $PACKAGES"
130
+ mount -t proc /proc $DEST/proc
131
+ mount /dev $DEST/dev -o bind
132
+ LC_ALL=C chroot "$DEST" /usr/bin/pacman \
133
+ --noconfirm --arch $ARCH -Sy --force $PACKAGES
134
+ sync
135
+ umount $DEST/{proc,dev}
136
+ }
137
+
138
+ show_usage() {
139
+ stderr "show_usage: $(basename "$0") [-a i686|x86_64] [-r REPO_URL] DIRECTORY"
140
+ }
141
+
142
+ main() {
143
+ # Process arguments and options
144
+ test $# -eq 0 && set -- "-h"
145
+ local ARCH=$DEFAULT_ARCH
146
+ local REPO_URL=$DEFAULT_REPO_URL
147
+
148
+ while getopts "a:r:h" ARG; do
149
+ case "$ARG" in
150
+ a) ARCH=$OPTARG;;
151
+ r) REPO_URL=$OPTARG;;
152
+ *) show_usage; return 1;;
153
+ esac
154
+ done
155
+ shift $(($OPTIND-1))
156
+ test $# -eq 1 || { show_usage; return 1; }
157
+
158
+ local DEST=$1
159
+ local REPO="${REPO_URL%/}/core/os/$ARCH"
160
+ local PACKDIR=$(mktemp -d)
161
+ trap "rm -rf '$PACKDIR'" KILL TERM EXIT
162
+ debug "destination directory: $DEST"
163
+ debug "core repository: $REPO"
164
+ debug "temporary directory: $PACKDIR"
165
+
166
+ # Fetch packages, install and do a minimal system configuration
167
+ mkdir -p "$DEST"
168
+ local LIST=$(fetch_packages_list $REPO)
169
+ install_pacman_packages "${BASIC_PACKAGES[*]}" "$DEST" "$LIST" "$PACKDIR"
170
+ configure_pacman "$DEST" "$ARCH"
171
+ configure_minimal_system "$DEST"
172
+ install_packages "$ARCH" "$DEST" "${BASIC_PACKAGES[*]} ${EXTRA_PACKAGES[*]}"
173
+ configure_pacman "$DEST" "$ARCH" # Pacman must be re-configured
174
+ rm -rf "$PACKDIR"
175
+
176
+ debug "done"
177
+ }
178
+
179
+ main "$@"
180
+ EOF
181
+
182
+ - call_arch_boostrap:
183
+ - exec_out: |
184
+ if [ $$enable_cache = true ]; then
185
+ [[ ! -f "$$rootfs_download_path/.kameleon_timestamp" ]] || CACHE_AVAILABLE=1
186
+ fi
187
+ [[ -n $CACHE_AVAILABLE ]] || \
188
+ bash $$kameleon_cwd/arch-bootstrap.sh -a $$arch -r $$mirror $$rootfs_download_path \
189
+ && date +%s > $$rootfs_download_path/.kameleon_timestamp
190
+ - on_clean:
191
+ - umount_out: $$rootfs_download_path/proc
192
+ - umount_out: $$rootfs_download_path/dev
193
+
194
+ - enable_sshd_service:
195
+ - exec_out: |
196
+ chroot $$rootfs_download_path \
197
+ ln -sf \
198
+ '/usr/lib/systemd/system/sshd.service' \
199
+ '/etc/systemd/system/multi-user.target.wants/sshd.service'
200
+
201
+ - enable_dhcp_service:
202
+ - exec_out: |
203
+ chroot $$rootfs_download_path \
204
+ ln -sf \
205
+ '/usr/lib/systemd/system/dhcpcd.service' \
206
+ '/etc/systemd/system/multi-user.target.wants/dhcpcd.service'
207
+
208
+ - add_nobody_user: ## To allow sshd to run correctly
209
+ - exec_out: echo "nobody:x:99:99:nobody:/:/bin/false" >> $$rootfs_download_path/etc/passwd
210
+ - exec_out: echo "nobody:x:99:" >> $$rootfs_download_path/etc/group
211
+ - exec_out: echo "nobody:x:14871::::::" >> $$rootfs_download_path/etc/shadow
212
+
213
+ - configure_pacman:
214
+ - on_setup_init:
215
+ # init pacman keyring
216
+ - exec_in: haveged -w 1024
217
+ - exec_in: pacman-key --init
218
+ - exec_in: pkill haveged
219
+ - exec_in: pacman-key --populate archlinux
@@ -0,0 +1,46 @@
1
+ # Install extlinux bootloader
2
+
3
+ - install_bootloader:
4
+ - rescue:
5
+ - exec_out: LC_ALL=POSIX chroot $$rootfs bash -c "command -V extlinux 2> /dev/null"
6
+ - breakpoint: "extlinux is missing"
7
+ - exec_out: cp -r $$rootfs/usr/lib/syslinux/bios/*.c32 $$rootfs/boot/syslinux/
8
+ - exec_out: LC_ALL=POSIX chroot $$rootfs extlinux --install /boot/syslinux 2>&1
9
+ - exec_out: |
10
+ MBR_PATH=
11
+ PATHS=("$$rootfs/usr/share/syslinux/mbr.bin"
12
+ "$$rootfs/usr/lib/bios/syslinux/mbr.bin"
13
+ "$$rootfs/usr/lib/syslinux/bios/mbr.bin"
14
+ "$$rootfs/usr/lib/extlinux/mbr.bin"
15
+ "$$rootfs/usr/lib/syslinux/mbr.bin")
16
+ for element in "${PATHS[@]}"
17
+ do
18
+ if [ -f "$element" ]; then
19
+ MBR_PATH="$element"
20
+ break
21
+ fi
22
+ done
23
+ if [ "$MBR_PATH" == "" ]; then
24
+ fail "unable to locate the extlinux mbr"
25
+ else
26
+ dd if="$MBR_PATH" of="$$nbd_device" bs=440 2>&1
27
+ fi
28
+ - exec_out: echo " sync..." ; sync
29
+ - write_out:
30
+ - $$rootfs/boot/syslinux/syslinux.cfg
31
+ - |
32
+ default kameleon
33
+ timeout 5
34
+
35
+ label kameleon
36
+ kernel ../`basename $$rootfs/boot/vmlinuz*`
37
+ initrd ../`basename $$rootfs/boot/init*`
38
+ # the net.ifnames option is disable to get default net interface
39
+ # names according to this page:
40
+ # https://wiki.archlinux.org/index.php/Network_Configuration#Device_names
41
+ append root=UUID=`blkid -s UUID -o value $${nbd_device}p1` rw net.ifnames=0
42
+ - exec_out: echo " sync..." ; sync
43
+ - on_bootstrap_clean:
44
+ - exec_out: |
45
+ dir=$$rootfs/var/lib/os-prober/mount
46
+ test ! -d "$dir" || (umount -f -l "$dir" && rmdir "$dir")
@@ -0,0 +1,39 @@
1
+ # Populate disk
2
+ #
3
+ # This step is partionning and populating the disk
4
+
5
+ - partition_disk:
6
+ - check_cmd_out: parted
7
+ - exec_out: |
8
+ echo "Partitioning disk..."
9
+ parted $${device} mklabel msdos
10
+ parted $${device} mkpart primary 0% 100%
11
+ parted $${device} set 1 boot on
12
+ - exec_out: |
13
+ echo Creating root partition...
14
+ mkfs.$$filesystem_type -q $${device}p1 || fail cannot create / ext4
15
+
16
+ - mount_mountdir:
17
+ - on_checkpoint: redo
18
+ - exec_out: mkdir -p $$mountdir
19
+ - exec_out: "echo Mounting root partition... ; mount $${device}p1 $$mountdir || fail cannot mount /"
20
+ - on_export_clean:
21
+ - exec_out: "echo try umount $$mountdir... ; mountpoint -q $$mountdir && umount -f -l $$mountdir || true"
22
+
23
+ - copy_rootfs:
24
+ - check_cmd_out: rsync
25
+ - exec_out: rsync -aAX $$rootfs_cache/* $$rootfs
26
+ - exec_out: echo "sync..." ; sync
27
+
28
+ - create_fstab:
29
+ - write_out:
30
+ - $$mountdir/etc/fstab
31
+ - |
32
+ # /etc/fstab: static file system information.
33
+ #
34
+ # Use 'blkid' to print the universally unique identifier for a
35
+ # device; this may be used with UUID= as a more robust way to name devices
36
+ # that works even if disks are added and removed. See fstab(5).
37
+ #
38
+ # <file system> <mount point> <type> <options> <dump> <pass>
39
+ UUID=`blkid -s UUID -o value $${device}p1` / $$filesystem_type errors=remount-ro 0 1
@@ -1,13 +1,21 @@
1
1
  # # Bootstrap
2
- - include: >
3
- ifupdown locales libui-dialog-perl dialog isc-dhcp-client netbase
4
- net-tools iproute acpid openssh-server pciutils
2
+ - enable_cache: true
3
+
5
4
  - debootstrap:
6
5
  - check_cmd_out: debootstrap
7
- - exec_out: mkdir -p $(dirname "$$rootfs_archive")
8
- - exec_out: ROOTFS=$(dirname "$$rootfs_archive")/rootfs
9
- - exec_out: mkdir -p $ROOTFS
10
- - exec_out: test -f "$$rootfs_archive" || debootstrap --no-check-gpg --arch=$$arch --include="$$include" $$release $ROOTFS $$repository
11
- - exec_out: test -f "$$rootfs_archive" || cat /etc/resolv.conf > $ROOTFS/etc/resolv.conf
12
- - exec_out: test -f "$$rootfs_archive" || tar zcf "$$rootfs_archive" -C "$ROOTFS" --numeric-owner --one-file-system .
13
- - exec_out: test -f "$$rootfs_archive" || rm -rf $ROOTFS
6
+ - exec_out: mkdir -p $$rootfs_download_path
7
+ - exec_out: |
8
+ if [ $$enable_cache = true ]; then
9
+ [[ ! -f "$$rootfs_download_path/.kameleon_timestamp" ]] || CACHE_AVAILABLE=1
10
+ fi
11
+ [[ -n $CACHE_AVAILABLE ]] || \
12
+ debootstrap --no-check-gpg --arch=$$arch --include="$$include_pkg" $$release $$rootfs_download_path $$repository \
13
+ && date +%s > $$rootfs_download_path/.kameleon_timestamp
14
+ - exec_out: cat /etc/resolv.conf > $$rootfs_download_path/etc/resolv.conf
15
+ - write_out:
16
+ - $$rootfs_download_path/etc/network/interfaces
17
+ - |
18
+ auto lo
19
+ iface lo inet loopback
20
+ auto eth0
21
+ iface eth0 inet dhcp
@@ -0,0 +1,31 @@
1
+ # # Bootstrap
2
+ - enable_cache: true
3
+
4
+ - debootstrap:
5
+ - check_cmd_out: debootstrap
6
+ - check_cmd_out: qemu-arm-static
7
+ - exec_out: |
8
+ if [ $$enable_cache = true ]; then
9
+ [[ ! -f "$$rootfs_download_path/.kameleon_timestamp" ]] || CACHE_AVAILABLE=1
10
+ fi
11
+ if [ -n $CACHE_AVAILABLE ]; then
12
+ mkdir -p $$rootfs_download_path
13
+ debootstrap --no-check-gpg --foreign --variant=minbase --arch=$$arch --include="$$include_pkg" $$release $$rootfs_download_path $$repository
14
+ QEMU_USER_PATH=$(which qemu-arm-static)
15
+ cp $QEMU_USER_PATH $$rootfs_download_path/usr/bin/qemu-arm-static
16
+ chroot $$rootfs_download_path /usr/bin/qemu-arm-static -cpu cortex-a9 /bin/sh /debootstrap/debootstrap --second-stage
17
+ echo "deb $$repository wheezy main contrib non-free" > $$rootfs_download_path/etc/apt/sources.list
18
+ chroot $$rootfs_download_path /usr/bin/qemu-arm-static -cpu cortex-a9 /bin/sh apt-get update
19
+ chroot $$rootfs_download_path /usr/bin/qemu-arm-static -cpu cortex-a9 /bin/sh apt-get install -y --force-yes vim
20
+ date +%s > $$rootfs_download_path/.kameleon_timestamp
21
+ fi
22
+ - exec_out: false
23
+ - exec_out: date +%s > $$rootfs_download_path/.kameleon_timestamp
24
+ - exec_out: cat /etc/resolv.conf > $$rootfs_download_path/etc/resolv.conf
25
+ - write_out:
26
+ - $$rootfs_download_path/etc/network/interfaces
27
+ - |
28
+ auto lo
29
+ iface lo inet loopback
30
+ auto eth0
31
+ iface eth0 inet dhcp