Commit e1478fea authored by Lucas Sulzbach's avatar Lucas Sulzbach

Improve Logger

parent f0fbd865
Pipeline #17178 passed with stage
in 14 seconds
......@@ -52,10 +52,6 @@ EOF
cat "${PREFIX}/helper/logging.incsh" >> "${script}"
}
getLogArguments() {
echo "\"$(basename "${BASH_SOURCE[1]}")\" \"${BASH_LINENO[0]}\""
}
addToChrootFile() {
local chrootdir="${1}"
local script_name="${2}"
......
......@@ -88,7 +88,7 @@ source "${PREFIX}/lib/overlay.sh"
# Installation of create-iso's dependencies
apt-get install isolinux syslinux squashfs-tools genisoimage xorriso --yes || \
perror "Failed to install basic tools"
createIsoLogger --message "Failed to install basic tools" --tag "apt-get"
mountTmpfs "${TMPFS}"
mountOverlay "${CHROOTDIR}" "${TMPFS}"
......@@ -96,7 +96,7 @@ mountOverlay "${CHROOTDIR}" "${TMPFS}"
# Each one of the available scripts is executed in numeric order
for script in "${SCRIPTSDIR}"/*; do
if [ -x "${script}" ] && grep -E --quiet '^[0-9]{2}-[A-Za-z]+' <<< "$(basename "${script}")"; then
pinfo "Running $(basename "${script}")..."
createIsoLogger --message "Running $(basename "${script}")..." --type info
if ! "${script}"\
"${_DIST}" \
"${_ARCH}" \
......@@ -136,11 +136,11 @@ done
# Finally generates the resulting iso image
NAME="LinuxEducacional6-$(echo "${_DIST}" | cut --delimiter='/' --fields=2).iso"
pushd "${TMP}/image" || perror "Unable to change directory"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" --tag "pushd"
xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -no-emul-boot -isohybrid-gpt-basdat \
-o "${PREFIX}/iso/${NAME}" . || perror "Failed to generate iso image."
popd || perror "Unable to change directory"
-o "${PREFIX}/iso/${NAME}" . || createIsoLogger --message "Failed to generate iso image." --tag "xorriso"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
cleanup "${CHROOTDIR}" "${TMP}"
umountOverlay "${CHROOTDIR}" "${TMPFS}"
......
......@@ -6,72 +6,57 @@ readonly ALL=15
VERBOSE_FLAGS=${ALL}
perror () {
if [ "$((${VERBOSE_FLAGS} & ${ERROR}))" -eq "${ERROR}" ]; then
if [ -z "${2}" ]; then
SCRIPT="${2}"
else
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
fi
if [ -z "${3}" ]; then
LINE_NUM="${3}"
else
LINE_NUM="${BASH_LINENO[0]}"
fi
echo -e "\033[38;5;9m[error]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}" 1>&2
echo -e "\033[38;5;9m[error]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}" >> "${LOG_FILE}"
/bin/bash
fi
mapType() {
case "${1}" in
e | error ) echo "${ERROR}" ;;
w | warning ) echo "${WARNING}" ;;
i | info ) echo "${INFO}" ;;
d | debug ) echo "${DEBUG}" ;;
* ) createIsoLogger -m "Invalid type '${1}'" -T "LOGGER"; return 1 ;;
esac
}
pwarning () {
if [ "$((${VERBOSE_FLAGS} & ${WARNING}))" -eq "${WARNING}" ]; then
if [ -z "${2}" ]; then
SCRIPT="${2}"
else
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
fi
if [ -z "${3}" ]; then
LINE_NUM="${3}"
else
LINE_NUM="${BASH_LINENO[0]}"
fi
echo -e "\033[38;5;11m[warning]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}"
echo -e "\033[38;5;11m[warning]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}" >> "${LOG_FILE}"
fi
}
createIsoLogger() {
pinfo () {
if [ "$((${VERBOSE_FLAGS} & ${INFO}))" -eq "${INFO}" ]; then
if [ -z "${2}" ]; then
SCRIPT="${2}"
else
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
fi
if [ -z "${3}" ]; then
LINE_NUM="${3}"
else
LINE_NUM="${BASH_LINENO[0]}"
fi
echo -e "\033[38;5;10m[info]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}"
echo -e "\033[38;5;10m[info]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}" >> "${LOG_FILE}"
TYPE="${ERROR}"
MSG=""
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
LINE="${BASH_LINENO[0]}"
while true; do
case "${1}" in
-t | --type ) TYPE="$(mapType "${2}")" || return; shift; shift ;;
-T | --tag ) TAG="${2}"; shift; shift ;;
-m | --message ) MSG="${2}"; shift; shift ;;
-s | --script ) SCRIPT="${2}"; shift; shift ;;
-l | --line ) LINE="${2}"; shift; shift ;;
-* ) createIsoLogger -m "Unrecognized option '${1}'" -T "LOGGER"; return ;;
* ) break ;;
esac
done
if [ "$((${VERBOSE_FLAGS} & ${TYPE}))" -eq "${TYPE}" ]; then
if [ -z "${TAG}" ]; then
LOG_LINE="[${SCRIPT}]: line ${LINE}: ${MSG}"
else
LOG_LINE="[${SCRIPT}]: line ${LINE}: [${TAG}]: ${MSG}"
fi
case "${TYPE}" in
"${ERROR}" ) LOG_LINE="\033[38;5;9m[ERROR]: ${LOG_LINE}\033[0m" ;;
"${WARNING}" ) LOG_LINE="\033[38;5;11m[WARNING]: ${LOG_LINE}\033[0m" ;;
"${INFO}" ) LOG_LINE="\033[38;5;10m[INFO]: ${LOG_LINE}\033[0m" ;;
"${DEBUG}" ) LOG_LINE="\033[38;5;6m[DEBUG]: ${LOG_LINE}\033[0m" ;;
* ) createIsoLogger -m "Invalid type '${TYPE}'" -T "LOGGER"; return ;;
esac
echo -e "${LOG_LINE}" 1>&2
echo -e "${LOG_LINE}" >> "${LOG_FILE}"
else
createIsoLogger -m "Tried to use disabled type '${TYPE}'" -T "LOGGER"
return
fi
}
pdebug () {
if [ "$((${VERBOSE_FLAGS} & ${DEBUG}))" -eq "${DEBUG}" ]; then
if [ -z "${2}" ]; then
SCRIPT="${2}"
else
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
fi
if [ -z "${3}" ]; then
LINE_NUM="${3}"
else
LINE_NUM="${BASH_LINENO[0]}"
fi
echo -e "\033[38;5;6m[debug]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}"
echo -e "\033[38;5;6m[debug]\033[0m ${SCRIPT}: line ${LINE_NUM}: ${1}" >> "${LOG_FILE}"
if [ "${TYPE}" -eq "${ERROR}" ]; then
/bin/bash
fi
}
......
......@@ -11,7 +11,7 @@ source "${PREFIX}/conf/${_DIST}/create-iso.conf"
source "${PREFIX}/common.sh"
mkdir -p "${TMP}/bl/"
cd "${TMP}/bl/" || perror "Unable to change directory"
cd "${TMP}/bl/" || createIsoLogger --message "Unable to change directory" --tag "cd"
cpio -i < "${ISOLINUX}/bootlogo"
sed -i 's/ubuntu/Linux Educacional/Ig' ./*.{tr,hlp}
echo "" > "${TMP}/list"
......@@ -21,7 +21,7 @@ done
#ls -l | awk '{if(NR>1)print}' | cut -c44- > "${TMP}/list"
cpio -o < "${TMP}/list" > bootlogo
mv "${TMP}/bl/bootlogo" "${ISOLINUX}"
cd "${ISOLINUX}" || perror "Unable to change directory"
cd "${ISOLINUX}" || createIsoLogger --message "Unable to change directory" --tag "cd"
sed -i 's/ubuntu/Linux Educacional/Ig' ./*.{tr,hlp}
rm -rf "${TMP:?}/bl/"
rm "${TMP:?}/list"
......
......@@ -42,7 +42,7 @@ TMP="${17}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
type perror >/dev/null 2>&1 || source "${PREFIX}/common.sh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/common.sh"
#########################################
# WARNING:
......@@ -62,9 +62,10 @@ if mountpoint --quiet "${CHROOTDIR}/proc"; then
fi
mksquashfs "${CHROOTDIR}" "${TMP}/image/casper/filesystem.squashfs" -b 1M -no-recovery -processors "$(nproc)" || \
perror "Failed to compress ${CHROOTDIR}."
pushd "${TMP}/image" || perror "Unable to change directory"
find . -type f -print0 | xargs -0 md5sum | grep --invert-match "\\./md5sum.txt" > md5sum.txt || perror "Failed to generate md5sum"
popd || perror "Unable to change directory"
createIsoLogger --message "Failed to compress ${CHROOTDIR}" --tag "mksquashfs"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" --tag "pushd"
find . -type f -print0 | xargs -0 md5sum | grep --invert-match "\\./md5sum.txt" > md5sum.txt || createIsoLogger \
--message "Failed to generate md5sum" --tag "md5sum"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
exit 0
......@@ -43,7 +43,7 @@ REPOPKGS="${19}"
PREFIX="${PWD}"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/common.sh"
(type perror >/dev/null 2>&1 && type pwarning >/dev/null 2>&1) || source "${PREFIX}/helper/logging.incsh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
mount --bind "/etc/resolv.conf" "${CHROOTDIR}/etc/resolv.conf"
fingerprint="$(gpg --list-keys --with-colons 'C3SL Live' | grep --max-count=1 'fpr' | cut --delimiter=':' --fields=10)"
......@@ -53,23 +53,28 @@ if test -z "${fingerprint}"; then
fi
cp --recursive --archive "${PREFIX}/src/local-repository/" "${PREFIX}/repo/"
sed -i "s/##ARCH##/ ${_ARCH}/" "${PREFIX}/repo/conf/distributions" || pwarning "Unable to setup architecture of local repository"
sed -i "s/##GPGKEY##/ ${fingerprint}/" "${PREFIX}/repo/conf/distributions" || pwarning "Unable to setup the key of local repository"
sed -i "s/##CODENAME##/ ${_REPO}/" "${PREFIX}/repo/conf/distributions" || pwarning "Unable to setup the codename of local repository"
sed -i "s/##ARCH##/ ${_ARCH}/" "${PREFIX}/repo/conf/distributions" || createIsoLogger --message \
"Unable to setup architecture of local repository" --type warning --tag "sed"
sed -i "s/##GPGKEY##/ ${fingerprint}/" "${PREFIX}/repo/conf/distributions" || createIsoLogger --message \
"Unable to setup the key of local repository" --type warning --tag "sed"
sed -i "s/##CODENAME##/ ${_REPO}/" "${PREFIX}/repo/conf/distributions" || createIsoLogger --message \
"Unable to setup the codename of local repository" --type warning --tag "sed"
chroot "${CHROOTDIR}" apt-get clean
# This disables the warning about word splitting (it is supposed to word split since each package has to be an argument):
# shellcheck disable=SC2046
chroot "${CHROOTDIR}" apt-get --download-only --yes install $(grep --invert-match '^#' < "${REPOPKGS}" | tr '\n' ' ') || \
perror "Unable to download packages to local repository"
createIsoLogger --message "Unable to download packages to local repository" --tag "apt-get"
reprepro --basedir "${PREFIX}/repo/" includedeb "${_REPO}" "${CHROOTDIR}"/var/cache/apt/archives/*.deb || \
perror "Unable to include package to local repository"
createIsoLogger --message "Unable to include package to local repository" --tag "reprepro"
chroot "${CHROOTDIR}" apt-get clean
mv repo/{dists,pool} "${TMP}/image/" || perror "Unable to move local repository to image"
mv repo/{dists,pool} "${TMP}/image/" || createIsoLogger --message "Unable to move local repository to image" --tag "mv"
rm --recursive --force "${PREFIX:?}/repo/"
gpg --armor --export 'C3SL Live' > "${CHROOTDIR}/tmp/public.key" || perror "Unable to export key"
chroot "${CHROOTDIR}" apt-key add /tmp/public.key || perror "Unable to add key of local repository"
gpg --armor --export 'C3SL Live' > "${CHROOTDIR}/tmp/public.key" || createIsoLogger --message "Unable to export key" \
--tag "gpg"
chroot "${CHROOTDIR}" apt-key add /tmp/public.key || createIsoLogger --message "Unable to add key of local repository" \
--tag "apt-key"
rm "${CHROOTDIR:?}/tmp/public.key"
umount "${CHROOTDIR}/etc/resolv.conf"
......
......@@ -42,14 +42,15 @@ DPLIST="${7}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type addToChrootFile >/dev/null 2>&1 && type getLogArguments >/dev/null 2>&1) || source "${PREFIX}/common.sh"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/common.sh"
grep --invert-match '^#' < "${DPLIST}" | tr '\n' ' '
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "export PATH='/fakebin:${PATH}' || \
perror \"Unable to export PATH\" $(getLogArguments)"
createIsoLogger --message \"Unable to export PATH\" --script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"export\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "export DEBIAN_FRONTEND=noninteractive || \
perror \"Unable to export DEBIAN_FRONTEND\" $(getLogArguments)"
createIsoLogger --message \"Unable to export DEBIAN_FRONTEND\" --script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"export\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get update && apt-get --quiet --yes install \
$(grep --invert-match '^#' < "${DPLIST}" | tr '\n' ' ') || perror \"Unable to install dependencies\" $(getLogArguments)"
$(grep --invert-match '^#' < "${DPLIST}" | tr '\n' ' ') || createIsoLogger --message \"Unable to install dependencies\" \
--script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"apt-get\""
exit 0
......@@ -42,16 +42,19 @@ INSTLIST="${8}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type addToChrootFile >/dev/null 2>&1 && type getLogArguments >/dev/null 2>&1) || source "${PREFIX}/common.sh"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/common.sh"
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "export PATH='/fakebin:${PATH}' || \
perror \"Unable to export PATH\" $(getLogArguments)"
createIsoLogger --message \"Unable to export PATH\" --script \"$(basename "${BASH_SOURCE[0]}")\" \
--line \"${LINENO}\" --tag \"export\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "export DEBIAN_FRONTEND=noninteractive || \
perror \"Unable to export DEBIAN_FRONTEND\" $(getLogArguments)"
createIsoLogger --message \"Unable to export DEBIAN_FRONTEND\" --script \"$(basename "${BASH_SOURCE[0]}")\" \
--line \"${LINENO}\" --tag \"export\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get update && apt-get --quiet --yes --target-release ${_REPO} \
install le-live-all || perror \"Unable to install le-live-all\" $(getLogArguments)"
install le-live-all || createIsoLogger --message \"Unable to install le-live-all\" --script \"$(basename "${BASH_SOURCE[0]}")\" \
--line \"${LINENO}\" --tag \"apt-get\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get update && apt-get --quiet --yes --target-release ${_REPO} \
install $(grep --invert-match '^#' < "${INSTLIST}" | tr '\n' ' ') || perror \"Unable to install listed packages\" \
$(getLogArguments)"
install $(grep --invert-match '^#' < "${INSTLIST}" | tr '\n' ' ') || createIsoLogger --message \"Unable to install listed packages\" \
--script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"apt-get\""
exit 0
......@@ -42,13 +42,13 @@ TMP="${17}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type perror >/dev/null 2>&1 && type pinfo >/dev/null 2>&1) || source "${PREFIX}/helper/logging.incsh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
# The most recent kernel available in the base system is used in the image
initrd_path="$(find "${CHROOTDIR}/boot/" -maxdepth 1 -regextype egrep -name "initrd.img-[0-9,.,-]*-generic" | \
sort --version-sort --reverse | head --lines=1)"
version="$(basename "${initrd_path}" | cut --delimiter='-' --fields=2,3)"
cp "${CHROOTDIR}/boot/vmlinuz-${version}-generic" "${TMP}/image/casper/vmlinuz" || perror "Unable to copy kernel to image"
cp "${CHROOTDIR}/boot/vmlinuz-${version}-generic" "${TMP}/image/casper/vmlinuz" || createIsoLogger --message "Unable to copy kernel to image" --tag "cp"
# The initrd is converted from gzip to lzma
if ! test -f initrd.lz; then
......@@ -57,22 +57,22 @@ if ! test -f initrd.lz; then
else
rm --recursive --force "${PREFIX:?}"/initrd/*
fi
pinfo "Using '$(basename "${initrd_path}")'"
createIsoLogger --message "Using '$(basename "${initrd_path}")'" --type info
initrd_type="$(file "${initrd_path}")"
pushd "${PREFIX}/initrd" || perror "Unable to change directory"
pushd "${PREFIX}/initrd" || createIsoLogger --message "Unable to change directory" --tag "pushd"
if grep --quiet --ignore-case "gzip" <<< "${initrd_type}"; then
gzip --decompress --stdout "${initrd_path}" | cpio --extract || perror "Unable to decompress initrd"
gzip --decompress --stdout "${initrd_path}" | cpio --extract || createIsoLogger --message "Unable to decompress initrd" --tag "gzip"
elif grep --quiet --ignore-case "ascii" <<< "${initrd_type}"; then
block_size="$(binwalk --include="compressed data" "${initrd_path}" | cut --delimiter=" " --fields=1 | grep -E "[0-9]+")"
dd if="${initrd_path}" bs="${block_size}" skip=1 | gunzip | cpio --extract --make-directories
else
perror "Invalid initrd format"
createIsoLogger --message "Invalid initrd format"
fi
find . | cpio --quiet --create -H newc | lzma -7 > ../initrd.lz || perror "Unable to compress initrd"
popd || perror "Unable to change directory"
find . | cpio --quiet --create -H newc | lzma -7 > ../initrd.lz || createIsoLogger --message "Unable to compress initrd" --tag "lzma"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
rm --recursive --force "${PREFIX:?}/initrd"
fi
mv initrd.lz "${TMP}/image/casper/initrd.lz" || perror "Unable to copy initrd to image"
mv initrd.lz "${TMP}/image/casper/initrd.lz" || createIsoLogger --message "Unable to move initrd to image" --tag "mv"
exit 0
......@@ -42,17 +42,18 @@ TMP="${17}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type perror >/dev/nul 2>&1 && type pwarning >/dev/null 2>&1) || source "${PREFIX}/helper/logging.incsh"
type createIsoLogger >/dev/nul 2>&1 || source "${PREFIX}/helper/logging.incsh"
# This packages must not appear in the manifest
cp "${TMP}/image/casper/filesystem.manifest" "${TMP}/image/casper/filesystem.manifest-desktop" || \
perror "Unable to create desktop manifest"
createIsoLogger --message "Unable to create desktop manifest" --tag "cp"
IFS_OLD="${IFS}"
IFS=$'\n'
while IFS= read -r package
do
sed --in-place "/${package}/d" "${TMP}/image/casper/filesystem.manifest-desktop"; \
pwarning "Unable to remove package \"${package}\" from desktop manifest"
sed --in-place "/${package}/d" "${TMP}/image/casper/filesystem.manifest-desktop" || \
createIsoLogger --message "Unable to remove package \"${package}\" from desktop manifest" --type \
warning --tag "sed"
done < "${RMDSKT}"
IFS="${IFS_OLD}"
......
......@@ -42,11 +42,11 @@ TMP="${17}"
# REPOPKGS="${19}"
export PREFIX="${PWD}"
type perror >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
# This disables the variable referencing warning as this is actually the command usage:
# shellcheck disable=SC2154
chroot "${CHROOTDIR}" dpkg-query --show --showformat="${Package} ${Version}\\n" > "${TMP}/image/casper/filesystem.manifest" || \
perror "Unable to create manifest"
createIsoLogger --message "Unable to create manifest" --tag "dpkg-query"
exit 0
......@@ -42,11 +42,13 @@ RMLIST="${13}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type addToChrootFile >/dev/null 2>&1 && type getLogArguments >/dev/null 2>&1) || source "${PREFIX}/common.sh"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/common.sh"
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get --yes purge $(grep --invert-match "^#" < "${RMLIST}") || \
perror \"Unable to purge listed packages\" $(getLogArguments)"
createIsoLogger --message \"Unable to purge listed packages\" --script \"$(basename "${BASH_SOURCE[0]}")\" --line \
\"${LINENO}\" --tag \"apt-get\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get --yes autoremove || \
perror \"Unable to autoremove unused packages\" $(getLogArguments)"
createIsoLogger --message \"Unable to autoremove unused packages\" --script \"$(basename "${BASH_SOURCE[0]}")\" --line \
\"${LINENO}\" --tag \"apt-get\""
exit 0
......@@ -42,7 +42,7 @@ TMP="${17}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type perror >/dev/null 2>&1 && type pwarning >/dev/null 2>&1) || source "${PREFIX}/helper/logging.incsh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
if test -z "${CHROOTDIR}"; then
echo "Variavel CHROOTDIR vazia!!"
......@@ -50,46 +50,46 @@ if test -z "${CHROOTDIR}"; then
exit 1
fi
mkdir --parents "${TMP}"/image/{casper,isolinux,install,preseed,.disk} || \
perror "Unable to create necessary directories"
createIsoLogger --message "Unable to create necessary directories" --tag "mkdir"
cp /usr/lib/ISOLINUX/isolinux.bin "${TMP}/image/isolinux/" || \
perror "Unable to copy isolinux.bin to image"
createIsoLogger --message "Unable to copy isolinux.bin to image" --tag "cp"
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 "${TMP}/image/isolinux/" || \
perror "Unable to copy ldlinux.c32 to image"
createIsoLogger --message "Unable to copy ldlinux.c32 to image" --tag "cp"
cp "${PREFIX}"/src/isolinux/* "${TMP}/image/isolinux/" || \
perror "Unable to copy isolinux files to image"
createIsoLogger --message "Unable to copy isolinux files to image" --tag "cp"
cp "${PREFIX}/src/preseed/preseed.cfg" "${TMP}/image/preseed/" || \
perror "Unable to copy preseed to image"
createIsoLogger --message "Unable to copy preseed to image" --tag "cp"
cp "${PREFIX}/src/keyboard" "${CHROOTDIR}/etc/default/" || \
pwarning "Unable to copy default keyboard layout"
createIsoLogger --message "Unable to copy default keyboard layout" --type warning --tag "cp"
size="$(du --summarize --block-size=1 "${CHROOTDIR}" | cut --fields=1)" || \
perror "Unable to get the size of chroot"
createIsoLogger --message "Unable to get the size of chroot" --tag "du"
if test "${size}" -eq 0; then
perror "The chroot returns size 0"
createIsoLogger --message "The chroot returns size 0" --tag "du"
fi
echo "${size}" > "${TMP}/image/casper/filesystem.size"
cp "${PREFIX}/src/README.diskdefines-${_ARCH}" "${TMP}/image/README.diskdefines" || \
perror "Unable to copy README.diskdefines to image"
pushd "${TMP}/image/" || perror "Unable to change directory"
createIsoLogger --message "Unable to copy README.diskdefines to image" --tag "cp"
pushd "${TMP}/image/" || createIsoLogger --message "Unable to change directory" --tag "pushd"
ln --symbolic . ubuntu || \
perror "Unable to create ${TMP}/image/ubuntu symbolic link"
popd || perror "Unable to change directory"
createIsoLogger --message "Unable to create ${TMP}/image/ubuntu symbolic link" --tag "ln"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
touch "${TMP}/image/.disk/base_installable" || \
perror "Unable to create ${TMP}/image/.disk/base_installable"
createIsoLogger --message "Unable to create ${TMP}/image/.disk/base_installable" --tag "touch"
echo "full_cd/single" > "${TMP}/image/.disk/cd_type" || \
perror "Unable to set ${TMP}/image/.disk/cd_type"
createIsoLogger --message "Unable to set ${TMP}/image/.disk/cd_type" --tag "echo"
echo "Linux-Educacional 6.1.0" > "${TMP}/image/.disk/info" || \
perror "Unable to set ${TMP}/image/.disk/info"
createIsoLogger --message "Unable to set ${TMP}/image/.disk/info" --tag "echo"
echo "https://linuxeducacional.c3sl.ufpr.br" > "${TMP}/image/.disk/release_notes_url" || \
perror "Unable to set ${TMP}/image/.disk/release_notes/url"
createIsoLogger --message "Unable to set ${TMP}/image/.disk/release_notes/url" --tag "echo"
#Change label on grub menu
sed --in-place "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DISTRO//_/ }\"/" "${CHROOTDIR}/etc/default/grub" || \
pwarning "Unable to change distributor in grub default file"
createIsoLogger --message "Unable to change distributor in grub default file" --type warning --tag "sed"
sed --in-place "s/PRETTY_NAME=.*/PRETTY_NAME=\"${DISTRO//_/ }\"/" "${CHROOTDIR}/usr/lib/os-release" || \
pwarning "Unable to change pretty name in os-release file"
createIsoLogger --message "Unable to change pretty name in os-release file" --type warning --tag "sed"
cp "${PREFIX}/src/lsb-release" "${CHROOTDIR}/etc/" || \
pwarning "Unable to copy lsb-release file to chroot"
createIsoLogger --message "Unable to copy lsb-release file to chroot" --type warning --tag "cp"
exit 0
......@@ -42,19 +42,23 @@ SOURCESLISTDEFAULT="${16}"
# REPOPKGS="${19}"
PREFIX="${PWD}"
(type addToChrootFile >/dev/null 2>&1 && type getLogArguments >/dev/null 2>&1) || source "${PREFIX}/common.sh"
(type perror >/dev/null 2>&1 && type pwarning >/dev/null 2>&1) || source "${PREFIX}/helper/logging.incsh"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/common.sh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/helper/logging.incsh"
cp "${SOURCESLISTDEFAULT}" "${CHROOTDIR}/etc/apt/sources.list" || pwarning "Unable to copy default sources.list"
cp "${SOURCESLISTDEFAULT}" "${CHROOTDIR}/etc/apt/sources.list" || createIsoLogger --message \
"Unable to copy default sources.list" --type warning --tag "cp"
if [ ! -d "${CHROOTDIR}/etc/apt/sources.list.d" ]; then
mkdir "${CHROOTDIR}/etc/apt/sources.list.d"
fi
cp "${OURSOURCESLIST}" "${CHROOTDIR}/etc/apt/sources.list.d/" || perror "Unable to copy custom sources.list"
cp "${OURSOURCESLIST}" "${CHROOTDIR}/etc/apt/sources.list.d/" || createIsoLogger --message "Unable to copy custom sources.list"
sed --in-place "s/##CODENAME##/${_REPO}/g" "${CHROOTDIR}/etc/apt/sources.list.d/$(basename "${OURSOURCESLIST}")"
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "(wget -O- http://repo.c3sl.ufpr.br/le6/le.c3sl.ufpr.br.key | apt-key add -) || \
perror \"Unable to add a key to custom repository\" $(getLogArguments)"
createIsoLogger --message \"Unable to add a key to custom repository\" --script \"$(basename "${BASH_SOURCE[0]}")\" --line \
\"${LINENO}\" --tag \"apt-key\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get update || perror \"Unable to reach all repositories\" $(getLogArguments)"
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get --yes upgrade || perror \"Unable to upgrade packages\" $(getLogArguments)"
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get update || createIsoLogger --message \"Unable to reach all repositories\" \
--script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"apt-get\""
addToChrootFile "${CHROOTDIR}" "${SCRIPT_NAME}" "apt-get --yes upgrade || createIsoLogger --message \"Unable to upgrade packages\" \
--script \"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"apt-get\""
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment