118 lines
3.6 KiB
Plaintext
118 lines
3.6 KiB
Plaintext
#!/bedrock/libexec/busybox sh
|
|
#
|
|
# Trisquel bootstrap support
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# version 2 as published by the Free Software Foundation.
|
|
#
|
|
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
|
|
#
|
|
|
|
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
|
|
. /bedrock/share/common-code
|
|
trap 'fetch_abort "Unexpected error occurred."' EXIT
|
|
|
|
check_supported() {
|
|
false
|
|
}
|
|
|
|
speed_test_url() {
|
|
echo "dists/${target_release}/Release"
|
|
}
|
|
|
|
list_mirrors() {
|
|
echo 'http://archive.trisquel.info/trisquel'
|
|
mirror_list_url='https://trisquel.info/mirmon/index.html'
|
|
wget -O- "${mirror_list_url}" 2>/dev/null |
|
|
awk '/<H2>report<.H2>/,/<.TABLE>/' |
|
|
list_links |
|
|
grep "^http"
|
|
}
|
|
|
|
brl_arch_to_distro() {
|
|
case "${1}" in
|
|
"i686") echo "i386" ;;
|
|
"x86_64") echo "amd64" ;;
|
|
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
|
|
esac
|
|
}
|
|
|
|
list_architectures() {
|
|
cat <<EOF
|
|
i686
|
|
x86_64
|
|
EOF
|
|
}
|
|
|
|
default_release() {
|
|
wget -O- 'http://mirror.fsf.org/trisquel/meta-release' 2>/dev/null | awk '
|
|
$1 == "Name:" {
|
|
name = tolower($2)
|
|
}
|
|
$1 == "Version:" {
|
|
version = $2
|
|
gsub(/[^0-9.]/, "", version)
|
|
}
|
|
name != "" && version != "" {
|
|
if (version > best_version) {
|
|
best_name = name
|
|
best_version = version
|
|
}
|
|
}
|
|
END {
|
|
print best_name
|
|
}
|
|
'
|
|
}
|
|
|
|
list_releases() {
|
|
wget -O- 'http://mirror.fsf.org/trisquel/meta-release' 2>/dev/null | awk '$1=="Name:" {print $2}'
|
|
}
|
|
|
|
fetch() {
|
|
# trisquel 8.0 flidas does not have debootstrap?
|
|
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv trisquel-keyring"
|
|
|
|
step "Downloading package information database"
|
|
wget -O "${bootstrap_dir}/Packages.gz" "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz"
|
|
gunzip "${bootstrap_dir}/Packages.gz"
|
|
|
|
step "Converting distro package information database to brl format"
|
|
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
|
|
|
|
step "Calculating required bootstrap packages"
|
|
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
|
|
|
|
step "Downloading bootstrap packages"
|
|
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
|
|
|
|
step "Extracting bootstrap packages"
|
|
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
|
|
# shellcheck disable=SC2086
|
|
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
|
|
|
|
step "Running bootstrap software"
|
|
setup_chroot "${bootstrap_dir}"
|
|
set +o pipefail
|
|
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
|
|
share_cache "packages" "${bootstrap_dir}/packages"
|
|
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
|
|
else
|
|
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
|
|
fi
|
|
set -o pipefail
|
|
|
|
step "Configuring"
|
|
echo "deb ${target_mirror} ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list"
|
|
echo "deb ${target_mirror} ${target_release}-updates main" >>"${target_dir}/etc/apt/sources.list"
|
|
setup_chroot "${target_dir}"
|
|
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
|
|
set +o pipefail
|
|
# word splitting is desired here
|
|
# shellcheck disable=SC2086
|
|
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
|
|
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
|
|
set -o pipefail
|
|
}
|