Subversion Repositories ALCASAR

Rev

Rev 2941 | Rev 2945 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2941 Rev 2944
Line 43... Line 43...
43
MAGEIA_VERSION=`echo $ISO_IN|cut -d"-" -f2`
43
MAGEIA_VERSION=`echo $ISO_IN|cut -d"-" -f2`
44
ARCH=`echo $ISO_IN |cut -d"-" -f3|cut -d"." -f1`
44
ARCH=`echo $ISO_IN |cut -d"-" -f3|cut -d"." -f1`
45
ALCASAR_TARBALL=`ls $RESSOURCES| grep '^alcasar.*gz'`
45
ALCASAR_TARBALL=`ls $RESSOURCES| grep '^alcasar.*gz'`
46
ALCASAR_EXTRACTED_DIR=$(echo $ALCASAR_TARBALL | rev | cut -d '.' -f 3- | rev)
46
ALCASAR_EXTRACTED_DIR=$(echo $ALCASAR_TARBALL | rev | cut -d '.' -f 3- | rev)
47
ALCASAR_VERSION=`echo $ALCASAR_EXTRACTED_DIR | cut -d"-" -f2`
47
ALCASAR_VERSION=`echo $ALCASAR_EXTRACTED_DIR | cut -d"-" -f2`
-
 
48
TMP_DIR=/var/tmp
48
MAGEIA_NEW_DIR=/var/tmp/mageia_new
49
MAGEIA_NEW_DIR=$TMP_DIR/mageia_new
49
MAGEIA_OFFICIAL_DIR=/var/tmp/mageia_official
50
MAGEIA_OFFICIAL_DIR=$TMP_DIR/mageia_official
50
MAGEIA_OFFICIAL_DIR_EFI=/var/tmp/mageia_official_efi
51
MAGEIA_OFFICIAL_DIR_EFI=$TMP_DIR/mageia_official_efi
51
coreDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/core
52
coreDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/core
52
nonFreeDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/nonfree
53
nonFreeDir=${MAGEIA_OFFICIAL_DIR}/${ARCH}/media/nonfree
53
coreDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/core/
54
coreDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/core/
54
nonFreeDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/nonfree
55
nonFreeDirNew=${MAGEIA_NEW_DIR}/${ARCH}/media/nonfree
55
plopFilePath=${MAGEIA_NEW_DIR}/${ARCH}/media/plop.idx
-
 
56
ISO_OUT=/var/tmp/iso
-
 
57
RPM_DIR=/var/tmp/rpms
-
 
58
 
-
 
59
 
56
 
60
# Drake installer
57
# Drake installer
61
INSTALLER_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/alcasar"
58
INSTALLER_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/alcasar"
62
EFI_GRUB_CFG="${MAGEIA_NEW_DIR}/boot/grub2/grub.cfg"
59
EFI_GRUB_CFG="${MAGEIA_NEW_DIR}/boot/grub2/grub.cfg"
63
ADVERT_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/extra/advertising"
60
ADVERT_DIR="${MAGEIA_NEW_DIR}/${ARCH}/install/extra/advertising"
64
AUTO_INSTALL_CFG="${ISO_OUT}/auto_inst.cfg.pl"
61
AUTO_INSTALL_CFG=$TMP_DIR/auto_inst.cfg.pl
65
 
62
 
66
# RPMs needed during an install stage
63
# RPMs needed during an install stage
67
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 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"
64
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 ldetect lftp lib64alsa-plugins lib64glib-networking-gnutls locales-en locales-fr lsof lvm2 mageia-theme-Default man-db 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 mandi mandi-ifw"
68
 
65
 
69
#######################
66
#######################
70
######    Main    ######
67
######    Main    ######
71
################################################################################
68
################################################################################
72
 
69
 
