node.js - 从源代码构建旧版本的 Atom 文本编辑器?

标签 node.js linux

我从 git(来自 https://github.com/atom/atom)获得了 Atom,并在前一段时间检查了版本 1.5.0-beta0,当时我用它构建了一个 32 位 deb;我在 Ubuntu 14.04 上。

现在,我想构建完全相同的版本,作为 64 位 deb。本来以为很简单,就直接在git源码文件夹下:

script/build
script/grunt mkdeb

这为我构建了一个 /tmp/atom-build/atom-1.5.0-beta0-amd64.deb,但是当我安装它时,它告诉我:

/usr/share/atom/atom: error while loading shared libraries: libnotify.so.4: cannot open shared object file: No such file or directory

...这很奇怪,因为在我的 64 位系统上:

$ locate libnotify.so.4
/usr/lib/x86_64-linux-gnu/libnotify.so.4
/usr/lib/x86_64-linux-gnu/libnotify.so.4.0.0

我想,这不可能,atom 的构建系统无法区分 32 位和 64 位构建?但事实确实如此,因为我尝试了 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu atom 并且它给了我一些错误(编辑:很可能是:“/usr/share/atom/atom: error while loading shared libraries: libnotify.so.4: wrong ELF class: ELFCLASS64") 这告诉我它可能确实有问题......

太棒了。好的,现在我先尝试清洁:

script/clean
script/build

现在,当我在这里通过无线网络进行构建时,npm(或 apm)会完全阻塞我的互联网连接,最终产生如下消息:

....
Installing build modules...
npm ERR! fetch failed https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.5.0.tgz
....

此时,如果我尝试在 Firefox 中加载一个页面,那么它只会一直旋转,而不会加载该页面。

于是,我从无线改成了有线,最后变成了这样:

atom_git$ script/clean
atom_git$ script/build
Node: v4.0.0
npm: v2.14.2
Installing build modules...
=> Took 94239ms.

Installing apm...
=> Took 67760ms.

Deleting old packages...
=> Took 418ms.

Installing modules ✓
Installing atom-dark-syntax@0.27.0 ✓
Installing atom-dark-ui@0.51.0 ✓
Installing atom-light-syntax@0.28.0 ✓
Installing atom-light-ui@0.43.0 ✓
Installing base16-tomorrow-dark-theme@1.1.0 ✓
Installing base16-tomorrow-light-theme@1.1.1 ✓
Installing one-dark-ui@1.1.9 ✓
Installing one-light-ui@1.1.9 ✓
Installing one-dark-syntax@1.1.2 ✓
Installing one-light-syntax@1.1.2 ✓
Installing solarized-dark-syntax@0.39.0 ✓
Installing solarized-light-syntax@0.23.0 ✓
Installing about@1.3.0 ✓
Installing archive-view@0.61.0 ✓
Installing autocomplete-atom-api@0.9.2 ✓
Installing autocomplete-css@0.11.0 ✓
Installing autocomplete-html@0.7.2 ✓
Installing autocomplete-plus@2.25.0 ✓
Installing autocomplete-snippets@1.9.0 ✓
Installing autoflow@0.26.0 ✓
Installing autosave@0.23.0 ✓
Installing background-tips@0.26.0 ✓
Installing bookmarks@0.38.0 ✓
Installing bracket-matcher@0.79.0 ✓
Installing command-palette@0.38.0 ✓
Installing deprecation-cop@0.54.0 ✓
Installing dev-live-reload@0.47.0 ✓
Installing encoding-selector@0.21.0 ✓
Installing exception-reporting@0.37.0 ✓
Installing find-and-replace@0.195.0 ✓
Installing fuzzy-finder@0.94.0 ✓
Installing git-diff@0.57.0 ✓
Installing go-to-line@0.30.0 ✓
Installing grammar-selector@0.48.0 ✓
Installing image-view@0.56.0 ✓
Installing incompatible-packages@0.25.0 ✓
Installing keybinding-resolver@0.33.0 ✓
Installing line-ending-selector@0.3.0 ✓
Installing link@0.31.0 ✓
Installing markdown-preview@0.157.1 ✓
Installing metrics@0.53.1 ✓
Installing notifications@0.62.1 ✓
Installing open-on-github@0.40.0 ✓
Installing package-generator@0.41.0 ✓
Installing settings-view@0.232.3 ✓
Installing snippets@1.0.1 ✓
Installing spell-check@0.65.0 ✓
Installing status-bar@0.80.0 ✓
Installing styleguide@0.45.0 ✓
Installing symbols-view@0.110.1 ✓
Installing tabs@0.88.0 ✗
Package version: 0.88.0 not found

...现在这里的构建过程停止了。我想该死的——我怎么能从源代码构建,既然它们依赖于不断被删除的互联网包?但后来我浏览了一下,发现https://github.com/atom/tabs/releases/tag/v0.88.0 - 伟大的;所以我尝试了这个:

cd /tmp
wget https://github.com/atom/tabs/archive/v0.88.0.zip
unzip v0.88.0.zip

cd /path/to/atom_git
mv /tmp/tabs-0.88.0 ./node_modules/

...并再次尝试构建:

atom_git$ script/build
Node: v4.0.0
npm: v2.13.3
Installing build modules...
=> Took 3473ms.

Installing apm...
=> Took 1122ms.

Deleting old packages...
Removing tabs-0.88.0 ✓
=> Took 1290ms.

Installing modules ✓
Installing tabs@0.88.0 ✗
Package version: 0.88.0 not found

该死的 - 它找到了 tabs@0.88.0,并将其删除!!我现在如何说服构建过程,而不是在线寻找 tabs@0.88.0,而是使用我提供给它的那个,这样构建脚本就可以继续构建?

最佳答案

好吧,我想我到了某个地方;

第一个问题是,当我解压缩 v0.88.0.zip 时,如上面的代码片段所示,我得到一个名为 tabs-0.88.0 的目录,我直接移动到 atom_git/node_modules/。但是,./script/bootstrap 告诉我们“Deleting old packages...”是由于 apm clean 造成的,如果我们调用帮助:

atom_git$ ./apm/node_modules/atom-package-manager/bin/apm clean --help
Usage: apm clean
Deletes all packages in the node_modules folder that are not referenced
as a dependency in the package.json file.

啊 - 我的 atom 源的 package.json 包含:

atom_git$ grep tabs package.json 
    "tabs": "0.88.0",

因此,它希望文件夹被命名为 tabs - 而不是 tabs-0.88.0;所以正确的做法是:

cd /tmp
wget https://github.com/atom/tabs/archive/v0.88.0.zip
unzip v0.88.0.zip

cd /path/to/atom_git
mv /tmp/tabs-0.88.0 ./node_modules/tabs

然后我在 tree-view 上遇到了同样的问题;所以我做了

cd /tmp
wget https://github.com/atom/tree-view/archive/v0.198.1.zip
unzip v0.198.1.zip

cd /path/to/atom_git
mv /tmp/tree-view-0.198.1 ./node_modules/tree-view

这使得构建继续直到:

Running "compile-packages-slug" task
>> tabs: No README data
Warning: Task "compile-packages-slug" failed. Use --force to continue.

解决方案在:NPM - How to fix "No readme data" -- 事实证明,现在插件的 package.json 必须包含一个 readme key ,所以我在 atom_git/node_modules/tabs/package 中添加了类似的内容。 json:

...
  "dependencies": {
    "temp": "~0.8.1",
    "underscore-plus": "1.x"
  },
  "readme": "# Tabs package",
  "readmeFilename": "README.md",
  "devDependencies": {
...

... 和 tree-view 一样 - 最后构建完成,script/grunt mkdeb 也工作了,创建了一个 64 位 deb;这个 deb 是可安装的 - atom 终于为我运行了(它在第一次启动时仍然吐出一个错误,我没有记录(编辑:它可能是“Uncaught TypeError: Cannot读取未定义的属性“长度”") - 但第二次启动没有导致任何错误,所以我想现在没问题了)...

编辑:不,这不行,每次我键入一个键时,它都会给我 Uncaught TypeError: Cannot read property 'length' of undefined...

这真是浪费时间......

关于node.js - 从源代码构建旧版本的 Atom 文本编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41040438/

相关文章:

node.js - 测试 WebSocket 时如何阻止 Jest 挂起?

javascript - Function.prototype.apply 给我留下了 undefined is not a function 错误

c++ - 通过施加内存压力来降低CPU频率

Linux:弱链接整个库,如 OS X ld -weak-lfoo

linux - 如何使用 sed 和 awk 命令提取模式?

javascript - 使用js过滤重复记录并添加附加条件插入数组

node.js - 从拉取的 github 项目启动 React App

node.js - Dialogflow agent.add 无法与 Promise 一起使用

Linux:查找包含 4 或 5 个字符的文件名

java - 在编写时也使 java 中新创建的文件不可读