Discussion:
dos2unix file endings
Rez P
2009-10-30 20:03:36 UTC
Permalink
Good Afternoon All

We're running CVS on a linux server and use WinCVS as client on Windows machines to connect via pserver method. We create shell scripts on windows machine and check them into the repository and I would like the files to retain their linux format file endings since they're only meant to be run on linux application servers eventually.

Although they get created on Window client machines, how can I ensure once they're checked in, they get checked in with Windows file format endings stripped off? Is there anything I could do on the CVS server side to prevent certain file types (*.sh) or folders containing such files from allowing Windows file format endings or ^M endings?

Thanks.

Rez


_________________________________________________________________
Windows 7: It helps you do more. Explore Windows 7.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009
Spiro Trikaliotis
2009-10-30 21:18:57 UTC
Permalink
Hello Rez,

* On Fri, Oct 30, 2009 at 01:03:36PM -0700 Rez P wrote:

> Although they get created on Window client machines, how can I ensure
> once they're checked in, they get checked in with Windows file format
> endings stripped off?

This is standard behaviour of CVS as long as you have not configured
anything else. Every text file is checked in with Unix line endings (LF)
only. In fact, you must explicitly mark a file as binary to check in the
Windows line endings.

Having said that, I do not know what exact behaviour WinCVS has here. It
might mess with that somehow. I never used WinCVS but for some small
tests, thus, I cannot comment. WinCVS uses CVSNT internally, which is a
different thing than CVS.

So, why do you see Windows line endings when you check out? That's
because the CVS client tries to adapt to the line endings that are
present on the system it works. Thus, the CVS changes LF -> CR/LF when
you are using a native Windows client.

(Note: IIRC, the Cygwin CVS client will check out with Unix line endings
if Cygwin is set to Unix line endings. You might want to use that)


To make a long story short: Regardless of the line endings you see on
your Windows system, as long as you do not check in the files as binary
(-kb) explicitly, the files are stored the Unix line endings on the
server. Thus, checking them out on a Linux machine will give them the
correct line endings. (I assume WinCVS + CVSNT behave the same here, or
you have a problem with them. They have a different mailing list,
though.)

Thus, I would not care about the line endings on Windows. If you really,
really need it different, then

1. use CVS from Cygwin, or
2. mark all files as binary and make sure you check them in after
dos2unix only


HTH,
Spiro.

--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Rez P
2009-10-30 22:14:03 UTC
Permalink
Thanks for your thorough reply Spiro. I suspected that they were ending up with the correct file endings on each environment respectively and that the wincvs client was converting them. So it looks like once I check them out, I have to run dos2unix on them and tar them up and ship them back to our application servers. thanks again.

> Date: Fri, 30 Oct 2009 22:18:57 +0100
> From: list-info-***@spiro.trikaliotis.net
> To: info-***@nongnu.org
> Subject: Re: dos2unix file endings
>
> Hello Rez,
>
> * On Fri, Oct 30, 2009 at 01:03:36PM -0700 Rez P wrote:
>
> > Although they get created on Window client machines, how can I ensure
> > once they're checked in, they get checked in with Windows file format
> > endings stripped off?
>
> This is standard behaviour of CVS as long as you have not configured
> anything else. Every text file is checked in with Unix line endings (LF)
> only. In fact, you must explicitly mark a file as binary to check in the
> Windows line endings.
>
> Having said that, I do not know what exact behaviour WinCVS has here. It
> might mess with that somehow. I never used WinCVS but for some small
> tests, thus, I cannot comment. WinCVS uses CVSNT internally, which is a
> different thing than CVS.
>
> So, why do you see Windows line endings when you check out? That's
> because the CVS client tries to adapt to the line endings that are
> present on the system it works. Thus, the CVS changes LF -> CR/LF when
> you are using a native Windows client.
>
> (Note: IIRC, the Cygwin CVS client will check out with Unix line endings
> if Cygwin is set to Unix line endings. You might want to use that)
>
>
> To make a long story short: Regardless of the line endings you see on
> your Windows system, as long as you do not check in the files as binary
> (-kb) explicitly, the files are stored the Unix line endings on the
> server. Thus, checking them out on a Linux machine will give them the
> correct line endings. (I assume WinCVS + CVSNT behave the same here, or
> you have a problem with them. They have a different mailing list,
> though.)
>
> Thus, I would not care about the line endings on Windows. If you really,
> really need it different, then
>
> 1. use CVS from Cygwin, or
> 2. mark all files as binary and make sure you check them in after
> dos2unix only
>
>
> HTH,
> Spiro.
>
> --
> Spiro R. Trikaliotis http://opencbm.sf.net/
> http://www.trikaliotis.net/ http://www.viceteam.org/
>
>

_________________________________________________________________
Windows 7: Simplify your PC. Learn more.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen1:102009
Jim Hyslop
2009-10-31 04:48:56 UTC
Permalink
Rez P wrote:
> Thanks for your thorough reply Spiro. I suspected that they were
> ending up with the correct file endings on each environment
> respectively and that the wincvs client was converting them. So it
> looks like once I check them out, I have to run dos2unix on them and
> tar them up and ship them back to our application servers. thanks
> again.

Hang on a sec - your original message didn't mention anything about tar.
Is this something you do already, or something you're going to add into
the mix? Can your application server check the files out directly, or
run a commit script on the CVS server that'll tar and upload the files?
That would save having to convert the line endings.

- --
Jim Hyslop
Dreampossible: Better software. Simply. http://www.dreampossible.ca
Consulting * Mentoring * Training in
C/C++ * OOD * SW Development & Practices * Version Management
Spiro Trikaliotis
2009-11-01 08:54:46 UTC
Permalink
Hello Rez,

* On Fri, Oct 30, 2009 at 03:14:03PM -0700 Rez P wrote:

> So it looks like once I check them out, I have to run dos2unix
> on them and tar them up and ship them back to our application
> servers.

Please also consider the advices by Jim and Larry!

This will remind me to ask about the "WHY" before giving such an answer
again... ;)

Best regards,
Spiro.

--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Rez P
2009-11-02 22:54:48 UTC
Permalink
Thanks for your help and suggestions Jim. Since I check out from cvs and do my builds with Ant. I found the quickest solution through Ant by using: <fixcrlf srcdir="scripts" includes="**/*.sh, **/*.sql, **/*.conf" eol="lf" eof="remove" />. It's a roundabout way to check out the files to windows machine from the linux server and then turn around and ship them back and deploy them on a linux server. Unfortunately the users on the production servers don't have access to the cvs linux server and I have to package and deliver the files.



Rez

> Date: Sat, 31 Oct 2009 00:48:56 -0400
> From: ***@dreampossible.ca
> To: ***@hotmail.com
> CC: list-info-***@spiro.trikaliotis.net; info-***@nongnu.org
> Subject: Re: dos2unix file endings
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Rez P wrote:
> > Thanks for your thorough reply Spiro. I suspected that they were
> > ending up with the correct file endings on each environment
> > respectively and that the wincvs client was converting them. So it
> > looks like once I check them out, I have to run dos2unix on them and
> > tar them up and ship them back to our application servers. thanks
> > again.
>
> Hang on a sec - your original message didn't mention anything about tar.
> Is this something you do already, or something you're going to add into
> the mix? Can your application server check the files out directly, or
> run a commit script on the CVS server that'll tar and upload the files?
> That would save having to convert the line endings.
>
> - --
> Jim Hyslop
> Dreampossible: Better software. Simply. http://www.dreampossible.ca
> Consulting * Mentoring * Training in
> C/C++ * OOD * SW Development & Practices * Version Management
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkrrwbgACgkQLdDyDwyJw+NP4wCgsQXFI6fXYKnDpc7buBZnZRpu
> 8k4AoLMJ+zd85CFp5qPEhyZPGBDS9ur/
> =gTM8
> -----END PGP SIGNATURE-----

_________________________________________________________________
Hotmail: Trusted email with Microsoft's powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
http://clk.atdmt.com/GBL/go/177141664/direct/01/
Larry Jones
2009-10-31 13:31:37 UTC
Permalink
Spiro Trikaliotis writes:
>
> (Note: IIRC, the Cygwin CVS client will check out with Unix line endings
> if Cygwin is set to Unix line endings. You might want to use that)

Only if you never ever use any regular Windows tools, too. Otherwise,
you're almost certain to end up with a mish mash of line endings, some
DOS and some Unix, even within the same file, that is nearly impossible
to straighten out.
--
Larry Jones

OK, there IS a middle ground, but it's for sissy weasels. -- Calvin
Spiro Trikaliotis
2009-11-01 08:53:14 UTC
Permalink
Hello Larry,

* On Sat, Oct 31, 2009 at 09:31:37AM -0400 Larry Jones wrote:
> Spiro Trikaliotis writes:
> >
> > (Note: IIRC, the Cygwin CVS client will check out with Unix line endings
> > if Cygwin is set to Unix line endings. You might want to use that)
>
> Only if you never ever use any regular Windows tools, too.

Yes, thanks for pointing out this important point which I forgot to
mention.

Best regards,
Spiro.

--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Larry Jones
2009-10-31 13:33:53 UTC
Permalink
Rez P writes:
>
> So it looks like once I check them out, I have to run dos2unix on them
> and tar them up and ship them back to our application servers.

It would be much simpler to just check them out (or export them) on the
servers. Or on one server and then rsync the others.
--
Larry Jones

I don't think math is a science, I think it's a religion. -- Calvin
Rez P
2009-11-02 22:56:06 UTC
Permalink
Thanks for the suggestion. I just changed my Ant scripts to do the job.

> Subject: Re: dos2unix file endings
> To: ***@hotmail.com
> Date: Sat, 31 Oct 2009 09:33:53 -0400
> CC: list-info-***@spiro.trikaliotis.net; info-***@nongnu.org
> From: ***@siemens.com
>
> Rez P writes:
> >
> > So it looks like once I check them out, I have to run dos2unix on them
> > and tar them up and ship them back to our application servers.
>
> It would be much simpler to just check them out (or export them) on the
> servers. Or on one server and then rsync the others.
> --
> Larry Jones
>
> I don't think math is a science, I think it's a religion. -- Calvin

_________________________________________________________________
Bing brings you maps, menus, and reviews organized in one place.
http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1
Loading...