From 99d226cca1bd66d7b3c74cb42f8d36a779fa3ff4 Mon Sep 17 00:00:00 2001 From: Francis Rowe Date: Sat, 16 May 2015 13:44:44 -0400 Subject: coreboot-libre: delete unused code (reduce size of src archive) --- (limited to 'resources/scripts/helpers/build') diff --git a/resources/scripts/helpers/build/release/archives b/resources/scripts/helpers/build/release/archives index 74547ef..a70f348 100755 --- a/resources/scripts/helpers/build/release/archives +++ b/resources/scripts/helpers/build/release/archives @@ -404,6 +404,9 @@ rm -rf libreboot_src/resources/utilities/coreboot-libre/ rm -rf libreboot_src/resources/scripts/helpers/build/release rm -f libreboot_src/download rm -rf libreboot_src/resources/scripts/helpers/download/ +# no need for script to purge sources, since purged sources +# are already included in libreboot_src +rm -rf libreboot_src/resources/scripts/helpers/build/trim/ # Patches are not needed, because they are # already merged in libreboot_src/coreboot/ diff --git a/resources/scripts/helpers/build/trim/coreboot b/resources/scripts/helpers/build/trim/coreboot new file mode 100755 index 0000000..efb7960 --- /dev/null +++ b/resources/scripts/helpers/build/trim/coreboot @@ -0,0 +1,313 @@ +#!/bin/bash + +# helper: trim the coreboot-libre source code (delete unused parts) +# +# Copyright (C) 2015 Francis Rowe +# +# 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 . +# + +# This script assumes that the working directory is the root +# of libreboot_src or git + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "purging unused parts of coreboot-libre...\n" + +printf "Size of coreboot directory before the purge: $(du -ch coreboot | grep total)\n" + +cd coreboot/ + +# __UNUSED BOARDS_______________________________________________________ + +printf "deleting unused boards\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/mainboard/ + +whitelist=" \ +$(find ./apple/macbook21/) \ +$(find ./emulation/qemu-i440fx/) \ +$(find ./emulation/qemu-q35/ ) \ +$(find ./lenovo/r400/) \ +$(find ./lenovo/t60/) \ +$(find ./lenovo/t400/) \ +$(find ./lenovo/t500/) \ +$(find ./lenovo/x60/) \ +$(find ./lenovo/x200/) \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __UNUSED VENDORCODE___________________________________________________ + +printf "deleting unused vendor code\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/vendorcode/ + +whitelist=" \ +./google/chromeos/chromeos.h \ +./google/chromeos/gnvs.h \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __Unused architectures________________________________________________ + +printf "deleting unused CPU architectures\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/arch/ + +whitelist=" \ +$(find ./x86/) \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __Unused SoC code_____________________________________________________ + +printf "deleting unused SoCs\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/soc/ + +whitelist=" \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __Unused northbridge code_____________________________________________ + +printf "deleting unused northbridges\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/northbridge/ + +whitelist=" \ +$(find ./intel/i945/) \ +$(find ./intel/gm45/) \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __Unused southbridge code_____________________________________________ + +printf "deleting unused southbridges\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/southbridge/ + +whitelist=" \ +$(find ./intel/i82371eb/) \ +$(find ./intel/i82801gx/) \ +$(find ./intel/i82801ix/) \ +$(find ./intel/common/) \ +$(find ./ti/pci1x2x/) \ +$(find ./ricoh/rl5c476/) \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +# __Unused CPU code_____________________________________________________ + +printf "deleting unused CPUs\n" + +# keep the Kconfig files in place, otherwise there are build errors + +cd src/cpu/ + +whitelist=" \ +$(find ./intel/) \ +$(find ./x86/) \ +$(find -type f -name 'Kconfig') \ +$(find -type f -name 'Makefile.inc') \ +" + +for file in $(find -type f); do + + # keep files that are in the whitelist + cnt="0" + for keep in $whitelist; do + if [ "$keep" = "$file" ]; then + cnt="1" + break + fi + done + if [ "$cnt" = "1" ]; then + continue + fi + + # delete if it's not in the whitelist + rm -f $file + +done + +cd ../../ + +# ______________________________________________________________________ + +cd ../ + +printf "Size of coreboot directory after the purge: $(du -ch coreboot | grep total)\n" + +printf "...done\n" + +printf "\n\n" -- cgit v0.9.1