From 6e940c2c85759ac197c29d335a929dd06822a9df Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Feb 06 2016 14:11:56 +0000 Subject: - Changed sha256sum (1) file verification logic to use dgst(1SSL) instead. - Removed support for particularly pathnames with whitespace or tab cha- racters. If you have whitespaces in your pathnames anyway, the script will methodically destroy every single file on your disk(s). --- diff --git a/000.fetch_git.build b/000.fetch_git.build index d8a891a..d66f195 100644 --- a/000.fetch_git.build +++ b/000.fetch_git.build @@ -1,8 +1,8 @@ # Git clone what we need. -fetch_git cbb-gcc-${PKG_GCC_VERSION} "${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION}"; -fetch_git lazy "${GITROOT}/lazy"; -fetch_git mmglue "${GITROOT}/mmglue"; -fetch_git portage "${GITROOT}/ports/portage"; -fetch_git psxstub "${GITROOT}/psxstub"; +fetch_git cbb-gcc-${PKG_GCC_VERSION} ${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION}; +fetch_git lazy ${GITROOT}/lazy; +fetch_git mmglue ${GITROOT}/mmglue; +fetch_git portage ${GITROOT}/ports/portage; +fetch_git psxstub ${GITROOT}/psxstub; # vim:filetype=sh diff --git a/003.psxstub.build b/003.psxstub.build index 37d4fcd..81eb8ed 100644 --- a/003.psxstub.build +++ b/003.psxstub.build @@ -1,9 +1,9 @@ if is_build_script_done finished; then exit 212; -elif [ "${TARGET}" = "i686-nt32-midipix" ]\ -|| [ "${TARGET}" = "x86_64-nt64-midipix" ]; then +elif [ "x${TARGET}" = "xi686-nt32-midipix" ]\ +|| [ "x${TARGET}" = "xx86_64-nt64-midipix" ]; then cd psxstub; - make ${MAKEFLAGS} DESTDIR="${PREFIX_TARGET}" TARGET="${TARGET}" install; + make ${MAKEFLAGS} DESTDIR=${PREFIX_TARGET} TARGET=${TARGET} install; set_build_script_done finished; fi; diff --git a/006.musl.build b/006.musl.build index b3b9ec6..201eb59 100644 --- a/006.musl.build +++ b/006.musl.build @@ -1,46 +1,45 @@ -export lz_arch="${ARCH}" lz_cflags_debug="-O2" lz_target="${TARGET}"; +export lz_arch=${ARCH} lz_cflags_debug=-O2 lz_target=${TARGET}; if is_build_script_done finished; then exit 212; elif [ "x${3}" = "xno-complex" ]; then # Musl: build (no-complex) - _install="install_no_complex"; - set_build_dir "musl-${PKG_MUSL_VERSION}" "${TARGET}-${3}"; - fetch "http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz" \ - "${PKG_MUSL_SHA256SUM}"; + _install=install_no_complex; + set_build_dir musl-${PKG_MUSL_VERSION} ${TARGET}-${3}; + fetch http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz \ + ${PKG_MUSL_SHA256SUM}; if ! is_build_script_done extracted; then - rm_if_exists "musl-${PKG_MUSL_VERSION}"; - tar -xf "musl-${PKG_MUSL_VERSION}.tar.gz"; - cp -R mmglue/* "musl-${PKG_MUSL_VERSION}/"; + rm_if_exists musl-${PKG_MUSL_VERSION}; + tar -xf musl-${PKG_MUSL_VERSION}.tar.gz; + cp -R mmglue/* musl-${PKG_MUSL_VERSION}/; set_build_script_done extracted -configured; fi; elif [ "x${3}" = "xnative" ]; then # Musl: build (full) - _destdir="${PREFIX_NATIVE}"; - _install="install"; - set_build_dir "musl-${PKG_MUSL_VERSION}" "${3}"; + _destdir=${PREFIX_NATIVE}; + _install=install; + set_build_dir musl-${PKG_MUSL_VERSION} ${3}; else # Musl: build (full) - _install="install"; - set_build_dir "musl-${PKG_MUSL_VERSION}" "${TARGET}"; + _install=install; + set_build_dir musl-${PKG_MUSL_VERSION} ${TARGET}; fi; if ! is_build_script_done configured; then - rm_if_exists -m -c "${_build_dir}"; + rm_if_exists -m -c ${_build_dir}; ../lazy/lazy \ - -a "${ARCH}" \ + -a ${ARCH} \ -c gcc \ - -f "${_destdir:-${PREFIX_TARGET}}" \ + -f ${_destdir:-${PREFIX_TARGET}} \ -n musl \ - -p "../musl-${PKG_MUSL_VERSION}" \ - -t "${lz_target}" \ + -p ../musl-${PKG_MUSL_VERSION} \ + -t ${lz_target} \ -x config; set_build_script_done configured -built; else - cd "${_build_dir}"; + cd ${_build_dir}; fi; if ! is_build_script_done built; then - ./lazy \ - -e "${_install}" \ + ./lazy -e ${_install} \ -x build; set_build_script_done built finished; fi; diff --git a/007.gcc.full.build b/007.gcc.full.build index c3343fe..68f7a15 100644 --- a/007.gcc.full.build +++ b/007.gcc.full.build @@ -5,8 +5,8 @@ if is_build_script_done finished; then elif [ "x${3}" = "xruntime" ]\ || [ "x${3}" = "xfull" ]; then export CFLAGS="${GCCFLAGS}" CXXFLAGS="${GCCFLAGS}"; - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" "${TARGET}"; - cd "${_build_dir}"; + set_build_dir cbb-gcc-${PKG_GCC_VERSION} ${TARGET}; + cd ${_build_dir}; if [ "x${3}" = "xruntime" ]; then # GCC, compiler runtime. if ! is_build_script_done built; then @@ -39,20 +39,20 @@ elif [ "x${3}" = "xruntime" ]\ else if [ "x${3}" = "xstage1" ]; then # GCC, stage1. - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" "${TARGET}"; - export cbb_ldflags_for_target="--sysroot=${PREFIX_TARGET}" \ - cbb_sysroot_for_libgcc="${PREFIX_TARGET}" \ - cbb_target="${TARGET}" \ - cbb_neutral_libiberty="no" \ - cbb_xgcc_for_specs="${WORKDIR}/${_build_dir}/gcc/xgcc"; + set_build_dir cbb-gcc-${PKG_GCC_VERSION} ${TARGET}; + export cbb_ldflags_for_target=--sysroot=${PREFIX_TARGET} \ + cbb_sysroot_for_libgcc=${PREFIX_TARGET} \ + cbb_target=${TARGET} \ + cbb_neutral_libiberty=no \ + cbb_xgcc_for_specs=${WORKDIR}/${_build_dir}/gcc/xgcc; GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_TARGET}"; elif [ "x${3}" = "xnative" ]; then # GCC, native. - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" "native"; - export cbb_ldflags_for_target="--sysroot=${PREFIX_NATIVE}" \ - cbb_sysroot_for_libgcc="${PREFIX_NATIVE}" \ - cbb_target="${TARGET}" \ - cbb_xgcc_for_specs="${TARGET}-gcc"; + set_build_dir cbb-gcc-${PKG_GCC_VERSION} native; + export cbb_ldflags_for_target=--sysroot=${PREFIX_NATIVE} \ + cbb_sysroot_for_libgcc=${PREFIX_NATIVE} \ + cbb_target=${TARGET} \ + cbb_xgcc_for_specs=${TARGET}-gcc; GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_NATIVE}"; fi; GCCFLAGS="${CFLAGS:+${CFLAGS} }--include $(readlink -f ${WORKDIR}/cbb-gcc-${PKG_GCC_VERSION}/libc/cbb-musl-pe.h)"; @@ -62,14 +62,14 @@ else export CFLAGS CXXFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET; if ! is_build_script_done configured; then if [ "x${3}" = "xstage1" ]; then - mkdir -p "${PREFIX_TARGET}/include"; - [ \! -d "${PREFIX_TARGET}/usr" ] && \ - ln -s . "${PREFIX_TARGET}/usr"; + mkdir -p ${PREFIX_TARGET}/include; + [ \! -d ${PREFIX_TARGET}/usr ] && \ + ln -s . ${PREFIX_TARGET}/usr; _configure_args="--prefix=${PREFIX} --with-sysroot=${PREFIX_TARGET}"; elif [ "x${3}" = "xnative" ]; then - mkdir -p "${PREFIX_NATIVE}/${TARGET}"; - if [ \! -d "${PREFIX_NATIVE}/${TARGET}/usr" ]; then - ln -s . "${PREFIX_NATIVE}/${TARGET}/usr"; + mkdir -p ${PREFIX_NATIVE}/${TARGET}; + if [ \! -d ${PREFIX_NATIVE}/${TARGET}/usr ]; then + ln -s . ${PREFIX_NATIVE}/${TARGET}/usr; fi; _configure_args=" \ --host=x86_64-nt64-midipix \ @@ -80,8 +80,8 @@ else --with-mpfr=${PREFIX_NATIVE} \ --with-sysroot="; fi; - rm_if_exists -m -c "${_build_dir}"; - "../cbb-gcc-${PKG_GCC_VERSION}/configure" \ + rm_if_exists -m -c ${_build_dir}; + ../cbb-gcc-${PKG_GCC_VERSION}/configure \ --disable-bootstrap \ --disable-libmudflap \ --disable-multilib \ @@ -107,7 +107,7 @@ else ${_configure_args}; set_build_script_done configured -built; else - cd "${_build_dir}"; + cd ${_build_dir}; fi; if ! is_build_script_done built; then if [ "x${3}" = "xstage1" ]; then @@ -124,7 +124,7 @@ else if [ "x${3}" = "xstage1" ]; then make ${MAKEFLAGS} install-gcc; elif [ "x${3}" = "xnative" ]; then - make -j18 DESTDIR="${PREFIX_NATIVE}" install; + make -j18 DESTDIR=${PREFIX_NATIVE} install; fi; set_build_script_done installed finished; fi; diff --git a/100.perk.build b/100.perk.build index 8ad9c10..f966813 100644 --- a/100.perk.build +++ b/100.perk.build @@ -1,7 +1,7 @@ if is_build_script_done finished; then exit 212; else - fetch_git perk "${GITROOT}/perk"; + fetch_git perk ${GITROOT}/perk; fi; if ! is_build_script_done configured1; then rm_if_exists -m -c perk-build; @@ -15,23 +15,22 @@ if ! is_build_script_done built1; then set_build_script_done built1 -installed1; fi; if ! is_build_script_done installed1; then - make DESTDIR="${PREFIX}" install; + make DESTDIR=${PREFIX} install; set_build_script_done installed1 -configured2; fi; if ! is_build_script_done configured2; then - rm_if_exists -m "../perk-build-${TARGET}"; - cd "../perk-build-${TARGET}"; - ../perk/configure --target="${TARGET}"; + rm_if_exists -m -c ../perk-build-${TARGET}; + ../perk/configure --target=${TARGET}; set_build_script_done configured2 -built2; else - cd "../perk-build-${TARGET}"; + cd ../perk-build-${TARGET}; fi; if ! is_build_script_done built2; then make; set_build_script_done built2 -installed2; fi; if ! is_build_script_done installed2; then - make DESTDIR="${PREFIX_NATIVE}" install; + make DESTDIR=${PREFIX_NATIVE} install; set_build_script_done installed2 finished; fi; diff --git a/101.gmp.build b/101.gmp.build index 67b2e51..1a09328 100644 --- a/101.gmp.build +++ b/101.gmp.build @@ -2,66 +2,66 @@ libelf_install_post() { rm -f lib/libelf.def || return 1; echo EXPORTS > lib/libelf.def || return 2; perk -e lib/libelf.so >> lib/libelf.def || return 3; - "${HOST_NATIVE}-dlltool" \ + ${HOST_NATIVE}-dlltool \ --output-lib lib/libelf.lib.a \ --dllname libelf.so \ --input-def lib/libelf.def || return 4; - cp lib/libelf.lib.a "${PREFIX}/lib" || return 5; + cp lib/libelf.lib.a ${PREFIX}/lib || return 5; }; -parse_with_pkg_name "${2}" \ - "https://gmplib.org/download/gmp/gmp-${PKG_GMP_VERSION}.tar.bz2" \ - "_configure_extra_args=--disable-assembly:_prefix_extra=${PREFIX_TARGET}" \ - "ftp://ftp.gnu.org/gnu/mpfr/mpfr-${PKG_MPFR_VERSION}.tar.bz2" \ - "_configure_extra_args=--with-gmp=${PREFIX_NATIVE}:_prefix_extra=${PREFIX_TARGET}" \ - "ftp://ftp.gnu.org/gnu/mpc/mpc-${PKG_MPC_VERSION}.tar.gz" \ - "_configure_extra_args=--with-gmp=${PREFIX_NATIVE},--with-mpfr=${PREFIX_NATIVE}:_prefix_extra=${PREFIX_TARGET}"\ - "http://www.mr511.de/software/libelf-${PKG_LIBELF_VERSION}.tar.gz" \ - "_no_libtool_midipix=1:_prefix=${PREFIX_NATIVE}:CC=${HOST_NATIVE}-gcc:DESTDIR=" \ - "ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2" \ - "_configure_extra_args=--with-libelf=${PREFIX_NATIVE},--with-gmp=${PREFIX_NATIVE},--with-mpc=${PREFIX_NATIVE},--with-mpfr=${PREFIX_NATIVE},--with-sysroot=/"; +parse_with_pkg_name ${2} \ + https://gmplib.org/download/gmp/gmp-${PKG_GMP_VERSION}.tar.bz2 \ + _configure_extra_args=--disable-assembly:_prefix_extra=${PREFIX_TARGET} \ + ftp://ftp.gnu.org/gnu/mpfr/mpfr-${PKG_MPFR_VERSION}.tar.bz2 \ + _configure_extra_args=--with-gmp=${PREFIX_NATIVE}:_prefix_extra=${PREFIX_TARGET} \ + ftp://ftp.gnu.org/gnu/mpc/mpc-${PKG_MPC_VERSION}.tar.gz \ + _configure_extra_args=--with-gmp=${PREFIX_NATIVE},--with-mpfr=${PREFIX_NATIVE}:_prefix_extra=${PREFIX_TARGET}\ + http://www.mr511.de/software/libelf-${PKG_LIBELF_VERSION}.tar.gz \ + _no_libtool_midipix=1:_prefix=${PREFIX_NATIVE}:CC=${HOST_NATIVE}-gcc:DESTDIR= \ + ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2 \ + _configure_extra_args=--with-libelf=${PREFIX_NATIVE},--with-gmp=${PREFIX_NATIVE},--with-mpc=${PREFIX_NATIVE},--with-mpfr=${PREFIX_NATIVE},--with-sysroot=/; if is_build_script_done finished; then exit 212; else - fetch "${_pkg_url}" "${_pkg_sha256sum}"; + fetch ${_pkg_url} ${_pkg_sha256sum}; fi; if ! is_build_script_done extracted; then - rm_if_exists "${_pkg_subdir}"; - tar -axf "${_pkg_fname}"; + rm_if_exists ${_pkg_subdir}; + tar -axf ${_pkg_fname}; set_build_script_done extracted -patched; fi; if ! is_build_script_done patched; then - patch -d "${_pkg_subdir}" -p1 \ - < "portage/${_pkg_subdir}.midipix.patch"; + patch -d ${_pkg_subdir} -p1 \ + < portage/${_pkg_subdir}.midipix.patch; if [ ${_no_libtool_midipix:-0} -eq 0 ]; then - cp portage/libtool.midipix "${_pkg_subdir}/"; + cp portage/libtool.midipix ${_pkg_subdir}/; fi; set_build_script_done patched -configured; fi; if ! is_build_script_done configured; then - rm_if_exists -c -m "${_pkg_subdir}-build-native${3:+-${3}}"; + rm_if_exists -c -m ${_pkg_subdir}-build-native${3:+-${3}}; run_configure_with_extra_args \ - "../${_pkg_subdir}/configure" \ + ../${_pkg_subdir}/configure \ "${_configure_extra_args}" \ - --host="${HOST_NATIVE}" \ + --host=${HOST_NATIVE} \ --prefix=${_prefix:-/} \ - --target="${TARGET}"; + --target=${TARGET}; set_build_script_done configured -built; else - cd "${_pkg_subdir}-build-native${3:+-${3}}"; + cd ${_pkg_subdir}-build-native${3:+-${3}}; fi; if ! is_build_script_done built; then make; set_build_script_done configured built -installed1; fi; if ! is_build_script_done installed1; then - make DESTDIR="${PREFIX_NATIVE}" install; + make DESTDIR=${PREFIX_NATIVE} install; set_build_script_done configured installed1 -installed2 -finished; fi; -if [ -n "${_prefix_extra}" ]; then +if [ -n ${_prefix_extra} ]; then if ! is_build_script_done installed2; then - make DESTDIR="${_prefix_extra}" install; + make DESTDIR=${_prefix_extra} install; set_build_script_done configured installed2 -finished; fi; fi; diff --git a/200.coreutils.build b/200.coreutils.build index 4a43e3b..2eaf442 100644 --- a/200.coreutils.build +++ b/200.coreutils.build @@ -1,51 +1,51 @@ export CFLAGS="${CFLAGS_PACKAGES}"; -parse_with_pkg_name "${2}" \ - "https://ftp.gnu.org/gnu/coreutils/coreutils-${PKG_COREUTILS_VERSION}.tar.xz" "" \ - "https://ftp.gnu.org/gnu/diffutils/diffutils-${PKG_DIFFUTILS_VERSION}.tar.xz" "" \ - "http://alpha.gnu.org/gnu/findutils/findutils-${PKG_FINDUTILS_VERSION}.tar.gz" \ - "CFLAGS=${CFLAGS:+${CFLAGS} }-Dendpwent=setpwent" \ - "https://ftp.gnu.org/gnu/patch/patch-${PKG_PATCH_VERSION}.tar.gz" "" \ - "https://ftp.gnu.org/gnu/gawk/gawk-${PKG_GAWK_VERSION}.tar.xz" "" \ - "https://ftp.gnu.org/gnu/bash/bash-${PKG_BASH_VERSION}.tar.gz" \ - "_configure_extra_args=--without-bash-malloc" \ - "https://ftp.gnu.org/gnu/make/make-${PKG_MAKE_VERSION}.tar.bz2" "" \ - "https://ftp.gnu.org/gnu/grep/grep-${PKG_GREP_VERSION}.tar.xz" "" \ - "https://ftp.gnu.org/gnu/sed/sed-${PKG_SED_VERSION}.tar.bz2" "" \ - "ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2" ""; +parse_with_pkg_name ${2} \ + https://ftp.gnu.org/gnu/coreutils/coreutils-${PKG_COREUTILS_VERSION}.tar.xz "" \ + https://ftp.gnu.org/gnu/diffutils/diffutils-${PKG_DIFFUTILS_VERSION}.tar.xz "" \ + http://alpha.gnu.org/gnu/findutils/findutils-${PKG_FINDUTILS_VERSION}.tar.gz \ + "CFLAGS=${CFLAGS:+${CFLAGS} }-Dendpwent=setpwent" \ + https://ftp.gnu.org/gnu/patch/patch-${PKG_PATCH_VERSION}.tar.gz "" \ + https://ftp.gnu.org/gnu/gawk/gawk-${PKG_GAWK_VERSION}.tar.xz "" \ + https://ftp.gnu.org/gnu/bash/bash-${PKG_BASH_VERSION}.tar.gz \ + _configure_extra_args=--without-bash-malloc \ + https://ftp.gnu.org/gnu/make/make-${PKG_MAKE_VERSION}.tar.bz2 "" \ + https://ftp.gnu.org/gnu/grep/grep-${PKG_GREP_VERSION}.tar.xz "" \ + https://ftp.gnu.org/gnu/sed/sed-${PKG_SED_VERSION}.tar.bz2 "" \ + ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2 ""; if is_build_script_done finished; then exit 212; else - fetch "${_pkg_url}" "${_pkg_sha256sum}"; - if [ "${_pkg_name}" = "binutils" ]\ - && [ "${3}" = "host" ]; then + fetch ${_pkg_url} ${_pkg_sha256sum}; + if [ "x${_pkg_name}" = "xbinutils" ]\ + && [ "x${3}" = "xhost" ]; then _configure_args="--disable-werror,--prefix=${PREFIX},--with-sysroot=${PREFIX_TARGET}"; - _no_config_cache=${_no_prefix:=1}; _target="${TARGET}"; + _no_config_cache=${_no_prefix:=1}; _target=${TARGET}; else _configure_args="-C,--host=${HOST_NATIVE},--prefix=${_configure_extra_args:+,${_configure_extra_args}}"; fi; fi; if ! is_build_script_done extracted; then - rm_if_exists "${_pkg_subdir}"; - tar -axf "${_pkg_fname}"; + rm_if_exists ${_pkg_subdir}; + tar -axf ${_pkg_fname}; set_build_script_done extracted -patched; fi; if ! is_build_script_done patched; then - patch -d "${_pkg_subdir}" -p1 \ - < "portage/${_pkg_subdir}.midipix.patch"; + patch -d ${_pkg_subdir} -p1 \ + < portage/${_pkg_subdir}.midipix.patch; set_build_script_done patched -configured; fi; if ! is_build_script_done configured; then - rm_if_exists -c -m "${_pkg_subdir}-build-${_target:-native}"; + rm_if_exists -c -m ${_pkg_subdir}-build-${_target:-native}; [ ${_no_config_cache:-0} -eq 0 ] &&\ - cp -a "../portage/config.cache" .; + cp -a ../portage/config.cache .; run_configure_with_extra_args \ - "../${_pkg_subdir}/configure" \ + ../${_pkg_subdir}/configure \ "${_configure_args}" \ - --target="${TARGET}"; + --target=${TARGET}; set_build_script_done configured -built; else - cd "${_pkg_subdir}-build-${_target:-native}"; + cd ${_pkg_subdir}-build-${_target:-native}; fi; if ! is_build_script_done built; then make ${MAKEFLAGS}; @@ -53,7 +53,7 @@ if ! is_build_script_done built; then fi; if ! is_build_script_done installed; then if [ ${_no_prefix:-0} -eq 0 ]; then - make ${MAKEFLAGS} DESTDIR="${PREFIX_NATIVE}" install; + make ${MAKEFLAGS} DESTDIR=${PREFIX_NATIVE} install; else make ${MAKEFLAGS} install; fi; diff --git a/207.libz.build b/207.libz.build index 231baf2..2c29870 100644 --- a/207.libz.build +++ b/207.libz.build @@ -1,31 +1,31 @@ if is_build_script_done finished; then exit 212; elif [ "x${2}" = "xlibz" ]; then - _pkg_url="https://sortix.org/libz/release/libz-${PKG_LIBZ_VERSION}.tar.gz"; - _pkg_fname="${_pkg_url##*/}"; - _pkg_sha256sum="${PKG_LIBZ_SHA256SUM}"; - _pkg_subdir="${2}-${PKG_LIBZ_VERSION}"; + _pkg_url=https://sortix.org/libz/release/libz-${PKG_LIBZ_VERSION}.tar.gz; + _pkg_fname=${_pkg_url##*/}; + _pkg_sha256sum=${PKG_LIBZ_SHA256SUM}; + _pkg_subdir=${2}-${PKG_LIBZ_VERSION}; elif [ "x${2}" = "xgzip" ]; then - _pkg_url="https://ftp.gnu.org/gnu/gzip/gzip-${PKG_GZIP_VERSION}.tar.gz"; - _pkg_fname="${_pkg_url##*/}"; - _pkg_sha256sum="${PKG_GZIP_SHA256SUM}"; - _pkg_subdir="${2}-${PKG_GZIP_VERSION}"; + _pkg_url=https://ftp.gnu.org/gnu/gzip/gzip-${PKG_GZIP_VERSION}.tar.gz; + _pkg_fname=${_pkg_url##*/}; + _pkg_sha256sum=${PKG_GZIP_SHA256SUM}; + _pkg_subdir=${2}-${PKG_GZIP_VERSION}; fi; -fetch "${_pkg_url}" "${_pkg_sha256sum}"; +fetch ${_pkg_url} ${_pkg_sha256sum}; if ! is_build_script_done extracted; then - rm_if_exists "${_pkg_fname%%.tar*}"; - tar -axf "${_pkg_fname}"; + rm_if_exists ${_pkg_fname%%.tar*}; + tar -axf ${_pkg_fname}; set_build_script_done extracted -patched; fi; if ! is_build_script_done configured; then - set_build_dir "${_pkg_fname%%-*}" "${TARGET}"; - rm_if_exists -c -m "${_build_dir}"; - cp -a "../portage/config.cache" .; + set_build_dir ${_pkg_fname%%-*} ${TARGET}; + rm_if_exists -c -m ${_build_dir}; + cp -a ../portage/config.cache .; CFLAGS="${CFLAGS_PACKAGES}" \ - "../${_pkg_subdir}/configure" \ - --host="${HOST_NATIVE}" \ - --prefix="" \ - --target="${TARGET}"; + ../${_pkg_subdir}/configure \ + --host=${HOST_NATIVE} \ + --prefix= \ + --target=${TARGET}; set_build_script_done configured -built; fi; if ! is_build_script_done built; then @@ -33,15 +33,15 @@ if ! is_build_script_done built; then make -j18; elif [ "x${3}" = "xgzip" ]; then make clean; - make CFLAGS="-g3 -O0 -I${PREFIX_NATIVE}/include" LDFLAGS="--sysroot=${PREFIX_NATIVE}"; + make CFLAGS="-g3 -O0 -I${PREFIX_NATIVE}/include" LDFLAGS=--sysroot=${PREFIX_NATIVE}; fi; set_build_script_done built -installed; fi; if ! is_build_script_done installed; then if [ "x${3}" = "xlibz" ]; then - make -j18 DESTDIR="${PREFIX_NATIVE}" install; + make -j18 DESTDIR=${PREFIX_NATIVE} install; elif [ "x${3}" = "xgzip" ]; then - cp -a gunzip gzip zcat "${PREFIX_NATIVE}/bin"; + cp -a gunzip gzip zcat ${PREFIX_NATIVE}/bin; fi; set_build_script_done installed finished; fi; diff --git a/build.sh b/build.sh index e493104..6cb7598 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ { unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS; . ./build.vars; . ./build.subr; -check_prereqs git make sed tar wget; +check_prereqs git make openssl sed tar wget; log_msg info "Build started by ${USER}@$(hostname)."; #trap (set -o errexit; mkdir -p "${PREFIX}" "${WORKDIR}"); diff --git a/build.subr b/build.subr index 492706d..2020d21 100644 --- a/build.subr +++ b/build.subr @@ -1,8 +1,12 @@ +# +# set -o errexit is assumed. +# + TIMESTAMP_FMT="${TIMESTAMP_FMT:-"%Y/%m/%d %H:%M:%S"}"; check_prereqs() { for _cmd in "$@"; do - if ! command -v "${_cmd}" >/dev/null; then + if ! command -v ${_cmd} >/dev/null; then log_msg fail "Error: missing prerequisite command \`${_cmd}"; exit 1; fi; @@ -14,25 +18,30 @@ date() { }; fetch() { - wget --no-check-certificate -N "${1}"; - if [ $# -eq 2 ]\ - && ! printf "${2} ${1##*/}\n" | sha256sum -c --status; then - log_msg fail "Error: sha256sum mismatch for URL \`${1##*/}'."; + wget --no-check-certificate -N ${1}; + if [ $# -eq 2 ] && ! compare_hash ${1##*/} ${2}; then + log_msg fail "Error: hash mismatch for URL \`${1##*/}'."; exit 1; fi; }; fetch_git() { - if [ -d "${1}" ]; then - (cd "${1}" && git pull origin main); + if [ -d ${1} ]; then + (cd ${1} && git pull origin main); else - git clone "${2}" "${1}"; + git clone ${2} ${1}; fi; }; +compare_hash() { + _hash_cmp=${2}; set -- $(openssl dgst -sha256 ${1}); + shift $((${#}-1)); set -- ${1} ${_hash_cmp}; unset _hash_cmp; + [ "x${1}" = "x${2}" ]; +}; + is_build_script_done() { - _script_fname="${SCRIPT_FNAME##*/}"; - if [ -f "${WORKDIR}/.${_script_fname%.build}.${1}" ]; then + _script_fname=${SCRIPT_FNAME##*/}; + if [ -f ${WORKDIR}/.${_script_fname%.build}.${1} ]; then unset script_fname; return 0; else @@ -41,13 +50,13 @@ is_build_script_done() { fi; }; set_build_script_done() { - _script_fname="${SCRIPT_FNAME##*/}"; - _done_fname="${WORKDIR}/.${_script_fname%.build}"; + _script_fname=${SCRIPT_FNAME##*/}; + _done_fname=${WORKDIR}/.${_script_fname%.build}; while [ $# -ge 1 ]; do if [ "x${1#-}" != "x${1}" ]; then - rm -f "${_done_fname}.${1#-}"; + rm -f ${_done_fname}.${1#-}; else - touch "${_done_fname}.${1}"; + touch ${_done_fname}.${1}; log_msg info "Finished build step ${1} of build script \`${_script_fname}'."; fi; shift; done; @@ -55,8 +64,8 @@ set_build_script_done() { }; log_msg() { - _lvl="${1}"; shift; - case "${_lvl}" in + _lvl=${1}; shift; + case ${_lvl} in fail) printf "\033[91m"; ;; info) printf "\033[97m"; ;; succ) printf "\033[92m"; ;; @@ -70,17 +79,17 @@ log_msg() { }; parse_with_pkg_name() { - _pkg_name="${1}"; shift; + _pkg_name=${1}; shift; while [ $# -ge 0 ]; do - _pkg_url="${1}"; _envvs="${2}"; _pkg_fname="${_pkg_url##*/}"; + _pkg_url=${1}; _envvs="${2}"; _pkg_fname=${_pkg_url##*/}; if [ "x${_pkg_fname%%-*}" = "x${_pkg_name}" ]; then _IFS="${IFS}"; IFS=:; for _envv in ${_envvs}; do export ${_envv}; done; IFS="${_IFS}"; unset _envvs _envv; - _pkg_subdir="${_pkg_fname%%.tar*}"; - eval _pkg_sha256sum=\""\${PKG_$(echo "${_pkg_name}" |\ - tr a-z A-Z)_SHA256SUM}"\"; + _pkg_subdir=${_pkg_fname%%.tar*}; + eval _pkg_sha256sum=\${PKG_$(echo "${_pkg_name}" |\ + tr a-z A-Z)_SHA256SUM}; return; fi; shift 2; done; @@ -90,30 +99,30 @@ parse_with_pkg_name() { rm_if_exists() { while [ $# -gt 1 ]; do [ "x${1%[a-z]}" = "x-" ] &&\ eval _${1#-}flag=1; shift; done; - _dir="${1}"; - if [ -d "${1}" ]; then - rm -rf "${1}" || return 1; + _dir=${1}; + if [ -d ${1} ]; then + rm -rf ${1} || return 1; fi; if [ ${_mflag:-0} -eq 1 ]; then - unset _mflag; mkdir "${1}" || return 2; + unset _mflag; mkdir ${1} || return 2; fi; if [ ${_cflag:-0} -eq 1 ]; then - unset _cflag; cd "${1}" || return 3; + unset _cflag; cd ${1} || return 3; fi; }; run_configure_with_extra_args() { - _IFS="${IFS}"; IFS=","; _script="${1}"; _extra_args="${2}"; - shift 2; "${_script}" "${@}" ${_extra_args}; IFS="${_IFS}"; + _IFS="${IFS}"; IFS=","; _script=${1}; _extra_args="${2}"; + shift 2; ${_script} "${@}" ${_extra_args}; IFS="${_IFS}"; unset _script _extra_args; }; set_build_dir() { - export _build_dir="${1}-build-${2}"; + export _build_dir=${1}-build-${2}; }; set_env_vars() { - _val="${1}"; shift; + _val=${1}; shift; while [ $# -ge 1 ]; do export "${1}=${_val}"; shift; done; unset _val; diff --git a/build.vars b/build.vars index 02337b2..f12a94c 100644 --- a/build.vars +++ b/build.vars @@ -1,3 +1,9 @@ +# +# WARNING: Do _NOT_ use whitespaces (` ') or tab (` ') +# characters in any of the variables below save for MAKEFLAGS, +# PATH, and TIMESTAMP_FMT. +# + : ${ARCH:=nt64}; : ${CFLAGS_PACKAGES:=-g3 -O0}; : ${GITROOT:=git://midipix.org};