Re: [Module::Build] ./Build on Win98
Status: Beta
Brought to you by:
kwilliams
|
From: demerphq <dem...@gm...> - 2006-02-23 10:45:20
|
On 2/22/06, Randy W. Sims <ml...@th...> wrote: > Joshua ben Jore wrote: > > On 2/22/06, Nick Ing-Simmons <ni...@in...> wrote: > >> Randy W. Sims <Ra...@Th...> writes: > > > >> Build.bat cannot delete itself on Windows. > >> You can't delete executing things. This is why Windows needs to > >> reboot after installing upgrades. > >> A running thing can ask for a delete on next reboot, but cannot delete > >> an open file. > > > > You can have it delete itself if you can manage to call the CreateFile > > Win32 API function with the FILE_FLAG_DELETE_ON_CLOSE flag. At least > > that's what demerphq told p5p about something similar when trying to > > get M::B to be able to install Cwd. > > That's true of binary executable images, batch scripts turn out to be > different... > > We start with a perl script 'Build', run it through the 'pl2bat' utility > which prefaces it with a batch script that invokes the perl interpreter > with itself, skipping the batch header. This produces the 'Build.bat' > file that we execute. Perl reads the entire file in, closing the handle. > > Initially, we tried deleting the 'Build.bat' from the perl side of the > script. It worked: the file was unlinked. But when execution returned > the shell, the batch script was no longer there, producing the "not > found" error. This seems to imply that batch files are opened, read & > executed one line at a time. This is important. > > The final solution, the one being tweaked now because of slight syntax > differences between commands on 9x vs NT, involves appending DOS > commands to the end of the batch script during the execution of the > 'realclean' action. The general solution was suggested by some people in > the alt.msdos.batch newsgroup. Basically, it's executing the following > commands from a batch file: And actually if you go back to the early mails on this, i suggested something along these lines at that time. (One nice use of this trick is that you can write a perl script that is then run through pl2bat which is capable of altering its parents enviornment.) Cheers, yves -- perl -Mre=3Ddebug -e "/just|another|perl|hacker/" |