delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/10/26/13:04:16

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: Thorsten Kampe <thorsten AT thorstenkampe DOT de>
Subject: Re: AllVersions: Running Cygwin X w/ Registy Entries
Date: Wed, 26 Oct 2005 17:54:21 +0100
Lines: 68
Message-ID: <1urn2nj8m3olr.2asrzsft004y$.dlg@40tude.net>
References: <1130262948 DOT 435e71a4abd76 AT webmail DOT mail DOT gatech DOT edu> <7ff9c2a10510251559x2aa2a4c3q6571a47b049d7a03 AT mail DOT gmail DOT com>
Mime-Version: 1.0
User-Agent: 40tude_Dialog/2.0.15.1
X-IsSubscribed: yes

* Svend Sorensen (2005-10-25 23:59 +0100)
> On 10/25/05, gtg793x AT mail DOT gatech DOT edu <gtg793x AT mail DOT gatech DOT edu> wrote:
>> I would like to be able to have a portable version of cygwin in my Flash Drive.
>> I have been able to do it but it requires that I enter some registry entries
>> such as:
>>
>> [HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/]
>><snip>
> 
> Here are the batch files I use.  In their current state, they must
> exist in the parent directory of the cygwin root, which must be named
> "cygwin".
> 
> install.bat backs up the current cygwin mount table, then creates a
> new table for the removable device.  It uses the users Windows %TEMP%
> dir for /tmp, because I wanted to minimize writes to the flash disk.
> 
> uninstall.bat removes the new mount table, and restores the backed up copy.
> 
> --begin install.bat--
> [...]
> --begin uninstall.bat--
> [...]
> --end uninstall.bat--

Wow, that's cute. I recently wrote a python script to do the same
thing but that batch solution is much simpler (and better):

I tried to "improve" your script a bit. This is the result. (For the
record I've included my Python script also)...

*** BEWARE: this overwrites all Cygwin settings in the registry
*** (it's meant for the average internet cafe user)
*** the script *has* to be on the usb drive/stick
@ echo off
set MOUNT=\cygwin\bin\mount -X -f -u -b

REM \cygwin\bin\umount -c
REM \cygwin\bin\umount -A
reg delete "hklm\software\cygnus solutions" /f > nul 2>&1
reg delete "hkcu\software\cygnus solutions" /f > nul 2>&1

%MOUNT% --change-cygdrive-prefix /cygdrive
%MOUNT% %~d0\cygwin/bin /usr/bin
%MOUNT% %~d0\cygwin/lib /usr/lib
%MOUNT% %~d0\cygwin     /
%MOUNT% %TEMP%          /tmp
%MOUNT% %TEMP%          /usr/tmp
%MOUNT% %TEMP%          /var/tmp

**********
import codecs, \
       os,     \
       re

regfile  = r'\data\config\cygwin.reg'

# '"native"="E:\\cygwin"' for instance
match    = r'(?<="native"=")[A-Z]:(?=\\\\cygwin)'
newdrive = os.path.splitdrive(os.getcwd())[0]
# 'ascii' for non unicode reg files
myfile   = codecs.open(regfile, 'r', 'utf_16')
content  = myfile.read()
myfile   = codecs.open(regfile, 'w', 'utf_16')

myfile.write(re.sub(match, newdrive, content))
myfile.close()
os.system('regedit /s %s' % regfile)


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019