73
# Some checks
70
# Some checks
74
[[ $(whoami) != 'root' ]] && errorExit 'Please run as root'
71
[[ $(whoami) != 'root' ]] && errorExit 'Please run as root'
75
[[ $ISO_IN == "" ]] && errorExit "No Mageia iso file in $RESSOURCES"
72
[[ $ISO_IN == "" ]] && errorExit "No Mageia iso file in $RESSOURCES"
76
[[ ! -f "$RESSOURCES/auto_inst.cfg.pl_template" ]] && errorExit "No auto_inst.cfg.pl_template file in $RESSOURCES"
73
[[ ! -f "$RESSOURCES/auto_inst.cfg.pl_template" ]] && errorExit "No auto_inst.cfg.pl_template file in $RESSOURCES"
77
[[ $ALCASAR_TARBALL == "" ]] && errorExit "No ALCASAR tarball file in $RESSOURCES"
74
[[ $ALCASAR_TARBALL == "" ]] && errorExit "No ALCASAR tarball file in $RESSOURCES"
-
 
75
 
78
for directory in $MAGEIA_NEW_DIR $MAGEIA_OFFICIAL_DIR $MAGEIA_OFFICIAL_DIR_EFI $ISO_OUT $RPM_DIR
76
for directory in $MAGEIA_NEW_DIR $MAGEIA_OFFICIAL_DIR $MAGEIA_OFFICIAL_DIR_EFI
79
do
77
do
80
	[ -d $directory ] || mkdir -p $directory
78
	[ -d $directory ] || mkdir -p $directory
81
done
79
done
82
printBold "Mageiar will be build with Mageia-$MAGEIA_VERSION-$ARCH and $ALCASAR_EXTRACTED_DIR" 
80
printBold "Mageiar will be build with Mageia-$MAGEIA_VERSION-$ARCH and $ALCASAR_EXTRACTED_DIR" 
83
 
81
 
84
# Retrieve list of Alcasar dependencies
82
# Retrieve list of installed RPM
85
tar -xf $RESSOURCES/$ALCASAR_TARBALL -C /tmp/ || errorExit "could not extract alcasar tar archive"
-
 
86
alcasarRpmList="$(grep -oP "(?<=PACKAGES=\").*?(?=\")" /tmp/$ALCASAR_EXTRACTED_DIR/scripts/alcasar-rpm.sh)"
83
ALCASAR_RPM_LIST="$(dnf list installed | cut -d " " -f1 | rev | cut -d "." -f2- | rev | grep -Ev 'coova-chilli|gammu|lib64gammu8|ipt-netflow|nfdump|wkhtmltopdf' | tail -n +2 | tr '\n' ' ')"
87
alcasarKernel="$(grep -oP "(?<=KERNEL=\").*?(?=\")" /tmp/$ALCASAR_EXTRACTED_DIR/scripts/alcasar-rpm.sh)"
-
 
88
alcasarRpmList="$alcasarRpmList $alcasarKernel"
-
 
89
 
-
 
90
# Make clean rpm list
84
# agregate & clean rpm list
91
rpmList=$(echo $BASE_RPM_LIST $alcasarRpmList | sed "s/ /\n/g" | sort | uniq | sed "s/\n/ /g")
85
RPM_LIST=$(echo $BASE_RPM_LIST $ALCASAR_RPM_LIST | sed "s/ /\n/g" | sort | uniq | sed "s/\n/ /g")
92
 
86
 
