From 112003a55671ffa5285145280988dc1248b26b08 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Fri, 23 Dec 2016 14:20:24 +0100 Subject: Paper build system initial import into Libreboot This is the initial import of the Paper build system into Libreboot. It was written as a flexible and painless replacement for the Libreboot build system, allowing to support many different configurations. It currently only supports the following CrOS devices: * Chromebook 13 CB5-311 (nyan big) * Chromebook 14 (nyan blaze) * Chromebook 11 (HiSense) (veyron jerry) * Chromebit CS10 (veyron mickey) * Chromebook Flip C100PA (veyron minnie) * Chromebook C201PA (veyron speedy) The build system also supports building various tools and provides various scripts to ease the installation on CrOS devices. Signed-off-by: Paul Kocialkowski --- projects/libreboot-release/install/install | 1 + .../libreboot-release/install/libreboot-release | 316 +++++++++++++++++++++ projects/libreboot-release/libreboot-release | 38 +++ 3 files changed, 355 insertions(+) create mode 100644 projects/libreboot-release/install/install create mode 100755 projects/libreboot-release/install/libreboot-release create mode 100755 projects/libreboot-release/libreboot-release (limited to 'projects/libreboot-release') diff --git a/projects/libreboot-release/install/install b/projects/libreboot-release/install/install new file mode 100644 index 00000000..c0df84f1 --- /dev/null +++ b/projects/libreboot-release/install/install @@ -0,0 +1 @@ +libreboot-release:libreboot-release diff --git a/projects/libreboot-release/install/libreboot-release b/projects/libreboot-release/install/libreboot-release new file mode 100755 index 00000000..b210d7d9 --- /dev/null +++ b/projects/libreboot-release/install/libreboot-release @@ -0,0 +1,316 @@ +#!/bin/bash + +# Copyright (C) 2016 Paul Kocialkowski +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +BUILD_SYSTEM="paper" + +SOURCES="sources" +SYSTEMS="systems" +IMAGES="images" +TOOLS="tools" + +TAR_XZ="tar.xz" +SHA256SUM="sha256sum" +ASC="asc" + +usage() { + printf "$executable [action] [projects...]\n" >&2 + + printf "\nActions:\n" >&2 + printf " download - Download project files\n" >&2 + printf " sources - Download project sources\n" >&2 + printf " verify - Verify project files\n" >&2 + printf " extract - Extract project files\n" >&2 + printf " prepare - Download, verify and extract project files\n" >&2 + + printf "\nEnvironment variables:\n" >&2 + printf " MACHINE - Machine architecture to use\n" >&2 + printf " DOWNLOAD_URL - Base URL to download files from\n" >&2 +} + +download() { + local project=$1 + + local ifs_save + local prefix + local directory + local path + local url + + printf "Downloading $project\n" + + for prefix in "$SYSTEMS/$MACHINE" "$IMAGES" "$TOOLS/$MACHINE" + do + ifs_save=$IFS + IFS=$'-' + + directory="" + + for part in $project + do + if [ -z "$directory" ] + then + directory="$part" + else + directory="$directory-$part" + fi + + path="$root/$prefix/$directory/$project.$TAR_XZ" + url="$DOWNLOAD_URL/$prefix/$directory/$project.$TAR_XZ" + + if wget --quiet --spider "$url" + then + mkdir -p "$( dirname "$path" )" + wget -O "$path" "$url" + wget -O "$path.$SHA256SUM" "$url.$SHA256SUM" + wget -O "$path.$ASC" "$url.$ASC" + + return 0 + fi + done + + IFS=$ifs_save + done + + printf "Could not download $project from $DOWNLOAD_URL\n" >&2 + return 1 +} + +sources() { + local project=$1 + + local url="$DOWNLOAD_URL/$SOURCES/$project/$project.$TAR_XZ" + local path="$root/$SOURCES/$project/$project.$TAR_XZ" + + printf "Downloading $project sources\n" + + if wget --quiet --spider "$url" + then + mkdir -p "$root/$project" + wget -O "$path" "$url" + wget -O "$path.$SHA256SUM" "$url.$SHA256SUM" + wget -O "$path.$ASC" "$url.$ASC" + else + printf "Could not download $project sources from $DOWNLOAD_URL\n" >&2 + return 1 + fi + +} + +verify() { + local project=$1 + + local checksum_path + local signature_path + local ifs_save + local prefix + local directory + local path + + printf "Verifying $project\n" + + for prefix in "$SYSTEMS/$MACHINE" "$IMAGES" "$TOOLS/$MACHINE" + do + ifs_save=$IFS + IFS=$'-' + + directory="" + + for part in $project + do + if [ -z "$directory" ] + then + directory="$part" + else + directory="$directory-$part" + fi + + path="$root/$prefix/$directory/$project.$TAR_XZ" + + if ! [ -f "$path" ] + then + continue + fi + + checksum_path="$path.$SHA256SUM" + signature_path="$path.$ASC" + + if [ -f "$checksum_path" ] + then + ( + cd "$( dirname "$path" )" + sha256sum -c "$project.$TAR_XZ.$SHA256SUM" + ) + else + printf "Could not verify $project checksum!\n" >&2 + fi + + if [ -f "$signature_path" ] + then + gpg --armor --verify "$signature_path" "$path" + else + printf "Could not verify $project signature!\n" >&2 + fi + + return 0 + done + + IFS=$ifs_save + done + + printf "Could not verify $project\n" >&2 + return 1 +} + +extract() { + local project=$1 + + local extract_path + local ifs_save + local prefix + local directory + local path + + printf "Extracting $project\n" + + for prefix in "$SYSTEMS/$MACHINE" "$IMAGES" "$TOOLS/$MACHINE" + do + ifs_save=$IFS + IFS=$'-' + + directory="" + + for part in $project + do + if [ -z "$directory" ] + then + directory="$part" + else + directory="$directory-$part" + fi + + path="$root/$prefix/$directory/$project.$TAR_XZ" + + if ! [ -f "$path" ] + then + continue + fi + + if [ "$prefix" = "$SYSTEMS/$MACHINE" ] + then + printf "Skiping $project extract\n" + return 0 + fi + + extract_path=$( dirname "$path" ) + + tar -xf "$path" -ps -C "$extract_path" + + return 0 + done + + IFS=$ifs_save + done + + printf "Could not extract $project\n" >&2 + return 1 +} + +requirements() { + local requirement + local requirement_path + + for requirement in "$@" + do + requirement_path=$( which "$requirement" || true ) + + if [ -z "$requirement_path" ] + then + printf "Missing requirement: $requirement\n" >&2 + exit 1 + fi + done +} + +setup() { + root=$( realpath "$( dirname "$0" )" ) + executable=$( basename "$0" ) + + if [ -z "$MACHINE" ] + then + MACHINE=$( uname -m ) + fi + + if [ -z "$DOWNLOAD_URL" ] + then + printf "Missing download URL\n" >&2 + exit 1 + fi +} + +libreboot_release() { + local action=$1 + shift + + set -e + + setup "$@" + + if [ -z "$action" ] + then + usage + exit 1 + fi + + requirements "tar" "sha256sum" "gpg" + + case $action in + "download") + for project in "$@" + do + download "$project" + done + ;; + "sources") + for project in "$@" + do + sources "$project" + done + ;; + "verify") + for project in "$@" + do + verify "$project" + done + ;; + "extract") + for project in "$@" + do + extract "$project" + done + ;; + "prepare") + for project in "$@" + do + download "$project" + verify "$project" + extract "$project" + done + ;; + esac +} + +libreboot_release "$@" diff --git a/projects/libreboot-release/libreboot-release b/projects/libreboot-release/libreboot-release new file mode 100755 index 00000000..5c4618a3 --- /dev/null +++ b/projects/libreboot-release/libreboot-release @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright (C) 2016 Paul Kocialkowski +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +install() { + local install_path=$( project_install_path "$project" "$@" ) + + project_install "$project" "$@" +} + +install_check() { + project_install_check "$project" "$@" +} + +release() { + project_release_install "$project" "$SOURCES" "$@" +} + +release_check() { + project_release_install_check "$project" "$SOURCES" "$@" +} + +clean() { + project_clean "$project" "$@" +} -- cgit v1.2.3-70-g09d2