monta_image.sh 3.85 KB
Newer Older
1
#!/bin/bash
2 3 4 5 6 7
#
# 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
#
8
# create-iso is free software; you can redistribute it and/or
9 10 11 12 13 14 15 16 17 18 19 20 21
# 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.
22

23 24 25
export PREFIX=$(pwd)
source ${PREFIX}/conf/pre.conf \
|| log ERROR "Preconfiguration file not found"
26

27 28 29 30 31
while true; do
    case "$1" in
        -h | --help   ) _HELP=true; shift ;;
        -d | --distro ) _DIST=$2; shift; shift ;;
        -a | --arch   ) _ARCH=$2; shift; shift ;;
32
        -r | --repo   ) _REPO=$2; shift; shift ;;
33 34 35 36 37 38
        -* )            echo "Unrecognized option. Try with --help."; exit 1 ;;
        *  )            break ;;
    esac
done

if [ ${_HELP} = true ]; then
39
    echo "Usage: $0 [OPTION] [ARGUMENT]..."
40 41
    echo ""
    echo "Examples:"
42 43
    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"
44 45
    echo ""
    echo "Options:"
46 47 48 49
    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 "    -r, --repo [stable | testing | unstable]   Select remote repository codename to download packages from"
50
    exit 2
51
fi
52

53 54
if [ -z ${_DIST} ]; then
    echo "No distro specified. Try with --help."
55 56 57
    exit 1
fi

58 59 60 61
if [ ${_ARCH} != "amd64" -a ${_ARCH} != "i386" ]; then
    echo "Unrecognized architecture. Try with --help."
    exit 1
fi
62

63 64 65 66 67
if [ ${_REPO} != "stable" -a ${_REPO} != "testing" -a ${_REPO} != "unstable" ]; then
    echo "Unrecognized remote repository codename. Try with --help."
    exit 1
fi

68 69 70
if [ "$(id -u)" != "0" ]; then
    echo "You must have more power to run this script. Are you root?"
    exit -1
71 72 73
fi

source ${PREFIX}/conf/$_DIST/create-iso.conf \
74
|| log ERROR "Configuration file not found for dist: \"${_DIST}\""
75

76
source common.sh
77 78
source lib/mktmpfs.sh
source lib/overlay.sh
79

Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
80
sudo apt-get install syslinux squashfs-tools genisoimage xorriso \
81 82
|| log ERROR "Failed to install basic tools: \"${_DIST}\""

83 84
mountTmpfs ${TMPFS}
mountOverlay ${CHROOTDIR} ${TMPFS}
85 86

mkdir -p ${TMP}
87 88 89
for file in $(ls ${SCRIPTSDIR}); do
    if [ -x "${SCRIPTSDIR}/${file}" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
        echo "$file"
90
        if ! "${SCRIPTSDIR}/${file}" ${_DIST} ${_ARCH} ${_REPO} ${CHROOTDIR} ${CHROOTFILE} ${DISTRO} ${DPLIST} ${INSTLIST} ${ISOLINUX} ${MOUNTLIST} ${OURSOURCESLIST} ${RMDSKT} ${RMLIST} ${SCRIPTSDIR} ${SHORTNAME} ${SOURCESLISTDEFAULT} ${TMP} ${TMPFS} ${REPOPKGS}; then
91 92 93
            log ERROR "While running \"${SCRIPTSDIR}/${file}\""
        fi
    fi
94
done
95 96 97 98

NAME="LinuxEducacional6-$(echo ${_DIST} | cut -d'/' -f2).iso"

cd ${TMP}/image
99 100 101
sudo 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/${_DIST}/${NAME} \
     . ||\
     log ERROR "Failed to generate iso image."
102 103 104
cd -

cleanTmpFiles
105 106
umountOverlay ${CHROOTDIR} ${TMPFS}
umountTmpfs ${TMPFS}
107 108

exit 0