Last active
October 4, 2016 11:01
-
-
Save alenbasic/d07ce1626531ee68cf36 to your computer and use it in GitHub Desktop.
A simple script I used to help automate some tasks while doing Linux From Scratch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run this by sourcing it, i.e. "source lfs -t" or ". lfs -t" | |
# you can make it easier on yourself by making an alias | |
# for example, alias lfs="source /path/to/lfs.sh" | |
# colors to use within the script | |
BLACK='\033[0;30m' | |
DGRAY='\033[1;30m' | |
RED='\033[0;31m' | |
LRED='\033[1;31m' | |
GREEN='\033[0;32m' | |
LGREEN='\033[1;32m' | |
ORANGE='\033[0;33m' | |
YELLOW='\033[1;33m' | |
BLUE='\033[0;34m' | |
LBLUE='\033[1;34m' | |
PURPLE='\033[0;35m' | |
LPURPLE='\033[1;35m' | |
CYAN='\033[0;36m' | |
LCYAN='\033[1;36m' | |
LGRAY='\033[0;37m' | |
WHITE='\033[1;37m' | |
NC='\033[0m' | |
case "$1" in | |
-t) | |
./configure --prefix=/tools | |
make -j$(nproc) | |
make install | |
printf "${LBLUE}configured and compiled for the ${YELLOW}/tools${NC}${LBLUE} directory for package: ${LGREEN}$lfs_package_dir${NC}\n" | |
;; | |
-u) | |
./configure --prefix=/usr | |
make -j$(nproc) | |
make install | |
printf "${LBLUE}configured and compiled for the ${YELLOW}/usr${NC}${LBLUE} directory for package: ${LGREEN}$lfs_package_dir${NC}\n" | |
;; | |
-r) | |
printf "moving to $lfs_source_dir and removing $lfs_package_dir directory and files...\n" | |
cd $lfs_source_dir | |
rm -rf $lfs_package_dir | |
unset lfs_source_dir | |
printf "${LBLUE}all files have been removed and temp variables unset for package: ${LGREEN}$lfs_package_dir${NC}\n" | |
unset lfs_package_dir | |
;; | |
-i) | |
export lfs_source_dir=$(pwd) | |
printf "${LBLUE}extracting files for package: ${LGREEN}$2{NC}\n" | |
file_list=$(tar -axvf $2) | |
created_dir=$(printf $file_list | cut -f1 -d"/") | |
export lfs_package_dir="$created_dir" | |
cd $lfs_package_dir | |
printf "${LBLUE}extraction complete. now in directory for package: ${LGREEN}$(pwd)${NC}\n" | |
;; | |
*) | |
printf "LFS Helper Script\n" | |
printf "\nOptions:\n" | |
printf " -i extracts the source file and then moves into the extracted directory\n" | |
printf " -t runs configure with the prefix set to /tools then runs make and make\n" | |
printf " install" | |
printf " -u same as -t, but with the prefix /usr instead of /tools\n" | |
printf " -r exits out of the directory and removes it and all its files as well as a\n" | |
printf " build directory, if one was created\n" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment