Subversion Repositories ALCASAR

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2941 → Rev 2940

/iso/build-iso.sh
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Deleted: svn:executable
-*
\ No newline at end of property
/iso/scripts/build-image.sh
0,0 → 1,268
#!/bin/bash
#
# Authors: Mageia Team
# Update for ALCASAR : Hamza ESSAYEGH (Querdos) - Rexy - Laurent Roux - Aurelien Dubois - Pierre Rivault
##
# Usage: $0 ARGS
# --iso-file, -i Mageia-xxx-xxxxxx-xxx.iso (mandatory)
# --lang, -l Language for installation (optional)
# Supported languages: fr;en
#
#######################
###### Variables ######
################################################################################
 
CURRENT_DIR="$(readlink -f "$(dirname $0)")"
LOG_FILE="$CURRENT_DIR/build-image.log"
 
# Mageia
MAGEIA_VERSION=`cat /etc/release|cut -d" " -f3`
ARCH=`cat /etc/release|cut -d" " -f6`
MAGEIA_NEW_DIR=/tmp/mageia_new
MAGEIA_OFFICIAL_DIR=/tmp/mageia_official
MAGEIA_OFFICIAL_DIR_EFI=/tmp/mageia_official_efi
# ISO file
ISO_DIR="/var/iso"
ISO_IN="$ISO_DIR/Mageia-$MAGEIA_VERSION-$ARCH.iso"
 
# Drake installer
INSTALLER_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/alcasar"
EFI_GRUB_CFG="${MAGEIA_NEW_DIR}/boot/grub2/grub.cfg"
AUTO_INSTALL_CFG="/var/iso/auto_inst.cfg.pl"
ADVERT_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/extra/advertising"
 
# Alcasar
ALCASAR_TAR="$1"
ALCASAR_EXTRACTED_DIR=$(echo $ALCASAR_TAR | rev | cut -d '.' -f 3- | rev)
 
# Mirrors
ISO_SUPPORT="http://ftp.free.fr/mirrors/mageia.org/iso/$MAGEIA_VERSION/Mageia-$MAGEIA_VERSION-$ARCH/Mageia-$MAGEIA_VERSION-$ARCH.iso"
ISO_MD5="http://ftp.free.fr/mirrors/mageia.org/iso/$MAGEIA_VERSION/Mageia-$MAGEIA_VERSION-$ARCH/Mageia-$MAGEIA_VERSION-$ARCH.iso.md5"
 
# RPMs
RPM_DIR="/root/rpms"
BASE_RPM_LIST="acpi acpid alsa-utils aoss arp-scan basesystem bash-completion coreutils-doc cpupower curl dhcp-client dmraid dnf dnf-plugins-core dosfstools dracut drakx-net-text gpm grub2 grub2-efi grub2-mageia-theme harddrake hdparm hexedit info iwlwifi-agn-ucode kernel-server-latest kernel-firmware kernel-firmware-nonfree ldetect lftp lib64alsa-plugins lib64glib-networking-gnutls locales-en locales-fr lsof lvm2 mageia-theme-Default man-db mandi-ifw man-pages microcode microcode_ctl mtools ntfs-3g numlock os-prober p11-kit perl-Hal-Cdroms plymouth procmail python3 python3-dbus radeon-firmware ralink-firmware rtlwifi-firmware sharutils shorewall-ipv6 strace sysfsutils tmpwatch tree vim-minimal vnstat xdg-user-dirs-gtk sudo socat"
 
#######################
###### Functions ######
################################################################################
# Print the given error message and exit 1
function errorExit()
{
tput bold
echo -e "ERROR : $1 \nAborting\n" >&2
echo "$1" > "$LOG_FILE"
tput sgr0
exit 1
}
#-------------------------------------------------------------------------------
# Print progress bar. $1 is a multiple of five
function printProgress()
{
local a
let "a = $1 / 5"
let "b = 25 - $a"
progressStr=$(printf "%${a}s")
progressStrBlanks=$(printf "%${b}s")
echo -en "Downloading...$1% [${progressStr// /#}${progressStrBlanks// / }]\r"
}
#-------------------------------------------------------------------------------
function printBold()
{
tput bold 2>/dev/null
echo $1
tput sgr0 2>/dev/null
}
#######################
###### Main ######
################################################################################
 
