new: mtsc-common, mp-build and mp-pool
This commit is contained in:
9
matter-iso/Makefile
Normal file
9
matter-iso/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
PREFIX = /usr
|
||||
|
||||
install:
|
||||
install -m755 "main.sh" $(DESTDIR)/$(PREFIX)/bin/matter-iso
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)/$(PREFIX)/lib/matter-iso
|
||||
|
||||
.PHONY: install uninstall
|
@ -8,4 +8,4 @@ a configuration directory:
|
||||
```
|
||||
matter-iso matterlinux_24.00.tar.gz isocfg
|
||||
```
|
||||
To learn more about the configuration, see the [wiki page for releases](/wiki/release).
|
||||
To learn more about the configuration, see the [wiki page for releases](/wiki/releases).
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# matter-iso | MatterLinux ISO Build Script
|
||||
# matter-iso | MatterLinux ISO build script
|
||||
# MatterLinux 2023-2024 (https://matterlinux.xyz)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -16,71 +16,35 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
############################
|
||||
## logging functions/vars ##
|
||||
############################
|
||||
BOLD="\e[1m"
|
||||
RESET="\e[0m"
|
||||
GREEN="\e[32m"
|
||||
BLUE="\e[34m"
|
||||
GRAY="\e[37m"
|
||||
RED="\e[31m"
|
||||
LOG_PREFIX=">>>"
|
||||
#############################
|
||||
## import common functions ##
|
||||
#############################
|
||||
location="$(dirname "${0}")"
|
||||
location="$(realpath "${location}")"
|
||||
commonsh="$(echo "${location}" | sed 's/\/bin/\/lib/g')/mtsc-common.sh"
|
||||
|
||||
echo_color() {
|
||||
echo -e "${1}"
|
||||
}
|
||||
source "${commonsh}"
|
||||
|
||||
success() {
|
||||
echo_color "${BOLD}${GREEN}${LOG_PREFIX}${RESET}${BOLD} $1 ${RESET}"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo_color "${BOLD}${BLUE}${LOG_PREFIX}${RESET}${BOLD} $1 ${RESET}"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo_color "${BOLD}${RED}${LOG_PREFIX}${RESET}${BOLD} $1 ${RESET}"
|
||||
if [ "${?}" != "0" ]; then
|
||||
echo "Failed to import mtsc-common"
|
||||
exit 1
|
||||
}
|
||||
|
||||
errorne() {
|
||||
echo_color "${BOLD}${RED}${LOG_PREFIX}${RESET}${BOLD} $1 ${RESET}"
|
||||
}
|
||||
|
||||
print() {
|
||||
echo_color "${BOLD}${GRAY}$1${RESET}"
|
||||
}
|
||||
|
||||
set_indent() {
|
||||
LOG_PREFIX="|>"
|
||||
}
|
||||
|
||||
unset_indent() {
|
||||
LOG_PREFIX=">>>"
|
||||
}
|
||||
fi
|
||||
|
||||
####################
|
||||
## util functions ##
|
||||
####################
|
||||
check_ret() {
|
||||
if [ $? -ne 0 ]; then
|
||||
error "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
check_retc() {
|
||||
if [ $? -ne 0 ]; then
|
||||
errorne "$1"
|
||||
error "${1}"
|
||||
clean_tmpdir
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
clean_tmpdir(){
|
||||
if [ -d $TMPDIR ]; then
|
||||
if [ -d "${tmpdir}" ]; then
|
||||
info "Cleaning up temp directory"
|
||||
rm -rf $TMPDIR
|
||||
rm -rf "${tmpdir}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -101,61 +65,71 @@ check_iso_vars() {
|
||||
#################
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
error "You should run this script as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
error "Please specify a release archive and a config directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ARCHIVE="$(realpath $1)"
|
||||
if [ ! -f $ARCHIVE ]; then
|
||||
archive="$(realpath "${1}")"
|
||||
|
||||
if [ ! -f "${archive}" ]; then
|
||||
error "Archive file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(file $ARCHIVE)" != *"gzip compressed data"* ]]; then
|
||||
if [[ "$(file "${archive}")" != *"gzip compressed data"* ]]; then
|
||||
error "Bad archive format"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONFDIR="$(realpath $2)"
|
||||
if [ ! -d $CONFDIR ]; then
|
||||
confdir="$(realpath "${2}")"
|
||||
|
||||
if [ ! -d "${confdir}" ]; then
|
||||
error "Config directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMPDIR="${CONFDIR}_tmp"
|
||||
DISTDIR="${CONFDIR}/dist"
|
||||
ROOTDIR="${DISTDIR}/root"
|
||||
ISOSH="${TMPDIR}/iso.sh"
|
||||
tmpdir="${confdir}_tmp"
|
||||
distdir="${confdir}/dist"
|
||||
rootdir="${distdir}/root"
|
||||
isoh="${tmpdir}/iso.sh"
|
||||
|
||||
mkdir -p $ROOTDIR
|
||||
mkdir -p "${rootdir}"
|
||||
success "Created root and dist directory"
|
||||
|
||||
info "Copying over the config directory"
|
||||
cp -r $CONFDIR $TMPDIR
|
||||
cp -r "${confdir}" "${tmpdir}"
|
||||
check_ret "Copy failed"
|
||||
|
||||
if [ ! -f $ISOSH ]; then
|
||||
if [ ! -f "${isoh}" ]; then
|
||||
error "ISO script not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source $ISOSH
|
||||
source "${isoh}"
|
||||
check_retc "Cannot source the ISO script"
|
||||
|
||||
check_iso_vars
|
||||
check_retc "ISO script is not valid"
|
||||
success "Sourced the ISO script"
|
||||
|
||||
info "Removing excluded files"
|
||||
rm -rf "$TMPDIR/dist"
|
||||
rm -rf "${tmpdir}/dist"
|
||||
set_indent
|
||||
for e in "${EXCLUDE[@]}"; do
|
||||
info "Removing $e"
|
||||
rm -rf "$TMPDIR/$e"
|
||||
info "Removing ${e}"
|
||||
rm -rf "${tmpdir}/${e}"
|
||||
done
|
||||
rm -rf "$TMPDIR/.git"
|
||||
rm -rf "${tmpdir}/.git"
|
||||
unset_indent
|
||||
|
||||
info "Extracting release archive"
|
||||
SECONDS=0
|
||||
tar --skip-old-files -xf "$ARCHIVE" -C "$TMPDIR"
|
||||
|
||||
tar --skip-old-files -xf "${archive}" -C "${tmpdir}"
|
||||
check_retc "Extract failed"
|
||||
success "Extracted in ${SECONDS}s"
|
||||
|
||||
@ -184,45 +158,45 @@ for p2 in "${PKGS2[@]}"; do
|
||||
done
|
||||
|
||||
info "Adding public keys"
|
||||
matter-chroot "$TMPDIR" gpg --receive-keys $keys_str
|
||||
matter-chroot "${tmpdir}" gpg --receive-keys $keys_str
|
||||
check_retc "Failed to add public keys"
|
||||
|
||||
if [ ! -z "${PKGS1}" ]; then
|
||||
info "Installing extra packages (1)"
|
||||
matter-chroot "$TMPDIR" mp-sync
|
||||
matter-chroot "${tmpdir}" matt sync
|
||||
check_retc "Sync failed"
|
||||
|
||||
matter-chroot "$TMPDIR" MP_YES=1 mp-install $pkgs1_str
|
||||
matter-chroot "${tmpdir}" matt install --yes $pkgs1_str
|
||||
check_retc "Install failed"
|
||||
fi
|
||||
|
||||
info "Running build script"
|
||||
echo "source /iso.sh && build" > "$TMPDIR/stager.sh"
|
||||
matter-chroot "$TMPDIR" chmod +x /stager.sh
|
||||
matter-chroot "$TMPDIR" /stager.sh
|
||||
echo "source /iso.sh && build" > "${tmpdir}/stager.sh"
|
||||
matter-chroot "${tmpdir}" chmod +x /stager.sh
|
||||
matter-chroot "${tmpdir}" /stager.sh
|
||||
check_ret "Build script failed"
|
||||
rm "$TMPDIR/stager.sh"
|
||||
rm "${tmpdir}/stager.sh"
|
||||
|
||||
info "Cleaning up and building initrd"
|
||||
rm "$ISOSH"
|
||||
rm "${isoh}"
|
||||
pushd "$TMPDIR" > /dev/null
|
||||
mkdir -p "$ROOTDIR/boot"
|
||||
find . | cpio --quiet -H newc -o | xz -T0 --check=crc32 > "$ROOTDIR/boot/initrd.img"
|
||||
mkdir -p "${rootdir}/boot"
|
||||
find . | cpio --quiet -H newc -o | xz -T0 --check=crc32 > "${rootdir}/boot/initrd.img"
|
||||
check_ret "Failed to build initrd"
|
||||
popd > /dev/null
|
||||
|
||||
if [ ! -z "${PKGS2}" ]; then
|
||||
info "Installing extra packages (2)"
|
||||
matter-chroot "$TMPDIR" MP_YES=1 mp-install $pkgs2_str
|
||||
matter-chroot "${tmpdir}" MP_YES=1 matt install --yes $pkgs2_str
|
||||
check_ret "Install failed"
|
||||
fi
|
||||
|
||||
info "Copying over the bootdir"
|
||||
cp -r "$TMPDIR/boot"/* "$ROOTDIR/boot"
|
||||
cp -r "${tmpdir}/boot"/* "${rootdir}/boot"
|
||||
|
||||
info "Building the ISO..."
|
||||
pushd "$DISTDIR" > /dev/null
|
||||
grub-mkrescue -o "$DISTDIR/${NAME}_${VERSION}.iso" root
|
||||
pushd "${distdir}" > /dev/null
|
||||
grub-mkrescue -o "${distdir}/${NAME}_${VERSION}.iso" root
|
||||
check_retc "grub-mkrescue failed"
|
||||
popd > /dev/null
|
||||
|
||||
|
Reference in New Issue
Block a user