如何在Windows上以Unix格式下载厨师食谱? [英] How do I get chef cookbooks to be downloaded in Unix format on Windows?

查看:75
本文介绍了如何在Windows上以Unix格式下载厨师食谱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Vagrant,Chef solo和berkshelf在Windows 7上使用VirtualBox运行Linux VM。

I'm using Vagrant, Chef solo and berkshelf to run up a Linux VM on Windows 7 using VirtualBox.

食谱是从git下载的,并带有Windows行尾。其中之一是Perl脚本,然后将其上载到vm并执行。但是它失败,因为第一行是

Cookbooks are downloaded from git and arrive with windows line endings. One of these is a Perl script, which is then uploaded to the vm and executed. However it fails because the first line is

#!/usr/bin/perl

,Linux VM将其视为命令

and the Linux VM sees this as the command

#!/usr/bin/perl^M

我该如何配置所需的任何工具(可能是Chef?)以Unix格式下载.pl文件?

How can I configure whichever tool needs it (probably Chef?) to download .pl files in Unix format?

推荐答案

好了,现在解决此问题似乎为时已晚点具有配置设置

Well, it seems it's too late to fix things at this point with configuration settings

git 使用的算法如下:


  1. 索引时间 git可以转换文本文件从特定于平台的行尾样式(例如,Windows上为CRLF,Linux和Mac上为LF,旧Mac上可能为CR)结帐git的LF

  2. 内部EOL表示形式将内部表示形式转换为所有文本文件中特定于平台的EOL
  3. >
  1. at index time git may convert a text file from platform specific end-of-line style (i.e. CRLF on Windows, and LF on Linux and Mac, probably CR on old Macs) to an "internal EOL representation" which is LF
  2. at checkout git converts the internal representation into platform-specific EOLs in all text files

控制是否应用此逻辑的设置称为 core.autocrlf

The setting controlling whether this logic is applied or not is called core.autocrlf

最后解决了问题,您应该将存储库准备为跨平台,即在所有(必要的)提交中对文件重新索引,以便将它们作为转换后的文本文件放入索引中。它是不应该修改现有提交的公共存储库吗?解决问题的方法取决于公开性。

So to finally solve the problem you should prepare your repository to be "cross-platform", i.e. re-index the files in all (necessary) commits so that they are put into the index as "converted text files". Is it a public repository in which existing commits shouldn't be modified or not? The recipe how to fix things depends on the "publicity".

您需要确定对您来说更重要的事情:

You need to decide what is more important for you:


  1. 您需要在存储库中的所有现有提交中使用正确的行尾。但是,所有现有提交都将被覆盖,存储库的其他用户将不得不重新克隆它,然后重新应用所有更改(带有很多琐碎的冲突)

  2. 通过仅为实际分支中的最高提交创建修订来修复行尾。现有的检出将照常获得新的提交,潜在的用户问题将更少。

这里是食谱

这篇关于如何在Windows上以Unix格式下载厨师食谱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