# Retrieve list of Alcasar dependencies
tar -xf /var/iso/$ALCASAR_TAR -C /tmp/ || errorExit "could not extract alcasar tar archive"
alcasarRpmList="$(grep -oP "(?<=PACKAGES=\").*?(?=\")" /tmp/$ALCASAR_EXTRACTED_DIR/scripts/alcasar-urpmi.sh)"
alcasarKernel="$(grep -oP "(?<=KERNEL=\").*?(?=\")" /tmp/$ALCASAR_EXTRACTED_DIR/scripts/alcasar-urpmi.sh)"
alcasarRpmList="$alcasarRpmList $alcasarKernel"
 
# Make clean rpm list
rpmList=$(echo $BASE_RPM_LIST $alcasarRpmList | sed "s/ /\n/g" | sort | uniq | sed "s/\n/ /g")
 
# Insert list into AUTO_INSTALL_CFG
formattedList=$(echo $rpmList | sed "s/[^ ]*/\'\0\'/g" | sed "s/ /,\n/g" | sed "/kernel-server/d")
cp "${AUTO_INSTALL_CFG}_template" "$AUTO_INSTALL_CFG" -f
insertLineNumber=$(grep -n "'default_packages' => " "$AUTO_INSTALL_CFG" | cut -d ':' -f1)
fileTop=$(head -n "+$insertLineNumber" "$AUTO_INSTALL_CFG")
fileBottom=$(tail -n "+$insertLineNumber" "$AUTO_INSTALL_CFG" | tail -n +2)
cat /dev/null > "$AUTO_INSTALL_CFG"
 
echo "$fileTop" > "$AUTO_INSTALL_CFG"
echo "$formattedList" >> "$AUTO_INSTALL_CFG"
echo "$fileBottom" >> "$AUTO_INSTALL_CFG"
 
# Installing tools to create the iso
printBold "Installing necessary tools"
dnf install 'dnf-command(download)' -y || errorExit "could not install necessary packages"
#dnf install 'dnf-command(config-manager)' -y || errorExit "could not install necessary packages"
dnf config-manager --set-enabled mageia-x86_64-nonfree updates-x86_64-nonfree || errorExit "could not install necessary packages"
dnf install -y lftp wget cdrkit-genisoimage xorriso rpmtools syslinux || errorExit "could not install necessary packages"
 
 
# Directories initialization
#-------------------------------------------------------------------------------
[[ ! -d "$RPM_DIR" ]] && mkdir -p "$RPM_DIR"
 
# Beggining work on the ISO
#-------------------------------------------------------------------------------
# Checking the optional Mageia image. If not present or does not match the
# docker's version, download it
if [[ ! -f "$ISO_IN" ]]; then
printBold "Downloading the Mageia iso"
cd $ISO_DIR || errorExit "could not cd to $ISO_DIR"
echo Installing lftp
lftpget -c $ISO_SUPPORT || ( cd "$CURRENT_DIR" && errorExit "could not download Mageia iso" )
cd $CURRENT_DIR
fi
 
# Mounting the image
printBold "Mounting the image"
[[ ! -d "$MAGEIA_OFFICIAL_DIR" ]] && mkdir -p "$MAGEIA_OFFICIAL_DIR"
mount -o ro,loop "$ISO_IN" "$MAGEIA_OFFICIAL_DIR" || (sleep 5 ; mount -o ro,loop "$ISO_IN" "$MAGEIA_OFFICIAL_DIR" || errorExit "failed mounting $ISO_IN. Running the script again might solve the issue.")
 
# Checking ARCHitecture
[[ -d ${MAGEIA_OFFICIAL_DIR}/x86_64 ]] && ARCH=x86_64 || ARCH=i586
 
# Creating new directory that will contains the "cleared" iso image
[[ -d ${MAGEIA_NEW_DIR} ]] && rm -rf ${MAGEIA_NEW_DIR}
mkdir ${MAGEIA_NEW_DIR}
 
# Copying main files except core and nonfree directories
echo "Extracting base image..."
cd $MAGEIA_OFFICIAL_DIR && \
tar cf - --exclude=${ARCH}/media . | (cd $MAGEIA_NEW_DIR && tar xf - ) && cd "${CURRENT_DIR}"
 