93
# Insert list into AUTO_INSTALL_CFG
87
# Insert list into AUTO_INSTALL_CFG
94
formattedList=$(echo $rpmList | sed "s/[^ ]*/\'\0\'/g" | sed "s/ /,\n/g" | sed "/kernel-server/d")
88
formattedList=$(echo $RPM_LIST | sed "s/[^ ]*/\'\0\'/g" | sed "s/ /,\n/g")
95
cp $RESSOURCES/auto_inst.cfg.pl_template $AUTO_INSTALL_CFG -f
89
cp -f $RESSOURCES/auto_inst.cfg.pl_template $AUTO_INSTALL_CFG
96
insertLineNumber=$(grep -n "'default_packages' => " "$AUTO_INSTALL_CFG" | cut -d ':' -f1)
90
insertLineNumber=$(grep -n "'default_packages' => " "$AUTO_INSTALL_CFG" | cut -d ':' -f1)
97
fileTop=$(head -n "+$insertLineNumber" "$AUTO_INSTALL_CFG")
91
fileTop=$(head -n "+$insertLineNumber" "$AUTO_INSTALL_CFG")
98
fileBottom=$(tail -n "+$insertLineNumber" "$AUTO_INSTALL_CFG" | tail -n +2)
92
fileBottom=$(tail -n "+$insertLineNumber" "$AUTO_INSTALL_CFG" | tail -n +2)
99
cat /dev/null > "$AUTO_INSTALL_CFG"
93
cat /dev/null > "$AUTO_INSTALL_CFG"
100
echo "$fileTop" > "$AUTO_INSTALL_CFG"
94
echo "$fileTop" > "$AUTO_INSTALL_CFG"
101
echo "$formattedList" >> "$AUTO_INSTALL_CFG"
95
echo "$formattedList" >> "$AUTO_INSTALL_CFG"
102
echo "$fileBottom" >> "$AUTO_INSTALL_CFG"
96
echo "$fileBottom" >> "$AUTO_INSTALL_CFG"
103
 
97
 
104
# Installing tools to create the iso
98
# Installing tools to create the iso file
105
printBold "Installing necessary tools"
99
printBold "Installing ISO building tools"
106
dnf install 'dnf-command(download)' -y || errorExit "could not install necessary packages"
100
dnf install 'dnf-command(download)' -y || errorExit "could not install necessary packages"
107
#dnf install 'dnf-command(config-manager)' -y || errorExit "could not install necessary packages"
-
 
108
#dnf config-manager --set-enabled mageia-x86_64-nonfree updates-x86_64-nonfree  || errorExit "could not install necessary packages"
-
 
109
dnf install -y lftp wget cdrkit-genisoimage xorriso rpmtools syslinux || errorExit "could not install necessary packages"
101
dnf install -y lftp wget cdrkit-genisoimage xorriso rpmtools syslinux || errorExit "could not install necessary packages"
110
 
102
 
111
# Mounting the ISO image
103
# Mounting the ISO image
112
printBold "Mounting the image"
104
printBold "Mounting the image"
-
 
105
if [ `mount |grep $MAGEIA_OFFICIAL_DIR | wc -l` -eq 0 ]; then # if not already mounted
113
mount -o ro,loop $RESSOURCES/$ISO_IN $MAGEIA_OFFICIAL_DIR || errorExit "failed mounting $ISO_IN."
106
	mount -o ro,loop $RESSOURCES/$ISO_IN $MAGEIA_OFFICIAL_DIR || errorExit "failed mounting $ISO_IN."
-
 
107
fi
114
sleep 1 # wait for mounting process
108
sleep 1 # wait for mounting process
115
[ -d ${MAGEIA_OFFICIAL_DIR}/x86_64 ] || umount $MAGEIA_OFFICIAL_DIR || errorExit "The ISO file isn't in the target architecture ($ARCH)" 
109
[ -d ${MAGEIA_OFFICIAL_DIR}/x86_64 ] || umount $MAGEIA_OFFICIAL_DIR || errorExit "The ISO file isn't in the target architecture ($ARCH)" 
116
 
110
 
117
# Copying main files except core and nonfree directories
111
# Copying main files except core and nonfree directories
118
echo "Extracting base image..."
112
echo "Extracting base image..."
Line 121... Line 115...
121
 
115
 
122
# Creating new directories core and nonfree and dir for alcasar stufs
116
# Creating new directories core and nonfree and dir for alcasar stufs
123
mkdir -p ${MAGEIA_NEW_DIR}/${ARCH}/{media/{core,nonfree},install/alcasar}
117
mkdir -p ${MAGEIA_NEW_DIR}/${ARCH}/{media/{core,nonfree},install/alcasar}
124
 
118
 
125
# Adding Alcasar image advert to the installer
119
# Adding Alcasar image advert to the installer
126
cp -f $RESSOURCES/install_slideshow/* "$ADVERT_DIR"
120
cp -f $RESSOURCES/install_slideshow/* "$ADVERT_DIR" || errorExit "could not copy custom slideshow to $ADVERT_DIR"
127
 
121
 
128
# Create the installed RPM list excluding those brought with alcasar archive (they aren't in repository)
122
# Create the installed RPM list excluding those brought with alcasar archive (they aren't in repository)
129
installedList="$(dnf list installed | cut -d ' ' -f1 | rev | cut -d . -f2- | rev | grep -Ev 'coova-chilli|gammu|lib64gammu8|ipt-netflow|nfdump|wkhtmltopdf' | tail -n +2 | tr '\n' ' ')"
-
 
130
nbInstalled=$(echo $installedList | wc -w)
123
nbInstalled=$(echo $RPM_LIST | wc -w)
131
rpmList="$installedList $BASE_RPM_LIST"
-
 
132
total=`echo $rpmList | wc -w`
124
total=`echo $RPM_LIST | wc -w`
133
count=0
125
count=0
134
# Copying the RPM in core and clearing the plop.idx file
126
# Copying the RPM in core and clearing the plop.idx file
135
echo "Copying RPMS in ISO ..."
127
echo "Copying $total RPMS in ISO ..."
136
echo /dev/null > ${plopFilePath}
-
 
137
for rpm in ${rpmList}; do
128
for rpm in ${RPM_LIST}; do
138
	let percent="${count} * 100 / ${total}"
129
	let percent="${count} * 100 / ${total}"
139
	if [[ $count -lt $nbInstalled ]] ; then
-
 
140
		dnf download -y --downloadonly --downloaddir $coreDirNew $rpm 1> /dev/null || errorExit "could not download $rpm"
-
 
141
	else
-
 
142
		dnf install -y --downloadonly --downloaddir $coreDirNew $rpm 1> /dev/null || errorExit "could not download $rpm"
130
	dnf download --downloaddir $coreDirNew $rpm 1> /dev/null || errorExit "could not download $rpm"
143
	fi
-
 
144
	printProgress ${percent}
131
	printProgress ${percent}
145
	count=$(expr ${count} + 1)
132
	count=$(expr ${count} + 1)
146
done
133
done
147
echo "STOP"; exit 1
-
 
148
 
-
 
149
# Sorting the plop file alphabetically
-
 
150
cat ${plopFilePath} | sort > /tmp/tmpFileMageia && mv /tmp/tmpFileMageia ${plopFilePath}
-
 
151
 
-
 
152
# Informations
-
 
153
printBold "$count RPMs copied"
134
printBold "$count RPMs copied"
154
 
135
 
155
# Downloading rpms needed by Alcasar
-
 
156
cd "$CURRENT_DIR"
-
 
157
printBold "Downloading Alcasar dependencies"
-
 
158
tar -xf /var/iso/$ALCASAR_TARBALL
-
 
159
 
-
 
160
# Copying the Alcasar tar to be put into the ISO
136
# Copying the Alcasar tarball & automatic install option into the ISO
161
cp /var/iso/$ALCASAR_TARBALL $INSTALLER_DIR/
-
 
162
 
-
 
163
# Add automatic install options
-
 
164
mkdir -p $INSTALLER_DIR || errorExit "could not create directory $INSTALLER_DIR"
137
mkdir -p $INSTALLER_DIR || errorExit "could not create directory $INSTALLER_DIR"
-
 
138
cp $RESSOURCES/$ALCASAR_TARBALL $INSTALLER_DIR || errorExit "could not copy $RESSOURCES/$ALCASAR_TARBALL to $INSTALLER_DIR"
165
cp $AUTO_INSTALL_CFG $INSTALLER_DIR || errorExit "could not copy $AUTO_INSTALL_CFG to $INSTALLER_DIR"
139
cp $AUTO_INSTALL_CFG $INSTALLER_DIR || errorExit "could not copy $AUTO_INSTALL_CFG to $INSTALLER_DIR"
166
 
140
 
167
# Generating media info for core
141
# Generating media info for core
168
echo "Generating media_info for core..."
142
echo "Generating media_info for core..."
169
genhdlist2 ${coreDirNew} --allow-empty-media --quiet
143
genhdlist2 ${coreDirNew} --allow-empty-media --quiet
170
 
-
 
171
echo "Generating media_info for nonfree..."
144
echo "Generating media_info for nonfree..."
172
genhdlist2 ${nonFreeDirNew} --allow-empty-media --quiet
145
genhdlist2 ${nonFreeDirNew} --allow-empty-media --quiet
173
 
146
 
174
# Puting pubkeys in media_info
147
# Puting pubkeys in media_info
175
cp ${coreDir}/media_info/pubkey ${coreDirNew}/media_info/
148
cp ${coreDir}/media_info/pubkey ${coreDirNew}/media_info/
Line 195... Line 168...
195
# Generating the iso file
168
# Generating the iso file
196
# Parameters for xorriso found using the following command on the original mageia iso
169
# Parameters for xorriso found using the following command on the original mageia iso
197
# xorriso -indev Mageia-7-x86_64.iso -report_el_torito as_mkisofs
170
# xorriso -indev Mageia-7-x86_64.iso -report_el_torito as_mkisofs
198
cd ${MAGEIA_NEW_DIR} && xorriso -as mkisofs \
171
cd ${MAGEIA_NEW_DIR} && xorriso -as mkisofs \
199
	-V 'Mageia-7.1-x86_64' \
172
	-V 'Mageia-7.1-x86_64' \
200
	--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt:${ISO_IN} \
-
 
201
	-partition_cyl_align off \
173
	-partition_cyl_align off \
202
	-partition_offset 0 \
174
	-partition_offset 0 \
203
	--mbr-force-bootable \
175
	--mbr-force-bootable \
204
	-append_partition 2 0xef --interval:local_fs:8785156d-8793347d::${ISO_IN} \
-
 
205
	-iso_mbr_part_type 0x00 \
176
	-iso_mbr_part_type 0x00 \
206
	-c '/boot.catalog' \
177
	-c 'boot.catalog' \
207
	-b '/boot/grub2/eltorito.img' \
178
	-b 'boot/grub2/eltorito.img' \
208
	-no-emul-boot \
179
	-no-emul-boot \
209
	-boot-load-size 4 \
180
	-boot-load-size 4 \
210
	-boot-info-table \
181
	-boot-info-table \
211
	--grub2-boot-info \
182
	--grub2-boot-info \
212
	-eltorito-alt-boot \
183
	-eltorito-alt-boot \
213
	-e '--interval:appended_partition_2_start_2196289s_size_8192d:all::' \
-
 
214
	-no-emul-boot \
-
 
215
	-boot-load-size 8192 \
184
	-boot-load-size 8192 \
216
	-o ${CURRENT_DIR}/${newIsoName} .
185
	-o ${TMP_DIR}/${newIsoName} .
217
 
-
 
218
 
186
 
219
# Unmounting & Removing temporary dir
187
# Unmounting & Removing temporary dir
220
echo "Umounting..."
188
echo "Umounting..."
221
umount $MAGEIA_OFFICIAL_DIR
189
umount $MAGEIA_OFFICIAL_DIR
222
for directory in $MAGEIA_NEW_DIR $MAGEIA_OFFICIAL_DIR $MAGEIA_OFFICIAL_DIR_EFI $ISO_OUT $RPM_DIR
190
for directory in $MAGEIA_NEW_DIR $MAGEIA_OFFICIAL_DIR $MAGEIA_OFFICIAL_DIR_EFI
223
do
191
do
224
	[ -d $directory ] && rm -rf $directory
192
	[ -d $directory ] && rm -rf $directory
225
done
193
done
226
 
-
 
227
mv ${CURRENT_DIR}/${newIsoName} /var/iso/
-
 
228
 
-
 
229
# Finished
-
 
230
rm -f "$AUTO_INSTALL_CFG"
194
rm -f "$AUTO_INSTALL_CFG"
231
echo "Done."
195
echo "Done."