trisquel 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. case $ARCH in
  2. amd64|i386)
  3. default_mirror http://archive.trisquel.info/trisquel
  4. ;;
  5. *)
  6. default_mirror http://ports.trisquel.info/trisquel
  7. ;;
  8. esac
  9. mirror_style release
  10. download_style apt
  11. finddebs_style from-indices
  12. variants - buildd fakechroot minbase
  13. keyring /usr/share/keyrings/trisquel-archive-keyring.gpg
  14. if doing_variant fakechroot; then
  15. test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
  16. fi
  17. case $ARCH in
  18. alpha|ia64) LIBC="libc6.1" ;;
  19. *) LIBC="libc6" ;;
  20. esac
  21. work_out_debs () {
  22. required="$(get_debs Priority: required)"
  23. if doing_variant -; then
  24. #required="$required $(get_debs Priority: important)"
  25. # ^^ should be getting debconf here somehow maybe
  26. base="$(get_debs Priority: important)"
  27. elif doing_variant buildd; then
  28. base="$(get_debs Build-Essential: yes)"
  29. elif doing_variant fakechroot || doing_variant minbase; then
  30. base="apt"
  31. fi
  32. case $MIRRORS in
  33. https://*)
  34. base="$base apt-transport-https ca-certificates"
  35. ;;
  36. esac
  37. }
  38. first_stage_install () {
  39. extract $required
  40. mkdir -p "$TARGET/var/lib/dpkg"
  41. : >"$TARGET/var/lib/dpkg/status"
  42. : >"$TARGET/var/lib/dpkg/available"
  43. setup_etc
  44. if [ ! -e "$TARGET/etc/fstab" ]; then
  45. echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
  46. chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
  47. fi
  48. setup_devices
  49. x_feign_install () {
  50. local pkg="$1"
  51. local deb="$(debfor $pkg)"
  52. local ver="$(extract_deb_field "$TARGET/$deb" Version)"
  53. mkdir -p "$TARGET/var/lib/dpkg/info"
  54. echo \
  55. "Package: $pkg
  56. Version: $ver
  57. Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
  58. touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
  59. }
  60. x_feign_install dpkg
  61. }
  62. second_stage_install () {
  63. x_core_install () {
  64. smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
  65. }
  66. p () {
  67. baseprog="$(($baseprog + ${1:-1}))"
  68. }
  69. if doing_variant fakechroot; then
  70. setup_proc_fakechroot
  71. else
  72. setup_proc
  73. in_target /sbin/ldconfig
  74. fi
  75. DEBIAN_FRONTEND=noninteractive
  76. DEBCONF_NONINTERACTIVE_SEEN=true
  77. export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
  78. baseprog=0
  79. bases=7
  80. p; progress $baseprog $bases INSTCORE "Installing core packages" #1
  81. info INSTCORE "Installing core packages..."
  82. p; progress $baseprog $bases INSTCORE "Installing core packages" #2
  83. ln -sf mawk "$TARGET/usr/bin/awk"
  84. x_core_install base-passwd
  85. x_core_install base-files
  86. p; progress $baseprog $bases INSTCORE "Installing core packages" #3
  87. x_core_install dpkg
  88. if [ ! -e "$TARGET/etc/localtime" ]; then
  89. ln -sf /usr/share/zoneinfo/Etc/UTC "$TARGET/etc/localtime"
  90. fi
  91. if doing_variant fakechroot; then
  92. install_fakechroot_tools
  93. fi
  94. p; progress $baseprog $bases INSTCORE "Installing core packages" #4
  95. x_core_install $LIBC
  96. p; progress $baseprog $bases INSTCORE "Installing core packages" #5
  97. x_core_install perl-base
  98. p; progress $baseprog $bases INSTCORE "Installing core packages" #6
  99. rm "$TARGET/usr/bin/awk"
  100. x_core_install mawk
  101. p; progress $baseprog $bases INSTCORE "Installing core packages" #7
  102. if doing_variant -; then
  103. x_core_install debconf
  104. fi
  105. baseprog=0
  106. bases=$(set -- $required; echo $#)
  107. info UNPACKREQ "Unpacking required packages..."
  108. smallyes '' |
  109. (repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" \
  110. dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 |
  111. dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
  112. info CONFREQ "Configuring required packages..."
  113. if doing_variant fakechroot; then
  114. # fix initscripts postinst (no mounting possible, and wrong if condition)
  115. sed -i '/dpkg.*--compare-versions/ s/\<lt\>/lt-nl/' "$TARGET/var/lib/dpkg/info/initscripts.postinst"
  116. fi
  117. echo \
  118. "#!/bin/sh
  119. exit 101" > "$TARGET/usr/sbin/policy-rc.d"
  120. chmod 755 "$TARGET/usr/sbin/policy-rc.d"
  121. mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
  122. echo \
  123. "#!/bin/sh
  124. echo
  125. echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
  126. chmod 755 "$TARGET/sbin/start-stop-daemon"
  127. if [ -x "$TARGET/sbin/initctl" ]; then
  128. mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
  129. echo \
  130. "#!/bin/sh
  131. if [ \"\$1\" = version ]; then exec /sbin/initctl.REAL \"\$@\"; fi
  132. echo
  133. echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
  134. chmod 755 "$TARGET/sbin/initctl"
  135. fi
  136. setup_dselect_method apt
  137. smallyes '' |
  138. (in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
  139. dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 |
  140. dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
  141. baseprog=0
  142. bases="$(set -- $base; echo $#)"
  143. info UNPACKBASE "Unpacking the base system..."
  144. setup_available $required $base
  145. done_predeps=
  146. while predep=$(get_next_predep); do
  147. # We have to resolve dependencies of pre-dependencies manually because
  148. # dpkg --predep-package doesn't handle this.
  149. predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
  150. # XXX: progress is tricky due to how dpkg_progress works
  151. # -- cjwatson 2009-07-29
  152. p; smallyes '' |
  153. in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
  154. base=$(without "$base" "$predep")
  155. done_predeps="$done_predeps $predep"
  156. done
  157. smallyes '' |
  158. (repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages. This will be re-attempted up to five times." "" \
  159. dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 |
  160. dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING) 7>&1
  161. info CONFBASE "Configuring the base system..."
  162. smallyes '' |
  163. (repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be re-attempted up to five times." "" \
  164. dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 |
  165. dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING) 7>&1
  166. if [ -x "$TARGET/sbin/initctl.REAL" ]; then
  167. mv "$TARGET/sbin/initctl.REAL" "$TARGET/sbin/initctl"
  168. fi
  169. mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
  170. rm -f "$TARGET/usr/sbin/policy-rc.d"
  171. progress $bases $bases CONFBASE "Configuring base system"
  172. info BASESUCCESS "Base system installed successfully."
  173. }