new: mtsc-common, mp-build and mp-pool
This commit is contained in:
9
matter-base/Makefile
Normal file
9
matter-base/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
PREFIX = /usr
|
||||
|
||||
install:
|
||||
install -m755 "main.sh" $(DESTDIR)/$(PREFIX)/bin/matter-base
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)/$(PREFIX)/lib/matter-base
|
||||
|
||||
.PHONY: install uninstall
|
@ -3,7 +3,7 @@ This script is used for building release archives.
|
||||
|
||||
### Usage
|
||||
Note that you will need to install and configure
|
||||
[`mp`](https://git.matterlinux.xyz/matterlinux/mp) before using
|
||||
[`matt`](https://git.matterlinux.xyz/matterlinux/matt) before using
|
||||
`matter-base`.
|
||||
|
||||
To use the `matter-base` script, specify a temporary target
|
||||
|
115
matter-base/main.sh
Normal file → Executable file
115
matter-base/main.sh
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# matter-base | Matterlinux Release Archive Build Script
|
||||
# matter-base | MatterLinux release archive build script
|
||||
# MatterLinux 2023-2024 (https://matterlinux.xyz)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -16,66 +16,54 @@
|
||||
# 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"
|
||||
#############################
|
||||
## import common functions ##
|
||||
#############################
|
||||
location="$(dirname "${0}")"
|
||||
location="$(realpath "${location}")"
|
||||
commonsh="$(echo "${location}" | sed 's/\/bin/\/lib/g')/mtsc-common.sh"
|
||||
|
||||
success() {
|
||||
echo -e "$BOLD$GREEN>>>$RESET$BOLD $1$RESET"
|
||||
}
|
||||
source "${commonsh}"
|
||||
|
||||
info() {
|
||||
echo -e "$BOLD$BLUE>>>$RESET$BOLD $1$RESET"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "$BOLD$RED>>>$RESET$BOLD $1$RESET"
|
||||
if [ "${?}" != "0" ]; then
|
||||
echo "Failed to import mtsc-common"
|
||||
exit 1
|
||||
}
|
||||
|
||||
####################
|
||||
## util functions ##
|
||||
####################
|
||||
check_ret() {
|
||||
if [ $? -ne 0 ]; then
|
||||
error "$1"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
#################
|
||||
## main script ##
|
||||
#################
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
error "You should run this script as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
error "Please specify a name for the archive"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NAME="$1"
|
||||
TARGET="$(realpath $1)"
|
||||
if [ -d $TARGET ]; then
|
||||
name="${1}"
|
||||
target="$(realpath "${1}")"
|
||||
|
||||
if [ -d "${target}" ]; then
|
||||
error "A directory with the specified archive name exists"
|
||||
exit 1
|
||||
fi
|
||||
mkdir $TARGET
|
||||
mkdir "${target}"
|
||||
|
||||
if ! type mp > /dev/null; then
|
||||
error "mp is not installed, please install and configure mp"
|
||||
if ! type matt > /dev/null; then
|
||||
error "matt is not installed, please install and configure matt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
info "Creating directory structure"
|
||||
pushd $TARGET > /dev/null
|
||||
mkdir -p {dev,proc,sys,run,tmp,root,home,boot,mnt}
|
||||
mkdir -p var/{log,mail,lib}
|
||||
mkdir -p usr/{bin,lib,sbin}
|
||||
mkdir -p etc/mp
|
||||
pushd "${target}" > /dev/null
|
||||
install -Ddm755 {dev,proc,sys,run,tmp,root,home,boot,mnt}
|
||||
install -Ddm755 var/{log,mail,lib}
|
||||
install -Ddm755 usr/{bin,lib,sbin}
|
||||
install -Ddm755 var/lib/matt
|
||||
install -Ddm755 etc/matt
|
||||
|
||||
ln -sf usr/lib lib
|
||||
ln -sf usr/lib lib64
|
||||
@ -126,25 +114,24 @@ EOF
|
||||
EOF
|
||||
popd > /dev/null
|
||||
|
||||
export MP_ROOT="$TARGET" MP_YES=1
|
||||
info "Syncing repositories"
|
||||
mp-sync
|
||||
check_ret "mp-sync command failed"
|
||||
info "Syncing repositories"
|
||||
matt sync --root "${target}" --yes
|
||||
check_ret "matt command failed"
|
||||
|
||||
info "Installing base system packages"
|
||||
mp-install acl attr coreutils binutils \
|
||||
bash e2fsprogs udev file release \
|
||||
findutils gawk grep gzip iana-etc \
|
||||
inetutils intltool iproute kmod less \
|
||||
openssl sed shadow tar tcl mandb \
|
||||
man-pages tzdata util-linux which \
|
||||
mp gettext iproute procps psmisc \
|
||||
mandb kbd dbus vim nano libxml2
|
||||
check_ret "mp-install command failed"
|
||||
unset MP_ROOT MP_YES
|
||||
info "Installing base system packages"
|
||||
matt install --root "${target}" --yes \
|
||||
acl attr coreutils binutils \
|
||||
bash e2fsprogs udev file release \
|
||||
findutils gawk grep gzip iana-etc \
|
||||
inetutils intltool iproute kmod less \
|
||||
openssl sed shadow tar tcl mandb \
|
||||
man-pages tzdata util-linux which \
|
||||
matt gettext iproute procps psmisc \
|
||||
mandb kbd dbus vim nano libxml2
|
||||
check_ret "matt command failed"
|
||||
success "Installed the base system"
|
||||
|
||||
cat > $TARGET/etc/inputrc << "EOF"
|
||||
cat > "${target}/etc/inputrc" << "EOF"
|
||||
# do not bell on tab-completion
|
||||
#set bell-style none
|
||||
|
||||
@ -183,24 +170,24 @@ $if mode=emacs
|
||||
$endif
|
||||
EOF
|
||||
|
||||
cat > $TARGET/etc/shells << "EOF"
|
||||
cat > "${target}/etc/shells" << "EOF"
|
||||
/bin/sh
|
||||
/bin/bash
|
||||
EOF
|
||||
|
||||
cp "$TARGET/etc/skel/."* "$TARGET/root"
|
||||
cp "${target}/etc/skel/."* "${target}/root"
|
||||
|
||||
info "Installing certs"
|
||||
wget -q https://hg.mozilla.org/projects/nss/raw-file/tip/lib/ckfw/builtins/certdata.txt -O "$TARGET/certdata.txt"
|
||||
matter-chroot $TARGET make-ca > /dev/null
|
||||
wget --show-progress -q https://hg.mozilla.org/projects/nss/raw-file/tip/lib/ckfw/builtins/certdata.txt -O "${target}/certdata.txt"
|
||||
matter-chroot "${target}" make-ca > /dev/null
|
||||
check_ret "Failed to run make-ca, install certs manually"
|
||||
rm -f "$TARGET/certdata.txt"
|
||||
rm -f "${target}/certdata.txt"
|
||||
|
||||
info "Setup complete, now creating the archive..."
|
||||
pushd $TARGET > /dev/null
|
||||
tar czf ../${NAME}.tar.gz *
|
||||
pushd "${target}" > /dev/null
|
||||
tar czf ../${name}.tar.gz *
|
||||
check_ret "Failed to create the archive"
|
||||
popd > /dev/null
|
||||
|
||||
success "Archive created, now cleaning up"
|
||||
rm -rf $TARGET && success "Build completed"
|
||||
rm -rf "${target}" && success "Build completed"
|
||||
|
Reference in New Issue
Block a user