From cd7c6e2e5def37abfd2ed056527c5d361e04ff5a Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Wed, 28 Dec 2016 21:16:37 +0100 Subject: libreboot-sources: Move and adapt libreboot-bootstrap to libreboot-sources Signed-off-by: Paul Kocialkowski --- projects/libreboot-bootstrap/install/install | 1 - .../install/libreboot-bootstrap | 182 --------------------- projects/libreboot-bootstrap/libreboot-bootstrap | 36 ---- projects/libreboot-sources/install/install | 1 + .../libreboot-sources/install/libreboot-sources | 146 +++++++++++++++++ projects/libreboot-sources/libreboot-sources | 14 ++ 6 files changed, 161 insertions(+), 219 deletions(-) delete mode 100644 projects/libreboot-bootstrap/install/install delete mode 100755 projects/libreboot-bootstrap/install/libreboot-bootstrap delete mode 100755 projects/libreboot-bootstrap/libreboot-bootstrap create mode 100644 projects/libreboot-sources/install/install create mode 100755 projects/libreboot-sources/install/libreboot-sources (limited to 'projects') diff --git a/projects/libreboot-bootstrap/install/install b/projects/libreboot-bootstrap/install/install deleted file mode 100644 index 1992866b..00000000 --- a/projects/libreboot-bootstrap/install/install +++ /dev/null @@ -1 +0,0 @@ -libreboot-bootstrap:libreboot-bootstrap diff --git a/projects/libreboot-bootstrap/install/libreboot-bootstrap b/projects/libreboot-bootstrap/install/libreboot-bootstrap deleted file mode 100755 index 422fcd27..00000000 --- a/projects/libreboot-bootstrap/install/libreboot-bootstrap +++ /dev/null @@ -1,182 +0,0 @@ -#!/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="libreboot" - -SOURCES="sources" - -TAR_XZ="tar.xz" -SHA256SUM="sha256sum" -ASC="asc" - -usage() { - printf "$executable [sources path] (extract path)\n" >&2 - - printf "\n When no extract path is provided, sources are extracted in the current\n" - printf " directory.\n" -} - -verify_sources() { - local sources_path=$1 - - local checksum_path - local signature_path - local archive - - if [ -z "$extract_path" ] - then - extract_path=$( pwd ) - fi - - printf "Verifying $BUILD_SYSTEM sources\n" - - archive=$( find $sources_path -name "$BUILD_SYSTEM-sources.$TAR_XZ" || true ) - if [ -z "$archive" ] - then - printf "Finding $BUILD_SYSTEM sources archive failed!\n" >&2 - usage - exit 1 - fi - - checksum_path="$archive.$SHA256SUM" - signature_path="$archive.$ASC" - - if [ -f "$checksum_path" ] - then - ( - cd "$( dirname "$archive" )" - sha256sum -c "$archive.$SHA256SUM" - ) - else - printf "Could not verify boostrap checksum!\n" >&2 - fi - - if [ -f "$signature_path" ] - then - gpg --armor --verify "$signature_path" "$archive" - else - printf "Could not verify boostrap signature!\n" >&2 - fi -} - -extract_sources() { - local sources_path=$1 - local extract_path=$2 - - local build_system_path - local archive - - if [ -z "$extract_path" ] - then - extract_path=$( pwd ) - fi - - build_system_path="$extract_path/$BUILD_SYSTEM" - - if [ -d "$build_system_path" ] - then - return - fi - - printf "Extracting $BUILD_SYSTEM sources from $sources_path to $extract_path\n" - - archive=$( find $sources_path -name "$BUILD_SYSTEM-sources.$TAR_XZ" || true ) - if [ -z "$archive" ] - then - printf "Finding $BUILD_SYSTEM sources archive failed!\n" >&2 - usage - exit 1 - fi - - tar -xf "$archive" -ps -C "$extract_path" -} - -copy_sources() { - local sources_path=$1 - local extract_path=$2 - - local build_system_path - local build_system_sources_path - local archives - local file - - if [ -z "$extract_path" ] - then - extract_path=$( pwd ) - fi - - build_system_path="$extract_path/$BUILD_SYSTEM" - build_system_sources_path="$build_system_path/$SOURCES" - - if ! [ -d "$build_system_path" ] - then - return - fi - - printf "Copying $BUILD_SYSTEM sources from $sources_path to $extract_path\n" - - mkdir -p "$build_system_path/$SOURCES" - - find "$sources_path" -type f -not -name "$BUILD_SYSTEM*" || true | while read file - do - cp "$file" "$build_system_sources_path" - done -} - -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" ) -} - -libreboot_bootstrap() { - local sources_path=$1 - local extract_path=$2 - - set -e - - setup "$@" - - if [ -z "$sources_path" ] - then - usage - exit 1 - fi - - requirements "tar" "sha256sum" "gpg" - - verify_sources "$sources_path" - extract_sources "$sources_path" "$extract_path" - copy_sources "$sources_path" "$extract_path" -} - -libreboot_bootstrap "$@" diff --git a/projects/libreboot-bootstrap/libreboot-bootstrap b/projects/libreboot-bootstrap/libreboot-bootstrap deleted file mode 100755 index f8166d3e..00000000 --- a/projects/libreboot-bootstrap/libreboot-bootstrap +++ /dev/null @@ -1,36 +0,0 @@ -#!/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() { - 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" "$@" -} diff --git a/projects/libreboot-sources/install/install b/projects/libreboot-sources/install/install new file mode 100644 index 00000000..97696cfe --- /dev/null +++ b/projects/libreboot-sources/install/install @@ -0,0 +1 @@ +libreboot-sources:libreboot-sources diff --git a/projects/libreboot-sources/install/libreboot-sources b/projects/libreboot-sources/install/libreboot-sources new file mode 100755 index 00000000..953d4a1e --- /dev/null +++ b/projects/libreboot-sources/install/libreboot-sources @@ -0,0 +1,146 @@ +#!/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="libreboot" + +SOURCES="sources" +TAR_XZ="tar.xz" + +usage() { + printf "$executable [action] [sources path] (extract path)\n" >&2 + + printf "\nActions:\n" >&2 + printf " extract - Extract build system sources\n" >&2 + printf " copy - Copy projects sources\n" >&2 + printf " prepare - Extract and copy sources\n" >&2 + + printf "\n When no extract path is provided, sources are extracted in the current\n" + printf " directory.\n" +} + +extract() { + local sources_path=$1 + local extract_path=$2 + + local build_system_path + local archive + + build_system_path="$extract_path/$BUILD_SYSTEM" + + if [ -d "$build_system_path" ] + then + return + fi + + archive=$( find $sources_path -name "$BUILD_SYSTEM-sources.$TAR_XZ" || true ) + if [ -z "$archive" ] + then + printf "Finding $BUILD_SYSTEM sources archive failed!\n" >&2 + usage + exit 1 + fi + + tar -xf "$archive" -ps -C "$extract_path" + + printf "\nExtracted $BUILD_SYSTEM sources from $sources_path to $extract_path\n" +} + +copy() { + local sources_path=$1 + local extract_path=$2 + + local build_system_path + local build_system_sources_path + local archives + local file + + build_system_path="$extract_path/$BUILD_SYSTEM" + build_system_sources_path="$build_system_path/$SOURCES" + + if ! [ -d "$build_system_path" ] + then + return + fi + + mkdir -p "$build_system_path/$SOURCES" + + ( find "$sources_path" -type f -not -name "$BUILD_SYSTEM*" || true ) | while read file + do + cp "$file" "$build_system_sources_path" + done + + printf "\nCopied $BUILD_SYSTEM sources from $sources_path to $extract_path\n" +} + +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" ) +} + +libreboot_sources() { + local action=$1 + local sources_path=$2 + local extract_path=$3 + + set -e + + setup "$@" + + if [ -z "$sources_path" ] + then + usage + exit 1 + fi + + if [ -z "$extract_path" ] + then + extract_path=$root + fi + + requirements "tar" "sha256sum" "gpg" + + case $action in + "extract") + extract "$sources_path" "$extract_path" + ;; + "copy") + copy "$sources_path" "$extract_path" + ;; + "prepare") + extract "$sources_path" "$extract_path" + copy "$sources_path" "$extract_path" + ;; + esac +} + +libreboot_sources "$@" diff --git a/projects/libreboot-sources/libreboot-sources b/projects/libreboot-sources/libreboot-sources index 99416251..a7fa5435 100755 --- a/projects/libreboot-sources/libreboot-sources +++ b/projects/libreboot-sources/libreboot-sources @@ -22,10 +22,22 @@ update() { git_merge "$repository_path" "$ORIGIN_HEAD" } +install() { + local install_path=$( project_install_path "$project" "$@" ) + + project_install "$project" "$@" +} + +install_check() { + project_install_check "$project" "$@" +} + release() { local archive_path=$( project_release_archive_path "$project" "$SOURCES" "$@" ) local sources_path=$root + project_release_install "$project" "$TOOLS" "$@" + echo "$VERSION" > "$sources_path/$DOTVERSION" echo "$SOURCE_DATE_EPOCH" > "$sources_path/$DOTEPOCH" @@ -41,6 +53,8 @@ release() { release_check() { local archive_path=$( project_release_archive_path "$project" "$SOURCES" "$@" ) + project_release_install_check "$project" "$TOOLS" "$@" + file_exists_check "$archive_path" } -- cgit v1.2.3-70-g09d2