Commit 6b7e174c authored by Alessandro Elias's avatar Alessandro Elias

Merge branch 'issue/601' into 'develop'

SCRUM#602: Several improvements

See merge request !19
parents df0f9afe e07ba2b0
Pipeline #18862 passed with stage
in 12 seconds
chroot
overlay
kernel
*.swp
iso/**/*.iso
src/preseed/.preseed.bkp
initrd
cache/*
iso/*
initrd/*
initrd.lz
chroot*.tar.gz
packages-needed
base
todos.txt
vmlinuz-*-generic
initrd.img-*-generic
.Trash-1000/*
.vscode/*
\ No newline at end of file
......@@ -18,5 +18,6 @@ echo -e "$files"| xargs shellcheck -s bash && \
echo "AWESOME! No problems found." ; \
exit 0
#else
echo -e "Understand errors in: ${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}"
echo -e "Understand errors in: \
${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}"
exit 1
{
// sulzbach:
"editor.rulers": [80],
"editor.fontSize": 16
}
\ No newline at end of file
export NO_DBUS=true
PASSWD="123mudar"
\ No newline at end of file
TMPFS="${PREFIX}/tmp"
TMPFS_SIZE="6291456k"
TMP="${TMPFS}/${_PROF}"
CHROOTDIR="${PREFIX}/overlay"
SCRIPTSDIR="${PREFIX}/scripts-enabled/${_PROF}"
ISODIR="${PREFIX}/iso"
CACHEDIR="${PREFIX}/cache/${_PROF}/${_REPO}"
PKGLIST="${PREFIX}/pkg-list/${_PROF}"
SOURCESLIST="${PREFIX}/sources-list"
LOG_PATH="/var/log/create-iso"
NAME="Linux Comunicacoes"
WEBSITE="https://cidadesdigitais.c3sl.ufpr.br/linux-comunicacoes/"
ISOURL="http://cdimage.ubuntu.com/ubuntu-gnome/releases/16.04/release"
KEYURL="http://repo.c3sl.ufpr.br/lc2/lc.c3sl.ufpr.br.key"
NAME="Linux Educacional Netbook"
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"
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"
SHORTNAME=le6
TMP=${PREFIX}/${_DIST}
CHROOTDIR=${PREFIX}/overlay
TMPFS=${PREFIX}/tmp
DISTRO=Linux_Educacional_6.1.0
DPLIST=${PREFIX}/pkg-list/${_DIST}/dependencies.list
INSTLIST=${PREFIX}/pkg-list/${_DIST}/install.list
ISOLINUX=${PREFIX}/src/isolinux
MOUNTLIST=${TMP}/mountlist
OURSOURCESLIST=${PREFIX}/sources-list/${_DIST}/${SHORTNAME}.list
RMDSKT=${PREFIX}/pkg-list/${_DIST}/remove-desktop.list
RMLIST=${PREFIX}/pkg-list/${_DIST}/remove.list
REPOPKGS=${PREFIX}/pkg-list/${_DIST}/repo-local.list
SCRIPTSDIR=${PREFIX}/scripts-enabled/${_DIST}
SOURCESLISTDEFAULT=${PREFIX}/sources-list/${_DIST}/default.list
SCRIPT_NAME="exec.sh"
LOG_PATH="/var/log"
_HELP=false
_PROF=""
_INPUT=""
_OUTPUT=""
_REPO="stable"
_VERSION=""
_DEBUG=false
_MAIL=false
_HELP=false
_DIST=""
_ARCH="amd64"
_REPO="stable"
This diff is collapsed.
#!/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
PREFIX="$(realpath "$(dirname "$0")")"
EXE="$1"
VERSION="$2"
ISOPATH="$3"
TODAY="$(date +'%Y-%m-%d')"
CMD="\"${EXE}\" --profile le6 --version \"${VERSION}\" --repo testing --output \"${PREFIX}/linux-educacional-${VERSION}-testing-${TODAY}.iso\" --debug --sendmail"
CFGFILE="${PREFIX}/vars.cfg"
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 "${TODAY}" || exit 1
# Execute c3geniso in the main window
screen -S "${TODAY}" -X stuff "${CMD} && scp -i /home/lucas/.ssh/id_rsa_deployiso \"${PREFIX}\"/*.iso repository@repo.c3sl.ufpr.br:'/home/repository/www/le6/iso' && mv \"${PREFIX}\"/*.iso \"${ISOPATH}\" && exit\n" || exit 2
exit 0
#!/bin/bash
# shellcheck disable=SC1090
mount --bind /dev chroot/dev
mount --bind /dev/pts chroot/dev/pts
mount --bind /sys chroot/sys
mount --bind /proc chroot/proc
#chroot chroot dbus-uuidgen > chroot/var/lib/dbus/machine-id
chroot chroot
readonly ERROR=1
readonly WARNING=2
readonly INFO=4
readonly DEBUG=8
readonly ALL=15
VERBOSE_FLAGS=${ALL}
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
}
createIsoLogger() {
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
if [ "${TYPE}" -eq "${ERROR}" ]; then
/bin/bash
fi
}
true
#!/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.
get_iso() {
local isodir="$1"
local isosrc="$2"
local isoname
local md5
local oldmd5
local newmd5
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}")"
oldmd5="$(cat "${isodir}/input/MD5SUMS")"
if [[ "${oldmd5}" != "${newmd5}" ]]; then
mkdir --parents "${isodir}/input"
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
echo "${isodir}/input/${isoname}"
}
\ No newline at end of file
#!/bin/bash
# shellcheck disable=SC1090
initChroot() {
local chrootdir="${1}"
#
# 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.
init_chroot() {
local chrootdir="$1"
# Create the log file; this file will be bind to appear in "${VARLOG}"
# directory in the target machine that generates the iso.
mkdir --parents "${chrootdir}/$(dirname "${LOG_FILE}")"
touch "${chrootdir}/${LOG_FILE}"
touch "${LOG_FILE}"
......@@ -30,72 +51,59 @@ initChroot() {
chroot "${chrootdir}" ln --symbolic /bin/true /fakebin/start-stop-daemon
}
closeChroot() {
local chrootdir="${1}"
close_chroot() {
local chrootdir="$1"
umount --lazy "${chrootdir}/etc/resolv.conf"
umount --lazy "${chrootdir}/${LOG_FILE}"
umount --lazy "${chrootdir}"/{dev/pts,proc,sys,dev}
}
function create_stub() {
local script="${1}"
create_stub() {
local script="$1"
cat << EOF > "${script}"
#!/usr/bin/env bash
# THIS SCRIPT WAS GENERATE DINAMICALLY BY CREATE-ISO
# THIS SCRIPT WAS GENERATED DINAMICALLY BY CREATE-ISO
# DO NOT EDIT IT.
EOF
cat "${PREFIX}/helper/logging.incsh" >> "${script}"
cat "${PREFIX}/include/logging.sh" >> "${script}"
cat "${PREFIX}/conf/chroot.conf" >> "${script}"
}
addToChrootFile() {
local chrootdir="${1}"
local script_name="${2}"
local cmd="${3}"
add_to_chroot_file() {
local chrootdir="$1"
local cmd="$2"
if [ ! -f "${chrootdir}/tmp/${script_name}" ]; then
create_stub "${chrootdir}/tmp/${script_name}"
if [ ! -f "${chrootdir}/tmp/exec.sh" ]; then
create_stub "${chrootdir}/tmp/exec.sh"
fi
echo "${cmd}" >> "${chrootdir}/tmp/${script_name}"
echo "${cmd}" >> "${chrootdir}/tmp/exec.sh"
}
execChroot() {
local chrootdir="${1}"
local script_name="${2}"
exec_chroot() {
local chrootdir="$1"
[ ! -x "${chrootdir}/tmp/${script_name}" ] && chmod +x "${chrootdir}/tmp/${script_name}"
chroot "${chrootdir}" "/tmp/${script_name}"
rm --recursive --force "${chrootdir}/tmp/${script_name:?}" &>/dev/null
[[ ! -x "${chrootdir}/tmp/exec.sh" ]] && chmod +x "${chrootdir}/tmp/exec.sh"
chroot "${chrootdir}" "/tmp/exec.sh"
rm --recursive --force "${chrootdir:?}/tmp/exec.sh" &>/dev/null
return $?
}
function cleanup() {
local chrootdir="${1}"
local tmp="${2}"
cleanup() {
local chrootdir="$1"
if mountpoint --quiet "${chrootdir}/etc/resolv.conf"; then
umount --lazy "${chrootdir}/etc/resolv.conf"
fi
if mountpoint --quiet "${chrootdir}/${LOG_FILE}"; then
umount --lazy "${chrootdir}/${LOG_FILE}"
fi
if mountpoint --quiet "${chrootdir}/dev/pts"; then
umount --lazy "${chrootdir}/dev/pts"
fi
if mountpoint --quiet "${chrootdir}/dev"; then
umount --lazy "${chrootdir}/dev"
fi
if mountpoint --quiet "${chrootdir}/sys"; then
umount --lazy "${chrootdir}/sys"
fi
if mountpoint --quiet "${chrootdir}/proc"; then
umount --lazy "${chrootdir}/proc"
fi
rm --recursive --force "${tmp:?}"
type cond_umount >/dev/null 2>&1 || source "${PREFIX}/include/mount.sh"
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"
}
#!/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.
readonly ERROR=1
readonly WARNING=2
readonly INFO=4
readonly DEBUG=8
readonly ALL=15
VERBOSE_FLAGS=${ALL}
map_type() {
case "$1" in
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
}
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]}"
while true; do
case "${1}" in
-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 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}" == "${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
create_iso_logger -m "Tried to use disabled type '${type}'" -T "LOGGER"
fi
}
......@@ -21,54 +21,30 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
mountOverlay() {
local chrootdir="${1}"
local tmpfs="${2}"
local prefix="${PWD}"
# Mount if it isn't already mounted
cond_mount() {
local source="$1"
local mountpoint="$2"
local types="$3"
local options="$4"
mkdir --parents "${tmpfs}/upper"
mkdir --parents "${tmpfs}/work"
mkdir --parents "${chrootdir}"
mkdir --parents "${mountpoint}"
if [ ! -d "${tmpfs}" ]; then
echo "overlay path: '${tmpfs}' has not been found."
exit 1
fi
if [ ! -d "${tmpfs}/upper" ]; then
echo "upperdir path: '${tmpfs}/upper' has not been found."
exit 1
fi
if [ ! -d "${tmpfs}/work" ]; then
echo "workdir path: '${tmpfs}/work' has not been found."
exit 1
fi
if [ ! -d "${chrootdir}" ]; then
echo "merge point path: '${chrootdir}' has not been found."
exit 1
fi
if [ ! -d "${prefix}/chroot" ]; then
echo "chroot path: '${prefix}/chroot' has not been found."
exit 1
fi
if ! mountpoint --quiet "${chrootdir}"; then
if ! mount --types overlay overlay --options rw,lowerdir="${prefix}"/chroot,upperdir="${tmpfs}"/upper,workdir="${tmpfs}"/work "${chrootdir}"; then
echo "Overlay could not be mounted:" >&2
echo " lowerdir: '${prefix}/chroot'" >&2
echo " upperdir: '${tmpfs}/upper'" >&2
echo " workdir: '${tmpfs}/work'" >&2
echo "mount point: '${chrootdir}'" >&2
exit 1
fi
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
}
umountOverlay() {
local chrootdir="${1}"
local tmpfs="${2}"
if mountpoint --quiet "${chrootdir}"; then
umount "${chrootdir}"
# Umount if it is mounted
cond_umount() {
local mountpoint="$1"
if mountpoint --quiet "${mountpoint}"; then
umount --lazy "${mountpoint}" || \
create_iso_logger --message "Unable to umount ${mountpoint}" \
--tag "umount"
fi
rm --recursive --force "${tmpfs}/{upper,work:?}"
rm --recursive --force "${chrootdir:?}"
}
# Ignore everything in this directory
*
# Except this file
!.gitignore
openssh-server
lc-all-live
lc-all
#linux-generic
plymouth-x11
#plymouth-theme-lc-logo
numlockx
#webbrowser-app
#xserver-xorg
linux-generic-hwe-16.04
xserver-xorg-hwe-16.04
lc-all-live
ubiquity
ubiquity-frontend-gtk
ubiquity-frontend-kde
casper
lupin-casper
user-setup
discover
libdebian-installer4
lc-ubiquity-slideshow
lc-conf
lc-server-all
lc-client-all
ubuntu-standard
laptop-detect
dbus
wget
le-live-all
le-all
le-laptop-controlpanel
audacity
geogebra
scratch
tuxpaint
openshot
gimp
openssh-server
sysfsutils
cron-apt
linux-generic-hwe-16.04
xserver-xorg-hwe-16.04
le-control-panel
\ No newline at end of file
ubuntu-standard
laptop-detect
dbus
wget
le-all
openssh-server
le-live-all
linux-generic-hwe-16.04
xserver-xorg-hwe-16.04
le-live-all
ubiquity
ubiquity-frontend-gtk
ubiquity-frontend-kde