From 52cb0ea321db1916c94301a59e57c7c7876bd984 Mon Sep 17 00:00:00 2001 From: r00t Date: Sun, 12 Jul 2015 03:04:09 -0400 Subject: [PATCH] working on dat cross-distro support.... --- bin/build.sh | 5 ++++- bin/clean.sh | 4 ++++ extra/build.conf.sample | 7 ++++++- lib/00-depcheck.func.sh | 34 +++++++++++++++++++++++++++++++++- lib/03-holla_atcha_boi.func.sh | 1 + lib/prereqs/Arch/meta | 6 ++++++ lib/prereqs/Arch/pkgs | 0 lib/prereqs/CentOS/meta | 6 ++++++ lib/prereqs/CentOS/pkgs | 0 lib/prereqs/Debian/meta | 6 ++++++ lib/prereqs/Debian/pkgs | 0 lib/prereqs/Fedora/meta | 6 ++++++ lib/prereqs/Fedora/pkgs | 0 lib/prereqs/Gentoo/meta | 6 ++++++ lib/prereqs/Gentoo/pkgs | 0 lib/prereqs/HUMAN | 18 ++++++++++++++++++ lib/prereqs/Mageia/meta | 6 ++++++ lib/prereqs/Mageia/pkgs | 0 lib/prereqs/Manjaro/meta | 6 ++++++ lib/prereqs/Manjaro/pkgs | 0 lib/prereqs/Mint/meta | 6 ++++++ lib/prereqs/Mint/pkgs | 0 lib/prereqs/RHEL/meta | 6 ++++++ lib/prereqs/RHEL/pkgs | 0 lib/prereqs/SUSE/meta | 6 ++++++ lib/prereqs/SUSE/pkgs | 0 lib/prereqs/Ubuntu/meta | 6 ++++++ lib/prereqs/Ubuntu/pkgs | 0 lib/prereqs/openSUSE/meta | 6 ++++++ lib/prereqs/openSUSE/pkgs | 0 30 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 lib/prereqs/Arch/meta create mode 100644 lib/prereqs/Arch/pkgs create mode 100644 lib/prereqs/CentOS/meta create mode 100644 lib/prereqs/CentOS/pkgs create mode 100644 lib/prereqs/Debian/meta create mode 100644 lib/prereqs/Debian/pkgs create mode 100644 lib/prereqs/Fedora/meta create mode 100644 lib/prereqs/Fedora/pkgs create mode 100644 lib/prereqs/Gentoo/meta create mode 100644 lib/prereqs/Gentoo/pkgs create mode 100644 lib/prereqs/HUMAN create mode 100644 lib/prereqs/Mageia/meta create mode 100644 lib/prereqs/Mageia/pkgs create mode 100644 lib/prereqs/Manjaro/meta create mode 100644 lib/prereqs/Manjaro/pkgs create mode 100644 lib/prereqs/Mint/meta create mode 100644 lib/prereqs/Mint/pkgs create mode 100644 lib/prereqs/RHEL/meta create mode 100644 lib/prereqs/RHEL/pkgs create mode 100644 lib/prereqs/SUSE/meta create mode 100644 lib/prereqs/SUSE/pkgs create mode 100644 lib/prereqs/Ubuntu/meta create mode 100644 lib/prereqs/Ubuntu/pkgs create mode 100644 lib/prereqs/openSUSE/meta create mode 100644 lib/prereqs/openSUSE/pkgs diff --git a/bin/build.sh b/bin/build.sh index 8a711dd..08350da 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -7,6 +7,8 @@ #DEBUG #set -x +echo "Starting at $(date)..." + ## Import settings if [ -f "build.conf" ]; then @@ -109,6 +111,7 @@ EOF ## FUNCTIONS ## +source lib/00-depcheck.func.sh source lib/02-im_batman.func.sh source lib/03-holla_atcha_boi.func.sh source lib/04-release_me.func.sh @@ -194,4 +197,4 @@ fi # yay! we're done! rm -f ${LOCKFILE} -echo "Finished successfully!" +echo "Finished successfully at $(date)!" diff --git a/bin/clean.sh b/bin/clean.sh index 2acfd83..d0b6f8c 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Started at $(date)..." + ## Import settings if [ -f "build.conf" ]; then @@ -82,3 +84,5 @@ do done rm -f ${LOCKFILE} + +echo "Finished successfully at $(date)!" diff --git a/extra/build.conf.sample b/extra/build.conf.sample index 887bc11..2ac9f19 100644 --- a/extra/build.conf.sample +++ b/extra/build.conf.sample @@ -3,7 +3,7 @@ ##################################################### # # This file is used to define various variables/settings used by the build script. -# +# # This should be an alpha-numeric string less than 8 characters. No spaces, etc. # Used for metainfo @@ -132,6 +132,11 @@ I_AM_A_RACECAR="no" # The following should not be changed unless you are ABSOLUTELY, 100% SURE and COMPLETELY POSITIVE # about what you are doing!!! +# This can be used to override automatic distro-detection. +# If you DO set this, be sure that you have a matching profile in +# ${BASEDIR}/lib/prereqs//meta !! +HOST_DIST="" + # This used to be defined statically, but is now dynamically appended. Please don't alter this # unless you renamed the chroot directory paths. CHROOTDIR="${BASEDIR}/" diff --git a/lib/00-depcheck.func.sh b/lib/00-depcheck.func.sh index eb8946c..ff3ca03 100755 --- a/lib/00-depcheck.func.sh +++ b/lib/00-depcheck.func.sh @@ -1,3 +1,35 @@ #!/bin/bash -# placeholder... +function so_check_me_out { + + if [[ -n ${HOST_DIST} ]]; + then + if [[ ! -f ${BASEDIR}/lib/prereqs/${HOST_DIST}/meta || ! -f ${BASEDIR}/lib/prereqs/${HOST_DIST}/pkgs ]]; + then + echo "ERROR: You have specified ${HOST_DIST} as your host system's distro, but it is missing a meta and/or pkgs profile." + exit 1 + fi + fi + + if [[ -z ${HOST_DIST} ]]; + then + for dist_profile in $(find ${BASEDIR}/lib/prereqs -type f -name 'meta'); + do + source ${dist_profile} + if [[ ${SUPPORTED} != "yes" ]]; + then + continue + fi + eval "${CHECK_METHOD}" > /dev/null 2>&1 + if [[ "${?}" == "0" ]]; + then + export HOST_DIST=${NAME} + echo "Detected distro as ${HOST_DIST}." + break 2 + fi + done + fi + +# So we've validated the distro. Here, check for packages and install if necessary. maybe use an array, but it'd be better to soft-fail if one of the packages is missing. + +} diff --git a/lib/03-holla_atcha_boi.func.sh b/lib/03-holla_atcha_boi.func.sh index 9ba8209..2c9d02d 100644 --- a/lib/03-holla_atcha_boi.func.sh +++ b/lib/03-holla_atcha_boi.func.sh @@ -7,6 +7,7 @@ function holla_atcha_boi { RACECAR_CHK="" fi + so_check_me_out # Do we have an existing chroot set up yet? If not, create. if [[ ! -d "root.x86_64/root" || ! -d "root.i686/root" ]]; diff --git a/lib/prereqs/Arch/meta b/lib/prereqs/Arch/meta new file mode 100644 index 0000000..977d4f8 --- /dev/null +++ b/lib/prereqs/Arch/meta @@ -0,0 +1,6 @@ +NAME='Arch' +SUPPORTED='yes' +CHECK_METHOD='egrep "^NAME=\"Arch Linux\"" /etc/os-release' +PKG_MGR='pacman -S' +PRE_RUN='pacman -Syyy' +PKG_CHK='pacman -Q' diff --git a/lib/prereqs/Arch/pkgs b/lib/prereqs/Arch/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/CentOS/meta b/lib/prereqs/CentOS/meta new file mode 100644 index 0000000..dec0748 --- /dev/null +++ b/lib/prereqs/CentOS/meta @@ -0,0 +1,6 @@ +NAME='CentOS' +SUPPORTED='yes' +CHECK_METHOD='egrep '^CentOS' /etc/redhat-release' +PKG_MGR='yum -y install' +PRE_RUN='none' +PKG_CHK='rpm -q' diff --git a/lib/prereqs/CentOS/pkgs b/lib/prereqs/CentOS/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Debian/meta b/lib/prereqs/Debian/meta new file mode 100644 index 0000000..89f1fc5 --- /dev/null +++ b/lib/prereqs/Debian/meta @@ -0,0 +1,6 @@ +NAME='Debian' +SUPPORTED='yes' +CHECK_METHOD='cat /etc/debian_version' +PKG_MGR='apt-get -y install' +PRE_RUN='apt-get update' +PKG_CHK='dpkg-query -l' diff --git a/lib/prereqs/Debian/pkgs b/lib/prereqs/Debian/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Fedora/meta b/lib/prereqs/Fedora/meta new file mode 100644 index 0000000..0415972 --- /dev/null +++ b/lib/prereqs/Fedora/meta @@ -0,0 +1,6 @@ +NAME='Fedora' +SUPPORTED='yes' +CHECK_METHOD='egrep '^Fedora' /etc/redhat-release' +PKG_MGR='yum -y install' +PRE_RUN='none' +PKG_CHK='rpm -q' diff --git a/lib/prereqs/Fedora/pkgs b/lib/prereqs/Fedora/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Gentoo/meta b/lib/prereqs/Gentoo/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/Gentoo/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/Gentoo/pkgs b/lib/prereqs/Gentoo/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/HUMAN b/lib/prereqs/HUMAN new file mode 100644 index 0000000..86acdb6 --- /dev/null +++ b/lib/prereqs/HUMAN @@ -0,0 +1,18 @@ +This directory is used to enable cross-distro support. A list of packages is needed for the *host* to build the ISO. Adding distro support is easy; there simply needs to be the following added: + +/lib/prereqs//{meta,pkgs} + +"pkgs" should contain a list of the specific package names needed to install for that specific distro (as this isn't always standardized). + +"meta" is a file consisting of the following variables (enclosed in single or double quotes, please: + +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= + +Oh- and your distro *must be able to install the package*. That means if you need to enable/add additional repositories, be sure to do so ahead of time. diff --git a/lib/prereqs/Mageia/meta b/lib/prereqs/Mageia/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/Mageia/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/Mageia/pkgs b/lib/prereqs/Mageia/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Manjaro/meta b/lib/prereqs/Manjaro/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/Manjaro/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/Manjaro/pkgs b/lib/prereqs/Manjaro/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Mint/meta b/lib/prereqs/Mint/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/Mint/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/Mint/pkgs b/lib/prereqs/Mint/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/RHEL/meta b/lib/prereqs/RHEL/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/RHEL/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/RHEL/pkgs b/lib/prereqs/RHEL/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/SUSE/meta b/lib/prereqs/SUSE/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/SUSE/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/SUSE/pkgs b/lib/prereqs/SUSE/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Ubuntu/meta b/lib/prereqs/Ubuntu/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/Ubuntu/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/Ubuntu/pkgs b/lib/prereqs/Ubuntu/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/openSUSE/meta b/lib/prereqs/openSUSE/meta new file mode 100644 index 0000000..7dc5cd7 --- /dev/null +++ b/lib/prereqs/openSUSE/meta @@ -0,0 +1,6 @@ +NAME= +SUPPORTED= +CHECK_METHOD= +PKG_MGR= +PRE_RUN= +PKG_CHK= diff --git a/lib/prereqs/openSUSE/pkgs b/lib/prereqs/openSUSE/pkgs new file mode 100644 index 0000000..e69de29