diff --git a/bin/build.sh b/bin/build.sh index 08350da..40b36fd 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -74,6 +74,8 @@ do fi done +source ${BASEDOR/}lib/00-depcheck.func.sh + if [ ! -f "./BUILDNO" ]; then echo '0' > ./BUILDNO @@ -88,7 +90,7 @@ BUILD="$(cat BUILDNO)" BUILD="$(expr ${BUILD} + 1)" echo ${BUILD} > ./BUILDNO BUILDTIME="$(date)" -BUILD_MACHINE="$(hostname -f)" +BUILD_MACHINE="$(hostname -f) (${HOST_DIST})" #BUILD_USERNAME="${SUDO_USER}" #BUILD_USERNAME="$(who am i | awk '{print $1}')" set +e ; logname > /dev/null 2>&1 @@ -111,18 +113,18 @@ 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 -source lib/05-facehugger.func.sh -source lib/06-chroot_wrapper.func.sh -source lib/07-jenny_craig.func.sh -source lib/08-centos_is_stupid.func.sh -source lib/09-will_it_blend.func.sh -source lib/10-stuffy.func.sh -source lib/11-yo_dj.func.sh -source lib/12-mentos.func.sh +#source ${BASEDIR}/lib/00-depcheck.func.sh ## this should be called like, VERYYYY first thing, right after sanity/safety checks and such. +#source ${BASEDIR}/lib/01-mk.chroot.func.sh ## this is called automatically and only if no chroot exists +source ${BASEDIR}/lib/02-holla_atcha_boi.func.sh +source ${BASEDIR}/lib/03-release_me.func.sh +source ${BASEDIR}/lib/04-facehugger.func.sh +source ${BASEDIR}/lib/05-chroot_wrapper.func.sh +source ${BASEDIR}/lib/06-jenny_craig.func.sh +source ${BASEDIR}/lib/07-centos_is_stupid.func.sh +source ${BASEDIR}/lib/08-will_it_blend.func.sh +source ${BASEDIR}/lib/09-stuffy.func.sh +source ${BASEDIR}/lib/10-yo_dj.func.sh +source ${BASEDIR}/lib/11-mentos.func.sh ## The Business-End(TM) ## diff --git a/lib/00-depcheck.func.sh b/lib/00-depcheck.func.sh index ff3ca03..079dc3f 100755 --- a/lib/00-depcheck.func.sh +++ b/lib/00-depcheck.func.sh @@ -11,25 +11,69 @@ function so_check_me_out { fi fi - if [[ -z ${HOST_DIST} ]]; + if [[ -z "${HOST_DIST}" ]]; then - for dist_profile in $(find ${BASEDIR}/lib/prereqs -type f -name 'meta'); + for dist_profile in $(find "${BASEDIR}"/lib/prereqs -type f -name 'meta'); do source ${dist_profile} - if [[ ${SUPPORTED} != "yes" ]]; + if [[ "${SUPPORTED}" != "yes" ]]; then continue fi eval "${CHECK_METHOD}" > /dev/null 2>&1 if [[ "${?}" == "0" ]]; then - export HOST_DIST=${NAME} + 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. + # Sanity is important. + if [[ -z "${HOST_DIST}" ]]; + then + echo "ERROR: Your distro was not found/detected, or is flagged as unsupported." + exit 1 + 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. + + DISTRO_DIR="${BASEDIR}/lib/prereqs/${HOST_DIST}" + META="${DISTRO_DIR}/meta" + PKGLIST="${DISTRO_DIR}/pkgs" + + if [[ "${PRE_RUN}" != 'none' ]]; + then + echo "Now updating your local package cache..." + set +e + eval "${PRE_RUN}" >> "${LOGFILE}.${FUNCNAME}" 2>&1 + if [[ "${?}" != "0" ]]; + then + echo "ERROR: Syncing your local package cache via ${PRE_RUN} command failed." + echo "Please ensure you are connected to the Internet/have repositories configured correctly." + exit 1 + fi + fi + + while read pkgname; + do + eval "${PKG_CHK}" >> "${LOGFILE}.${FUNCNAME}" 2>&1 + if [[ "${?}" != "0" ]]; + then + echo "Installing ${pkgname}..." + eval "${PKG_MGR}" >> "${LOGFILE}.${FUNCNAME}" 2>&1 + if [[ "${?}" != "0" ]]; + then + echo "ERROR: ${pkgname} was not found to be installed and we can't install it." + echo "This usually means you aren't connected to the Internet or your package repositories" + echo "are not configured correctly. Review the list of packages in ${PKGLIST} and ensure" + echo "they are all available to be installed." + fi + fi + done < ${PKGLIST} + + set -e } + +so_check_me_out diff --git a/lib/03-holla_atcha_boi.func.sh b/lib/02-holla_atcha_boi.func.sh similarity index 100% rename from lib/03-holla_atcha_boi.func.sh rename to lib/02-holla_atcha_boi.func.sh diff --git a/lib/02-im_batman.func.sh b/lib/02-im_batman.func.sh deleted file mode 100644 index 0cf972a..0000000 --- a/lib/02-im_batman.func.sh +++ /dev/null @@ -1,30 +0,0 @@ -function im_batman { - set +e # false errors are bad mmk - # Detect the distro and set some vars - if [ -f "/usr/bin/yum" ]; # CentOS/Redhat, etc. - then - OS_STRING='RHEL-like' - DISTRO='RHEL' - INST_CMD='yum -y install ' - elif [ -f "/usr/bin/pacman" ]; # Arch, Manjaro, etc. - then - OS_STRING='Arch-like' - DISTRO='Arch' - INST_CMD='pacman -S ' - elif [ -f "/usr/bin/emerge" ]; # Gentoo - then - OS_STRING='Gentoo-like' - DISTRO='Gentoo' - INST_CMD='emerge ' - elif [ -f "/usr/bin/apt-get" ]; # Debian, Ubuntu (and derivatives), etc. - then - OS_STRING='Debian-like' - DISTRO="Debian" - INST_CMD='apt-get install ' - else - echo 'Sorry, I cannot detect which distro you are running. Please report this along with what distro you are running. Dying now.' - exit 1 - fi - - set -e # and turn this back on lolz -} diff --git a/lib/04-release_me.func.sh b/lib/03-release_me.func.sh similarity index 100% rename from lib/04-release_me.func.sh rename to lib/03-release_me.func.sh diff --git a/lib/05-facehugger.func.sh b/lib/04-facehugger.func.sh similarity index 100% rename from lib/05-facehugger.func.sh rename to lib/04-facehugger.func.sh diff --git a/lib/06-chroot_wrapper.func.sh b/lib/05-chroot_wrapper.func.sh similarity index 100% rename from lib/06-chroot_wrapper.func.sh rename to lib/05-chroot_wrapper.func.sh diff --git a/lib/07-jenny_craig.func.sh b/lib/06-jenny_craig.func.sh similarity index 100% rename from lib/07-jenny_craig.func.sh rename to lib/06-jenny_craig.func.sh diff --git a/lib/08-centos_is_stupid.func.sh b/lib/07-centos_is_stupid.func.sh similarity index 100% rename from lib/08-centos_is_stupid.func.sh rename to lib/07-centos_is_stupid.func.sh diff --git a/lib/09-will_it_blend.func.sh b/lib/08-will_it_blend.func.sh similarity index 100% rename from lib/09-will_it_blend.func.sh rename to lib/08-will_it_blend.func.sh diff --git a/lib/10-stuffy.func.sh b/lib/09-stuffy.func.sh similarity index 100% rename from lib/10-stuffy.func.sh rename to lib/09-stuffy.func.sh diff --git a/lib/11-yo_dj.func.sh b/lib/10-yo_dj.func.sh similarity index 99% rename from lib/11-yo_dj.func.sh rename to lib/10-yo_dj.func.sh index c45c272..05ddcdd 100644 --- a/lib/11-yo_dj.func.sh +++ b/lib/10-yo_dj.func.sh @@ -1,7 +1,7 @@ function yo_dj () { ARCH="${1}" echo "Building the actual .iso image. This may take a while." - im_batman + #im_batman ## WHYTF IS THIS HERE?! ISOFILENAME="${UXNAME}-${VERSION}.iso" #MINIFILENAME="${UXNAME}-${VERSION}-mini.iso" MINIFILENAME="${UXNAME}-mini.iso" diff --git a/lib/12-mentos.func.sh b/lib/11-mentos.func.sh similarity index 100% rename from lib/12-mentos.func.sh rename to lib/11-mentos.func.sh diff --git a/lib/prereqs/Antergos/meta b/lib/prereqs/Antergos/meta new file mode 100644 index 0000000..d4cfc84 --- /dev/null +++ b/lib/prereqs/Antergos/meta @@ -0,0 +1,7 @@ +NAME='Antergos' +SUPPORTED='yes' +CHECK_METHOD='egrep "^NAME=\"Antergos Linux\"" /etc/os-release' +PKG_MGR='pacman --noconfirm -S ${pkgname}' +PRE_RUN='pacman -Syyy' +PKG_CHK='pacman -Q ${pkgname}' +URL='http://antergos.com/' diff --git a/lib/prereqs/Antergos/pkgs b/lib/prereqs/Antergos/pkgs new file mode 100644 index 0000000..e69de29 diff --git a/lib/prereqs/Arch/meta b/lib/prereqs/Arch/meta index 977d4f8..1efef4e 100644 --- a/lib/prereqs/Arch/meta +++ b/lib/prereqs/Arch/meta @@ -1,6 +1,7 @@ NAME='Arch' SUPPORTED='yes' CHECK_METHOD='egrep "^NAME=\"Arch Linux\"" /etc/os-release' -PKG_MGR='pacman -S' +PKG_MGR='pacman --noconfirm -S ${pkgname}' PRE_RUN='pacman -Syyy' -PKG_CHK='pacman -Q' +PKG_CHK='pacman -Q ${pkgname}' +URL='https://www.archlinux.org/' diff --git a/lib/prereqs/CentOS/meta b/lib/prereqs/CentOS/meta index dec0748..660c2d6 100644 --- a/lib/prereqs/CentOS/meta +++ b/lib/prereqs/CentOS/meta @@ -1,6 +1,7 @@ NAME='CentOS' SUPPORTED='yes' -CHECK_METHOD='egrep '^CentOS' /etc/redhat-release' -PKG_MGR='yum -y install' +CHECK_METHOD='egrep "^CentOS" /etc/redhat-release' +PKG_MGR='yum -y install ${pkgname}' PRE_RUN='none' -PKG_CHK='rpm -q' +PKG_CHK='rpm -q ${pkgname} | egrep "^${pkgname}-[0-9]"' +URL='http://centos.org/' diff --git a/lib/prereqs/Debian/meta b/lib/prereqs/Debian/meta index 89f1fc5..8002207 100644 --- a/lib/prereqs/Debian/meta +++ b/lib/prereqs/Debian/meta @@ -1,6 +1,8 @@ NAME='Debian' SUPPORTED='yes' -CHECK_METHOD='cat /etc/debian_version' -PKG_MGR='apt-get -y install' +CHECK_METHOD='egrep "^[0-9.]*$" /etc/debian_version' +CHECK_METHOD='egrep "^NAME=\"Debian\ GNU/Linux\"" /etc/os-release' +PKG_MGR='apt-get -y install ${pkgname}' PRE_RUN='apt-get update' -PKG_CHK='dpkg-query -l' +PKG_CHK='dpkg-query -l ${pkgname}' +URL='http://www.debian.org/' diff --git a/lib/prereqs/Fedora/meta b/lib/prereqs/Fedora/meta index 0415972..96ae174 100644 --- a/lib/prereqs/Fedora/meta +++ b/lib/prereqs/Fedora/meta @@ -1,6 +1,7 @@ NAME='Fedora' SUPPORTED='yes' CHECK_METHOD='egrep '^Fedora' /etc/redhat-release' -PKG_MGR='yum -y install' +PKG_MGR='yum -y install ${pkgname}' PRE_RUN='none' -PKG_CHK='rpm -q' +PKG_CHK='rpm -q ${pkgname} | egrep "^${pkgname}-[0-9]"' +URL='https://getfedora.org/' diff --git a/lib/prereqs/Gentoo/meta b/lib/prereqs/Gentoo/meta index 7dc5cd7..b0382df 100644 --- a/lib/prereqs/Gentoo/meta +++ b/lib/prereqs/Gentoo/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='Gentoo' +SUPPORTED='yes' +CHECK_METHOD='egrep "^Gentoo\ Base\ System" /etc/gentoo-release' +PKG_MGR='emerge -qD ${pkgname}' +PRE_RUN='emerge -q --sync' +PKG_CHK='emerge -qp @installed 2>/dev/null | egrep -E "/${pkgname}-[0-9.]+"' +URL='https://www.gentoo.org/' diff --git a/lib/prereqs/HUMAN b/lib/prereqs/HUMAN index 86acdb6..c852969 100644 --- a/lib/prereqs/HUMAN +++ b/lib/prereqs/HUMAN @@ -14,5 +14,6 @@ PKG_MGR= PKG_CHK= +URL= 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 index 7dc5cd7..c7e0156 100644 --- a/lib/prereqs/Mageia/meta +++ b/lib/prereqs/Mageia/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='Mageia' +SUPPORTED='yes' +CHECK_METHOD='egrep "^Mageia\ release\ " /etc/mageia-release' +PKG_MGR='urpmi ${pkgname}' +PRE_RUN='urpmi.update -a' +PKG_CHK='rpm -q ${pkgname} | egrep "^${pkgname}-[0-9]"' +URL='https://www.mageia.org/' diff --git a/lib/prereqs/Manjaro/meta b/lib/prereqs/Manjaro/meta index 7dc5cd7..1ab4a60 100644 --- a/lib/prereqs/Manjaro/meta +++ b/lib/prereqs/Manjaro/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='Manjaro' +SUPPORTED='yes' +CHECK_METHOD='egrep "^NAME=\"Manjaro Linux\"" /etc/os-release' +PKG_MGR='pacman --noconfirm -S ${pkgname}' +PRE_RUN='pacman -Syyyu' +PKG_CHK='pacman -Q ${pkgname}' +URL='https://manjaro.org/' diff --git a/lib/prereqs/Mint/meta b/lib/prereqs/Mint/meta index 7dc5cd7..27c545e 100644 --- a/lib/prereqs/Mint/meta +++ b/lib/prereqs/Mint/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='Mint' +SUPPORTED='yes' +CHECK_METHOD='egrep "^DESCRIPTION=\"Linux\ Mint\"" /etc/linuxmint/info' +PKG_MGR='apt-get -y install ${pkgname}' +PRE_RUN='apt-get -y update' +PKG_CHK='dpkg-query -l ${pkgname}' +URL='http://www.linuxmint.com/' diff --git a/lib/prereqs/RHEL/meta b/lib/prereqs/RHEL/meta index 7dc5cd7..1fb5bfe 100644 --- a/lib/prereqs/RHEL/meta +++ b/lib/prereqs/RHEL/meta @@ -1,6 +1,8 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME=RHEL +SUPPORTED=yes +# Red Hat Enterprise Linux Server release 6.5 (Santiago) +CHECK_METHOD='egrep "^Red\ Hat\ Enterprise\ Linux" /etc/redhat-release' +PKG_MGR='yum -y install' +PRE_RUN='none' +PKG_CHK='rpm -q ${pkgname} | egrep "^${pkgname}-[0-9]"' +URL='http://www.redhat.com/en/technologies/linux-platforms/enterprise-linux' diff --git a/lib/prereqs/SUSE/meta b/lib/prereqs/SUSE/meta index 7dc5cd7..9f5fa5a 100644 --- a/lib/prereqs/SUSE/meta +++ b/lib/prereqs/SUSE/meta @@ -1,6 +1,8 @@ -NAME= +NAME='SUSE' SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +# Both SLED and SLES. We can probably safely combine them. +CHECK_METHOD='egrep "^NAME=\"SLE(D|S)\"" /etc/os-release' +PKG_MGR='zypper install -l ${pkgname}' +PRE_RUN='none' +PKG_CHK='rpm -q ${pkgname} | egrep "^${pkgname}-[0-9]"' +URL='https://www.suse.com/' diff --git a/lib/prereqs/Ubuntu/meta b/lib/prereqs/Ubuntu/meta index 7dc5cd7..d9e71b5 100644 --- a/lib/prereqs/Ubuntu/meta +++ b/lib/prereqs/Ubuntu/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='Ubuntu' +SUPPORTED='yes' +CHECK_METHOD='egrep "^DISTRIB_ID=Ubuntu$" /etc/lsb-release' +PKG_MGR='apt-get -y install ${pkgname}' +PRE_RUN='apt-get -y update' +PKG_CHK='dpkg-query -l ${pkgname} | egrep "^ii[[:space:]]*${pkgname}"' +URL='http://www.ubuntu.com/' diff --git a/lib/prereqs/openSUSE/meta b/lib/prereqs/openSUSE/meta index 7dc5cd7..1bef9b1 100644 --- a/lib/prereqs/openSUSE/meta +++ b/lib/prereqs/openSUSE/meta @@ -1,6 +1,7 @@ -NAME= -SUPPORTED= -CHECK_METHOD= -PKG_MGR= -PRE_RUN= -PKG_CHK= +NAME='openSUSE' +SUPPORTED='yes' +CHECK_METHOD='' +PKG_MGR='' +PRE_RUN='' +PKG_CHK='' +URL='https://www.opensuse.org/'