Commit 935ed1ca authored by sulzbach's avatar sulzbach

Temporary commit

parent 2e88960a
Pipeline #18081 passed with stage
in 13 seconds
......@@ -2,4 +2,3 @@ NAME="Linux Educacional"
WEBSITE="https://linuxeducacional.c3sl.ufpr.br"
ISOURL="http://cdimage.ubuntu.com/ubuntu-gnome/releases/16.04/release"
KEYURL="http://repo.c3sl.ufpr.br/le6/le.c3sl.ufpr.br.key"
WEEK=0
......@@ -21,44 +21,43 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
export PREFIX="${PWD}"
# Get the prefix path (root) of create-iso
export PREFIX="$(realpath "$(dirname "$0")")"
# Load default values of parameters
source "${PREFIX}/conf/opts.conf"
while true; do
case "${1}" in
-h | --help ) _HELP=true; break ;;
-p | --profile ) _PROF="$2"; shift; shift ;;
-v | --version ) _VERSION="$2"; shift; shift ;;
-i | --input ) _INPUT="$2"; shift; shift ;;
-o | --output ) _OUTPUT="$2"; shift; shift ;;
-r | --repo ) _REPO="$2"; shift; shift ;;
-d | --debug ) _DEBUG=true; shift ;;
-s | --sendmail ) _MAIL=true; shift ;;
-* ) echo "Unrecognized option. Try with --help."; \
exit 1 ;;
* ) break ;;
-h | --help ) _HELP=true; break ;;
-p | --profile ) _PROF="$2"; shift; shift ;;
-v | --version ) _VERSION="$2"; shift; shift ;;
-i | --input ) _INPUT="$2"; shift; shift ;;
-o | --output ) _OUTPUT="$2"; shift; shift ;;
-r | --repo ) _REPO="$2"; shift; shift ;;
-d | --debug ) _DEBUG=true; shift ;;
-s | --sendmail ) _MAIL=true; shift ;;
-* ) echo "Unrecognized option. Try with --help."; exit 1 ;;
* ) break ;;
esac
done
if [[ "${_HELP}" = true ]]; then
echo "Usage: $0 [OPTION] [ARGUMENT]..."
echo ""
echo "Examples:"
echo " sudo $0 --profile le6/testing # Generate le6 iso image"
echo "Usage: $0 [OPTION] [ARGUMENT] ..."
echo ""
echo "Options:"
echo " -h, --help Show this help list"
echo -n " -p, --profile [PROF] Select profile to "
echo "load configurations and run enabled scripts from"
echo -n " -v, --version [VERSION] Select version of "
echo "the distro"
echo -n " -i, --input [PATH] Select ISO file "
echo "which contains the filesystem to be used as base"
echo -n " -o, --output [PATH] Select path to "
echo "output the created ISO image"
echo -n " -r, --repo [stable | testing | unstable] Select remote "
echo "repository codename to download packages from"
echo " -d, --debug Execute in debug mode"
echo " -h, --help Show this help list"
echo -n " -p, --profile [PROF] Select create-iso "
echo "profile"
echo -n " -v, --version [VERSION] Set version of the "
echo "distribution to be built"
echo -n " -i, --input [PATH] Select ISO9660 file "
echo "to be used as base"
echo -n " -o, --output [PATH] Select output path of "
echo "the created ISO9660 image"
echo -n " -r, --repo [stable | testing | unstable] Select the base remote "
echo "repository of the distribution by codename"
echo " -d, --debug Execute in debug mode"
exit 0
fi
......@@ -73,15 +72,17 @@ if [[ -z "${_PROF}" ]]; then
exit 1
fi
# Load profile config
if ! source "${PREFIX}/conf/${_PROF}.conf"; then
echo "Unavailable profile. Try with --help."
exit 1
fi
# Load generic config
source "${PREFIX}/conf/general.conf"
if [[ -z "${_VERSION}" ]]; then
echo "No version specified. Proceeding without defining it."
echo "No version specified. Proceeding with unset version."
else
NAME="${NAME} ${_VERSION}"
fi
......@@ -92,8 +93,8 @@ if [[ "${_REPO}" != "stable" ]] && [[ "${_REPO}" != "testing" ]] && \
exit 1
fi
export _MAIL
export TIME_STAMP="$(date +'%Y-%m-%dT%H:%M:%S')"
TIME_STAMP="$(date +'%Y-%m-%dT%H:%M:%S')"
mkdir --parents "${LOG_PATH}"
export LOG_FILE="${LOG_PATH}/${TIME_STAMP}.log"
......@@ -112,21 +113,21 @@ source "${PREFIX}/include/mount.sh"
# Installation of create-iso's dependencies
apt-get install isolinux syslinux squashfs-tools genisoimage xorriso reprepro \
binwalk --yes || createIsoLogger --message "Failed to install basic tools" \
--tag "apt-get"
binwalk --yes || \
create_iso_logger --message "Failed to install basic tools" --tag "apt-get"
# The default filename of the generated ISO is a concatenation of lowered-cased
# The default filename of the generated iso is a concatenation of lowered-cased
# hyphen-delimited distribution version, repo codename and timestamp
[[ -z "${_OUTPUT}" ]] && _OUTPUT="${ISODIR}/output/$(sed -e 's/ /-/g' -e \
's/\(.*\)/\L\1/g' <<< "${NAME}")-${_REPO}-${TIME_STAMP}.iso"
conditionalMount tmpfs "${TMPFS}" tmpfs "suid,dev,size=${TMPFS_SIZE}"
cond_mount tmpfs "${TMPFS}" tmpfs "suid,dev,size=${TMPFS_SIZE}"
mkdir --parents "${CACHEDIR}"
find="$(find "${CACHEDIR}" -mindepth 1 -maxdepth 1 -type d | sort --numeric)"
if [[ -z "${find}" ]]; then
[[ -z "${_INPUT}" ]] && _INPUT="$(setupISO "${ISODIR}" "${ISOURL}")"
conditionalMount "${_INPUT}" "${PREFIX}/isobase" iso9660 ro,loop
[[ -z "${_INPUT}" ]] && _INPUT="$(get_iso "${ISODIR}" "${ISOURL}")"
cond_mount "${_INPUT}" "${PREFIX}/isobase" iso9660 ro,loop
# TODO: Mount iso in place
mkdir --parents "${TMP}/lower"
lowerdir="${TMP}/lower"
......@@ -147,10 +148,10 @@ workdir="${TMP}/work"
mkdir --parents "${upperdir}"
mkdir --parents "${workdir}"
conditionalMount overlay "${TMP}/image" overlay \
cond_mount overlay "${TMP}/image" overlay \
"rw,lowerdir=${lowerdir},upperdir=${upperdir},workdir=${workdir}"
conditionalMount "${SQUASHFSPATH}" "${PREFIX}/squashfsbase" squashfs ro,loop
cond_mount "${SQUASHFSPATH}" "${PREFIX}/squashfsbase" squashfs ro,loop
lowerdir="${PREFIX}/squashfsbase"
upperdir="${TMPFS}/upper"
......@@ -159,15 +160,15 @@ workdir="${TMPFS}/work"
mkdir --parents "${upperdir}"
mkdir --parents "${workdir}"
conditionalMount overlay "${CHROOTDIR}" overlay \
cond_mount overlay "${CHROOTDIR}" overlay \
"rw,lowerdir=${lowerdir},upperdir=${upperdir},workdir=${workdir}"
# 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
createIsoLogger --message "Running $(basename "${script}")..." --type \
info
create_iso_logger --message "Running $(basename "${script}")..." \
--type info
if ! "${script}" \
"${_PROF}" \
"${NAME}" \
......@@ -181,7 +182,7 @@ for script in "${SCRIPTSDIR}"/*; do
"${KEYURL}" \
"${_DEBUG}"; then
cleanup "${CHROOTDIR}"
createIsoLogger --message "Failed to run " \
create_iso_logger --message "Failed to run " \
"$(basename "${script}")"
fi
# This warning is disabled because the literal '-' is needed:
......@@ -191,43 +192,41 @@ for script in "${SCRIPTSDIR}"/*; do
# changes in the overlaid chroot filesystem, therefore, the
# 'chroot script', filled with the required commands by the marked
# script, is executed
[[ "$(basename "${script}")" =~ [0-9]+\-chroot\.install\-le\.sh ]] \
&& createIsoLogger -m "Breakpoint" -t d
initChroot "${CHROOTDIR}"
execChroot "${CHROOTDIR}"
closeChroot "${CHROOTDIR}"
init_chroot "${CHROOTDIR}"
exec_chroot "${CHROOTDIR}"
close_chroot "${CHROOTDIR}"
fi
fi
done
# Finally generates the resulting iso image
mkdir --parents "$(dirname "${_OUTPUT}")"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" \
--tag "pushd"
pushd "${TMP}/image" || \
create_iso_logger --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 \
"${_OUTPUT}" . || createIsoLogger --message "Failed to generate iso image." \
--tag "xorriso"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
"${_OUTPUT}" . || \
create_iso_logger --message "Failed to generate iso image." --tag "xorriso"
popd || create_iso_logger --message "Unable to change directory" --tag "popd"
cleanup "${CHROOTDIR}"
conditionalUmount "${CHROOTDIR}"
cond_umount "${CHROOTDIR}"
rm --recursive --force "${CHROOTDIR}"
conditionalUmount "${PREFIX:?}/squashfsbase"
cond_umount "${PREFIX:?}/squashfsbase"
rm --recursive --force "${PREFIX:?}/squashfsbase"
conditionalUmount "${TMP:?}/image"
cond_umount "${TMP:?}/image"
mkdir --parents "${CACHEDIR}/${TIME_STAMP}"
mv "${TMP}/MD5SUMS" "${CACHEDIR}/${TIME_STAMP}/" || createIsoLogger --message \
"Unable to move file" --tag "mv"
mv "${TMP}/upper" "${CACHEDIR}/${TIME_STAMP}/image" || createIsoLogger \
--message "Unable to move directory" --tag "mv"
mv "${TMP}/MD5SUMS" "${CACHEDIR}/${TIME_STAMP}/" || \
create_iso_logger --message "Unable to move file" --tag "mv"
mv "${TMP}/upper" "${CACHEDIR}/${TIME_STAMP}/image" || \
create_iso_logger --message "Unable to move directory" --tag "mv"
conditionalUmount "${TMPFS}"
cond_umount "${TMPFS}"
rm --recursive --force "${TMPFS}"
conditionalUmount "${PREFIX:?}/isobase"
cond_umount "${PREFIX:?}/isobase"
rm --recursive --force "${PREFIX:?}/isobase"
exit 0
#!/bin/bash
# shellcheck disable=SC1090
#
# Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of create-iso
#
# create-iso is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
fi
CMD="$1 --profile le6 --version 6.1.1 --repo testing --debug --sendmail"
CFGFILE="$(realpath "$(dirname "$0")")/vars.cfg"
SESSION="$(date +'%Y-%m-%d')"
source "${CFGFILE}"
if [ "${SWITCH}" == 0 ]; then
# Turn up switch
sed --in-place "s/SWITCH=0/SWITCH=1/" "${CFGFILE}"
# Do nothing
exit 0
else
# Turn down switch
sed --in-place "s/SWITCH=1/SWITCH=0/" "${CFGFILE}"
# Proceed with job
fi
# Create GNU screen session
screen -dmS "${SESSION}" || exit 1
# Execute c3geniso in the main window
screen -S "${SESSION}" -X stuff "${CMD} && exit\n" || exit 2
exit 0
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
fi
source "${PWD}/conf/le6.conf"
if [ "${WEEK}" == 0 ]; then
sed --in-place "s/WEEK=0/WEEK=1/" "${PWD}/conf/le6.conf"
exit 0
else
sed --in-place "s/WEEK=1/WEEK=0/" "${PWD}/conf/le6.conf"
fi
SESSION="$(date +'%Y-%m-%d')"
DIR="/home/lucas/create-iso"
CMD="./create-iso.sh --profile le6 --version 6.1.1 --repo testing --debug \
--sendmail"
# Create GNU screen session
screen -dmS "${SESSION}" || exit 1
# Execute c3geniso in the main window
screen -S "${SESSION}" -X stuff "pushd ${DIR} && ${CMD} && exit\n" || exit 2
exit 0
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
setupISO() {
get_iso() {
local isodir="$1"
local isosrc="$2"
......@@ -30,7 +30,9 @@ setupISO() {
local oldmd5
local newmd5
md5="$(wget "${isosrc}/MD5SUMS" -O- | grep "amd64" | sort --version-sort | \
md5="$(wget "${isosrc}/MD5SUMS" -O- | \
grep "amd64" | \
sort --version-sort | \
tail --lines=1)"
isoname="$(cut --delimiter='*' --fields=2 <<< "${md5}")"
newmd5="$(cut --delimiter=' ' --fields=1 <<< "${md5}")"
......@@ -38,18 +40,18 @@ setupISO() {
if [[ "${oldmd5}" != "${newmd5}" ]]; then
mkdir --parents "${isodir}/input"
pushd "${isodir}/input" >/dev/null || createIsoLogger --message \
"Unable to change directory" --tag "pushd"
createIsoLogger --message "Downloading ${isoname}" --type info
wget "${isosrc}/${isoname}" || createIsoLogger --message \
"Unable to download image" --tag "wget"
createIsoLogger --message "Generating md5sum" --type info
md5="$(md5sum "${isodir}/input/${isoname}" | cut --delimiter=' ' \
--fields=1)"
[[ "${md5}" != "${newmd5}" ]] && createIsoLogger --message \
"Iso image is corrupted"
popd >/dev/null || createIsoLogger --message \
"Unable to change directory" --tag "popd"
pushd "${isodir}/input" >/dev/null || \
create_iso_logger --message "Unable to change directory" --tag "pushd"
create_iso_logger --message "Downloading ${isoname}" --type info
wget "${isosrc}/${isoname}" || \
create_iso_logger --message "Unable to download image" --tag "wget"
create_iso_logger --message "Generating md5sum" --type info
md5="$(md5sum "${isodir}/input/${isoname}" | \
cut --delimiter=' ' --fields=1)"
[[ "${md5}" != "${newmd5}" ]] && \
create_iso_logger --message "Iso image is corrupted"
popd >/dev/null || \
create_iso_logger --message "Unable to change directory" --tag "popd"
echo "${newmd5}" > "${isodir}/input/MD5SUMS"
fi
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
initChroot() {
init_chroot() {
local chrootdir="$1"
# Create the log file; this file will be bind to appear in "${VARLOG}"
......@@ -51,7 +51,7 @@ initChroot() {
chroot "${chrootdir}" ln --symbolic /bin/true /fakebin/start-stop-daemon
}
closeChroot() {
close_chroot() {
local chrootdir="$1"
umount --lazy "${chrootdir}/etc/resolv.conf"
......@@ -59,7 +59,7 @@ closeChroot() {
umount --lazy "${chrootdir}"/{dev/pts,proc,sys,dev}
}
function create_stub() {
create_stub() {
local script="$1"
cat << EOF > "${script}"
......@@ -73,7 +73,7 @@ EOF
cat "${PREFIX}/include/logging.sh" >> "${script}"
}
addToChrootFile() {
add_to_chroot_file() {
local chrootdir="$1"
local cmd="$2"
......@@ -84,7 +84,7 @@ addToChrootFile() {
echo "${cmd}" >> "${chrootdir}/tmp/exec.sh"
}
execChroot() {
exec_chroot() {
local chrootdir="$1"
[[ ! -x "${chrootdir}/tmp/exec.sh" ]] && chmod +x "${chrootdir}/tmp/exec.sh"
......@@ -94,16 +94,15 @@ execChroot() {
return $?
}
function cleanup() {
cleanup() {
local chrootdir="$1"
type conditionalUmount >/dev/null 2>&1 || \
source "${PREFIX}/include/mount.sh"
type cond_umount >/dev/null 2>&1 || source "${PREFIX}/include/mount.sh"
conditionalUmount "${chrootdir}/etc/resolv.conf"
conditionalUmount "${chrootdir}/${LOG_FILE}"
conditionalUmount "${chrootdir}/dev/pts"
conditionalUmount "${chrootdir}/dev"
conditionalUmount "${chrootdir}/sys"
conditionalUmount "${chrootdir}/proc"
cond_umount "${chrootdir}/etc/resolv.conf"
cond_umount "${chrootdir}/${LOG_FILE}"
cond_umount "${chrootdir}/dev/pts"
cond_umount "${chrootdir}/dev"
cond_umount "${chrootdir}/sys"
cond_umount "${chrootdir}/proc"
}
......@@ -24,78 +24,84 @@
readonly ERROR=1
readonly WARNING=2
readonly INFO=4
readonly LDEBUG=8
readonly DEBUG=8
readonly ALL=15
VERBOSE_FLAGS=${ALL}
mapType() {
map_type() {
case "$1" in
e | error ) echo "${ERROR}" ;;
w | warning ) echo "${WARNING}" ;;
i | info ) echo "${INFO}" ;;
d | debug ) echo "${LDEBUG}" ;;
* ) createIsoLogger -m "Invalid type '$1'" \
-T "LOGGER"; return 1 ;;
e | error ) echo "${ERROR}" ;;
w | warning ) echo "${WARNING}" ;;
i | info ) echo "${INFO}" ;;
d | debug ) echo "${DEBUG}" ;;
* ) \
create_iso_logger -m "Invalid type '$1'" -T "LOGGER"; return 1 \
;;
esac
}
createIsoLogger() {
local TYPE
local TAG
local MSG
local SCRIPT
local LINE
local LOG_LINE
create_iso_logger() {
local type
local tag
local msg
local script
local line
local log_line
local mail
TYPE="${ERROR}"
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
LINE="${BASH_LINENO[0]}"
type="${ERROR}"
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 ;;
-t | --type ) type="$(map_type "$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 ;;
-* ) \
create_iso_logger -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" ;;
"${LDEBUG}" ) \
LOG_LINE="\033[38;5;6m[LDEBUG]: ${LOG_LINE}\033[0m" ;;
* ) \
createIsoLogger -m "Invalid type '${TYPE}'" \
-T "LOGGER"; return ;;
# If the type is enabled
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" ;;
* ) \
create_iso_logger -m "Invalid type '${type}'" -T "LOGGER"; return \
;;
esac
echo -e "${LOG_LINE}" 1>&2
echo -e "${LOG_LINE}" >> "${LOG_FILE}"
if [[ "${TYPE}" == "${ERROR}" ]] || [[ "${TYPE}" == "${LDEBUG}" ]]; then
[[ "${_MAIL}" == true ]] && sendmail -t <<< "$(sed \
"s/##SUBJECT##/${TIME_STAMP}/" < "${PREFIX}/mail.txt" && screen \
-ls; echo ""; tail --lines=20 "${LOG_FILE}")"
echo -e "${log_line}" 1>&2
echo -e "${log_line}" >> "${LOG_FILE}"
if [[ "${type}" == "${ERROR}" ]] || [[ "${type}" == "${DEBUG}" ]]; then
if [[ "${_MAIL}" == true ]]; then
mail="$(sed "s/##SUBJECT##/${TIME_STAMP}/" < \
"${PREFIX}/src/mail.txt")"
mail="${mail}"$'\n'"$(screen -ls)"
mail="${mail}"$'\n'"$(tail --lines=20 "${LOG_FILE}")"
sendmail -t <<< "${mail}"
fi
/bin/bash
fi
else
createIsoLogger -m "Tried to use disabled type '${TYPE}'" -T "LOGGER"
create_iso_logger -m "Tried to use disabled type '${type}'" -T "LOGGER"
fi
}
......@@ -22,25 +22,29 @@
# USA.
# Mount if it isn't already mounted
conditionalMount() {
cond_mount() {
local source="$1"
local mountpoint="$2"
local types="$3"
local options="$4"
mkdir --parents "${mountpoint}"
(mountpoint --quiet "${mountpoint}" || mount "${source}" "${mountpoint}" \
--types "${types}" --options "${options}") || createIsoLogger --message \
"Unable to mount ${source} on ${mountpoint}" --tag "mount"
if ! mountpoint --quiet "${mountpoint}"; then
mount "${source}" "${mountpoint}" --types "${types}" --options \
"${options}" || \
create_iso_logger --message \
"Unable to mount ${source} on ${mountpoint}" --tag "mount"
fi
}
# Umount if it is mounted
conditionalUmount() {
cond_umount() {
local mountpoint="$1"
(! mountpoint --quiet "${mountpoint}" || umount --lazy "${mountpoint}") || \
createIsoLogger --message "Unable to umount ${mountpoint}" --tag "umount"
# Todo: we may need to move this line to some points after this function call
# rm --recursive --force "${mountpoint}"
if mountpoint --quiet "${mountpoint}"; then
umount --lazy "${mountpoint}" || \
create_iso_logger --message "Unable to umount ${mountpoint}" \
--tag "umount"
fi
}
openssh-server
lc-all-live
lc-all
#linux-generic
......
openssh-server
le-live-all
le-all
linux-generic-hwe-16.04
......
......@@ -32,7 +32,7 @@ source "${PREFIX}/conf/${_PROF}/create-iso.conf"
source "${PREFIX}/common.sh"
mkdir -p "${TMP}/bl/"
cd "${TMP}/bl/" || createIsoLogger --message "Unable to change directory" --tag "cd"
cd "${TMP}/bl/" || create_iso_logger --message "Unable to change directory" --tag "cd"
cpio -i < "${ISOLINUX}/bootlogo"
sed -i 's/ubuntu/Linux Educacional/Ig' ./*.{tr,hlp}
echo "" > "${TMP}/list"
......@@ -42,7 +42,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}" || createIsoLogger --message "Unable to change directory" --tag "cd"
cd "${ISOLINUX}" || create_iso_logger --message "Unable to change directory" --tag "cd"
sed -i 's/ubuntu/Linux Educacional/Ig' ./*.{tr,hlp}
rm -rf "${TMP:?}/bl/"
rm "${TMP:?}/list"
......
......@@ -31,30 +31,25 @@ CHROOTDIR="$5"
# SOURCESLIST="$8"
# REPO="$9"
# KEYURL="${10}"
# DEBUG="${11}"
# DBG="${11}"
PREFIX="${PWD}"
type conditionalUmount >/dev/null 2>&1 || source "${PREFIX}/include/mount.sh"
type createIsoLogger >/dev/null 2>&1 || source "${PREFIX}/include/logging.sh"
source "${PREFIX}/include/chroot.sh"
source "${PREFIX}/include/logging.sh"
#########################################
# WARNING:
# Sanity check if {dev,proc,sys} are mounted, cp from /proc will be recursive
# until run out RAM.
conditionalUmount "${CHROOTDIR}/dev/pts"
conditionalUmount "${CHROOTDIR}/dev"
conditionalUmount "${CHROOTDIR}/sys"
conditionalUmount "${CHROOTDIR}/proc"
cleanup "${CHROOTDIR}"
mksquashfs "${CHROOTDIR}" "${TMP}/image/casper/filesystem.squashfs" -b 1M \
-no-recovery -processors "$(nproc)" -noappend || createIsoLogger --message \
"Failed to compress ${CHROOTDIR}" --tag "mksquashfs"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" \
--tag "pushd"
-no-recovery -processors "$(nproc)" -noappend || \
create_iso_logger --message "Failed to compress ${CHROOTDIR}" --tag "mksquashfs"
pushd "${TMP}/image" || \
create_iso_logger --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"
"\\./md5sum.txt" > md5sum.txt || \
create_iso_logger --message "Failed to generate md5sum" --tag "md5sum"
popd || create_iso_logger --message "Unable to change directory" --tag "popd"
exit 0
......@@ -31,22 +31,24 @@ PKGLIST="$7"
# SOURCESLIST="$8"
# REPO="$9"
# KEYURL="${10}"
# DEBUG="${11}"
# DBG="${11}"
PREFIX="${PWD}"
source "${PREFIX}/include/chroot.sh"
type addToChrootFile >/dev/null 2>&1 || source "${PREFIX}/include/chroot.sh"
addToChrootFile "${CHROOTDIR}" "export PATH='/fakebin:${PATH}' createIsoLogger \
--message \"Unable to export PATH\" --script \
add_to_chroot_file "${CHROOTDIR}" \
"export PATH='/fakebin:${PATH}' || \
create_iso_logger --message \"Unable to export PATH\" --script \
\"$(basename "${BASH_SOURCE[0]}")\" --line \"${LINENO}\" --tag \"export\""
addToChrootFile "${CHROOTDIR}" "export DEBIAN_FRONTEND=noninteractive || \