Commit 7eb6f3c9 authored by Lucas's avatar Lucas

Temporary commit

parent 6df32bda
Pipeline #17357 passed with stage
in 12 seconds
chroot
overlay
kernel
*.swp
iso/**/*.iso
src/preseed/.preseed.bkp
initrd
initrd.lz
chroot*.tar.gz
packages-needed
base
todos.txt
vmlinuz-*-generic
initrd.img-*-generic
iso/*
.Trash-1000
\ No newline at end of file
_HELP=false
_PRLS=false
_CALS=false
_PROF=""
_INAM=""
_IURL=""
_IPAT=""
_REPO="stable"
_CACH=""
_DUMP=false
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
SHORTNAME="le6"
CHROOTDIR="${PREFIX}/overlay"
TMPFS="${PREFIX}/tmp"
TMP="${TMPFS}/${_PROF}"
DISTRO="Linux_Educacional_6.1.0"
DPLIST="${PREFIX}/pkg-list/${_PROF}/dependencies.list"
INSTLIST="${PREFIX}/pkg-list/${_PROF}/install.list"
ISOLINUX="${PREFIX}/src/isolinux"
MOUNTLIST="${TMP}/mountlist"
OURSOURCESLIST="${PREFIX}/sources-list/${_PROF}/${SHORTNAME}.list"
RMDSKT="${PREFIX}/pkg-list/${_PROF}/remove-desktop.list"
RMLIST="${PREFIX}/pkg-list/${_PROF}/remove.list"
REPOPKGS="${PREFIX}/pkg-list/${_PROF}/repo-local.list"
SCRIPTSDIR="${PREFIX}/scripts-enabled/${_PROF}"
SOURCESLISTDEFAULT="${PREFIX}/sources-list/${_PROF}/default.list"
SCRIPT_NAME="exec.sh"
LOG_PATH="/var/log"
ISOIN="${PREFIX}/iso/input"
ISONAME="ubuntu-gnome-16.04-desktop-amd64.iso"
ISOURL="http://cdimage.ubuntu.com/ubuntu-gnome/releases/16.04/release/"
ISOPATH="${ISODIR}/${ISONAME}"
ISOOUT="${PREFIX}/iso/output"
\ No newline at end of file
_HELP=false
_DIST=""
_ARCH="amd64"
_REPO="stable"
......@@ -22,16 +22,22 @@
# USA.
export PREFIX="${PWD}"
source "${PREFIX}/conf/pre.conf"
source "${PREFIX}/conf/common.conf"
while true; do
case "${1}" in
-h | --help ) _HELP=true; shift ;;
-d | --distro ) _DIST="${2}"; shift; shift ;;
-a | --arch ) _ARCH="${2}"; shift; shift ;;
-r | --repo ) _REPO="${2}"; shift; shift ;;
-* ) echo "Unrecognized option. Try with --help."; exit 1 ;;
* ) break ;;
-h | --help ) _HELP=true; break ;;
-l | --list-profiles ) _PRLS=true; break ;;
-L | --list-entries ) _CALS=true; break ;;
-p | --profile ) _PROF="${2}"; shift; shift ;;
-n | --iso-name ) _INAM="${2}"; shift; shift ;;
-u | --iso-url ) _IURL="${2}"; shift; shift ;;
-P | --iso-path ) _IPAT="${2}"; shift; shift ;;
-r | --repo ) _REPO="${2}"; shift; shift ;;
-c | --cache ) _CACH="${2}"; shift; shift ;;
-d | --dump ) _DUMP=true; shift ;;
-* ) echo "Unrecognized option. Try with --help."; exit 1 ;;
* ) break ;;
esac
done
......@@ -39,47 +45,84 @@ if [ "${_HELP}" = true ]; then
echo "Usage: ${0} [OPTION] [ARGUMENT]..."
echo ""
echo "Examples:"
echo " sudo ${0} --distro le6/testing # Generate default arch (amd64) le6 iso image"
echo " sudo ${0} -d le6/testing -a i386 # Generate i386 architecture le6 iso image"
echo " sudo ${0} --profile le6/testing # Generate le6 iso image"
echo ""
echo "Options:"
echo " -h, --help Show this help list"
echo " -d, --distro [DIST] Select iso image's distro"
echo " -a, --arch [amd64 | i386] Select iso image's architecture"
echo " -l, --list-profiles List available profiles"
echo " -L, --list-entries List available cache entries (base system images) by profile"
echo " -p, --profile [PROF] Select profile to load configurations and run enabled scripts from"
echo " -n, --iso-name [NAME] Select name of the ISO image to be downloaded"
echo " -u, --iso-url [URL] Select source URL of the ISO image"
echo " -P, --iso-path [PATH] Select local path for source ISO image"
echo " -r, --repo [stable | testing | unstable] Select remote repository codename to download packages from"
exit 2
echo " -c, --cache [TIMESTAMP] Select available overlaid base system to build image by timestamp"
echo " -d, --dump Dump base system at the end"
exit 0
fi
if [ -z "${_DIST}" ]; then
echo "No distro specified. Try with --help."
exit 1
if [ "${_PRLS}" = true ]; then
# TODO: List profiles here
exit 0
fi
if [ "${_CALS}" = true ]; then
# TODO: List cache entries here
exit 0
fi
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
fi
if [ "${_ARCH}" != "amd64" ] && [ "${_ARCH}" != "i386" ]; then
echo "Unrecognized architecture. Try with --help."
if [ -z "${_PROF}" ]; then
echo "No profile specified. Try with --help or --list-profiles."
exit 1
fi
# TODO: This does not work (just exits the "()")
source "${PREFIX}/conf/${_PROF}/create-iso.conf" || \
(echo "Unavailable profile. Try with --help or --list-profiles."; exit 1)
if [ -z "${_IPAT}" ]; then
# TODO: This must be improved
mkdir --parents "${ISODIR}"
touch "${ISODIR}/MD5SUMS"
OLDMD5="$(cat ${ISODIR}/MD5SUMS)"
NEWMD5="$(wget "${_IURL}/MD5SUMS" -O- | grep "${_INAM}" | cut --delimiter=" " --fields=1)"
if [ "${OLDMD5}" != "${NEWMD5}" ]; then
pushd "${ISODIR}"
wget "${_IURL}/${_INAM}"
popd
echo "${NEWMD5}" > "${ISODIR}/MD5SUMS"
fi
_IPAT="${ISODIR}/${_INAM}"
fi
if [ "${_REPO}" != "stable" ] && [ "${_REPO}" != "testing" ] && [ "${_REPO}" != "unstable" ]; then
echo "Unrecognized remote repository codename. Try with --help."
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
TIME_STAMP="$(date +'%Y-%m-%dT%H:%M:%S')"
if [ -z "${_CACH}" ]; then
_CACH="${TIME_STAMP}"
mkdir --parents "${CHROOTDIR}/${_PROF}/${_CACH}"
elif [ ! -d "${CHROOTDIR}/${_PROF}/${_CACH}" ]; then
echo "Unexistent cache entry. Try with --help or --list-entries."
exit 1
fi
source "${PREFIX}/conf/${_DIST}/create-iso.conf"
CHROOTDIR="${CHROOTDIR}/${_PROF}/${_CACH}"
TIME_STAMP="$(date +'%Y-%m-%dT%H:%M:%S')"
export LOG_FILE="${LOG_PATH}/create-iso-${TIME_STAMP}.log"
exec 1<&-
exec 2<&-
exec 1<> "${LOG_FILE}"
exec 1>&1
mkdir --parents "${TMP}"
source "${PREFIX}/common.sh"
source "${PREFIX}/helper/logging.incsh"
......@@ -90,15 +133,24 @@ source "${PREFIX}/lib/overlay.sh"
apt-get install isolinux syslinux squashfs-tools genisoimage xorriso --yes || \
createIsoLogger --message "Failed to install basic tools" --tag "apt-get"
mkdir --parents "${PREFIX}"/{base,chroot}
mount -t iso9660 -o ro,loop "${_IPAT}" "${PREFIX}/base" || createIsoLogger --message \
"Unable to mount iso9660" --tag "mount"
mount -t squashfs -o ro,loop "${PREFIX}/base/casper/filesystem.squashfs" "${PREFIX}/chroot" \
|| createIsoLogger -m "Unable to mount squashfs" --tag "mount"
mountTmpfs "${TMPFS}"
mountOverlay "${CHROOTDIR}" "${TMPFS}"
# TODO: This configuration is deprecated
_ARCH="amd64"
# 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
if ! "${script}"\
"${_DIST}" \
"${_PROF}" \
"${_ARCH}" \
"${_REPO}" \
"${CHROOTDIR}" \
......@@ -122,7 +174,7 @@ for script in "${SCRIPTSDIR}"/*; do
exit 1
fi
# If the script is marked as 'chroot', it means it performs changes in the overlayed chroot filesystem,
# If the script is marked as 'chroot', it means it performs changes in the overlaid chroot filesystem,
# therefore, the 'chroot script', filled with the required commands by the marked script, is executed
# This warning is disabled because the literal '-' is actually needed:
# shellcheck disable=SC1001
......@@ -135,11 +187,12 @@ for script in "${SCRIPTSDIR}"/*; do
done
# Finally generates the resulting iso image
NAME="LinuxEducacional6-$(echo "${_DIST}" | cut --delimiter='/' --fields=2).iso"
# TODO: This name shouldn't be hardcoded
NAME="LinuxEducacional6-$(echo "${_PROF}" | cut --delimiter='/' --fields=2).iso"
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}" . || createIsoLogger --message "Failed to generate iso image." --tag "xorriso"
-o "${ISOOUT}/${NAME}" . || createIsoLogger --message "Failed to generate iso image." --tag "xorriso"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
cleanup "${CHROOTDIR}" "${TMP}"
......
#!/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
......@@ -4,10 +4,10 @@
#set -x
_DIST="${1}"
_PROF="${1}"
PREFIX="${PWD}"
source "${PREFIX}/conf/${_DIST}/create-iso.conf"
source "${PREFIX}/conf/${_PROF}/create-iso.conf"
source "${PREFIX}/common.sh"
mkdir -p "${TMP}/bl/"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
_ARCH="${2}"
_REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
_REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
# CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
_ARCH="${2}"
# _REPO="${3}"
CHROOTDIR="${4}"
......@@ -77,12 +77,16 @@ touch "${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" || \
createIsoLogger --message "Unable to set ${TMP}/image/.disk/cd_type" --tag "echo"
# TODO: Var "${DISTRO}" should be used here
echo "Linux-Educacional 6.1.0" > "${TMP}/image/.disk/info" || \
createIsoLogger --message "Unable to set ${TMP}/image/.disk/info" --tag "echo"
# TODO: This should be in the config file instead
echo "https://linuxeducacional.c3sl.ufpr.br" > "${TMP}/image/.disk/release_notes_url" || \
createIsoLogger --message "Unable to set ${TMP}/image/.disk/release_notes/url" --tag "echo"
#Change label on grub menu
# Change label on grub menu
# TODO: Var "${DISTRO}" should be already using spaces, we can double quote the value in the config file to
# prevent word splitting
sed --in-place "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DISTRO//_/ }\"/" "${CHROOTDIR}/etc/default/grub" || \
createIsoLogger --message "Unable to change distributor in grub default file" --type warning --tag "sed"
......
......@@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# _DIST="${1}"
# _PROF="${1}"
# _ARCH="${2}"
_REPO="${3}"
CHROOTDIR="${4}"
......
#!/bin/bash
# shellcheck disable=SC1090
PREFIX="${PWD}"
umount -l "${PREFIX}/chroot/casper" || echo "chroot/casper"
umount -l "${PREFIX}/chroot/dev/pts" || echo "chroot/dev/pts nao montado"
umount -l "${PREFIX}/chroot/dev" || echo "chroot/dev nao montado"
umount -l "${PREFIX}/chroot/sys" || echo "chroot/sys nao montado"
umount -l "${PREFIX}/chroot/proc" || echo "chroot/proc nao montado"
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