Add option to create virtual editions
This commit is contained in:
parent
847e1b1083
commit
9b9245a7b6
145
convert.sh
145
convert.sh
@ -1,5 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
scriptName="UUP Converter v0.4.1"
|
scriptName="UUP Converter v0.5.0"
|
||||||
|
UUP_CONVERTER_SCRIPT=1
|
||||||
|
|
||||||
|
if [ -f `pwd`/convert_ve_plugin ]; then
|
||||||
|
. `pwd`/convert_ve_plugin
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f `pwd`/convert_config_linux ]; then
|
||||||
|
. `pwd`/convert_config_linux
|
||||||
|
else
|
||||||
|
VIRTUAL_EDITIONS_LIST="CoreSingleLanguage Enterprise EnterpriseN Education \
|
||||||
|
EducationN ProfessionalEducation ProfessionalEducationN \
|
||||||
|
ProfessionalWorkstation ProfessionalWorkstationN ServerRdsh IoTEnterprise"
|
||||||
|
fi
|
||||||
|
|
||||||
editions='analogonecore
|
editions='analogonecore
|
||||||
andromeda
|
andromeda
|
||||||
@ -229,18 +242,35 @@ resetColor="\033[0m"
|
|||||||
|
|
||||||
if [ "$1" == "-?" -o "$1" == "--help" -o "$1" == "-h" ]; then
|
if [ "$1" == "-?" -o "$1" == "--help" -o "$1" == "-h" ]; then
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "$0 [compression] [uups_directory]"
|
echo "$0 [compression] [uups_directory] [create_virtual_editions]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Compression options:"
|
echo -e "${infoColor}compression options:${resetColor}"
|
||||||
echo "wim - standard compression"
|
echo "wim - standard compression (default)"
|
||||||
echo "esd - solid compression"
|
echo "esd - solid compression"
|
||||||
|
echo ""
|
||||||
|
echo -e "${infoColor}create_virtual_editions options:${resetColor}"
|
||||||
|
echo "0 - do not create virtual editions (default)"
|
||||||
|
echo "1 - create virtual edtitions"
|
||||||
|
echo ""
|
||||||
|
echo -e "${infoColor}convert_config_linux file${resetColor}"
|
||||||
|
echo "This file can be used to configure some advanced options of this script."
|
||||||
|
echo "It is required to place configuration in the same directory as script."
|
||||||
|
echo ""
|
||||||
|
echo "Possible configuration options:"
|
||||||
|
echo "VIRTUAL_EDITIONS_LIST='space delimited editions sequence'"
|
||||||
|
echo ""
|
||||||
|
echo -e "${infoColor}List of editions created if you enable virtual edtitions creation:${resetColor}"
|
||||||
|
for edition in $VIRTUAL_EDITIONS_LIST; do
|
||||||
|
echo "- $edition"
|
||||||
|
done
|
||||||
|
echo "When VIRTUAL_EDITIONS_LIST is not configured, this list contains all editions."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! which cabextract >/dev/null \
|
if ! which cabextract >/dev/null 2>&1 \
|
||||||
|| ! which wimlib-imagex >/dev/null \
|
|| ! which wimlib-imagex >/dev/null 2>&1 \
|
||||||
|| ! which chntpw >/dev/null \
|
|| ! which chntpw >/dev/null 2>&1 \
|
||||||
|| ! which genisoimage >/dev/null; then
|
|| ! which genisoimage >/dev/null 2>&1; then
|
||||||
echo "One of required applications is not installed."
|
echo "One of required applications is not installed."
|
||||||
echo "The following applications need to be installed to use this script:"
|
echo "The following applications need to be installed to use this script:"
|
||||||
echo " - cabextract"
|
echo " - cabextract"
|
||||||
@ -271,6 +301,12 @@ else
|
|||||||
uupDir="UUPs"
|
uupDir="UUPs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [ -z $3 ]; then
|
||||||
|
runVirtualEditions="$3"
|
||||||
|
else
|
||||||
|
runVirtualEditions=0
|
||||||
|
fi
|
||||||
|
|
||||||
if ! [ -d "$uupDir" ]; then
|
if ! [ -d "$uupDir" ]; then
|
||||||
echo -e "$errorColor""Specified directory containing UUP files does not exist!""$resetColor"
|
echo -e "$errorColor""Specified directory containing UUP files does not exist!""$resetColor"
|
||||||
exit 1
|
exit 1
|
||||||
@ -288,6 +324,14 @@ function cleanup() {
|
|||||||
rm -rf "$tempDir"
|
rm -rf "$tempDir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function errorHandler() {
|
||||||
|
if [ $1 != 0 ]; then
|
||||||
|
echo -e "${errorColor}$2${resetColor}"
|
||||||
|
cleanup
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -e ISODIR ]; then
|
if [ -e ISODIR ]; then
|
||||||
rm -rf ISODIR
|
rm -rf ISODIR
|
||||||
fi
|
fi
|
||||||
@ -314,24 +358,21 @@ extractDir="$tempDir/extract"
|
|||||||
|
|
||||||
echo -e "\033[1m$scriptName\033[0m"
|
echo -e "\033[1m$scriptName\033[0m"
|
||||||
|
|
||||||
|
if [ $runVirtualEditions -eq 1 ] && [ "$VIRTUAL_EDITIONS_PLUGIN_LOADED" != "1" ]; then
|
||||||
|
echo "Virtual editions will be not created, because plugin isn't loaded."
|
||||||
|
runVirtualEditions=0
|
||||||
|
fi
|
||||||
|
|
||||||
for file in `find "$uupDir" -type f -iname "*.cab"`; do
|
for file in `find "$uupDir" -type f -iname "*.cab"`; do
|
||||||
fileName=`basename $file .cab`
|
fileName=`basename $file .cab`
|
||||||
echo -e "$infoColor""CAB -> ESD:""$resetColor"" $fileName"
|
echo -e "$infoColor""CAB -> ESD:""$resetColor"" $fileName"
|
||||||
|
|
||||||
mkdir "$extractDir"
|
mkdir "$extractDir"
|
||||||
cabextract -d "$extractDir" "$file" >/dev/null 2>/dev/null
|
cabextract -d "$extractDir" "$file" >/dev/null 2>/dev/null
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to extract $fileName.cab"
|
||||||
echo -e -e "$errorColor""Failed to extract $fileName.cab""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
wimlib-imagex capture "$extractDir" "$tempDir/$fileName.esd" >/dev/null
|
wimlib-imagex capture "$extractDir" "$tempDir/$fileName.esd" >/dev/null
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to create $fileName.esd"
|
||||||
echo -e "$errorColor""Failed to create $fileName.esd""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf "$extractDir"
|
rm -rf "$extractDir"
|
||||||
done
|
done
|
||||||
@ -345,12 +386,9 @@ mkdir ISODIR
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "$infoColor""Creating ISO structure...""$resetColor"
|
echo -e "$infoColor""Creating ISO structure...""$resetColor"
|
||||||
|
|
||||||
wimlib-imagex apply "$firstMetadata" 1 ISODIR --no-acls 2>/dev/null
|
wimlib-imagex apply "$firstMetadata" 1 ISODIR --no-acls 2>/dev/null
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to create ISO structure"
|
||||||
echo -e "$errorColor""Failed to create ISO structure""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "$infoColor""Exporting winre.wim...""$resetColor"
|
echo -e "$infoColor""Exporting winre.wim...""$resetColor"
|
||||||
@ -358,11 +396,7 @@ echo -e "$infoColor""Exporting winre.wim...""$resetColor"
|
|||||||
wimlib-imagex export "$firstMetadata" 2 "$tempDir/winre.wim" \
|
wimlib-imagex export "$firstMetadata" 2 "$tempDir/winre.wim" \
|
||||||
--compress=maximum --boot
|
--compress=maximum --boot
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to export winre.wim"
|
||||||
echo -e "$errorColor""Failed to export winre.wim""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "$infoColor""Creating boot.wim...""$resetColor"
|
echo -e "$infoColor""Creating boot.wim...""$resetColor"
|
||||||
@ -374,11 +408,7 @@ wimlib-imagex info ISODIR/sources/boot.wim 1 "Microsoft Windows PE" \
|
|||||||
wimlib-imagex extract ISODIR/sources/boot.wim 1 --dest-dir="$tempDir" \
|
wimlib-imagex extract ISODIR/sources/boot.wim 1 --dest-dir="$tempDir" \
|
||||||
"/Windows/System32/config/SOFTWARE" --no-acls >/dev/null
|
"/Windows/System32/config/SOFTWARE" --no-acls >/dev/null
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to extract registry"
|
||||||
echo -e "$errorColor""Failed to extract registry""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 'cd Microsoft\Windows NT\CurrentVersion
|
echo 'cd Microsoft\Windows NT\CurrentVersion
|
||||||
nv 1 SystemRoot
|
nv 1 SystemRoot
|
||||||
@ -403,11 +433,7 @@ wimlib-imagex update ISODIR/sources/boot.wim 1 \
|
|||||||
wimlib-imagex export "$tempDir/winre.wim" 1 \
|
wimlib-imagex export "$tempDir/winre.wim" 1 \
|
||||||
ISODIR/sources/boot.wim "Microsoft Windows Setup"
|
ISODIR/sources/boot.wim "Microsoft Windows Setup"
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to create second index of boot.wim"
|
||||||
echo -e "$errorColor""Failed to create second index of boot.wim""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
wimlib-imagex extract "$firstMetadata" 3 "/Windows/System32/xmllite.dll" \
|
wimlib-imagex extract "$firstMetadata" 3 "/Windows/System32/xmllite.dll" \
|
||||||
--no-acls --dest-dir="ISODIR/sources" >/dev/null
|
--no-acls --dest-dir="ISODIR/sources" >/dev/null
|
||||||
@ -432,11 +458,7 @@ for i in $files; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
wimlib-imagex update ISODIR/sources/boot.wim 2 <"$tempDir/update.txt" >/dev/null
|
wimlib-imagex update ISODIR/sources/boot.wim 2 <"$tempDir/update.txt" >/dev/null
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to add required files to second index of boot.wim"
|
||||||
echo -e "$errorColor""Failed to add required files to second index of boot.wim""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
wimlib-imagex optimize ISODIR/sources/boot.wim
|
wimlib-imagex optimize ISODIR/sources/boot.wim
|
||||||
rm "ISODIR/sources/xmllite.dll"
|
rm "ISODIR/sources/xmllite.dll"
|
||||||
@ -454,11 +476,7 @@ for metadata in $metadataFiles; do
|
|||||||
wimlib-imagex export "$metadata" 3 ISODIR/sources/install.$type \
|
wimlib-imagex export "$metadata" 3 ISODIR/sources/install.$type \
|
||||||
"$editionName" $compressParam --ref="$uupDir/*.esd" --ref "$tempDir/*.esd"
|
"$editionName" $compressParam --ref="$uupDir/*.esd" --ref "$tempDir/*.esd"
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to export $editionName to install.$type""$resetColor"
|
||||||
echo -e "$errorColor""Failed to export $editionName to install.$type""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
let indexesExported++
|
let indexesExported++
|
||||||
|
|
||||||
@ -472,6 +490,25 @@ done
|
|||||||
|
|
||||||
info=`wimlib-imagex info "$firstMetadata" 3`
|
info=`wimlib-imagex info "$firstMetadata" 3`
|
||||||
build=`grep -i "^Build:" <<< "$info" | sed "s/.* //g"`
|
build=`grep -i "^Build:" <<< "$info" | sed "s/.* //g"`
|
||||||
|
|
||||||
|
addedVirtualEditions=0
|
||||||
|
if [ $runVirtualEditions -eq 1 ] && [ $build -ge 17063 ]; then
|
||||||
|
echo -e "$infoColor""Creating virtual editions...""$resetColor"
|
||||||
|
for virtualEdition in $VIRTUAL_EDITIONS_LIST; do
|
||||||
|
echo -e "$infoColor""Adding $virtualEdition edition...""$resetColor"
|
||||||
|
createVirtualEdition "$virtualEdition"
|
||||||
|
error=$?
|
||||||
|
if [ $error -ne 1 ]; then
|
||||||
|
errorHandler $error "Failed to create virtual edition"
|
||||||
|
let addedVirtualEditions++
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
elif [ $build -lt 17063 ]; then
|
||||||
|
echo "Virtual editions creation requires build 17063 or later"
|
||||||
|
fi
|
||||||
|
|
||||||
|
let indexesSum=$addedVirtualEditions+$indexesExported
|
||||||
spbuild=`grep -i "^Service Pack Build:" <<< "$info" | sed "s/.* //g"`
|
spbuild=`grep -i "^Service Pack Build:" <<< "$info" | sed "s/.* //g"`
|
||||||
arch=`grep -i "^Architecture:" <<< "$info" | sed "s/.* //g"`
|
arch=`grep -i "^Architecture:" <<< "$info" | sed "s/.* //g"`
|
||||||
|
|
||||||
@ -479,7 +516,7 @@ if [ "$arch" == "x86_64" ]; then
|
|||||||
arch="x64"
|
arch="x64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $indexesExported -gt 1 ]; then
|
if [ $indexesSum -gt 1 ]; then
|
||||||
isoEdition="MULTI"
|
isoEdition="MULTI"
|
||||||
else
|
else
|
||||||
isoEdition=`grep -i "^Edition ID:" <<< "$info" | sed "s/.* //g"`
|
isoEdition=`grep -i "^Edition ID:" <<< "$info" | sed "s/.* //g"`
|
||||||
@ -492,6 +529,10 @@ if [ -e "$isoName" ]; then
|
|||||||
rm "$isoName"
|
rm "$isoName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "$infoColor""Optimizing install.$type...""$resetColor"
|
||||||
|
wimlib-imagex optimize ISODIR/sources/install.$type
|
||||||
|
echo ""
|
||||||
|
|
||||||
echo -e "$infoColor""Creating ISO image...""$resetColor"
|
echo -e "$infoColor""Creating ISO image...""$resetColor"
|
||||||
find ISODIR -exec touch {} +
|
find ISODIR -exec touch {} +
|
||||||
|
|
||||||
@ -499,11 +540,7 @@ genisoimage -b "boot/etfsboot.com" --no-emul-boot \
|
|||||||
--eltorito-alt-boot -b "efi/microsoft/boot/efisys.bin" --no-emul-boot \
|
--eltorito-alt-boot -b "efi/microsoft/boot/efisys.bin" --no-emul-boot \
|
||||||
--udf --hide "*" -V "$isoLabel" -o "$isoName" ISODIR
|
--udf --hide "*" -V "$isoLabel" -o "$isoName" ISODIR
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
errorHandler $? "Failed to create ISO image""$resetColor"
|
||||||
echo -e "$errorColor""Failed to create ISO image""$resetColor"
|
|
||||||
cleanup
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
echo -e "\033[1;92mDone.""$resetColor"
|
echo -e "\033[1;92mDone.""$resetColor"
|
||||||
|
1438
convert_ve_plugin
Normal file
1438
convert_ve_plugin
Normal file
File diff suppressed because it is too large
Load Diff
39
readme.md
39
readme.md
@ -11,13 +11,17 @@ Updates to created images.
|
|||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
```
|
```
|
||||||
./convert.sh [compression] [uups_directory]
|
./convert.sh [compression] [uups_directory] [create_virtual_editions]
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Compression options:
|
###### compression options:
|
||||||
* wim - standard wim compression (`/Compress:max` in DISM)
|
* wim - standard wim compression (`/Compress:max` in DISM) (default)
|
||||||
* esd - solid esd compression (`/Compress:recovery` in DISM)
|
* esd - solid esd compression (`/Compress:recovery` in DISM)
|
||||||
|
|
||||||
|
###### create_virtual_editions options:
|
||||||
|
* 0 - do not create virtual editions (default)
|
||||||
|
* 1 - create virtual edtitions
|
||||||
|
|
||||||
### Usage examples
|
### Usage examples
|
||||||
* `./convert.sh` - starts the conversion using files from `UUPs` directory and
|
* `./convert.sh` - starts the conversion using files from `UUPs` directory and
|
||||||
creates an ISO image with `install.wim`
|
creates an ISO image with `install.wim`
|
||||||
@ -28,6 +32,35 @@ Updates to created images.
|
|||||||
* `./convert.sh wim MyUUP` - starts the conversion using files from `MyUUP`
|
* `./convert.sh wim MyUUP` - starts the conversion using files from `MyUUP`
|
||||||
directory and creates an ISO image with `install.wim`
|
directory and creates an ISO image with `install.wim`
|
||||||
|
|
||||||
|
* `./convert.sh wim MyUUP 1` - starts the conversion using files from `MyUUP`
|
||||||
|
directory, creates virtual editions and creates an ISO image with
|
||||||
|
`install.wim`
|
||||||
|
|
||||||
|
### Virtual editions
|
||||||
|
Since version 0.5.0 this script supports creation of virtual editions.
|
||||||
|
To run creation of all virtial editions simply use create_virtual_editions
|
||||||
|
switch in command line. If you want to customize which editions will be created
|
||||||
|
when this switch is set, please use VIRTUAL_EDITIONS_LIST in configuration file.
|
||||||
|
|
||||||
|
Virtual editions creation can be only done when convert_ve_plugin is present in
|
||||||
|
the same directory as converter.
|
||||||
|
|
||||||
|
Thanks to abbodi1406 for providing information which allowed creation of this
|
||||||
|
option.
|
||||||
|
|
||||||
|
### Configuration file
|
||||||
|
Configuration of advanced script options can be modified using
|
||||||
|
convert_config_linux file.
|
||||||
|
|
||||||
|
###### Configuration options
|
||||||
|
```
|
||||||
|
VIRTUAL_EDITIONS_LIST='space delimited editions sequence'
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Configuration options explanation
|
||||||
|
* VIRTUAL_EDITIONS_LIST - configures which editions will be created when
|
||||||
|
create_virtual_editions is enabled.
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
This script uses the following commands to do its work:
|
This script uses the following commands to do its work:
|
||||||
* cabextract - to extract cabs
|
* cabextract - to extract cabs
|
||||||
|
Loading…
Reference in New Issue
Block a user