delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/19/04:23:46

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <003701c34dce$d3fd4b20$c99ac250@leper>
Reply-To: <fergus AT bonhard DOT uklinux DOT net>
From: <fergus AT bonhard DOT uklinux DOT net>
To: <cygwin AT cygwin DOT com>
Cc: <fergus AT bonhard DOT uklinux DOT net>
Subject: How to make your own portable Cygwin on CD
Date: Sat, 19 Jul 2003 09:22:01 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-OriginalArrivalTime: 19 Jul 2003 08:23:32.0176 (UTC) FILETIME=[0A3BB500:01C34DCF]
Note-from-DJ: This may be spam

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

This topic has received some attention on this list since about May. I think
the following procedure works well (it does for me, and the finished CD has
worked faultlessly on a selection of other Windows machines). I got through
half a box of CD blanks to get where I wanted, and a lot depends on the
degree of personalisation that a user will require. But if you felt like
trying this out and offering any enhancements or improvements to the
instruction sequence, that would be really nice. Thank you. Enjoy, I hope.

Fergus

Step 0

If you already have Cygwin installed on your machine, climb into it and then

        mount -m > /bin/remount.txt
        umount -A

and exit. Then, from Windows, rename your Cygwin directory to something
else: for the avoidance of doubt, why not use the name CygOld. This
installation will be recovered as the final step in this instruction list

Step 1

Make a fresh up-to-date Cygwin installation by changing from "All Default"
to "All Install" in Setup and then de-selecting entirely the groups
Publishing and XFree86 (and Games, maybe) by again choosing "Default" for
these three (the default being, not to install them). Clicking the "View"
button once to move on to the detailed view of what is to be installed,
additionally de-select the associated files lily*, tetex* and texmf*,
residing in Dev, Doc, Text, etc. Do not select any source files.

This set of choices will lead to an almost complete provision that will also
fit on a CD. (You might prefer a different compromise but this works well.)

Step 2

Having installed this "almost-maximal" version, start a Cygwin session. The
supplied Desktop shortcut provides exactly what is needed to do this, but if
you did not say Yes to that shortcut when you were offered it, the required
command is

        Start -> Run -> \Cygwin\bin\bash --login -i

N.B. From now on, everything that follows, up to the Exit at Step 6, is run
in this single Cygwin session.

Step 3

Depending on the Windows machine at which you are now seated, your HOME will
be /home/admin or /home/Guest or something similar. In this architecture,
you should be aware that HOME will be set to /home/user/, a convenient
default. Prepare for that change now, by making a new directory /home/user/
and moving there, deleting the existing /home/admin/ (or whatever). It does
not matter that you will lose the file /home/admin/.bash_profile.

