Wednesday, 7 August 2013
Saturday, 2 March 2013
create a vfat Grub2 boot floppy
Create a small Grub2 boot .iso using :
grub-mkrescue --diet -o fd.iso
create some directories, names are important
mkdir -p mnt fdboot/boot /grub
mount the .iso and copy all files in /boot/grub/i386-pc into fdboot/boot /grub
Then create a fdboot/boot /grub/grub.cfg that match your need, for example :
set timeout=5
set default=0 # Set the default menu entry
menuentry "This is the floppy that will boot on first disk" {
set root=(hd0)
chainloader +1
boot
}
If you want to create a real 1.44Mo floppy, you have to remove some file in fdboot/boot /grub.
I choose to create a 2.88Mo floppy, because VMware don't care about the size of the floppy :-)
Then cut&paste the script bellow adapt the 2880 and the -a to mach the size of your floppy and the version of your Grub2. 5760 means 2.88Mo, use 2880 for 1.44Mo floppy.
The run the scrip below. the scrip come from Robert at Re: [SOLVED] Re: Grub2 editable floppy?
#!/bin/sh
# Creates a vfat editable Grub2 boot floppy (not a read-only ISO9660 one like grub-mkrescue)
#
# template folder ./fdboot/boot/grub shall contain a grub2 tree like /boot/grub
# including a grub.cfg, stripped down to <= 1.4MB;
# or a tree copy from a "grub-mkrescue [--diet] -o fd.iso" iso floppy
# (and do "cd fdboot/boot/grub; mv i386-pc/* ." ! because the boot.img+bootdisk looks there)
# ("--diet" unfortunately disappeared in v1.99)
#
# Note: used with Grub2 v1.98 and v1.99; v1.99 requires the "-a" flag in "grub-setup -a ..."
# output image filename
fdimg=fdb.fat
# script
umount mnt
losetup -d /dev/loop0
dd if=/dev/zero of=$fdimg count=5760
losetup /dev/loop0 $fdimg || exit 1
fdformat /dev/loop0
mkfs.vfat /dev/loop0 || exit 1
mount /dev/loop0 mnt || exit 1
##rm fdboot/boot/grub/i386-pc/efiemu.mod grcy_* ... strip off to 1.4MB / create by "grub-mkrescue --diet ..."
cp -a fdboot/* mnt/ || exit 1
##cp /boot/grub/grub.cfg mnt/boot/grub/
cat > mnt/boot/grub/device.map <<EOF
EOF
##(fd0) /dev/fd0
##(hd0) /dev/sda
##(hd1) /dev/sdb
cp /boot/grub/boot.img mnt/boot/grub/ || exit 1
grub-mkimage -o mnt/boot/grub/core.img -O i386-pc biosdisk fat part_msdos || exit 1
# --force is needed to force blocklists (for core.img) on floppy:
##grub-setup --force -d mnt/boot/grub -m mnt/boot/grub/device.map /dev/loop0 || exit 1
# variant with -a required for Grub2 1.99+ :
grub-setup -a --force -d mnt/boot/grub -m mnt/boot/grub/device.map /dev/loop0 || exit 1
umount mnt
losetup -d /dev/loop0
# copy the image to virtual machine image folder
cp -a $fdimg /hptemp/boot/
echo Grub2 VFAT editable boot floppy image $fdimg created. Done.
echo TO MOUNT: mount -o loop $fdimg mnt
echo TO WRITE TO REAL FLOPPY: cp $fdimg /dev/fd0
##cp $fdimg /dev/fd0
Friday, 1 March 2013
Run python-2.7 program inside the WinPE environment
This is notes I took few hours after the performance. They are incomplete.
Since version 2.6, python binaries are compiled with a compiler that depend of an annoying DLL. Because they don't have the right to redistribute this DLL, you have to download this free DLL and install it yourself.
99% of the time this DLL is installed by another package and you don't event know that you need it.
This DLL is missing in WinPE and is particular because it is handled by SxS.
Here is what I did.
First I have installed the python 2.7 32bits from Activestate on my XP.
Then I have booted the target host using a WinPE CD.
I have mounted the C: drive of my XP on the WinPE on G:
net use G: \\name_or_ip\C$ /user:Administrator password
Then cd to G:\Python27, an tried to start python interpreter :
G:\Python27:\>python.exe
The application has failed to start because its side-by-side configuration is in
correct. Please see the application event log or use the command-line
sxstrace.exe tool for more detail.
I have used sxstrace as follow :
X:\>SxsTrace Trace -logfile:SxsTrace.etl
Tracing started. Trace will be saved to file SxsTrace.etl.
Press Enter to stop tracing...
Then I ran python.exe once again to get the trace, stopped SxsTrace and parsed the .etl file
X:\>SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt
Parsing log file SxsTrace.etl...
Parsing finished! Output saved to file SxsTrace.txt.
In the file, I found something like this (this one is about python-2.6) but is identical :
=================
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = x86
CultureFallBacks = en-US;en
ManifestPath = G:\Python26\python.exe
AssemblyDirectory = G:\Python26\
Application Config File =
-----------------
INFO: Parsing Manifest File G:\Python26\python.exe.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
INFO: Resolving reference for ProcessorArchitecture x86.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at X:\windows\assembly\GAC_32\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.MANIFEST.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT\Microsoft.VC90.CRT.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.
The two most important lines are :
X:\windows\assembly\GAC_32\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.MANIFEST.
On my XP I just copied few files :
copy C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375\*.dll C:\Python27
copy c:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375.manifest G:\Python26\Microsoft.VC90.CRT.MANIFEST
copy C:\Windows\system32\python27.dll c:\Python27
I started again python.exe and it was working.
I'have not yet tried, but I expect that copying the whole C:\Python27 to the WinPE CD should be enough.
I have copied the same .dll to my Python26 and to a official Python27 install and both worked too.
Hope this help.
Since version 2.6, python binaries are compiled with a compiler that depend of an annoying DLL. Because they don't have the right to redistribute this DLL, you have to download this free DLL and install it yourself.
99% of the time this DLL is installed by another package and you don't event know that you need it.
This DLL is missing in WinPE and is particular because it is handled by SxS.
Here is what I did.
First I have installed the python 2.7 32bits from Activestate on my XP.
Then I have booted the target host using a WinPE CD.
I have mounted the C: drive of my XP on the WinPE on G:
net use G: \\name_or_ip\C$ /user:Administrator password
Then cd to G:\Python27, an tried to start python interpreter :
G:\Python27:\>python.exe
The application has failed to start because its side-by-side configuration is in
correct. Please see the application event log or use the command-line
sxstrace.exe tool for more detail.
I have used sxstrace as follow :
X:\>SxsTrace Trace -logfile:SxsTrace.etl
Tracing started. Trace will be saved to file SxsTrace.etl.
Press Enter to stop tracing...
Then I ran python.exe once again to get the trace, stopped SxsTrace and parsed the .etl file
X:\>SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt
Parsing log file SxsTrace.etl...
Parsing finished! Output saved to file SxsTrace.txt.
In the file, I found something like this (this one is about python-2.6) but is identical :
=================
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = x86
CultureFallBacks = en-US;en
ManifestPath = G:\Python26\python.exe
AssemblyDirectory = G:\Python26\
Application Config File =
-----------------
INFO: Parsing Manifest File G:\Python26\python.exe.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
INFO: Resolving reference for ProcessorArchitecture x86.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at X:\windows\assembly\GAC_32\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.MANIFEST.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT\Microsoft.VC90.CRT.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.
The two most important lines are :
X:\windows\assembly\GAC_32\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL.
INFO: Attempt to probe manifest at G:\Python26\Microsoft.VC90.CRT.MANIFEST.
On my XP I just copied few files :
copy C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375\*.dll C:\Python27
copy c:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375.manifest G:\Python26\Microsoft.VC90.CRT.MANIFEST
copy C:\Windows\system32\python27.dll c:\Python27
I started again python.exe and it was working.
I'have not yet tried, but I expect that copying the whole C:\Python27 to the WinPE CD should be enough.
I have copied the same .dll to my Python26 and to a official Python27 install and both worked too.
Hope this help.
Friday, 4 January 2013
pyzmail easy mail library for python
pyzmail 1.0 is out !
pyzmail is a high level mail library for Python. It provides functions and classes that help to read, compose and send emails. pyzmail exists because their is no reasons that handling mails with Python would be more difficult than with popular mail clients like Outlook or Thunderbird. pyzmail hides the difficulties of the MIME structure and MIME encoding/decoding. It also hides the problem of the internationalized header encoding/decoding.
Previous version 0.9.9 was out for more than 1 year, version 1.0 contains a minor bug fix.
Subscribe to:
Posts (Atom)