make-initrd.sh 2.47 KB
Newer Older
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#
# 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
#
# le6-conf 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.
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
22 23

_DIST=$1
24 25 26 27 28 29 30 31 32 33 34 35 36 37
CHROOTDIR=$2
CHROOTFILE=$3
DISTRO=$4
DPLIST=$5
INSTLIST=$6
ISOLINUX=$7
MOUNTLIST=$8
OURSOURCESLIST=$9
RMDSKT=${10}
RMLIST=${11}
SCRIPTSDIR=${12}
SHORTNAME=${13}
SOURCESLISTDEFAULT=${14}
TMP=${15}
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
38 39 40 41
PREFIX=$PWD

source ${PREFIX}/common.sh

42
#cp ${CHROOTDIR}/boot/vmlinuz-*-generic ${TMP}/image/casper/vmlinuz || exit 1
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
43 44 45 46 47 48
if [ ! -d ${PREFIX}/initrd ]; then
    mkdir ${PREFIX}/initrd
else
    rm -rf ${PREFIX}/initrd/*
fi
initname=$(ls "${CHROOTDIR}/boot/" | grep "initrd.*")
49 50 51
if [ "$(ls "${CHROOTDIR}/boot/" | grep -c "initrd.*")" -gt "1" ]; then
    initname="initrd"$(echo ${initname##*initrd})
fi
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
52 53 54
echo "initname = '${initname}'"
cd ${PREFIX}/initrd
gzip -dc ${CHROOTDIR}/boot/${initname} | cpio -id
55
cp ${PREFIX}/src/preseed/preseed.cfg ${PREFIX}/initrd/
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
broken_links=$(find . -type l ! -exec test -e {} \; -print)
for broken_link in ${broken_links}; do
    path_file=$(readlink -m ${broken_link})
    # Expand path_file and remove prefix presents in broken_link variable
    # ex: path_file = /usr/share/plymouth/themes/le-text/le-text.plymouth
    # $(dirname broken_link) = ./usr/share/plymouth/themes/
    # so relative_path = le-text/le-text.plymouth
    # parameter expansion used "${PARAMETER#PATTERN}" remove substring from PARAMETER that matches with PATTHERN
    link_dir=$(dirname ${broken_link})
    link_name=$(basename ${broken_link})
    cd ${link_dir}
    relative_path=${path_file#*${link_dir#.}/}
    rm ${link_name}
    ln -s ${relative_path} ${link_name}
    cd -
done
find . | cpio --quiet --dereference -o -H newc | lzma -7 > ../initrd.lz
cd ..
74
cp initrd.lz ${TMP}/image/casper/initrd.lz || exit 1
Daniel Bissani Furlin's avatar
Daniel Bissani Furlin committed
75
exit 0