Copy, or create, any extra material you require under /home/ and under
/usr/local/. (So, copy anything that you are used to having available in
~/bin/, for instance; or if you normally have a directory called ~/tmp/,
create that too. (Remember, once burned, your CD is immutable. However, CD
blanks are cheap: it is unlikely that you will have things entirely as you
want them at your first attempt, and you might find that you are only happy
with your 3rd or 4th. Coping with anything normally to be found in your
startup files ~/.bash_profile or ~/.bashrc is the subject of Step 4.

Don't forget to create some convenient links to other drives than your CD
drive, if you want them, as in

        ln -s /cygdrive/a /a
        ln -s /cygdrive/c /c
        ln -s /cygdrive/d /d

Step 3a

At this point I re-named all of /etc/profile, /etc/group and /etc/passwd to
*.0 to conceal them from what is intended to be a maximally portable system,
and thereby remove some opportunities for confusion. It is not clear to me
that this step is actually necessary, and you will end up on most machines
named "unknown" and belonging to group "mkpasswd". If there's a convenient
approach that leads to a neater (more elegant) id that can be maintained
across all systems, it would be nice to know it.

Step 4

This is the only slightly difficult step: it consists of tweaking existing
files or making new ones, all to render the CD version usable.

There are five files attached to this instruction document.

One attachment is a script to help you make the CD version: it is called
lnk.update.sh. It should be copied to your home directory ~.

Two of the attachments are to be located in /. They are cygmin.bat and
cygmin.ini. The batch file cygmin.bat is the only one of the five
attachments that should be DOS terminated <CR><LF>: all others are
Unix-terminated <LF>. It would be a good idea to check this after the files'
correct placement.

The file cygwin.bat is sent as cygwin.tab to get through gateways.

The 4th attachment is an example file bashrc.eg, providing the basis for a
CD-bound ~/.bashrc. You may not require or even desire some of the entries:
you may want others. These vital details are attended to next. For the
moment place the file in your home directory ~ and re-name it  .bashrc).

Finally: the default startup mode is barest bash, defined in cygmin.bat. The
5th attached file called rxvt.sh provides an example of an enhanced
environment which you might prefer (possibly after editing some of the
detail of it).

Now we will look at three of the files in more detail.

/cygmin.bat

This file does not need altering (though after some usage you might decide
to change it: in particular, you might wish to incorporate the terminal
window rxvt into your default startup). However, notice that it seeks and,
if necessary, creates, a directory on your C: drive called c:\tmp\. (Most
people's day-to-day usage will probably involve a requirement for some such
scratch area. If you don't like the name, or know your requirement to be a
different location, then change it, but note the requirement for a matching
change to the file /cygwin.ini.)

/cygmin.ini

This sets export'd variables once and for all. They are the usual suspects,
SHELL, HOME, PATH and PS1. You will find that one or both of TEMP and TMP
are inherited from your Windows environment. Earlier testing of a CD version
was frustrated by one application's insistence on writing to a specifically
named temporary directory called TMPDIR, and so that is defined
appropriately here. You may well find other similar requirements and
barriers to convenient usage emerging, in which case you can make the
appropriate adjustments to this file and burn another CD.

~/bashrc.eg

The provided example sets preferred aliases (if any) and with the final
command (cd) sees to the user's starting location. As you can see from
scrutinising the contents of /cygmin.ini, this is called anyway by the
starting procedure. However, this re-statement is necessary if during a
single session you decide to initiate new processes.

Having re-located and re-named this file as ~/.bashrc, edit it to suit
yourself, possibly with reference to your "own" startup files residing in
the directory currently known as c:\CygOld.

Notice two important lines: (1) history-writing is turned off to forestall
attempts to write to the CD. Also (you might not need this) you can see from
its alias that vim is directed to a specific vimrc file rather than a
default ~/.vimrc, and this turns off ~/viminfo, another file that would by
default be written to disk during vim usage. (The designated vimrc should
contain the additional line set vi=<space> to achieve this.)

Note: you will almost certainly discover additional tweaks and commands that
you will wish to add to your ~/.bashrc, specific to CD usage. These
discoveries will almost certainly not all be obvious to you now.

That's it. If you have other standard easements with which you are familiar,
don't forget to make these too.

Step 5

This step is designed to cope with the later transfer of symlinks to the CD.
Its point is to identify these links on the HD whether they have been
created as Windows System files or Windows Read-only *.lnk files, and to
re-create them all as Read-only *.lnk files. The reason for this is that
files on the CD will necessarily be marked +R, and the +S attribute does not
migrate properly to CDs.

(You will probably have as many as about 3000 such links, so this step takes
time.)

From your home directory ~, run the script as

        ./lnk.update.sh

[This procedure is achieved step by step through the creation of temporary
files and can certainly be shortened. An earlier version reduced the whole
thing to one piped instruction, but I found that that the -sf switch for ln
(replacing the sequence rm then ln -s) did not work as I wanted (or as I
expected).]

Step 6

You are about to exit this "temporary" Cygwin system. Because of the minor
tweaks to files that were made in Step 4, it is not quite ideal as your
standard HD provision, and should be un-mounted in the interests of
neatness.

(Anyway, the type of user who has successfully come this far will typically
already possess a HD-based Cygwin system that they will not normally wish to
replace with this one.)

From ~, run

        /bin/umount -A

and, finally

        exit

Step 7

As a final step before copying to CD and, absolutely essential, recovering
your previous and "real" Cygwin installation, it will be nice to clear up
any straggling unwanted files from Windows. (You should not want or need
c:\Cygwin\cygwin.bat, which will have survived. Delete any .bash_history
files, c:\Cygwin\home\user\lnk.update.sh, and any other temporary files you
can see but don't want.). Then

        rename \Cygwin to \CygNew;

then
        rename \CygOld to \Cygwin

Step 8

Recover your pre-existing installation with

        \Cygwin\bin\bash

to obtain a bash window. You might get a "warning: could not find /tmp"
error message, but this does not matter. From here

        pwd

to check your location (it should be /cygdrive/c/Cygwin/bin/) and then

        PATH=.
        bash ./remount.txt
        exit

Step 9

Burn your CD: that is, copy across everything in \CygNew (not \CygNew
itself) to the root of the CD.

Step 10

And start your CD in any Windows machine, containing a pre-existing Cygwin
installation or not, with the command

        h:\cygmin<space>h:

where h: is the local CD driveletter. (Notice: no trailing slashes. This too
it would be nice to tidy, but CD driveletters vary across machines, and I do
not know any better startup command.)

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: application/octet-stream;
	name="rxvt.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="rxvt.sh"

#! /bin/sh=0A=
/bin/rxvt -title "" -bg antiquewhite -fg midnightblue -color10 green4 =
-color14 brown -fn "Lucida Console-14" -geometry 80x59+0+0 -sl 4000 -sr =
-tn cygwin=0A=

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: application/octet-stream;
	name="cygmin.tab"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="cygmin.tab"

@echo Starting CygMin ...
@%1\bin\mkdir /cygdrive/c/tmp > nul
@%1\bin\mount -m | %1\bin\sed s/mount/"%1\\/bin\\/mount"/ > c:\tmp\mnt.log
@%1\bin\umount -c > nul
@%1\bin\umount -A
@%1\bin\mount -bfu %1/ /
@%1\bin\mount -bfu %1/bin /usr/bin
@%1\bin\mount -bfu %1/lib /usr/lib
@%1\bin\bash -rcfile /cygmin.ini
@%1\bin\umount -c > nul
@%1\bin\umount -A
@%1\bin\bash c:\tmp\mnt.log
@echo ... closing CygMin

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: application/octet-stream;
	name="cygmin.ini"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="cygmin.ini"

export SHELL=3D/bin/bash=0A=
export HOME=3D/home/user=0A=
export PATH=3D"~/bin:/usr/local/bin:/usr/bin:/bin:"=0A=
export PS1=3D"\w> "=0A=
export TMPDIR=3D/cygdrive/c/tmp=0A=
=0A=
source ~/.bashrc=0A=

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: application/octet-stream;
	name="lnk.update.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="lnk.update.sh"

#! /bin/sh=0A=
/bin/find / -type l > tmpf.0=0A=
/bin/sed 's/^\/usr\/bin\/.*$//;s/^\/usr\/lib.*$//;/^$/d' tmpf.0 > tmpf.1=0A=
/bin/sed 's/^/\/bin\/ls -al /' tmpf.1 > tmpf.2=0A=
/bin/bash tmpf.2 > tmpf.3=0A=
/bin/sed 's/^[^\/]*\//\//' tmpf.3 > tmpf.4=0A=
/bin/sed 's/^/\/bin\/rm /' tmpf.1 > tmpf.5=0A=
/bin/sed 's/^\(.*\) -> \(.*\)$/\/bin\/ln -s \2 \1/' tmpf.4 > tmpf.6=0A=
/bin/bash tmpf.5=0A=
/bin/bash tmpf.6=0A=
/bin/rm tmpf.*=0A=

------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: application/octet-stream;
	name="bashrc.eg"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="bashrc.eg"

unset HISTFILE=0A=
HISTIGNORE=3D"&"=0A=
=0A=
alias cp=3D"cp -i"=0A=
alias ls=3D"ls -F --color=3Dauto"=0A=
alias mv=3D"mv -i"=0A=
alias rm=3D"rm -i"=0A=
alias more1=3D"less -X -F"=0A=
alias nano=3D"nano -xS"=0A=
alias vim=3D"vim -u ~/vimrc"=0A=
=0A=
cd=0A=


------=_NextPart_000_0034_01C34DD7.35B0EA40
Content-Type: text/plain; charset=us-ascii

--
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/
------=_NextPart_000_0034_01C34DD7.35B0EA40--

- Raw text -


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