# Creating new directories core and nonfree and dir for alcasar stufs
mkdir -p ${MAGEIA_NEW_DIR}/${ARCH}/{media/{core,nonfree},install/alcasar}
 
# Adding Alcasar image advert to the installer
cp -f /var/iso/install_slideshow/* "$ADVERT_DIR"
 
# Retrieving core and nonfree dirs (official)
coreDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/core
nonFreeDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/nonfree
 
# Retrieving core and nonfree dirs (new)
coreDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/core/
nonFreeDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/nonfree
plopFilePath=${MAGEIA_NEW_DIR}/${ARCH}/media/plop.idx
 
# Initializing counts
count=0
 
# Getting list of rpms needed by Mageia
#mageiaRpms="$(cat $MINIMAL_rpmList)"
 
# Copying the RPM in core and nonfree and clearing the plop.idx file
echo "Copying RPMS in ISO ..."
echo /dev/null > ${plopFilePath}
 
dnf upgrade -y
 
installedList="$(dnf list installed | cut -d ' ' -f1 | rev | cut -d . -f2- | rev | tail -n +2 | tr '\n' ' ')"
nbInstalled=$(echo $installedList | wc -w)
rpmList="$installedList $BASE_RPM_LIST $alcasarRpmList"
total=`echo $rpmList | wc -w`
 
for rpm in ${rpmList}; do
let percent="${count} * 100 / ${total}"
if [[ $count -lt $nbInstalled ]] ; then
dnf reinstall -y --downloadonly --downloaddir $coreDirNew $rpm 1> /dev/null || errorExit "could not download $rpm"
else
dnf install -y --downloadonly --downloaddir $coreDirNew $rpm 1> /dev/null || errorExit "could not download $rpm"
fi
printProgress ${percent}
 
count=$(expr ${count} + 1)
done
 
# Sorting the plop file alphabetically
cat ${plopFilePath} | sort > /tmp/tmpFileMageia && mv /tmp/tmpFileMageia ${plopFilePath}
 
# Informations
printBold "$count RPMs copied"
 
# Downloading rpms needed by Alcasar
cd "$CURRENT_DIR"
printBold "Downloading Alcasar dependencies"
tar -xf /var/iso/$ALCASAR_TAR
 
# Copying the Alcasar tar to be put into the ISO
cp /var/iso/$ALCASAR_TAR $INSTALLER_DIR/
 
# Add automatic install options
mkdir -p $INSTALLER_DIR || errorExit "could not create directory $INSTALLER_DIR"
cp $AUTO_INSTALL_CFG $INSTALLER_DIR || errorExit "could not copy $AUTO_INSTALL_CFG to $INSTALLER_DIR"
 
# Generating media info for core
echo "Generating media_info for core..."
genhdlist2 ${coreDirNew} --allow-empty-media --quiet
 
echo "Generating media_info for nonfree..."
genhdlist2 ${nonFreeDirNew} --allow-empty-media --quiet
 
# Puting pubkeys in media_info
cp ${coreDir}/media_info/pubkey ${coreDirNew}/media_info/
cp ${nonFreeDir}/media_info/pubkey ${nonFreeDirNew}/media_info/
 
# Retrieving media.cfg & compssUsers.pl depending on the arch
mkdir ${MAGEIA_NEW_DIR}/${ARCH}/media/media_info
cp ${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/media_info/compssUsers.pl ${MAGEIA_NEW_DIR}/${ARCH}/media/media_info/compssUsers.pl
cp ${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/media_info/media.cfg ${MAGEIA_NEW_DIR}/${ARCH}/media/media_info/media.cfg
 
# Specify install configuration
#sed -i -e 's*rdz*rdz kickstart=/tmp/media/x86_64/install/alcasar/auto_inst.cfg.pl*g' ${MAGEIA_NEW_DIR}/isolinux/isolinux.cfg
sed -i -e 's*noiswmd*noiswmd kickstart=/tmp/media/x86_64/install/alcasar/auto_inst.cfg.pl*g' $EFI_GRUB_CFG
 
# Generating distr
echo "Generating mirror tree..."
gendistrib -s ${MAGEIA_NEW_DIR}/${ARCH}
 
# Creating the new iso file
echo "Creating the isofile..."
alcasarVersion=$(echo $ALCASAR_TAR | cut -d '-' -f2 | rev | cut -d '.' -f 3- | rev )
newIsoName=Mageia-$MAGEIA_VERSION-${ARCH}-Alcasar${alcasarVersion}.iso
 
# Generating the iso file
# Parameters for xorriso found using the following command on the original mageia iso
# xorriso -indev Mageia-7-x86_64.iso -report_el_torito as_mkisofs
cd ${MAGEIA_NEW_DIR} && xorriso -as mkisofs \
-V 'Mageia-7.1-x86_64' \
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt:${ISO_IN} \
-partition_cyl_align off \
-partition_offset 0 \
--mbr-force-bootable \
-append_partition 2 0xef --interval:local_fs:8785156d-8793347d::${ISO_IN} \
-iso_mbr_part_type 0x00 \
-c '/boot.catalog' \
-b '/boot/grub2/eltorito.img' \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--grub2-boot-info \
-eltorito-alt-boot \
-e '--interval:appended_partition_2_start_2196289s_size_8192d:all::' \
-no-emul-boot \
-boot-load-size 8192 \
-o ${CURRENT_DIR}/${newIsoName} .
 
 
# Unmounting
echo "Umounting..."
umount ${MAGEIA_OFFICIAL_DIR} && rmdir ${MAGEIA_OFFICIAL_DIR}
 
# Removing temporary dir
rm -rf ${MAGEIA_NEW_DIR}
 
mv ${CURRENT_DIR}/${newIsoName} /var/iso/
 
# Finished
rm -f "$AUTO_INSTALL_CFG"
echo "Done."
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:executable
+*
\ No newline at end of property
/iso/ressources/install_slideshow/02_IM_mageia.pl
0,0 → 1,0
$title = N("Make it yours!");
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/iso/ressources/install_slideshow/02_IM_mageia.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/iso/ressources/install_slideshow/list
1,3 → 1,2
01_IM_mageia.png
02_IM_mageia.png
alcasar.png
/iso/README.md
1,27 → 1,34
Mageia + ALCASAR (Mageiar) ISO builder
Mageiar ISO builder
===================
 
Goal
----
 
The goal is to create a minimalist ISO image to install both Mageia and Alcasar with all its dependencies.
The goal here is to create a minimalist ISO image to install both Mageia and Alcasar with all its dependencies, wth only one command.
 
How it works
------------
 
The script lists the RPMs installed on a running ALCASAR in order to download them from Internet repository.
Then, it downloads the RPM need to create an ISO file.
Once the ISO is done, one can boot on it and install the OS normally. The ALCASAR archive is copied in /root folder
The script uses an official Mageia docker image to retrieve a recursive list of dependecies that are downloaded and packaged in the installation ISO. Alcasar dependencies list, as well as its kernel version, are retrieved from the Alcasar tar archive.
 
Once the ISO is done, one can boot on it and install the OS normally. The dependencies are installed along the basesystem packages, which means that the Alcasar installer will only download updates.
 
What it needs
-------------
 
The Mageia ISO image and ALCASAR archive are to be placed in the `ressources` directory before running the script.
The script can be provided with both the Alcasar tar archive as well as the Mageia ISO image.
The Alcasar archive can be given in argument using the `-a` option. Otherwise it will be downloaded automatically in its latest version.
 
The Mageia ISO image is to be placed in the `ressources` directory.
If Mageia image has been provided, it will be downloaded in the docker.
This is because the version has to match the one in the docker
 
The script's only dependency is the docker service. All other dependencies, such as the RPM and ISO tools, will be installed within the docker.
 
How to use
----------
 
Usage : build-iso.sh
Usage : buildMageiar [-a alcasar.tar.gz]
 
What can be done
----------------
29,6 → 36,5
The ISO image seems to be already as light as it can be. With all the necessary packages, it weighs around 800Mo.
 
Here is a list of interesting functionnalities:
- if a needed RPM has not been updated, copy it from the Mageia iso file instead of download it from repository
- Use DrakX to install and configure Alcasar graphically
- Propose an automatic partition table suitable for Alcasar
/iso/buildMageiar.sh
0,0 → 1,109
#!/bin/bash
 
#######################
###### Variables ######
################################################################################
 
# Script variables
CURRENT_DIR="$(readlink -f "$(dirname $0)")"
RESSOURCES="$CURRENT_DIR/ressources"
SCRIPTS_DIR="$CURRENT_DIR/scripts"
SCRIPTS_TMP_DIR="$CURRENT_DIR/scripts_tmp"
BUILDER_SCRIPT="build-image.sh"
LOG_FILE="${CURRENT_DIR}/mageiarBuilder.log"
 
 
#######################
###### Functions ######
################################################################################
# Print the given error message and exit 1
function errorExit()
{
tput bold
echo -e "ERROR : $1 \nAborting\n" >&2
echo "$1" > "$LOG_FILE"
tput sgr0
exit 1
}
#-------------------------------------------------------------------------------
function printBold()
{
tput bold 2>/dev/null
echo $1
tput sgr0 2>/dev/null
}
#######################
###### Main ######
################################################################################
 
# Check root
[[ $(whoami) != 'root' ]] && errorExit 'Please run as root'
 
# Check options
while getopts "a:h" option; do
case $option in
a) # Alcasar image
alcasarTar="$(echo $OPTARG | rev | cut -d '/' -f 1 | rev)"
[[ ! -f "$OPTARG" ]] && errorExit "could not find $OPTARG"
# Copy the image in the ressource directory to be accessible from the docker
printBold "Copying $OPTARG" in $RESSOURCES
rsync -usP "$OPTARG" "$RESSOURCES/$alcasarTar" || \
errorExit "could not copy $OPTARG to $RESSOURCES"
 
;;
*)
echo "Usage : buildMageiar [-a alcasar.tar.gz]"
exit 1
;;
esac
done
 
# Check if auto_inst.cfg.pl is present
[[ ! -f "$RESSOURCES/auto_inst.cfg.pl_template" ]] && errorExit "No auto_inst.cfg.pl_template file in $RESSOURCES"
 
#-------------------------------------------------------------------------------
# If needed, download Alcasar image
#-------------------------------------------------------------------------------
 
if [[ -z $alcasarTar ]]; then
latestAlcasarVersion="-$(dig version.alcasar.net txt | \
grep "ANSWER SECTION" -A 1 | \
grep version | cut -d '"' -f2 || \
errorExit "could not retrieve Alcasar latest version")"
alcasarTar="alcasar$latestAlcasarVersion.tar.gz"
 
printBold "Downloading Alcasar image"
wget -O "$RESSOURCES/$alcasarTar" "ftp.alcasar.net:/pub/stable/$alcasarTar" || errorExit 'could not download Alcasar'
fi
 
#
# If Mageia image isn't provided here, it will be downloaded in the docker.
# This is because the version has to match the one in the docker
#
 
#-------------------------------------------------------------------------------
# Run docker image
#-------------------------------------------------------------------------------
systemctl start docker || errorExit 'could not start docker service'
 
# Copy script folder to temporary one
cp -r "$SCRIPTS_DIR" "$SCRIPTS_TMP_DIR"
 
 
printBold "Running mageia docker"
docker run --privileged --rm --volume "$RESSOURCES":/var/iso --volume "$SCRIPTS_TMP_DIR":/root/ -it mageia "/root/$BUILDER_SCRIPT" "$alcasarTar"
 
[[ -d "$SCRIPTS_TMP_DIR" ]] && rm -Rf "$SCRIPTS_TMP_DIR" 2>/dev/null
 
# Retrieve created iso image
mv "$RESSOURCES"/Mageia*Alcasar* "$CURRENT_DIR" 2>/dev/null
 
# Give it to SUDO_USER if exists
[[ ! -z $SUDO_USER ]] && chown -R $SUDO_USER "$CURRENT_DIR"/* 2>/dev/null
 
#-------------------------------------------------------------------------------
# Stopping
#-------------------------------------------------------------------------------
read -p 'Stop docker service ? [Y/n] : ' ynAnswer
[[ ! $ynAnswer = [nN] ]] && systemctl stop docker
#-------------------------------------------------------------------------------
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:executable
+*
\ No newline at end of property