mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
52082a0e4d
@ -1,19 +1,15 @@
|
||||
“开箱即用” 的 Kubernetes 集群
|
||||
============================================================
|
||||
|
||||
|
||||
这是我以前的 [10 分钟内配置 Kubernetes][10] 教程的精简版和更新版。我删除了一些我认为可以去掉的内容,所以,这个指南仍然是可理解的。当你想在云上创建一个集群或者尽可能快地构建基础设施时,你可能会用到它。
|
||||
这是我以前的 [10 分钟内配置 Kubernetes][10] 教程的精简版和更新版。我删除了一些我认为可以去掉的内容,所以,这个指南仍然是通顺的。当你想在云上创建一个集群或者尽可能快地构建基础设施时,你可能会用到它。
|
||||
|
||||
### 1.0 挑选一个主机
|
||||
|
||||
我们在本指南中将使用 Ubuntu 16.04,这样你就可以直接拷贝/粘贴所有的指令。下面是我用本指南测试过的几种环境。根据你运行的主机,你可以从中挑选一个。
|
||||
|
||||
* [DigitalOcean][1] - 开发者云
|
||||
|
||||
* [Civo][2] - UK 开发者云
|
||||
|
||||
* [Packet][3] - 裸机云
|
||||
|
||||
* 2x Dell Intel i7 服务器 —— 它在我家中
|
||||
|
||||
> Civo 是一个相对较新的开发者云,我比较喜欢的一点是,它开机时间只有 25 秒,我就在英国,因此,它的延迟很低。
|
||||
@ -25,14 +21,12 @@
|
||||
下面是一些其他的指导原则:
|
||||
|
||||
* 最好选至少有 2 GB 内存的双核主机
|
||||
|
||||
* 在准备主机的时候,如果你可以自定义用户名,那么就不要使用 root。例如,Civo 通常让你在 `ubuntu`、`civo` 或者 `root` 中选一个。
|
||||
|
||||
现在,在每台机器上都运行以下的步骤。它将需要 5-10 钟时间。如果你觉得太慢了,你可以使用我的脚本 [kept in a Gist][11]:
|
||||
现在,在每台机器上都运行以下的步骤。它将需要 5-10 钟时间。如果你觉得太慢了,你可以使用我[放在 Gist][11] 的脚本 :
|
||||
|
||||
```
|
||||
$ curl -sL https://gist.githubusercontent.com/alexellis/e8bbec45c75ea38da5547746c0ca4b0c/raw/23fc4cd13910eac646b13c4f8812bab3eeebab4c/configure.sh | sh
|
||||
|
||||
```
|
||||
|
||||
### 1.2 登入和安装 Docker
|
||||
@ -42,7 +36,6 @@ $ curl -sL https://gist.githubusercontent.com/alexellis/e8bbec45c75ea38da5547746
|
||||
```
|
||||
$ sudo apt-get update \
|
||||
&& sudo apt-get install -qy docker.io
|
||||
|
||||
```
|
||||
|
||||
### 1.3 禁用 swap 文件
|
||||
@ -69,7 +62,6 @@ $ sudo apt-get update \
|
||||
kubelet \
|
||||
kubeadm \
|
||||
kubernetes-cni
|
||||
|
||||
```
|
||||
|
||||
### 1.5 创建集群
|
||||
@ -80,7 +72,6 @@ $ sudo apt-get update \
|
||||
|
||||
```
|
||||
$ sudo kubeadm init
|
||||
|
||||
```
|
||||
|
||||
如果你错过一个步骤或者有问题,`kubeadm` 将会及时告诉你。
|
||||
@ -90,41 +81,37 @@ $ sudo kubeadm init
|
||||
```
|
||||
mkdir -p $HOME/.kube
|
||||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
||||
|
||||
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
||||
```
|
||||
|
||||
确保你一定要记下如下的加入 token 命令。
|
||||
确保你一定要记下如下的加入 `token` 的命令。
|
||||
|
||||
```
|
||||
$ sudo kubeadm join --token c30633.d178035db2b4bb9a 10.0.0.5:6443 --discovery-token-ca-cert-hash sha256:<hash>
|
||||
|
||||
```
|
||||
|
||||
### 2.0 安装网络
|
||||
|
||||
Kubernetes 可用于任何网络供应商的产品或服务,但是,默认情况下什么也没有,因此,我们使用来自 [Weaveworks][12] 的 Weave Net,它是 Kebernetes 社区中非常流行的选择之一。它倾向于不需要额外配置的 “开箱即用”。
|
||||
许多网络提供商提供了 Kubernetes 支持,但是,默认情况下 Kubernetes 都没有包括。这里我们使用来自 [Weaveworks][12] 的 Weave Net,它是 Kebernetes 社区中非常流行的选择之一。它近乎不需要额外配置的 “开箱即用”。
|
||||
|
||||
```
|
||||
$ kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
|
||||
|
||||
```
|
||||
|
||||
如果在你的主机上启用了私有网络,那么,你可能需要去修改 Weavenet 使用的私有子网络,以便于为 Pods(容器)分配 IP 地址。下面是命令示例:
|
||||
如果在你的主机上启用了私有网络,那么,你可能需要去修改 Weavenet 使用的私有子网络,以便于为 Pod(容器)分配 IP 地址。下面是命令示例:
|
||||
|
||||
```
|
||||
$ curl -SL "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')&env.IPALLOC_RANGE=172.16.6.64/27" \
|
||||
| kubectl apply -f -
|
||||
|
||||
```
|
||||
|
||||
> Weave 也有很酷的称为 Weave Cloud 的可视化工具。它是免费的,你可以在它上面看到你的 Pods 之间的路径流量。[这里有一个使用 OpenFaaS 项目的示例][6]。
|
||||
> Weave 也有很酷的称为 Weave Cloud 的可视化工具。它是免费的,你可以在它上面看到你的 Pod 之间的路径流量。[这里有一个使用 OpenFaaS 项目的示例][6]。
|
||||
|
||||
### 2.2 在集群中加入工作节点
|
||||
|
||||
现在,你可以切换到你的每一台工作节点,然后使用 1.5 节中的 `kubeadm join` 命令。运行完成后,登出那个工作节点。
|
||||
|
||||
### 3.0 收益
|
||||
### 3.0 收获
|
||||
|
||||
到此为止 —— 我们全部配置完成了。你现在有一个正在运行着的集群,你可以在它上面部署应用程序。如果你需要设置仪表板 UI,你可以去参考 [Kubernetes 文档][13]。
|
||||
|
||||
@ -134,21 +121,21 @@ NAME STATUS ROLES AGE VERSION
|
||||
openfaas1 Ready master 20m v1.9.2
|
||||
openfaas2 Ready <none> 19m v1.9.2
|
||||
openfaas3 Ready <none> 19m v1.9.2
|
||||
|
||||
```
|
||||
|
||||
如果你想看到我一步一步创建集群并且展示 `kubectl` 如何工作的视频,你可以看下面我的视频,你可以订阅它。
|
||||
|
||||
![](https://youtu.be/6xJwQgDnMFE)
|
||||
|
||||
想在你的 Mac 电脑上,使用 Minikube 或者 Docker 的 Mac Edge 版本,安装一个 “开箱即用” 的 Kubernetes 集群,[阅读在这里的我的评估和第一印象][14]。
|
||||
你也可以在你的 Mac 电脑上,使用 Minikube 或者 Docker 的 Mac Edge 版本,安装一个 “开箱即用” 的 Kubernetes 集群。[阅读在这里的我的评估和第一印象][14]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.alexellis.io/your-instant-kubernetes-cluster/
|
||||
|
||||
作者:[Alex Ellis ][a]
|
||||
作者:[Alex Ellis][a]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,14 +1,17 @@
|
||||
如何在 Linux 中查找文件
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0)
|
||||
如果你是 Windows 或 OSX 的非高级用户,那么可能使用 GUI 来查找文件。你也可能发现界面限制,令人沮丧,或者两者兼而有之,并学会组织文件并记住它们的确切顺序。你也可以在 Linux 中做到这一点 - 但你不必这样做。
|
||||
> 使用简单的命令在 Linux 下基于类型、内容等快速查找文件。
|
||||
|
||||
Linux 的好处之一是它提供了多种方式来处理。你可以打开任何文件管理器或按下 `ctrl` +`f`,你也可以使用程序手动打开文件,或者你可以开始输入字母,它会过滤当前目录列表。
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0)
|
||||
|
||||
如果你是 Windows 或 OSX 的非资深用户,那么可能使用 GUI 来查找文件。你也可能发现界面受限,令人沮丧,或者两者兼而有之,并学会了组织文件并记住它们的确切顺序。你也可以在 Linux 中做到这一点 —— 但你不必这样做。
|
||||
|
||||
Linux 的好处之一是它提供了多种方式来处理。你可以打开任何文件管理器或按下 `Ctrl+F`,你也可以使用程序手动打开文件,或者你可以开始输入字母,它会过滤当前目录列表。
|
||||
|
||||
![Screenshot of how to find files in Linux with Ctrl+F][2]
|
||||
|
||||
使用 Ctrl+F 在 Linux 中查找文件的截图
|
||||
*使用 Ctrl+F 在 Linux 中查找文件的截图*
|
||||
|
||||
但是如果你不知道你的文件在哪里,又不想搜索整个磁盘呢?对于这个以及其他各种情况,Linux 都很合适。
|
||||
|
||||
@ -16,7 +19,7 @@ Linux 的好处之一是它提供了多种方式来处理。你可以打开任
|
||||
|
||||
如果你习惯随心所欲地放文件,Linux 文件系统看起来会让人望而生畏。对我而言,最难习惯的一件事是找到程序在哪里。
|
||||
|
||||
例如,`which bash` 通常会返回 `/bin/bash`,但是如果你下载了一个程序并且它没有出现在你的菜单中,`which` 命令可以是一个很好的工具。
|
||||
例如,`which bash` 通常会返回 `/bin/bash`,但是如果你下载了一个程序并且它没有出现在你的菜单中,那么 `which` 命令就是一个很好的工具。
|
||||
|
||||
一个类似的工具是 `locate` 命令,我发现它对于查找配置文件很有用。我不喜欢输入程序名称,因为像 `locate php` 这样的简单程序通常会提供很多需要进一步过滤的结果。
|
||||
|
||||
@ -25,31 +28,29 @@ Linux 的好处之一是它提供了多种方式来处理。你可以打开任
|
||||
* `man which`
|
||||
* `man locate`
|
||||
|
||||
### find
|
||||
|
||||
`find` 工具提供了更先进的功能。以下是我安装在许多服务器上的脚本示例,我用于确保特定模式的文件(也称为 glob)仅存在五天,并且所有早于此的文件都将被删除。 (自上次修改以来,分数用于保留最多 240 分钟的偏差)
|
||||
|
||||
### Find
|
||||
|
||||
`find` 工具提供了更先进的功能。以下是我安装在许多服务器上的脚本示例,我用于确保特定模式的文件(也称为 glob)仅存在五天,并且所有早于该文件的文件都将被删除。 (自上次修改以来,十进制用于计算最多 240 分钟的差异)
|
||||
```
|
||||
find ./backup/core-files*.tar.gz -mtime +4.9 -exec rm {} \;
|
||||
|
||||
```
|
||||
|
||||
`find` 工具有许多高级用法,但最常见的是对结果执行命令,而不用链式地按照类型、创建日期、修改日期过滤文件。
|
||||
|
||||
find 的另一个有趣用处是找到所有有可执行权限的文件。这有助于确保没有人在你昂贵的服务器上安装比特币挖矿程序或僵尸网络。
|
||||
`find` 的另一个有趣用处是找到所有有可执行权限的文件。这有助于确保没有人在你昂贵的服务器上安装比特币挖矿程序或僵尸网络。
|
||||
|
||||
```
|
||||
find / -perm /+x
|
||||
|
||||
```
|
||||
|
||||
有关 `find` 的更多信息,请使用 `man find` 参考 `man` 页面。
|
||||
|
||||
### Grep
|
||||
### grep
|
||||
|
||||
想通过内容中查找文件? Linux 已经实现了。你可以使用许多 Linux 工具来高效搜索符合模式的文件,但是 `grep` 是我经常使用的工具。
|
||||
|
||||
假设你有一个程序发布代码引用和堆栈跟踪的错误消息。你要在日志中找到这些。 grep 不总是最好的方法,但如果文件是一个给定的值,我经常使用 `grep -R`。
|
||||
假设你有一个程序发布代码引用和堆栈跟踪的错误消息。你要在日志中找到这些。 `grep` 不总是最好的方法,但如果文件是一个给定的值,我经常使用 `grep -R`。
|
||||
|
||||
越来越多的 IDE 正在实现查找功能,但是如果你正在访问远程系统或出于任何原因没有 GUI,或者如果你想在当前目录递归查找,请使用:`grep -R {searchterm} ` 或在支持 `egrep` 别名的系统上,只需将 `-e` 标志添加到命令 `egrep -r {regex-pattern}`。
|
||||
|
||||
@ -62,9 +63,9 @@ find / -perm /+x
|
||||
via: https://opensource.com/article/18/4/how-find-files-linux
|
||||
|
||||
作者:[Lewis Cowles][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,63 @@
|
||||
Get started with Pidgin: An open source replacement for Skype for Business
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/meeting-team-listen-communicate.png?itok=KEBP6vZ_)
|
||||
Technology is at an interesting crossroads, where Linux rules the server landscape but Microsoft rules the enterprise desktop. Office 365, Skype for Business, Microsoft Teams, OneDrive, Outlook... the list goes on of Microsoft software and services that dominate the enterprise workspace.
|
||||
|
||||
What if you could replace that proprietary software with free and open source applications and make them work with an Office 365 backend you have no choice but to use? Buckle up, because that is exactly what we are going to do with Pidgin, an open source replacement for Skype.
|
||||
|
||||
### Installing Pidgin and SIPE
|
||||
|
||||
Microsoft's Office Communicator became Microsoft Lync which became what we know today as Skype for Business. There are [pay software options][1] for Linux that provide feature parity with Skype for Business, but [Pidgin][2] is a fully free and open source option licensed under the GNU GPL.
|
||||
|
||||
Pidgin can be found in just about every Linux distro's repository, so getting your hands on it should not be a problem. The only Skype feature that won't work with Pidgin is screen sharing, and file sharing can be a bit hit or miss—but there are ways to work around it.
|
||||
|
||||
You also need a [SIPE][3] plugin, as it's part of the secret sauce to make Pidgin work as a Skype for Business replacement. Please note that the `sipe` library has different names in different distros. For example, the library's name on System76's Pop_OS! is `pidgin-sipe` while in the Solus 3 repo it is simply `sipe`.
|
||||
|
||||
With the prerequisites out of the way, you can begin configuring Pidgin.
|
||||
|
||||
### Configuring Pidgin
|
||||
|
||||
When firing up Pidgin for the first time, click on **Add** to add a new account. In the Basic tab (shown in the screenshot below), select** Office Communicator** in the **Protocol** drop-down, then type your **business email address** in the **Username** field.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pidgin_basic_account_screen_final.png?itok=1zoSbZjy)
|
||||
|
||||
Next, click on the Advanced tab. In the **Server[:Port]** field enter **sipdir.online.lync.com:443** and in **User Agent** enter **UCCAPI/16.0.6965.5308 OC/16.0.6965.2117**.
|
||||
|
||||
Your Advanced tab should now look like this:
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pidgin_advanced_account_screen.png?itok=Z6loRfGi)
|
||||
|
||||
You shouldn't need to make any changes to the Proxy tab or the Voice and Video tab. Just to be certain, make sure **Proxy type** is set to **Use Global Proxy Settings** and in the Voice and Video tab, the **Use silence suppression** checkbox is **unchecked**.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pidgin_account_proxy_screen.png?itok=iDgszWy0)
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pidgin_voiceandvideo_screen.png?itok=klkbt5hr)
|
||||
|
||||
After you've completed those configurations, click **Add,** and you'll be prompted for your email account's password.
|
||||
|
||||
### Adding contacts
|
||||
|
||||
To add contacts to your buddy list, click on **Manage Accounts** in the **Buddy Window**. Hover over your account and select **Contact Search** to look up your colleagues. If you run into any problems when searching by first and last name, try searching with your colleague's full email address, and you should always get the right person.
|
||||
|
||||
You are now up and running with a Skype for Business replacement that gives you about 98% of the functionality you need to banish the proprietary option from your desktop.
|
||||
|
||||
Ray Shimko will be speaking about [Linux in a Microsoft World][4] at [LinuxFest NW][5] April 28-29. See program highlights or register to attend.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/pidgin-open-source-replacement-skype-business
|
||||
|
||||
作者:[Ray Shimko][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/shickmo
|
||||
[1]:https://tel.red/linux.php
|
||||
[2]:https://pidgin.im/
|
||||
[3]:http://sipe.sourceforge.net/
|
||||
[4]:https://www.linuxfestnorthwest.org/conferences/lfnw18/program/proposals/32
|
||||
[5]:https://www.linuxfestnorthwest.org/conferences/lfnw18
|
@ -1,3 +1,6 @@
|
||||
translating---geekpi
|
||||
|
||||
|
||||
Easily Install Android Studio in Ubuntu And Linux Mint
|
||||
======
|
||||
[Android Studio][1], Google’s own IDE for Android development, is a nice alternative to Eclipse with ADT plugin. Android Studio can be installed from its source code but in this quick post, we shall see **how to install Android Studio in Ubuntu 18.04, 16.04 and corresponding Linux Mint variants**.
|
||||
|
@ -1,3 +1,5 @@
|
||||
translating by Auk7F7
|
||||
|
||||
Learn to code with Thonny — a Python IDE for beginners
|
||||
======
|
||||
|
||||
|
@ -1,123 +0,0 @@
|
||||
Translating by MjSeven
|
||||
|
||||
|
||||
Could we run Python 2 and Python 3 code in the same VM with no code changes?
|
||||
======
|
||||
|
||||
Theoretically, yes. Zed Shaw famously jested that if this is impossible then Python 3 must not be Turing-complete. But in practice, this is unrealistic and I'll share why by giving you a few examples.
|
||||
|
||||
### What does it mean to be a dict?
|
||||
|
||||
Let’s imagine a Python 6 VM. It can read `module3.py` which was written for Python 3.6 but in this module it can import `module2.py` which was written for Python 2.7 and successfully use it with no issues. This is obviously toy code but let’s say that `module2.py` includes functions like:
|
||||
```
|
||||
|
||||
|
||||
def update_config_from_dict(config_dict):
|
||||
items = config_dict.items()
|
||||
while items:
|
||||
k, v = items.pop()
|
||||
memcache.set(k, v)
|
||||
|
||||
def config_to_dict():
|
||||
result = {}
|
||||
for k, v in memcache.getall():
|
||||
result[k] = v
|
||||
return result
|
||||
|
||||
def update_in_place(config_dict):
|
||||
for k, v in config_dict.items():
|
||||
new_value = memcache.get(k)
|
||||
if new_value is None:
|
||||
del config_dict[k]
|
||||
elif new_value != v:
|
||||
config_dict[k] = v
|
||||
|
||||
```
|
||||
|
||||
Now, when we want to use those functions from `module3`, we are faced with a problem: the dict type in Python 3.6 is different from the dict type in Python 2.7. In Python 2, dicts were unordered and their `.keys()`, `.values()`, `.items()` methods returned proper lists. That meant calling `.items()` created a copy of the state in the dictionary. In Python 3 those methods return dynamic views on the current state of the dictionary.
|
||||
|
||||
This means if `module3` called `module2.update_config_from_dict(some_dictionary)`, it would fail to run because the value returned by `dict.items()` in Python 3 isn’t a list and doesn’t have a `.pop()` method. The reverse is also true. If `module3` called `module2.config_to_dict()`, it would presumably return a Python 2 dictionary. Now calling `.items()` is suddenly returning a list so this code would not work correctly (which works fine with Python 3 dictionaries):
|
||||
```
|
||||
|
||||
|
||||
def main(cmdline_options):
|
||||
d = module2.config_to_dict()
|
||||
items = d.items()
|
||||
for k, v in items:
|
||||
print(f'Config from memcache: {k}={v}')
|
||||
for k, v in cmdline_options:
|
||||
d[k] = v
|
||||
for k, v in items:
|
||||
print(f'Config with cmdline overrides: {k}={v}')
|
||||
|
||||
```
|
||||
|
||||
Finally, using `module2.update_in_place()` would fail because the value of `.items()` in Python 3 now doesn’t allow the dictionary to change during iteration.
|
||||
|
||||
There’s more issues with this dictionary situation. Should a Python 2 dictionary respond `True` to `isinstance(d, dict)` on Python 3? If it did, it’d be a lie. If it didn’t, code would break anyway.
|
||||
|
||||
### Python should magically know types and translate!
|
||||
|
||||
Why can’t our Python 6 VM recognize that in Python 3 code we mean something else when calling `some_dict.keys()` than in Python 2 code? Well, Python doesn’t know what the author of the code thought `some_dict` should be when she was writing that code. There is nothing in the code that signifies whether it’s a dictionary at all. Type annotations weren’t there in Python 2 and, since they’re optional, even in Python 3 most code doesn’t use them yet.
|
||||
|
||||
At runtime, when you call `some_dict.keys()`, Python simply looks up an attribute on the object that happens to hide under the `some_dict` name and tries to run `__call__()` on that attribute. There’s some technicalities with method binding, descriptors, slots, etc. but this is the gist of it. We call this behavior “duck typing”.
|
||||
|
||||
Because of duck typing, the Python 6 VM would not be able to make compile-time decisions to translate calls and attribute lookups correctly.
|
||||
|
||||
### OK, so let’s make this decision at runtime instead
|
||||
|
||||
The Python 6 VM could implement this by tagging every attribute lookup with information “call comes from py2” or “call comes from py3” and make the object on the other side dispatch the right attribute. That would slow things down a lot and use more memory, too. It would require us to keep both versions of the given type in memory with a proxy used by user code. We would need to sync the state of those objects behind the user’s back, doubling the work. After all, the memory representation of the new dictionary is different than in Python 2.
|
||||
|
||||
If your head spun thinking about the problems with dictionaries, think about all the issues with Unicode strings in Python 3 and the do-it-all byte strings in Python 2.
|
||||
|
||||
### Is everything lost? Can’t Python 3 run old code ever?
|
||||
|
||||
Everything is not lost. Projects get ported to Python 3 every day. The recommended way to port Python 2 code to work on both versions of Python is to run [Python-Modernize][1] on your code. It will catch code that wouldn’t work on Python 3 and translate it to use the [six][2] library instead so it runs on both Python 2 and Python 3 after. It’s an adaptation of `2to3` which was producing Python 3-only code. `Modernize` is preferred since it provides a more incremental migration route. All this is outlined very well in the [Porting Python 2 Code to Python 3][3] document in the Python documentation.
|
||||
|
||||
But wait, didn’t you say a Python 6 VM couldn’t do this automatically? Right. `Modernize` looks at your code and tries to guess what’s going to be safe. It will make some changes that are unnecessary and miss others that are necessary. Famously, it won’t help you with strings. That transformation is not trivial if your code didn’t keep the boundaries between “binary data from outside” and “text data within the process”.
|
||||
|
||||
So, migrating big projects cannot be done automatically and involves humans running tests, finding problems and fixing them. Does it work? Yes, I helped [moving a million lines of code to Python 3][4] and the switch caused no incidents. This particular move regained 1/3 of memory on our servers and made the code run 12% faster. That was on Python 3.5. But Python 3.6 got quite a bit faster and depending on your workload you could maybe even achieve [a 4X speedup][5] .
|
||||
|
||||
### Dear Zed
|
||||
|
||||
Hi, man. I follow your story for over 10 years now. I’ve been watching when you were upset you were getting no credit for Mongrel even though the Rails ecosystem pretty much ran all on it. I’ve been there when you reimagined it and started the Mongrel 2 project. I was following your surprising move to use Fossil for it. I’ve seen you abruptly depart from the Ruby community with your “Rails is a Ghetto” post. I was thrilled when you started working on “Learn Python The Hard Way” and have been recommending it ever since. I met you in 2013 at [DjangoCon Europe][6] and we talked quite a bit about painting, singing and burnout. [This photo of you][7] is one of my first posts on Instagram.
|
||||
|
||||
You almost pulled another “Is a Ghetto” move with your [“The Case Against Python 3”][8] post. I think your heart is in the right place but that post caused a lot of confusion, including many people seriously thinking you believe Python 3 is not Turing-complete. I spent quite a few hours convincing people that you said so in jest. But given your very valuable contribution of “Learn Python The Hard Way”, I think it was worth doing that. Especially that you did update your book for Python 3. Thank you for doing that work. If there really are people in our community that called for blacklisting you and your book on the grounds of your post alone, call them out. It’s a lose-lose situation and it’s wrong.
|
||||
|
||||
For the record, no core Python dev thinks that the Python 2 -> Python 3 transition was smooth and well planned, [including Guido van Rossum][9]. Seriously, watch that video. Hindsight is 20/20 of course. In this sense we are in fact aggressively agreeing with each other. If we went to do it all over again, it would look differently. But at this point, [on January 1st 2020 Python 2 will reach End Of Life][10]. Most third-party libraries already support Python 3 and even started releasing Python 3-only versions (see [Django][11] or the [Python 3 Statement of the scientific projects][12]).
|
||||
|
||||
We are also aggressively agreeing on another thing. Just like you with Mongrel, Python core devs are volunteers who aren’t compensated for their work. Most of us invested a lot of time and effort in this project, and so [we are naturally sensitive][13] to dismissive and aggressive comments against their contribution. Especially if the message is both attacking the current state of affairs and calling for more free labor.
|
||||
|
||||
I hoped that by 2018 you’d let your 2016 post go. There were a bunch of good rebuttals. [I especially like eevee’s][14]. It specifically addresses the “run Python 2 alongside Python 3” scenario as not realistic, just like running Ruby 1.8 and Ruby 2.x in the same VM, or like running Lua 5.1 alongside 5.3. You can’t even run C binaries compiled against libc.so.5 with libc.so.6. What I find most surprising though is that you claimed that Python core is “purposefully” creating broken tools like 2to3, created by Guido in whose best interest it is for everybody to migrate as smoothly and quickly as possible. I’m glad that you backed out of that claim in your post later but you have to realize you antagonized people who read the original version. Accusations of deliberate harm better be backed by strong evidence.
|
||||
|
||||
But it seems like you still do that. [Just today][15] you said that Python core “ignores” attempts to solve the API problem, specifically `six`. As I wrote above, `six` is covered by the official porting guide in the Python documentation. More importantly, `six` was written by Benjamin Peterson, the release manager of Python 2.7. A lot of people learned to program thanks to you and you have a large following online. People will read a tweet like this and they will believe it at face value. This is harmful.
|
||||
|
||||
I have a suggestion. Let’s put this “Python 3 was poorly managed” dispute behind us. Python 2 is dying, we are slow to kill it and the process was ugly and bloody but it’s a one way street. Arguing about it is not actionable anymore. Instead, let’s focus on what we can do now to make Python 3.8 better than any other Python release. Maybe you prefer the role of an outsider looking in, but you would be much more impactful as a member of this community. Saying “we” instead of “they”.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://lukasz.langa.pl/13/could-we-run-python-2-and-python-3-code-same-vm/
|
||||
|
||||
作者:[Łukasz Langa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://lukasz.langa.pl
|
||||
[1]:https://python-modernize.readthedocs.io/
|
||||
[2]:http://pypi.python.org/pypi/six
|
||||
[3]:https://docs.python.org/3/howto/pyporting.html
|
||||
[4]:https://www.youtube.com/watch?v=66XoCk79kjM
|
||||
[5]:https://twitter.com/llanga/status/963834977745022976
|
||||
[6]:https://www.instagram.com/p/ZVC9CwH7G1/
|
||||
[7]:https://www.instagram.com/p/ZXtdtUn7Gk/
|
||||
[8]:https://learnpythonthehardway.org/book/nopython3.html
|
||||
[9]:https://www.youtube.com/watch?v=Oiw23yfqQy8
|
||||
[10]:https://mail.python.org/pipermail/python-dev/2018-March/152348.html
|
||||
[11]:https://pypi.python.org/pypi/Django/2.0.3
|
||||
[12]:http://python3statement.org/
|
||||
[13]:https://www.youtube.com/watch?v=-Nk-8fSJM6I
|
||||
[14]:https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/
|
||||
[15]:https://twitter.com/zedshaw/status/977909970795745281
|
@ -1,157 +0,0 @@
|
||||
translating----geekpi
|
||||
|
||||
BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI
|
||||
===============================================
|
||||
|
||||
### Intro
|
||||
|
||||
This post is a summary of my research on building Go projects in a Docker container on CI (Gitlab, specifically). I found solving private dependencies quite hard (coming from a Node/.NET background) so that is the main reason I wrote this up. Please feel free to reach out if there are any issues or a submit pull request on the Docker image.
|
||||
|
||||
### Dep
|
||||
|
||||
As dep is the best option for managing Go dependencies right now, the build will need to run `dep ensure` before building.
|
||||
|
||||
Note: I personally do not commit my `vendor/` folder into source control, if you do, I’m not sure if this step can be skipped or not.
|
||||
|
||||
The best way to do this with Docker builds is to use `dep ensure -vendor-only`. [See here][1].
|
||||
|
||||
### Docker Build Image
|
||||
|
||||
I first tried to use `golang:1.10` but this image doesn’t have:
|
||||
|
||||
* curl
|
||||
|
||||
* git
|
||||
|
||||
* make
|
||||
|
||||
* dep
|
||||
|
||||
* golint
|
||||
|
||||
I have created my own Docker image for builds ([github][2] / [dockerhub][3]) which I will keep up to date - but I offer no guarantees so you should probably create and manage your own.
|
||||
|
||||
### Internal Dependencies
|
||||
|
||||
We’re quite capable of building any project that has publicly accessible dependencies so far. But what about if your project depends on another private gitlab repository?
|
||||
|
||||
Running `dep ensure` locally should work with your git setup, but once on CI this doesn’t apply and builds will fail.
|
||||
|
||||
### Gitlab Permissions Model
|
||||
|
||||
This was [added in Gitlab 8.12][4] and the most useful feature we care about is the `CI_JOB_TOKEN` environment variable made available during builds.
|
||||
|
||||
This basically means we can clone [dependent repositories][5] like so
|
||||
|
||||
```
|
||||
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/myuser/mydependentrepo
|
||||
|
||||
```
|
||||
|
||||
However we do want to make this a bit more user friendly as dep will not magically add credentials when trying to pull code.
|
||||
|
||||
We will add this line to the `before_script` section of the `.gitlab-ci.yml`.
|
||||
|
||||
```
|
||||
before_script:
|
||||
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
|
||||
|
||||
```
|
||||
|
||||
Using the `.netrc` file allows you to specify which credentials to use for which server. This method allows you to avoid entering a username and password every time you pull (or push) from Git. The password is stored in plaintext so you shouldn’t do this on your own machine. This is actually for `cURL` which Git uses behind the scenes. [Read more here][6].
|
||||
|
||||
Project Files
|
||||
============================================================
|
||||
|
||||
### Makefile
|
||||
|
||||
While this is optional, I have found it makes things easier.
|
||||
|
||||
Configuring these steps below means in the CI script (and locally) we can run `make lint`, `make build` etc without repeating steps each time.
|
||||
|
||||
```
|
||||
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
|
||||
GOPACKAGES = $(shell go list ./... | grep -v /vendor/)
|
||||
|
||||
default: build
|
||||
|
||||
workdir:
|
||||
mkdir -p workdir
|
||||
|
||||
build: workdir/scraper
|
||||
|
||||
workdir/scraper: $(GOFILES)
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o workdir/scraper .
|
||||
|
||||
test: test-all
|
||||
|
||||
test-all:
|
||||
@go test -v $(GOPACKAGES)
|
||||
|
||||
lint: lint-all
|
||||
|
||||
lint-all:
|
||||
@golint -set_exit_status $(GOPACKAGES)
|
||||
|
||||
```
|
||||
|
||||
### .gitlab-ci.yml
|
||||
|
||||
This is where the Gitlab CI magic happens. You may want to swap out the image for your own.
|
||||
|
||||
```
|
||||
image: sjdweb/go-docker-build:1.10
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- cd $GOPATH/src
|
||||
- mkdir -p gitlab.com/$CI_PROJECT_NAMESPACE
|
||||
- cd gitlab.com/$CI_PROJECT_NAMESPACE
|
||||
- ln -s $CI_PROJECT_DIR
|
||||
- cd $CI_PROJECT_NAME
|
||||
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
|
||||
- dep ensure -vendor-only
|
||||
|
||||
lint_code:
|
||||
stage: test
|
||||
script:
|
||||
- make lint
|
||||
|
||||
unit_tests:
|
||||
stage: test
|
||||
script:
|
||||
- make test
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- make
|
||||
|
||||
```
|
||||
|
||||
### What This Is Missing
|
||||
|
||||
I would usually be building a Docker image with my binary and pushing that to the Gitlab Container Registry.
|
||||
|
||||
You can see I’m building the binary and exiting, you would at least want to store that binary somewhere (such as a build artifact).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://seandrumm.co.uk/blog/building-go-projects-with-docker-on-gitlab-ci/
|
||||
|
||||
作者:[ SEAN DRUMM][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://seandrumm.co.uk/
|
||||
[1]:https://github.com/golang/dep/blob/master/docs/FAQ.md#how-do-i-use-dep-with-docker
|
||||
[2]:https://github.com/sjdweb/go-docker-build/blob/master/Dockerfile
|
||||
[3]:https://hub.docker.com/r/sjdweb/go-docker-build/
|
||||
[4]:https://docs.gitlab.com/ce/user/project/new_ci_build_permissions_model.html
|
||||
[5]:https://docs.gitlab.com/ce/user/project/new_ci_build_permissions_model.html#dependent-repositories
|
||||
[6]:https://github.com/bagder/everything-curl/blob/master/usingcurl-netrc.md
|
@ -0,0 +1,154 @@
|
||||
Things You Should Know About Ubuntu 18.04
|
||||
======
|
||||
[Ubuntu 18.04 release][1] is just around the corner. I can see lots of questions from Ubuntu users in various Facebook groups and forums. I also organized Q&A sessions on Facebook and Instagram to know what Ubuntu users are wondering about Ubuntu 18.04.
|
||||
|
||||
I have tried to answer those frequently asked questions about Ubuntu 18.04 here. I hope it helps clear your doubts if you had any. And if you still have questions, feel free to ask in the comment section below.
|
||||
|
||||
### What to expect in Ubuntu 18.04
|
||||
|
||||
![Ubuntu 18.04 Frequently Asked Questions][2]
|
||||
|
||||
Just for clarification, some of the answers here are influenced by my personal opinion. If you are an experienced/aware Ubuntu user, some of the questions may sound silly to you. If that’s case, just ignore those questions.
|
||||
|
||||
#### Can I install Unity on Ubuntu 18.04?
|
||||
|
||||
Yes, you can.
|
||||
|
||||
Canonical knows that there are people who simply loved Unity. This is why it has made Unity 7 available in the Universe repository. This is a community maintained edition and Ubuntu doesn’t develop it directly.
|
||||
|
||||
I advise using the default GNOME first and if you really cannot tolerate it, then go on [installing Unity on Ubuntu 18.04][3].
|
||||
|
||||
#### What GNOME version does it have?
|
||||
|
||||
At the time of its release, Ubuntu 18.04 has GNOME 3.28.
|
||||
|
||||
#### Can I install vanilla GNOME on it?
|
||||
|
||||
Yes, you can.
|
||||
|
||||
Existing GNOME users might not like the Unity resembling, customized GNOME desktop in Ubuntu 18.04. There are some packages available in Ubuntu’s main and universe repositories that allows you to [install vanilla GNOME on Ubuntu 18.04][4].
|
||||
|
||||
#### Has the memory leak in GNOME fixed?
|
||||
|
||||
Yes. The [infamous memory leak in GNOME 3.28][5] has been fixed and [Ubuntu is already testing the fix][6].
|
||||
|
||||
Just to clarify, the memory leak was not caused by Ubuntu. It was/is impacting all Linux distributions that use GNOME 3.28. A new patch was released under GNOME 3.28.1 to fix this memory leak.
|
||||
|
||||
#### How long will Ubuntu 18.04 be supported?
|
||||
|
||||
It is a long-term support (LTS) release and like any LTS release, it will be supported for five years. Which means that Ubuntu 18.04 will get security and maintenance updates until April 2023. This is also true for all participating flavors except Ubuntu Studio.
|
||||
|
||||
#### When will Ubuntu 18.04 be released?
|
||||
|
||||
Ubuntu 18.04 LTS has been released on 26th April. All the participating flavors like Kubuntu, Lubuntu, Xubuntu, Budgie, MATE etc will have their 18.04 release available on the same day.
|
||||
|
||||
It seems [Ubuntu Studio will not have 18.04 as LTS release][7].
|
||||
|
||||
#### Is it possible to upgrade to Ubuntu 18.04 from 16.04/17.10? Can I upgrade from Ubuntu 16.04 with Unity to Ubuntu 18.04 with GNOME?
|
||||
|
||||
Yes, absolutely. Once Ubuntu 18.04 LTS is released, you can easily upgrade to the new version.
|
||||
|
||||
If you are using Ubuntu 17.10, make sure that in Software & Updates -> Updates, the ‘Notify me of a new Ubuntu version’ is set to ‘For any new version’.
|
||||
|
||||
![Get notified for a new version in Ubuntu][8]
|
||||
|
||||
If you are using Ubuntu 16.04, make sure that in Software & Updates -> Updates, the ‘Notify me of a new Ubuntu version’ is set to ‘For long-term support versions’.
|
||||
|
||||
![Ubuntu 18.04 upgrade from Ubuntu 16.04][9]
|
||||
|
||||
You should get system notification about the availability of the new versions. After that, upgrading to Ubuntu 18.04 is a matter of clicks.
|
||||
|
||||
Even if Ubuntu 16.04 was Unity, you can still [upgrade to Ubuntu 18.04][10] GNOME.
|
||||
|
||||
#### What does upgrading to Ubuntu 18.04 mean? Will I lose my data?
|
||||
|
||||
If you are using Ubuntu 17.10 or Ubuntu 16.04, sooner or later, Ubuntu will notify you that Ubuntu 18.04 is available. If you have a good internet connection that can download 1.5 Gb of data, you can upgrade to Ubuntu 18.04 in a few clicks and in under 30 minutes.
|
||||
|
||||
You don’t need to create a new USB and do a fresh install. Once the upgrade procedure finishes, you’ll have the new Ubuntu version available.
|
||||
|
||||
Normally, your data, documents etc are safe in the upgrade procedure. However, keeping a backup of your important documents is always a good idea.
|
||||
|
||||
#### When will I get to upgrade to Ubuntu 18.04?
|
||||
|
||||
If you are using Ubuntu 17.10 and have correct update settings in place (as mentioned in the previous section), you should be notified for upgrading to Ubuntu 18.04 within a few days of Ubuntu 18.04 release. Since Ubuntu servers encounter heavy load on the release day, not everyone gets the upgrade the same day.
|
||||
|
||||
For Ubuntu 16.04 users, it may take some weeks before they are officially notified of the availability of Ubuntu 18.04. Usually, this will happen after the first point release Ubuntu 18.04.1. This point release fixes the newly discovered bugs in 18.04.
|
||||
|
||||
#### If I upgrade to Ubuntu 18.04 can I downgrade to 17.10 or 16.04?
|
||||
|
||||
No, you cannot. While upgrading to the newer version is easy, there is no option to downgrade. If you want to go back to Ubuntu 16.04, you’ll have to do a fresh install.
|
||||
|
||||
#### Can I use Ubuntu 18.04 on 32-bit systems?
|
||||
|
||||
Yes and no.
|
||||
|
||||
If you are already using the 32-bit version of Ubuntu 16.04 or 17.10, you may still get to upgrade to Ubuntu 18.04. However, you won’t find Ubuntu 18.04 bit ISO in 32-bit format anymore. In other words, you cannot do a fresh install of the 32-bit version of Ubuntu 18.04 GNOME.
|
||||
|
||||
The good news here is that other official flavors like Ubuntu MATE, Lubuntu etc still have the 32-bit ISO of their new versions.
|
||||
|
||||
In any case, if you have a 32-bit system, chances are that your system is weak on hardware. You’ll be better off using lightweight [Ubuntu MATE][11] or [Lubuntu][12] on such system.
|
||||
|
||||
#### Where can I download Ubuntu 18.04?
|
||||
|
||||
Once 18.04 is released, you can get the ISO image of Ubuntu 18.04 from its website. You have both direct download and torrent options. Other official flavors will be available on their official websites.
|
||||
|
||||
#### Should I do a fresh install of Ubuntu 18.04 or upgrade to it from 16.04/17.10?
|
||||
|
||||
If you have a choice, make a backup of your data and do a fresh install of Ubuntu 18.04.
|
||||
|
||||
Upgrading to 18.04 from an existing version is a convenient option. However, in my opinion, it still keeps some traces/packages of the older version. A fresh install is always cleaner.
|
||||
|
||||
For a fresh install, should I install Ubuntu 16.04 or Ubuntu 18.04?
|
||||
|
||||
If you are going to install Ubuntu on a system, go for Ubuntu 18.04 instead of 16.04.
|
||||
|
||||
Both of them are long-term support release and will be supported for a long time. Ubuntu 16.04 will get maintenance and security updates until 2021 and 18.04 until 2023.
|
||||
|
||||
However, I would suggest that you use Ubuntu 18.04. Any LTS release gets [hardware updates for a limited time][13] (two and a half years I think). After that, it only gets maintenance updates. If you have newer hardware, you’ll get better support in 18.04.
|
||||
|
||||
Also, many application developers will start focusing on Ubuntu 18.04 soon. Newly created PPAs might only support 18.04 in a few months. Using 18.04 has its advantages over 16.04.
|
||||
|
||||
#### Will it be easier to install printer-scanner drivers instead of using the CLI?
|
||||
|
||||
I am not an expert when it comes to printers so my opinion is based on my limited knowledge in this field. Most of the new printers support [IPP protocol][14] and thus they should be well supported in Ubuntu 18.04. I cannot say the same about older printers.
|
||||
|
||||
#### Does Ubuntu 18.04 have better support for Realtek and other WiFi adapters?
|
||||
|
||||
No specific information on this part.
|
||||
|
||||
#### What are the system requirements for Ubuntu 18.04?
|
||||
|
||||
For the default GNOME version, you should have [4 GB of RAM for a comfortable use][15]. A processor released in last 8 years will work as well. Anything older than that should use a [lightweight Linux distribution][16] such as [Lubuntu][12].
|
||||
|
||||
#### Any other questions about Ubuntu 18.04?
|
||||
|
||||
If you have any other doubts regarding Ubuntu 18.04, please feel free to leave a comment below. If you think some other information should be added to the list, please let me know.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/ubuntu-18-04-faq/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/abhishek/
|
||||
[1]:https://itsfoss.com/ubuntu-18-04-release-features/
|
||||
[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/ubuntu-18-04-faq-800x450.png
|
||||
[3]:https://itsfoss.com/use-unity-ubuntu-17-10/
|
||||
[4]:https://itsfoss.com/vanilla-gnome-ubuntu/
|
||||
[5]:https://feaneron.com/2018/04/20/the-infamous-gnome-shell-memory-leak/
|
||||
[6]:https://community.ubuntu.com/t/help-test-memory-leak-fixes-in-18-04-lts/5251
|
||||
[7]:https://www.omgubuntu.co.uk/2018/04/ubuntu-studio-plans-to-reboot
|
||||
[8]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/03/upgrade-ubuntu-2.jpeg
|
||||
[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/ubuntu-18-04-upgrade-settings-800x379.png
|
||||
[10]:https://itsfoss.com/upgrade-ubuntu-version/
|
||||
[11]:https://ubuntu-mate.org/
|
||||
[12]:https://lubuntu.net/
|
||||
[13]:https://www.ubuntu.com/info/release-end-of-life
|
||||
[14]:https://www.pwg.org/ipp/everywhere.html
|
||||
[15]:https://help.ubuntu.com/community/Installation/SystemRequirements
|
||||
[16]:https://itsfoss.com/lightweight-linux-beginners/
|
@ -0,0 +1,79 @@
|
||||
Configuring local storage in Linux with Stratis
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-storage.png?itok=95-zvHYl)
|
||||
Configuring local storage is something desktop Linux users do very infrequently—maybe only once, during installation. Linux storage tech moves slowly, and many storage tools used 20 years ago are still used regularly today. But some things have improved since then. Why aren't people taking advantage of these new capabilities?
|
||||
|
||||
This article is about Stratis, a new project that aims to bring storage advances to all Linux users, from the simple laptop single SSD to a hundred-disk array. Linux has the capabilities, but its lack of an easy-to-use solution has hindered widespread adoption. Stratis's goal is to make Linux's advanced storage features accessible.
|
||||
|
||||
### Simple, reliable access to advanced storage features
|
||||
|
||||
Stratis aims to make three things easier: initial configuration of storage; making later changes; and using advanced storage features like snapshots, thin provisioning, and even tiering.
|
||||
|
||||
### Stratis: a volume-managing filesystem
|
||||
|
||||
Stratis is a volume-managing filesystem (VMF) like [ZFS][1] and [Btrfs][2] . It starts with the central idea of a storage "pool," an idea common to VMFs and also standalone volume managers such as [LVM][3] . This pool is created from one or more local disks (or partitions), and volumes are created from the pool. Their exact layout is not specified by the user, unlike traditional disk partitioning using [fdisk][4] or [GParted][5]
|
||||
|
||||
VMFs take it a step further and integrate the filesystem layer. The user no longer picks a filesystem to put on the volume. The filesystem and volume are merged into a single thing—a conceptual tree of files (which ZFS calls a dataset, Btrfs a subvolume, and Stratis a filesystem) whose data resides in the pool but that has no size limit except for the pool's total size.
|
||||
|
||||
Another way of looking at this: Just as a filesystem abstracts the actual location of storage blocks that make up a single file within the filesystem, a VMF abstracts the actual storage blocks of a filesystem within the pool.
|
||||
|
||||
The pool enables other useful features. Some of these, like filesystem snapshots, occur naturally from the typical implementation of a VMF, where multiple filesystems can share physical data blocks within the pool. Others, like redundancy, tiering, and integrity, make sense because the pool is a central place to manage these features for all the filesystems on the system.
|
||||
|
||||
The result is that a VMF is simpler to set up and manage and easier to enable for advanced storage features than independent volume manager and filesystem layers.
|
||||
|
||||
### What makes Stratis different from ZFS or Btrfs?
|
||||
|
||||
Stratis is a new project, which gives it the benefit of learning from previous projects. What Stratis learned from ZFS, Btrfs, and LVM will be covered in depth in [Part 2][6], but to summarize, the differences in Stratis come from seeing what worked and what didn't work for others, from changes in how people use and automate computers, and changes in the underlying hardware.
|
||||
|
||||
First, Stratis focuses on being easy and safe to use. This is important for the individual user, who may go for long stretches of time between interactions with Stratis. If these interactions are unfriendly, especially if there's a possibility of losing data, most people will stick with the basics instead of using new features.
|
||||
|
||||
Second, APIs and DevOps-style automation are much more important today than they were even a few years ago. Stratis supports automation by providing a first-class API, so people and software tools alike can use Stratis directly.
|
||||
|
||||
Third, SSDs have greatly expanded in capacity as well as market share. Earlier filesystems went to great lengths to optimize for rotational media's slow access times, but flash-based media makes these efforts less important. Even if a pool's data is too big to use SSDs economically for the entire pool, an SSD caching tier is still an option and can give excellent results. Assuming good performance because of SSDs lets Stratis focus its pool design on flexibility and reliability.
|
||||
|
||||
Finally, Stratis has a very different implementation model from ZFS and Btrfs (I'll this discuss further in [Part 2][6]). This means some things are easier for Stratis, while other things are harder. It also increases Stratis's pace of development.
|
||||
|
||||
### Learn more
|
||||
|
||||
To learn more about Stratis, check out [Part 2][6] of this series. You'll also find a detailed [design document][7] on the [Stratis website][8].
|
||||
|
||||
### Get involved
|
||||
|
||||
To develop, test, or offer feedback on Stratis, subscribe to our [mailing list][9].
|
||||
|
||||
Development is on [GitHub][10] for both the [daemon][11] (written in [Rust][12]) and the [command-line tool][13] (written in [Python][14]).
|
||||
|
||||
Join us on the [Freenode][15] IRC network on channel #stratis-storage.
|
||||
|
||||
Andy Grover will be speaking at LinuxFest Northwest this year. See [program highlights][16] or [register to attend][17].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/stratis-easy-use-local-storage-management-linux
|
||||
|
||||
作者:[Andy Grover][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/agrover
|
||||
[1]:https://en.wikipedia.org/wiki/ZFS
|
||||
[2]:https://en.wikipedia.org/wiki/Btrfs
|
||||
[3]:https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)
|
||||
[4]:https://en.wikipedia.org/wiki/Fdisk
|
||||
[5]:https://gparted.org/
|
||||
[6]:https://opensource.com/article/18/4/stratis-lessons-learned
|
||||
[7]:https://stratis-storage.github.io/StratisSoftwareDesign.pdf
|
||||
[8]:https://stratis-storage.github.io/
|
||||
[9]:https://lists.fedoraproject.org/admin/lists/stratis-devel.lists.fedorahosted.org/
|
||||
[10]:https://github.com/stratis-storage/
|
||||
[11]:https://github.com/stratis-storage/stratisd
|
||||
[12]:https://www.rust-lang.org/
|
||||
[13]:https://github.com/stratis-storage/stratis-cli
|
||||
[14]:https://www.python.org/
|
||||
[15]:https://freenode.net/
|
||||
[16]:https://www.linuxfestnorthwest.org/conferences/lfnw18
|
||||
[17]:https://www.linuxfestnorthwest.org/conferences/lfnw18/register/new
|
@ -0,0 +1,93 @@
|
||||
Enhance your Python with an interactive shell
|
||||
======
|
||||
![](https://fedoramagazine.org/wp-content/uploads/2018/03/python-shells-816x345.jpg)
|
||||
The Python programming language has become one of the most popular languages used in IT. One reason for this success is it can be used to solve a variety of problems. From web development to data science, machine learning to task automation, the Python ecosystem is rich in popular frameworks and libraries. This article presents some useful Python shells available in the Fedora packages collection to make development easier.
|
||||
|
||||
### Python Shell
|
||||
|
||||
The Python Shell lets you use the interpreter in an interactive mode. It’s very useful to test code or try a new library. In Fedora you can invoke the default shell by typing python3 in a terminal session. Some more advanced and enhanced shells are available to Fedora, though.
|
||||
|
||||
### IPython
|
||||
|
||||
IPython provides many useful enhancements to the Python shell. Examples include tab completion, object introspection, system shell access and command history retrieval. Many of these features are also used by the [Jupyter Notebook][1] , since it uses IPython underneath.
|
||||
|
||||
#### Install and run IPython
|
||||
```
|
||||
dnf install ipython3
|
||||
ipython3
|
||||
|
||||
```
|
||||
|
||||
Using tab completion prompts you with possible choices. This features comes in handy when you use an unfamiliar library.
|
||||
|
||||
![][2]
|
||||
|
||||
If you need more information, use the documentation by typing the ? command. For more details, you can use the ?? command.
|
||||
|
||||
![][3]
|
||||
|
||||
Another cool feature is the ability to execute a system shell command using the ! character. The result of the command can then be referenced in the IPython shell.
|
||||
|
||||
![][4]
|
||||
|
||||
A comprehensive list of IPython features is available in the [official documentation][5].
|
||||
|
||||
### bpython
|
||||
|
||||
bpython doesn’t do as much as IPython, but nonetheless it provides a useful set of features in a simple and lightweight package. Among other features, bpython provides:
|
||||
|
||||
* In-line syntax highlighting
|
||||
* Autocomplete with suggestions as you type
|
||||
* Expected parameter list
|
||||
* Ability to send or save code to a pastebin service or file
|
||||
|
||||
|
||||
|
||||
#### Install and run bpython
|
||||
```
|
||||
dnf install bpython3
|
||||
bpython3
|
||||
|
||||
```
|
||||
|
||||
As you type, bpython offers you choices to autocomplete your code.
|
||||
|
||||
![][6]
|
||||
|
||||
When you call a function or method, the expected parameters and the docstring are automatically displayed.
|
||||
|
||||
![][7]
|
||||
|
||||
Another neat feature is the ability to open the current bpython session in an external editor (Vim by default) using the function key F7. This is very useful when testing more complex programs.
|
||||
|
||||
For more details about configuration and features, consult the bpython [documentation][8].
|
||||
|
||||
### Conclusion
|
||||
|
||||
Using an enhanced Python shell is a good way to increase productivity. It gives you enhanced features to write a quick prototype or try out a new library. Are you using an enhanced Python shell? Feel free to mention it in the comment section below.
|
||||
|
||||
Photo by [David Clode][9] on [Unsplash][10]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/enhance-python-interactive-shell/
|
||||
|
||||
作者:[Clément Verna][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://fedoramagazine.org/author/cverna/
|
||||
[1]:https://ipython.org/notebook.html
|
||||
[2]:https://fedoramagazine.org/wp-content/uploads/2018/03/ipython-tabcompletion.png
|
||||
[3]:https://fedoramagazine.org/wp-content/uploads/2018/03/ipyhton_doc1.png
|
||||
[4]:https://fedoramagazine.org/wp-content/uploads/2018/03/ipython_shell.png
|
||||
[5]:https://ipython.readthedocs.io/en/stable/overview.html#main-features-of-the-interactive-shell
|
||||
[6]:https://fedoramagazine.org/wp-content/uploads/2018/03/bpython1.png
|
||||
[7]:https://fedoramagazine.org/wp-content/uploads/2018/03/bpython2.png
|
||||
[8]:https://docs.bpython-interpreter.org/
|
||||
[9]:https://unsplash.com/photos/d0CasEMHDQs?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[10]:https://unsplash.com/search/photos/python?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
@ -0,0 +1,294 @@
|
||||
Things to do After Installing Ubuntu 18.04
|
||||
======
|
||||
**Brief: This list of things to do after installing Ubuntu 18.04 helps you get started with Bionic Beaver for a smoother desktop experience.**
|
||||
|
||||
[Ubuntu][1] 18.04 Bionic Beaver releases today. You are perhaps already aware of the [new features in Ubuntu 18.04 LTS][2] release. If not, here’s the video review of Ubuntu 18.04 LTS:
|
||||
|
||||
[Subscribe to YouTube Channel for more Ubuntu Videos][3]
|
||||
|
||||
If you opted to install Ubuntu 18.04, I have listed out a few recommended steps that you can follow to get started with it.
|
||||
|
||||
### Things to do after installing Ubuntu 18.04 Bionic Beaver
|
||||
|
||||
![Things to do after installing Ubuntu 18.04][4]
|
||||
|
||||
I should mention that the list of things to do after installing Ubuntu 18.04 depends a lot on you and your interests and needs. If you are a programmer, you’ll focus on installing programming tools. If you are a graphic designer, you’ll focus on installing graphics tools.
|
||||
|
||||
Still, there are a few things that should be applicable to most Ubuntu users. This list is composed of those things plus a few of my of my favorites.
|
||||
|
||||
Also, this list is for the default [GNOME desktop][5]. If you are using some other flavor like [Kubuntu][6], Lubuntu etc then the GNOME-specific stuff won’t be applicable to your system.
|
||||
|
||||
You don’t have to follow each and every point on the list blindly. You should see if the recommended action suits your requirements or not.
|
||||
|
||||
With that said, let’s get started with this list of things to do after installing Ubuntu 18.04.
|
||||
|
||||
#### 1\. Update the system
|
||||
|
||||
This is the first thing you should do after installing Ubuntu. Update the system without fail. It may sound strange because you just installed a fresh OS but still, you must check for the updates.
|
||||
|
||||
In my experience, if you don’t update the system right after installing Ubuntu, you might face issues while trying to install a new program.
|
||||
|
||||
To update Ubuntu 18.04, press Super Key (Windows Key) to launch the Activity Overview and look for Software Updater. Run it to check for updates.
|
||||
|
||||
![Software Updater in Ubuntu 17.10][7]
|
||||
|
||||
**Alternatively** , you can use these famous commands in the terminal ( Use Ctrl+Alt+T):
|
||||
```
|
||||
sudo apt update && sudo apt upgrade
|
||||
|
||||
```
|
||||
|
||||
#### 2\. Enable additional repositories for more software
|
||||
|
||||
[Ubuntu has several repositories][8] from where it provides software for your system. These repositories are:
|
||||
|
||||
* Main – Free and open-source software supported by Ubuntu team
|
||||
* Universe – Free and open-source software maintained by the community
|
||||
* Restricted – Proprietary drivers for devices.
|
||||
* Multiverse – Software restricted by copyright or legal issues.
|
||||
* Canonical Partners – Software packaged by Ubuntu for their partners
|
||||
|
||||
|
||||
|
||||
Enabling all these repositories will give you access to more software and proprietary drivers.
|
||||
|
||||
Go to Activity Overview by pressing Super Key (Windows key), and search for Software & Updates:
|
||||
|
||||
![Software and Updates in Ubuntu 17.10][9]
|
||||
|
||||
Under the Ubuntu Software tab, make sure you have checked all of the Main, Universe, Restricted and Multiverse repository checked.
|
||||
|
||||
![Setting repositories in Ubuntu 18.04][10]
|
||||
|
||||
Now move to the **Other Software** tab, check the option of **Canonical Partners**.
|
||||
|
||||
![Enable Canonical Partners repository in Ubuntu 17.10][11]
|
||||
|
||||
You’ll have to enter your password in order to update the software sources. Once it completes, you’ll find more applications to install in the Software Center.
|
||||
|
||||
#### 3\. Install media codecs
|
||||
|
||||
In order to play media files like MP#, MPEG4, AVI etc, you’ll need to install media codecs. Ubuntu has them in their repository but doesn’t install it by default because of copyright issues in various countries.
|
||||
|
||||
As an individual, you can install these media codecs easily using the Ubuntu Restricted Extra package. Click on the link below to install it from the Software Center.
|
||||
|
||||
[Install Ubuntu Restricted Extras][12]
|
||||
|
||||
Or alternatively, use the command below to install it:
|
||||
```
|
||||
sudo apt install ubuntu-restricted-extras
|
||||
|
||||
```
|
||||
|
||||
#### 4\. Install software from the Software Center
|
||||
|
||||
Now that you have setup the repositories and installed the codecs, it is time to get software. If you are absolutely new to Ubuntu, please follow this [guide to installing software in Ubuntu][13].
|
||||
|
||||
There are several ways to install software. The most convenient way is to use the Software Center that has thousands of software available in various categories. You can install them in a few clicks from the software center.
|
||||
|
||||
![Software Center in Ubuntu 17.10 ][14]
|
||||
|
||||
It depends on you what kind of software you would like to install. I’ll suggest some of my favorites here.
|
||||
|
||||
* **VLC** – media player for videos
|
||||
* **GIMP** – Photoshop alternative for Linux
|
||||
* **Pinta** – Paint alternative in Linux
|
||||
* **Calibre** – eBook management tool
|
||||
* **Chromium** – Open Source web browser
|
||||
* **Kazam** – Screen recorder tool
|
||||
* [**Gdebi**][15] – Lightweight package installer for .deb packages
|
||||
* **Spotify** – For streaming music
|
||||
* **Skype** – For video messaging
|
||||
* **Kdenlive** – [Video editor for Linux][16]
|
||||
* **Atom** – [Code editor][17] for programming
|
||||
|
||||
|
||||
|
||||
You may also refer to this list of [must-have Linux applications][18] for more software recommendations.
|
||||
|
||||
#### 5\. Install software from the Web
|
||||
|
||||
Though Ubuntu has thousands of applications in the software center, you may not find some of your favorite applications despite the fact that they support Linux.
|
||||
|
||||
Many software vendors provide ready to install .deb packages. You can download these .deb files from their website and install it by double-clicking on it.
|
||||
|
||||
[Google Chrome][19] is one such software that you can download from the web and install it.
|
||||
|
||||
#### 6\. Opt out of data collection in Ubuntu 18.04 (optional)
|
||||
|
||||
Ubuntu 18.04 collects some harmless statistics about your system hardware and your system installation preference. It also collects crash reports.
|
||||
|
||||
You’ll be given the option to not send this data to Ubuntu servers when you log in to Ubuntu 18.04 for the first time.
|
||||
|
||||
![Opt out of data collection in Ubuntu 18.04][20]
|
||||
|
||||
If you miss it that time, you can disable it by going to System Settings -> Privacy and then set the Problem Reporting to Manual.
|
||||
|
||||
![Privacy settings in Ubuntu 18.04][21]
|
||||
|
||||
#### 7\. Customize the GNOME desktop (Dock, themes, extensions and more)
|
||||
|
||||
The GNOME desktop looks good in Ubuntu 18.04 but doesn’t mean you cannot change it.
|
||||
|
||||
You can do a few visual changes from the System Settings. You can change the wallpaper of the desktop and the lock screen, you can change the position of the dock (launcher on the left side), change power settings, Bluetooth etc. In short, you can find many settings that you can change as per your need.
|
||||
|
||||
![Ubuntu 17.10 System Settings][22]
|
||||
|
||||
Changing themes and icons are the major way to change the looks of your system. I advise going through the list of [best GNOME themes][23] and [icons for Ubuntu][24]. Once you have found the theme and icon of your choice, you can use them with GNOME Tweaks tool.
|
||||
|
||||
You can install GNOME Tweaks via the Software Center or you can use the command below to install it:
|
||||
```
|
||||
sudo apt install gnome-tweak-tool
|
||||
|
||||
```
|
||||
|
||||
Once it is installed, you can easily [install new themes and icons][25].
|
||||
|
||||
![Change theme is one of the must to do things after installing Ubuntu 17.10][26]
|
||||
|
||||
You should also have a look at [use GNOME extensions][27] to further enhance the looks and capabilities of your system. I made this video about using GNOME extensions in 17.10 and you can follow the same for Ubuntu 18.04.
|
||||
|
||||
If you are wondering which extension to use, do take a look at this list of [best GNOME extensions][28].
|
||||
|
||||
I also recommend reading this article on [GNOME customization in Ubuntu][29] so that you can know the GNOME desktop in detail.
|
||||
|
||||
#### 8\. Prolong your battery and prevent overheating
|
||||
|
||||
Let’s move on to [prevent overheating in Linux laptops][30]. TLP is a wonderful tool that controls CPU temperature and extends your laptops’ battery life in the long run.
|
||||
|
||||
Make sure that you haven’t installed any other power saving application such as [Laptop Mode Tools][31]. You can install it using the command below in a terminal:
|
||||
```
|
||||
sudo apt install tlp tlp-rdw
|
||||
|
||||
```
|
||||
|
||||
Once installed, run the command below to start it:
|
||||
```
|
||||
sudo tlp start
|
||||
|
||||
```
|
||||
|
||||
#### 9\. Save your eyes with Nightlight
|
||||
|
||||
Nightlight is my favorite feature in GNOME desktop. Keeping [your eyes safe at night][32] from the computer screen is very important. Reducing blue light helps reducing eye strain at night.
|
||||
|
||||
![flux effect][33]
|
||||
|
||||
GNOME provides a built-in Night Light option, which you can activate in the System Settings.
|
||||
|
||||
Just go to System Settings-> Devices-> Displays and turn on the Night Light option.
|
||||
|
||||
![Enabling night light is a must to do in Ubuntu 17.10][34]
|
||||
|
||||
#### 9\. Disable automatic suspend for laptops
|
||||
|
||||
Ubuntu 18.04 comes with a new automatic suspend feature for laptops. If the system is running on battery and is inactive for 20 minutes, it will go in suspend mode.
|
||||
|
||||
I understand that the intention is to save battery life but it is an inconvenience as well. You can’t keep the power plugged in all the time because it’s not good for the battery life. And you may need the system to be running even when you are not using it.
|
||||
|
||||
Thankfully, you can change this behavior. Go to System Settings -> Power. Under Suspend & Power Button section, either turn off the Automatic Suspend option or extend its time period.
|
||||
|
||||
![Disable automatic suspend in Ubuntu 18.04][35]
|
||||
|
||||
You can also change the screen dimming behavior in here.
|
||||
|
||||
#### 10\. System cleaning
|
||||
|
||||
I have written in detail about [how to clean up your Ubuntu system][36]. I recommend reading that article to know various ways to keep your system free of junk.
|
||||
|
||||
Normally, you can use this little command to free up space from your system:
|
||||
```
|
||||
sudo apt autoremove
|
||||
|
||||
```
|
||||
|
||||
It’s a good idea to run this command every once a while. If you don’t like the command line, you can use a GUI tool like [Stacer][37] or [Bleach Bit][38].
|
||||
|
||||
#### 11\. Going back to Unity or Vanilla GNOME (not recommended)
|
||||
|
||||
If you have been using Unity or GNOME in the past, you may not like the new customized GNOME desktop in Ubuntu 18.04. Ubuntu has customized GNOME so that it resembles Unity but at the end of the day, it is neither completely Unity nor completely GNOME.
|
||||
|
||||
So if you are a hardcore Unity or GNOMEfan, you may want to use your favorite desktop in its ‘real’ form. I wouldn’t recommend but if you insist here are some tutorials for you:
|
||||
|
||||
#### 12\. Can’t log in to Ubuntu 18.04 after incorrect password? Here’s a workaround
|
||||
|
||||
I noticed a [little bug in Ubuntu 18.04][39] while trying to change the desktop session to Ubuntu Community theme. It seems if you try to change the sessions at the login screen, it rejects your password first and at the second attempt, the login gets stuck. You can wait for 5-10 minutes to get it back or force power it off.
|
||||
|
||||
The workaround here is that after it displays the incorrect password message, click Cancel, then click your name, then enter your password again.
|
||||
|
||||
#### 13\. Experience the Community theme (optional)
|
||||
|
||||
Ubuntu 18.04 was supposed to have a dashing new theme developed by the community. The theme could not be completed so it could not become the default look of Bionic Beaver release. I am guessing that it will be the default theme in Ubuntu 18.10.
|
||||
|
||||
![Ubuntu 18.04 Communitheme][40]
|
||||
|
||||
You can try out the aesthetic theme even today. [Installing Ubuntu Community Theme][41] is very easy. Just look for it in the software center, install it, restart your system and then at the login choose the Communitheme session.
|
||||
|
||||
#### 14\. Get Windows 10 in Virtual Box (if you need it)
|
||||
|
||||
In a situation where you must use Windows for some reasons, you can [install Windows in virtual box inside Linux][42]. It will run as a regular Ubuntu application.
|
||||
|
||||
It’s not the best way but it still gives you an option. You can also [use WINE to run Windows software on Linux][43]. In both cases, I suggest trying the alternative native Linux application first before jumping to virtual machine or WINE.
|
||||
|
||||
#### What do you do after installing Ubuntu?
|
||||
|
||||
Those were my suggestions for getting started with Ubuntu. There are many more tutorials that you can find under [Ubuntu 18.04][44] tag. You may go through them as well to see if there is something useful for you.
|
||||
|
||||
Enough from myside. Your turn now. What are the items on your list of **things to do after installing Ubuntu 18.04**? The comment section is all yours.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/abhishek/
|
||||
[1]:https://www.ubuntu.com/
|
||||
[2]:https://itsfoss.com/ubuntu-18-04-release-features/
|
||||
[3]:https://www.youtube.com/c/itsfoss?sub_confirmation=1
|
||||
[4]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/things-to-after-installing-ubuntu-18-04-featured-800x450.jpeg
|
||||
[5]:https://www.gnome.org/
|
||||
[6]:https://kubuntu.org/
|
||||
[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/software-update-ubuntu-17-10.jpg
|
||||
[8]:https://help.ubuntu.com/community/Repositories/Ubuntu
|
||||
[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/software-updates-ubuntu-17-10.jpg
|
||||
[10]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/repositories-ubuntu-18.png
|
||||
[11]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/software-repository-ubuntu-17-10.jpeg
|
||||
[12]:apt://ubuntu-restricted-extras
|
||||
[13]:https://itsfoss.com/remove-install-software-ubuntu/
|
||||
[14]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/Ubuntu-software-center-17-10-800x551.jpeg
|
||||
[15]:https://itsfoss.com/gdebi-default-ubuntu-software-center/
|
||||
[16]:https://itsfoss.com/best-video-editing-software-linux/
|
||||
[17]:https://itsfoss.com/best-modern-open-source-code-editors-for-linux/
|
||||
[18]:https://itsfoss.com/essential-linux-applications/
|
||||
[19]:https://www.google.com/chrome/
|
||||
[20]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/opt-out-of-data-collection-ubuntu-18-800x492.jpeg
|
||||
[21]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/privacy-ubuntu-18-04-800x417.png
|
||||
[22]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/System-Settings-Ubuntu-17-10-800x573.jpeg
|
||||
[23]:https://itsfoss.com/best-gtk-themes/
|
||||
[24]:https://itsfoss.com/best-icon-themes-ubuntu-16-04/
|
||||
[25]:https://itsfoss.com/install-themes-ubuntu/
|
||||
[26]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/GNOME-Tweak-Tool-Ubuntu-17-10.jpeg
|
||||
[27]:https://itsfoss.com/gnome-shell-extensions/
|
||||
[28]:https://itsfoss.com/best-gnome-extensions/
|
||||
[29]:https://itsfoss.com/gnome-tricks-ubuntu/
|
||||
[30]:https://itsfoss.com/reduce-overheating-laptops-linux/
|
||||
[31]:https://wiki.archlinux.org/index.php/Laptop_Mode_Tools
|
||||
[32]:https://itsfoss.com/night-shift-flux-ubuntu-linux/
|
||||
[33]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2016/03/flux-eyes-strain.jpg
|
||||
[34]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/10/Enable-Night-Light-Feature-Ubuntu-17-10-800x396.jpeg
|
||||
[35]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/disable-automatic-suspend-ubuntu-18-800x586.jpeg
|
||||
[36]:https://itsfoss.com/free-up-space-ubuntu-linux/
|
||||
[37]:https://itsfoss.com/optimize-ubuntu-stacer/
|
||||
[38]:https://itsfoss.com/bleachbit-2-release/
|
||||
[39]:https://gitlab.gnome.org/GNOME/gnome-shell/issues/227
|
||||
[40]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/ubunt-18-theme.jpeg
|
||||
[41]:https://itsfoss.com/ubuntu-community-theme/
|
||||
[42]:https://itsfoss.com/install-windows-10-virtualbox-linux/
|
||||
[43]:https://itsfoss.com/use-windows-applications-linux/
|
||||
[44]:https://itsfoss.com/tag/ubuntu-18-04/
|
@ -0,0 +1,125 @@
|
||||
Using machine learning to color cartoons
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/art-yearbook-paint-draw-create-creative.png?itok=t9fOdlyJ)
|
||||
A big problem with supervised machine learning is the need for huge amounts of labeled data. It's a big problem especially if you don't have the labeled data—and even in a world awash with big data, most of us don't.
|
||||
|
||||
Although a few companies have access to enormous quantities of certain kinds of labeled data, for most organizations and many applications, creating sufficient quantities of the right kind of labeled data is cost prohibitive or impossible. Sometimes the domain is one in which there just isn't much data (for example, when diagnosing a rare disease or determining whether a signature matches a few known exemplars). Other times the volume of data needed multiplied by the cost of human labeling by [Amazon Turkers][1] or summer interns is just too high. Paying to label every frame of a movie-length video adds up fast, even at a penny a frame.
|
||||
|
||||
### The big problem of big data requirements
|
||||
|
||||
The specific problem our group set out to solve was: Can we train a model to automate applying a simple color scheme to a black and white character without hand-drawing hundreds or thousands of examples as training data?
|
||||
|
||||
* A rule-based strategy for extreme augmentation of small datasets
|
||||
* A borrowed TensorFlow image-to-image translation model, Pix2Pix, to automate cartoon coloring with very limited training data
|
||||
|
||||
|
||||
|
||||
In this experiment (which we called DragonPaint), we confronted the problem of deep learning's enormous labeled-data requirements using:
|
||||
|
||||
I had seen [Pix2Pix][2], a machine learning image-to-image translation model described in a paper ("Image-to-Image Translation with Conditional Adversarial Networks," by Isola, et al.), that colorizes landscapes after training on AB pairs where A is the grayscale version of landscape B. My problem seemed similar. The only problem was training data.
|
||||
|
||||
I needed the training data to be very limited because I didn't want to draw and color a lifetime supply of cartoon characters just to train the model. The tens of thousands (or hundreds of thousands) of examples often required by deep-learning models were out of the question.
|
||||
|
||||
Based on Pix2Pix's examples, we would need at least 400 to 1,000 sketch/colored pairs. How many was I willing to draw? Maybe 30. I drew a few dozen cartoon flowers and dragons and asked whether I could somehow turn this into a training set.
|
||||
|
||||
### The 80% solution: color by component
|
||||
|
||||
|
||||
![Characters colored by component rules][4]
|
||||
|
||||
Characters colored by component rules
|
||||
|
||||
When faced with a shortage of training data, the first question to ask is whether there is a good non-machine-learning based approach to our problem. If there's not a complete solution, is there a partial solution, and would a partial solution do us any good? Do we even need machine learning to color flowers and dragons? Or can we specify geometric rules for coloring?
|
||||
|
||||
|
||||
![How to color by components][6]
|
||||
|
||||
How to color by components
|
||||
|
||||
There is a non-machine-learning approach to solving my problem. I could tell a kid how I want my drawings colored: Make the flower's center orange and the petals yellow. Make the dragon's body orange and the spikes yellow.
|
||||
|
||||
At first, that doesn't seem helpful because our computer doesn't know what a center or a petal or a body or a spike is. But it turns out we can define the flower or dragon parts in terms of connected components and get a geometric solution for coloring about 80% of our drawings. Although 80% isn't enough, we can bootstrap from that partial-rule-based solution to 100% using strategic rule-breaking transformations, augmentations, and machine learning.
|
||||
|
||||
Connected components are what is colored when you use Windows Paint (or a similar application). For example, when coloring a binary black and white image, if you click on a white pixel, the white pixels that are be reached without crossing over black are colored the new color. In a "rule-conforming" cartoon dragon or flower sketch, the biggest white component is the background. The next biggest is the body (plus the arms and legs) or the flower's center. The rest are spikes or petals, except for the dragon's eye, which can be distinguished by its distance from the background.
|
||||
|
||||
### Using strategic rule breaking and Pix2Pix to get to 100%
|
||||
|
||||
Some of my sketches aren't rule-conforming. A sloppily drawn line might leave a gap. A back limb will get colored like a spike. A small, centered daisy will switch a petal and the center's coloring rules.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint4.png?itok=MOiaVxMS)
|
||||
|
||||
For the 20% we couldn't color with the geometric rules, we needed something else. We turned to Pix2Pix, which requires a minimum training set of 400 to 1,000 sketch/colored pairs (i.e., the smallest training sets in the [Pix2Pix paper][7]) including rule-breaking pairs.
|
||||
|
||||
So, for each rule-breaking example, we finished the coloring by hand (e.g., back limbs) or took a few rule-abiding sketch/colored pairs and broke the rule. We erased a bit of a line in A or we transformed a fat, centered flower pair A and B with the same function (f) to create a new pair f(A) and f(B)—a small, centered flower. That got us to a training set.
|
||||
|
||||
### Extreme augmentations with gaussian filters and homeomorphisms
|
||||
|
||||
It's common in computer vision to augment an image training set with geometric transformations, such as rotation, translation, and zoom.
|
||||
|
||||
But what if we need to turn sunflowers into daisies or make a dragon's nose bulbous or pointy?
|
||||
|
||||
Or what if we just need an enormous increase in data volume without overfitting? Here we need a dataset 10 to 30 times larger than what we started with.
|
||||
|
||||
![Sunflower turned into a daisy with r -> r cubed][9]
|
||||
|
||||
Sunflower turned into a daisy with r -> r cubed
|
||||
|
||||
![Gaussian filter augmentations][11]
|
||||
|
||||
Gaussian filter augmentations
|
||||
|
||||
Certain homeomorphisms of the unit disk make good daisies (e.g., r -> r cubed) and Gaussian filters change a dragon's nose. Both were extremely useful for creating augmentations for our dataset and produced the augmentation volume we needed, but they also started to change the style of the drawings in ways that an [affine transformation][12] could not.
|
||||
|
||||
This inspired questions beyond how to automate a simple coloring scheme: What defines an artist's style, either to an outside viewer or the artist? When does an artist adopt as their own a drawing they could not have made without the algorithm? When does the subject matter become unrecognizable? What's the difference between a tool, an assistant, and a collaborator?
|
||||
|
||||
### How far can we go?
|
||||
|
||||
How little can we draw for input and how much variation and complexity can we create while staying within a subject and style recognizable as the artist's? What would we need to do to make an infinite parade of giraffes or dragons or flowers? And if we had one, what could we do with it?
|
||||
|
||||
Those are questions we'll continue to explore in future work.
|
||||
|
||||
But for now, the rules, augmentations, and Pix2Pix model worked. We can color flowers really well, and the dragons aren't bad.
|
||||
|
||||
|
||||
![Results: flowers colored by model trained on flowers][14]
|
||||
|
||||
Results: Flowers colored by model trained on flowers
|
||||
|
||||
|
||||
![Results: dragons trained on model trained on dragons][16]
|
||||
|
||||
Results: Dragons trained on model trained on dragons
|
||||
|
||||
To learn more, attend Gretchen Greene's talk, [DragonPaint – bootstrapping small data to color cartoons][17], at [PyCon Cleveland 2018][18].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/dragonpaint-bootstrapping
|
||||
|
||||
作者:[K. Gretchen Greene][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/kggreene
|
||||
[1]:https://www.mturk.com/
|
||||
[2]:https://phillipi.github.io/pix2pix/
|
||||
[3]:/file/393246
|
||||
[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint2.png?itok=qw_q72A5 (Characters colored by component rules)
|
||||
[5]:/file/393251
|
||||
[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint3.png?itok=JK3TPcvp (How to color by components)
|
||||
[7]:https://arxiv.org/abs/1611.07004
|
||||
[8]:/file/393261
|
||||
[9]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint5.png?itok=GvipU8l8 (Sunflower turned into a daisy with r -> r cubed)
|
||||
[10]:/file/393266
|
||||
[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint6.png?itok=r14I2Fyz (Gaussian filter augmentations)
|
||||
[12]:https://en.wikipedia.org/wiki/Affine_transformation
|
||||
[13]:/file/393271
|
||||
[14]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint7.png?itok=xKWvyi_T (Results: flowers colored by model trained on flowers)
|
||||
[15]:/file/393276
|
||||
[16]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dragonpaint8.png?itok=fSM5ovBT (Results: dragons trained on model trained on dragons)
|
||||
[17]:https://us.pycon.org/2018/schedule/presentation/113/
|
||||
[18]:https://us.pycon.org/2018/
|
@ -0,0 +1,155 @@
|
||||
How To Check System Hardware Manufacturer, Model And Serial Number In Linux
|
||||
======
|
||||
Getting system hardware information is not a problem for Linux GUI and Windows users but CLI users facing trouble to get this details.
|
||||
|
||||
Even most of us don’t know what is the best command to get this. There are many utilities available in Linux to get system hardware information such as
|
||||
|
||||
System Hardware Manufacturer, Model And Serial Number.
|
||||
|
||||
We are trying to write possible ways to get this details but you can choose the best method for you.
|
||||
|
||||
It is mandatory to know all these information because it will be needed when you raise a case with hardware vendor for any kind of hardware issues.
|
||||
|
||||
This can be achieved in six methods, let me show you how to do that.
|
||||
|
||||
### Method-1 : Using Dmidecode Command
|
||||
|
||||
Dmidecode is a tool which reads a computer’s DMI (stands for Desktop Management Interface) (some say SMBIOS – stands for System Management BIOS) table contents and display system hardware information in a human-readable format.
|
||||
|
||||
This table contains a description of the system’s hardware components, as well as other useful information such as serial number, Manufacturer information, Release Date, and BIOS revision, etc,.,
|
||||
|
||||
The DMI table doesn’t only describe what the system is currently made of, it also can report the possible evolution (such as the fastest supported CPU or the maximal amount of memory supported).
|
||||
|
||||
This will help you to analyze your hardware capability like whether it’s support latest application version or not?
|
||||
```
|
||||
# dmidecode -t system
|
||||
|
||||
# dmidecode 2.12
|
||||
# SMBIOS entry point at 0x7e7bf000
|
||||
SMBIOS 2.7 present.
|
||||
|
||||
Handle 0x0024, DMI type 1, 27 bytes
|
||||
System Information
|
||||
Manufacturer: IBM
|
||||
Product Name: System x2530 M4: -[1214AC1]-
|
||||
Version: 0B
|
||||
Serial Number: MK2RL11
|
||||
UUID: 762A99BF-6916-450F-80A6-B2E9E78FC9A1
|
||||
Wake-up Type: Power Switch
|
||||
SKU Number: Not Specified
|
||||
Family: System X
|
||||
|
||||
Handle 0x004B, DMI type 12, 5 bytes
|
||||
System Configuration Options
|
||||
Option 1: JP20 pin1-2: TPM PP Disable, pin2-3: TPM PP Enable
|
||||
|
||||
Handle 0x004D, DMI type 32, 20 bytes
|
||||
System Boot Information
|
||||
Status: No errors detected
|
||||
|
||||
```
|
||||
|
||||
**Suggested Read :** [Dmidecode – Easy Way To Get Linux System Hardware Information][1]
|
||||
|
||||
### Method-2 : Using inxi Command
|
||||
|
||||
inxi is a nifty tool to check hardware information on Linux and offers wide range of option to get all the hardware information on Linux system that i never found in any other utility which are available in Linux. It was forked from the ancient and mindbendingly perverse yet ingenius infobash, by locsmif.
|
||||
|
||||
inxi is a script that quickly shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version(s), Processes, RAM usage, and a wide variety of other useful information, also used for forum technical support & debugging tool.
|
||||
```
|
||||
# inxi -M
|
||||
Machine: Device: server System: IBM product: N/A v: 0B serial: MK2RL11
|
||||
Mobo: IBM model: 00Y8494 serial: 37M17D UEFI: IBM v: -[VVE134MUS-1.50]- date: 08/30/2013
|
||||
|
||||
```
|
||||
|
||||
**Suggested Read :** [inxi – A Great Tool to Check Hardware Information on Linux][2]
|
||||
|
||||
### Method-3 : Using lshw Command
|
||||
|
||||
lshw (stands for Hardware Lister) is a small nifty tool that generates detailed reports about various hardware components on the machine such as memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, usb, network card, graphics cards, multimedia, printers, bus speed, etc.
|
||||
|
||||
It’s generating hardware information by reading varies files under /proc directory and DMI table.
|
||||
|
||||
lshw must be run as super user to detect the maximum amount of information or it will only report partial information. Special option is available in lshw called class which will shows specific given hardware information in detailed manner.
|
||||
```
|
||||
# lshw -C system
|
||||
enal-dbo01t
|
||||
description: Blade
|
||||
product: System x2530 M4: -[1214AC1]-
|
||||
vendor: IBM
|
||||
version: 0B
|
||||
serial: MK2RL11
|
||||
width: 64 bits
|
||||
capabilities: smbios-2.7 dmi-2.7 vsyscall32
|
||||
configuration: boot=normal chassis=enclosure family=System X uuid=762A99BF-6916-450F-80A6-B2E9E78FC9A1
|
||||
|
||||
```
|
||||
|
||||
**Suggested Read :** [LSHW (Hardware Lister) – A Nifty Tool To Get A Hardware Information On Linux][3]
|
||||
|
||||
### Method-4 : Using /sys file system
|
||||
|
||||
The kernel expose some DMI information in the /sys virtual filesystem. So we can easily get the machine type by running grep command with following format.
|
||||
```
|
||||
# grep "" /sys/class/dmi/id/[pbs]*
|
||||
|
||||
```
|
||||
|
||||
Alternatively we can print only specific details by using cat command.
|
||||
```
|
||||
# cat /sys/class/dmi/id/board_vendor
|
||||
IBM
|
||||
|
||||
# cat /sys/class/dmi/id/product_name
|
||||
System x2530 M4: -[1214AC1]-
|
||||
|
||||
# cat /sys/class/dmi/id/product_serial
|
||||
MK2RL11
|
||||
|
||||
# cat /sys/class/dmi/id/bios_version
|
||||
-[VVE134MUS-1.50]-
|
||||
|
||||
```
|
||||
|
||||
### Method-5 : Using dmesg Command
|
||||
|
||||
The dmesg command is used to write the kernel messages (boot-time messages) in Linux before syslogd or klogd start. It obtains its data by reading the kernel ring buffer. dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system.
|
||||
```
|
||||
# dmesg | grep -i DMI
|
||||
DMI: System x2530 M4: -[1214AC1]-/00Y8494, BIOS -[VVE134MUS-1.50]- 08/30/2013
|
||||
|
||||
```
|
||||
|
||||
### Method-6 : Using hwinfo Command
|
||||
|
||||
hwinfo stands for hardware information tool is another great utility that used to probe for the hardware present in the system and display detailed information about varies hardware components in human readable format.
|
||||
|
||||
It reports information about CPU, RAM, keyboard, mouse, graphics card, sound, storage, network interface, disk, partition, bios, and bridge, etc,., This tool could display more detailed information among others like lshw, dmidecode, inxi, etc,.
|
||||
|
||||
hwinfo uses libhd library libhd.so to gather hardware information on the system. This tool especially designed for openSUSE system, later other distributions are included the tool into their official repository.
|
||||
```
|
||||
# hwinfo | egrep "system.hardware.vendor|system.hardware.product"
|
||||
system.hardware.vendor = 'IBM'
|
||||
system.hardware.product = 'System x2530 M4: -[1214AC1]-'
|
||||
|
||||
```
|
||||
|
||||
**Suggested Read :** [hwinfo (Hardware Info) – A Nifty Tool To Detect System Hardware Information On Linux][4]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-check-system-hardware-manufacturer-model-and-serial-number-in-linux/
|
||||
|
||||
作者:[VINOTH KUMAR][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.2daygeek.com/author/vinoth/
|
||||
[1]:https://www.2daygeek.com/dmidecode-get-print-display-check-linux-system-hardware-information/
|
||||
[2]:https://www.2daygeek.com/inxi-system-hardware-information-on-linux/
|
||||
[3]:https://www.2daygeek.com/lshw-find-check-system-hardware-information-details-linux/
|
||||
[4]:https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/
|
@ -0,0 +1,66 @@
|
||||
What Stratis learned from ZFS, Btrfs, and Linux Volume Manager | Opensource.com
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud-windows-building-containers.png?itok=0XvZLZ8k)
|
||||
|
||||
As discussed in [Part 1][1] of this series, Stratis is a volume-managing filesystem (VMF) with functionality similar to [ZFS][2] and [Btrfs][3]. In designing Stratis, we studied the choices that developers of existing solutions made.
|
||||
|
||||
### Why not adopt an existing solution?
|
||||
|
||||
The reasons vary. First, let's consider [ZFS][2]. Originally developed by Sun Microsystems for Solaris (now owned by Oracle), ZFS has been ported to Linux. However, its [CDDL][4]-licensed code cannot be merged into the [GPL][5]-licensed Linux source tree. Whether CDDL and GPLv2 are truly incompatible is a subject for debate, but the uncertainty is enough to make enterprise Linux vendors unwilling to adopt and support it.
|
||||
|
||||
[Btrfs][3] is also well-established and has no licensing issues. For years it was the "Chosen One" for many users, but it just hasn't yet gotten to where it needs to be in terms of stability and features.
|
||||
|
||||
So, fuelled by a desire to improve the status quo and frustration with existing options, Stratis was conceived.
|
||||
|
||||
### How Stratis is different
|
||||
|
||||
One thing that ZFS and Btrfs have clearly shown is that writing a VMF as an in-kernel filesystem takes a tremendous amount of work and time to work out the bugs and stabilize. It's essential to get right when it comes to precious data. Starting from scratch and taking the same approach with Stratis would probably take a decade as well, which was not acceptable.
|
||||
|
||||
Instead, Stratis chose to use some of the Linux kernel's other existing capabilities: The [device mapper][6] subsystem, which is most notably used by LVM to provide RAID, thin-provisioning, and other features on top of block devices; and the well-tested and high-performance [XFS][7] filesystem. Stratis builds its pool using layers of existing technology, with the goal of managing them to appear as a seamless whole to the user.
|
||||
|
||||
### What Stratis learned from ZFS
|
||||
|
||||
For many users, ZFS set the expectations for what a next-generation filesystem should be. Reading comments online from people talking about ZFS helped set Stratis's initial development goals. ZFS's design also implicitly highlighted things to avoid. For example, ZFS requires an "import" step when attaching a pool created on another system. There are a few reasons for this, and each reason was likely an issue that Stratis had to solve, either by taking the same approach or a different one.
|
||||
|
||||
One thing we didn't like about ZFS was that it has some restrictions on adding new hard drives or replacing existing drives with bigger ones, especially if the pool is configured for redundancy. Of course, there is a reason for this, but we thought it was an area we could improve.
|
||||
|
||||
Finally, using ZFS's tools at the command line, once learned, is a good experience. We wanted to have that same feeling with Stratis's command-line tool, and we also liked the tool's tendency to use positional parameters and limit the amount of typing required for each command.
|
||||
|
||||
### What Stratis learned from Btrfs
|
||||
|
||||
One thing we liked about Btrfs was the single command-line tool, with positional subcommands. Btrfs also treats redundancy (Btrfs profiles) as a property of the pool, which seems easier to understand than ZFS's approach and allows drives to be added and even removed.
|
||||
|
||||
Finally, looking at the features that both ZFS and Btrfs offer, such as snapshot implementations and send/receive support, helped determine which features Stratis should include.
|
||||
|
||||
### What Stratis learned from LVM
|
||||
|
||||
From the early design stages of Stratis, we studied LVM extensively. LVM is currently the most significant user of the Linux device mapper (DM) subsystem—in fact, DM is maintained by the LVM core team. We examined it both from the possibility of actually using LVM as a layer of Stratis and an example of using DM, which Stratis could do directly with LVM as a peer. We looked at LVM's on-disk metadata format (along with ZFS's and XFS's) for inspiration in defining Stratis's on-disk metadata format.
|
||||
|
||||
Among the listed projects, LVM shares the most in common with Stratis internally, because they both use DM. However, from a usage standpoint, LVM is much more transparent about its inner workings. This gives expert users a great deal of control and options for precisely configuring the volume group (pool) layout in a way that Stratis doesn't.
|
||||
|
||||
### A diversity of solutions
|
||||
|
||||
One great thing about working on free software and open source is that there are no irreplaceable components. Every part—even the kernel—is open for view, modification, and even replacement if the current software isn't meeting users' needs. A new project doesn't need to end an existing one if there is enough support for both to be sustained in parallel.
|
||||
|
||||
Stratis is an attempt to better meet some users' needs for local storage management—those looking for a no-hassle, easy-to-use, powerful solution. This means making design choices that might not be right for all users. Alternatives make tough choices possible since users have other options. All users ultimately benefit from their ability to use whichever tool works best for them.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/stratis-lessons-learned
|
||||
|
||||
作者:[Andy Grover][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/agrover
|
||||
[1]:https://opensource.com/article/18/4/stratis-easy-use-local-storage-management-linux
|
||||
[2]:https://en.wikipedia.org/wiki/ZFS
|
||||
[3]:https://en.wikipedia.org/wiki/Btrfs
|
||||
[4]:https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License
|
||||
[5]:https://en.wikipedia.org/wiki/GNU_General_Public_License
|
||||
[6]:https://en.wikipedia.org/wiki/Device_mapper
|
||||
[7]:https://en.wikipedia.org/wiki/XFS
|
90
sources/tech/20180427 How to use FIND in Linux.md
Normal file
90
sources/tech/20180427 How to use FIND in Linux.md
Normal file
@ -0,0 +1,90 @@
|
||||
How to use FIND in Linux
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux31x_cc.png?itok=Pvim4U-B)
|
||||
|
||||
In [a recent Opensource.com article][1], Lewis Cowles introduced the `find` command.
|
||||
|
||||
`find` is one of the more powerful and flexible command-line programs in the daily toolbox, so it's worth spending a little more time on it.
|
||||
|
||||
At a minimum, `find` takes a path to find things. For example:
|
||||
```
|
||||
find /
|
||||
|
||||
```
|
||||
|
||||
will find (and print) every file on the system. And since everything is a file, you will get a lot of output to sort through. This probably doesn't help you find what you're looking for. You can change the path argument to narrow things down a bit, but it's still not really any more helpful than using the `ls` command. So you need to think about what you're trying to locate.
|
||||
|
||||
Perhaps you want to find all the JPEG files in your home directory. The `-name` argument allows you to restrict your results to files that match the given pattern.
|
||||
```
|
||||
find ~ -name '*jpg'
|
||||
|
||||
```
|
||||
|
||||
But wait! What if some of them have an uppercase extension? `-iname` is like `-name`, but it is case-insensitive.
|
||||
```
|
||||
find ~ -iname '*jpg'
|
||||
|
||||
```
|
||||
|
||||
Great! But the 8.3 name scheme is so 1985. Some of the pictures might have a .jpeg extension. Fortunately, we can combine patterns with an "or," represented by `-o`.
|
||||
```
|
||||
find ~ ( -iname 'jpeg' -o -iname 'jpg' )
|
||||
|
||||
```
|
||||
|
||||
We're getting closer. But what if you have some directories that end in jpg? (Why you named a directory `bucketofjpg` instead of `pictures` is beyond me.) We can modify our command with the `-type` argument to look only for files.
|
||||
```
|
||||
find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f
|
||||
|
||||
```
|
||||
|
||||
Or maybe you'd like to find those oddly named directories so you can rename them later:
|
||||
```
|
||||
find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type d
|
||||
|
||||
```
|
||||
|
||||
It turns out you've been taking a lot of pictures lately, so let's narrow this down to files that have changed in the last week.
|
||||
```
|
||||
find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7
|
||||
|
||||
```
|
||||
|
||||
`ctime`), modification time (`mtime`), or access time (`atime`). These are in days, so if you want finer-grained control, you can express it in minutes instead (`cmin`, `mmin`, and `amin`, respectively). Unless you know exactly the time you want, you'll probably prefix the number with `+` (more than) or `–` (less than).
|
||||
|
||||
You can do time filters based on file status change time (), modification time (), or access time (). These are in days, so if you want finer-grained control, you can express it in minutes instead (, and, respectively). Unless you know exactly the time you want, you'll probably prefix the number with(more than) or(less than).
|
||||
|
||||
But maybe you don't care about your pictures. Maybe you're running out of disk space, so you want to find all the gigantic (let's define that as "greater than 1 gigabyte") files in the `log` directory:
|
||||
```
|
||||
find /var/log -size +1G
|
||||
|
||||
```
|
||||
|
||||
Or maybe you want to find all the files owned by bcotton in `/data`:
|
||||
```
|
||||
find /data -owner bcotton
|
||||
|
||||
```
|
||||
|
||||
You can also look for files based on permissions. Perhaps you want to find all the world-readable files in your home directory to make sure you're not oversharing.
|
||||
```
|
||||
find ~ -perm -o=r
|
||||
|
||||
```
|
||||
|
||||
This post only scratches the surface of what `find` can do. Combining tests with Boolean logic can give you incredible flexibility to find exactly the files you're looking for. And with arguments like `-exec` or `-delete`, you can have `find` take action on what it... finds. Have any favorite `find` expressions? Share them in the comments!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/how-use-find-linux
|
||||
|
||||
作者:[Ben Cotton][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/bcotton
|
||||
[1]:https://opensource.com/article/18/4/how-find-files-linux
|
@ -0,0 +1,120 @@
|
||||
我们可以在同一个虚拟机中运行 Python 2 和 Python 3 代码而不需要更改代码吗?
|
||||
=====
|
||||
|
||||
从理论上来说,可以。Zed Shaw 说过一句著名的话,如果不行,那么 Python 3 一定不是图灵完备的。但在实践中,这是不现实的,我将通过给你们举几个例子来说明原因。
|
||||
|
||||
### 对于字典(dict)来说,这意味着什么?
|
||||
|
||||
让我们来想象一台拥有 Python 6 的虚拟机,它可以读取 Python 3.6 编写的 `module3.py`。但是在这个模块中,它可以导入 Python 2.7 编写的 `module2.py`,并成功使用它,没有问题。这显然是实验代码,但假设 `module2.py` 包含以下的功能:
|
||||
```
|
||||
|
||||
|
||||
def update_config_from_dict(config_dict):
|
||||
items = config_dict.items()
|
||||
while items:
|
||||
k, v = items.pop()
|
||||
memcache.set(k, v)
|
||||
|
||||
def config_to_dict():
|
||||
result = {}
|
||||
for k, v in memcache.getall():
|
||||
result[k] = v
|
||||
return result
|
||||
|
||||
def update_in_place(config_dict):
|
||||
for k, v in config_dict.items():
|
||||
new_value = memcache.get(k)
|
||||
if new_value is None:
|
||||
del config_dict[k]
|
||||
elif new_value != v:
|
||||
config_dict[k] = v
|
||||
|
||||
```
|
||||
|
||||
现在,当我们想从 `module3` 中调用这些函数时,我们遇到了一个问题:Python 3.6 中的字典类型与 Python 2.7 中的字典类型不同。在 Python 2 中,dicts 是无序的,它们的 `.keys()`, `.values()`, `.items()` 方法返回了正确的序列,这意味着调用 `.items()` 会在字典中创建状态的副本。在 Python 3 中,这些方法返回字典当前状态的动态视图。
|
||||
|
||||
这意味着如果 `module3` 调用 `module2.update_config_from_dict(some_dictionary)`,它将无法运行,因为 Python 3 中 `dict.items()` 返回的值不是一个列表,并且没有 `.pop()` 方法。反过来也是如此。如果 `module3` 调用 `module2.config_to_dict()`,它可能会返回一个 Python 2 的字典。现在调用 `.items()` 突然返回一个列表,所以这段代码无法正常工作(这对 Python 3 字典来说工作正常):
|
||||
```
|
||||
|
||||
def main(cmdline_options):
|
||||
d = module2.config_to_dict()
|
||||
items = d.items()
|
||||
for k, v in items:
|
||||
print(f'Config from memcache: {k}={v}')
|
||||
for k, v in cmdline_options:
|
||||
d[k] = v
|
||||
for k, v in items:
|
||||
print(f'Config with cmdline overrides: {k}={v}')
|
||||
|
||||
```
|
||||
|
||||
最后,使用 `module2.update_in_place()` 会失败,因为 Python 3 中 `.items()` 的值现在不允许在迭代过程中改变。
|
||||
|
||||
对于字典来说,还有很多问题。Python 2 的字典在 Python 3 上使用 `isinstance(d, dict)` 应该返回 `True` 吗?如果是的话,这将是一个谎言。如果没有,代码将无法继续。
|
||||
|
||||
### Python 应该神奇地知道类型并会自动转换!
|
||||
|
||||
为什么拥有 Python 6 的虚拟机无法识别 Python 3 的代码,在 Python 2 中调用 `some_dict.keys()` 时,我们还有别的意思吗?好吧,Python 不知道代码的作者在编写代码时,她所认为的 `some_dict` 应该是什么。代码中没有任何内容表明它是否是一个字典。在 Python 2 中没有类型注释,因为它们是可选的,即使在 Python 3 中,大多数代码也不会使用它们。
|
||||
|
||||
在运行时,当你调用 `some_dict.keys()` 的时候,Python 只是简单地在对象上查找一个属性,该属性恰好隐藏在 `some_dict` 名下,并试图在该属性上运行 `__call__()`。这里有一些关于方法绑定,描述符,slots 等技术问题,但这是它的核心。我们称这种行为为“鸭子类型”。
|
||||
|
||||
由于鸭子类型,Python 6 的虚拟机将无法做出编译时决定,以正确转换调用和属性查找。
|
||||
|
||||
### 好的,让我们在运行时做出这个决定
|
||||
|
||||
Python 6 的虚拟机可以通过标记每个属性查找来实现这一点,信息是“来自 py2 的调用”或“来自 py3 的调用”,并使对象发送正确的属性。这会让事情变得很慢,并且使用更多的内存。这将要求我们使用用户代码使用的代理将两种版本的给定类型保留在内存中。我们需要将这些对象的状态同步到用户背后,使工作加倍。毕竟,新字典的内存表示与 Python 2 不同。
|
||||
|
||||
如果你在思考字典问题,考虑 Python 3 中的 Unicode 字符串和 Python 2 中的字节(byte)字符串的所有问题。
|
||||
|
||||
### 一切都会丢失吗?Python 3 不能运行旧代码?
|
||||
|
||||
一切都不会丢失。每天都会有项目移植到 Python 3。将 Python 2 代码移植到两个版本的 Python 上推荐方法是在代码上运行 [Python-Modernize][1]。它会捕获那些在 Python 3 上不起作用的代码,并使用 [six][2] 库将其替换,以便它在 Python 2 和 Python 3 上运行。这是对 `2to3` 的改编,它正在生成 Python 3-only 代码。`Modernize` 是首选,因为它提供了更多的增量迁移路线。所有的这些在 Python 文档中的 [Porting Python 2 Code to Python 3][3]文档中都有很好的概述。
|
||||
|
||||
但是,等一等,你不是说 Python 6 的虚拟机不能自动执行此操作吗?对。`Modernize` 查看你的代码,并试图猜测哪些是安全的。它会做出一些不必要的改变,还会错过其他必要的改变。但是,它不会帮助你处理字符串。如果你的代码没有保留“来自外部的二进制数据”和“流程中的文本数据”之间的界限,那么这种转换并非微不足道。
|
||||
|
||||
因此,迁移大项目不能自动完成,并且涉及人类进行测试,发现问题并修复它们。它工作吗?是的,我曾帮助[将一百万行代码迁移到 Python 3][4],并且交换没有造成事故。这一举措重获了我们服务器内存的 1/3,并使代码运行速度提高了 12%。那是在 Python 3.5 上,但是 Python 3.6 的速度要快得多,根据你的工作量,你甚至可以达到 [4 倍加速][5]。
|
||||
|
||||
### 亲爱的 Zed
|
||||
|
||||
hi,伙计,我关注你已经超过 10 年了。我一直在观察,当你感到沮丧的时候,你对 Mongrel 没有任何信任,尽管 Rails 生态系统几乎全部都在上面运行。当你重新设计它并开始 Mongrel 2 项目时,我一直在观察。我一直在关注你使用 Fossil 这一令人惊讶的举动。随着你发布 “Rails 是一个贫民窟”的帖子,我看到你突然离开了 Ruby 社区。当你开始编写 “Learn Python The Hard Way” 并且开始推荐它时,我感到非常兴奋。2013 年我在 [DjangoCon Europe][6] 见过你,我们谈了很多关于绘画,唱歌和倦怠的内容。关于[这张你的照片][7]是我在 Instagram 上的第一篇文章。
|
||||
|
||||
你几乎把另一个“贫民区”的行动与 [“反对 Python 3” 案例][8] 文章拉到一起。我认为你本意是好的,但是这篇文章引起了很多混乱,包括许多人认为你认为 Python 3 不是图灵完整的。我花了好几个小时让人们相信,你是在开玩笑。但是,鉴于你对 Python 学习方式的重大贡献,我认为这是值得的。特别是你为 Python 3 更新了你的书。感谢你做这件事。如果我们社区中真的有人要求因你的帖子为由将你和你的书列入黑名单,把他们请出去。这是一个双输的局面,这是错误的。
|
||||
|
||||
在记录中,没有一个核心 Python 开发人员认为 Python 2 到 Python 3 的转换过程会顺利而且计划得当,[包括 Guido van Rossum][9]。真的,可以看那个视频,这有点事后诸葛亮的意思了。从这个意义上说,我们实际上是积极地相互认同的。如果我们再做一次,它会看起来不一样。但在这一点上,[在 2020 年 1 月 1 日,Python 2 将会到达终结][10]。大多数第三方库已经支持 Python 3,甚至开始发布只支持 Python 3 版本(参见[Django][11]或 [科学项目关于 Python 3 的声明][12])。
|
||||
|
||||
我们也积极地就另一件事达成一致。就像你于 Mongrel 一样,Python 核心开发人员是志愿者,他们的工作没有得到报酬。我们大多数人在这个项目上投入了大量的时间和精力,因此[我们自然而然敏感][13]于那些对他们的贡献不屑一顾和激烈的评论。特别是如果这个信息既攻击目前的事态,又要求更多的自由劳动。
|
||||
|
||||
我希望到 2018 年你会让忘记 2016 发布的帖子,有一堆好的反驳。[我特别喜欢 eevee][14](译注:eevee 是一个为 Blender 设计的渲染器)。它特别针对“一起运行 Python 2 和 Python 3 ”的场景,这是不现实的,就像在同一个虚拟机中运行 Ruby 1.8 和 Ruby 2.x 一样,或者像 Lua 5.3 和 Lua 5.1 同时运行一样。你甚至不能用 libc.so.6 运行针对 libc.so.5 编译的 C 二进制文件。然而,我发现最令人惊讶的是,你声称 Python 核心开发者是“有目的地”创造诸如 2to3 之类的破坏工具,这些由 Guido 创建,其最大利益就是让每个人尽可能顺利,快速地迁移。我很高兴你在之后的帖子中放弃了这个说法,但是你必须意识到你会激怒那些阅读原始版本的人。对蓄意伤害的指控最好有强有力的证据支持。
|
||||
|
||||
但看起来你仍然会这样做。[就在今天][15]你说 Python 核心开发者“忽略”尝试解决 API 的问题,特别是 `six`。正如我上面写的那样,Python 文档中的官方移植指南涵盖了 “six”。更重要的是,`six` 是由 Python 2.7 的发布管理者 Benjamin Peterson 编写。很多人学会了编程,这要归功于你,而且由于你在网上有大量的粉丝,人们会阅读这样的推文,他们会相信它的价值,这是有害的。
|
||||
|
||||
我有一个建议,让我们把 “Python 3 管理不善”的争议搁置起来。Python 2 正在死亡,这个过程会很慢,并且它是丑陋而血腥的,但它是一条单行道。争论那些没有用。相反,让我们专注于我们现在可以做什么来使 Python 3.8 比其他任何 Python 版本更好。也许你更喜欢看外面的角色,但作为这个社区的成员,你会更有影响力。请说“我们”而不是“他们”。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://lukasz.langa.pl/13/could-we-run-python-2-and-python-3-code-same-vm/
|
||||
|
||||
作者:[Łukasz Langa][a]
|
||||
译者:[MjSeven](https://github.com/MjSeven)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://lukasz.langa.pl
|
||||
[1]:https://python-modernize.readthedocs.io/
|
||||
[2]:http://pypi.python.org/pypi/six
|
||||
[3]:https://docs.python.org/3/howto/pyporting.html
|
||||
[4]:https://www.youtube.com/watch?v=66XoCk79kjM
|
||||
[5]:https://twitter.com/llanga/status/963834977745022976
|
||||
[6]:https://www.instagram.com/p/ZVC9CwH7G1/
|
||||
[7]:https://www.instagram.com/p/ZXtdtUn7Gk/
|
||||
[8]:https://learnpythonthehardway.org/book/nopython3.html
|
||||
[9]:https://www.youtube.com/watch?v=Oiw23yfqQy8
|
||||
[10]:https://mail.python.org/pipermail/python-dev/2018-March/152348.html
|
||||
[11]:https://pypi.python.org/pypi/Django/2.0.3
|
||||
[12]:http://python3statement.org/
|
||||
[13]:https://www.youtube.com/watch?v=-Nk-8fSJM6I
|
||||
[14]:https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/
|
||||
[15]:https://twitter.com/zedshaw/status/977909970795745281
|
@ -0,0 +1,155 @@
|
||||
在 GITLAB CI 中使用 DOCKER 构建 GO 项目
|
||||
===============================================
|
||||
|
||||
### 介绍
|
||||
|
||||
这篇文章是我在 CI 的 Docker 容器中构建 Go 项目的研究总结(特别是在 Gitlab 中)。我发现很难解决私有依赖问题(来自 Node/.NET 背景),因此这是我写这篇文章的主要原因。如果 Docker 镜像上存在任何问题或提交请求,请随时与我们联系。
|
||||
|
||||
### Dep
|
||||
|
||||
由于 dep 是现在管理 Go 依赖关系的最佳选择,因此在构建前之前运行 `dep ensure`。
|
||||
|
||||
注意:我个人不会将我的 `vendor/` 文件夹提交到源码控制,如果你这样做,我不确定这个步骤是否可以跳过。
|
||||
|
||||
使用 Docker 构建的最好方法是使用 `dep ensure -vendor-only`。 [见这里][1]。
|
||||
|
||||
### Docker 构建镜像
|
||||
|
||||
我第一次尝试使用 `golang:1.10`,但这个镜像没有:
|
||||
|
||||
* curl
|
||||
|
||||
* git
|
||||
|
||||
* make
|
||||
|
||||
* dep
|
||||
|
||||
* golint
|
||||
|
||||
我已经为我将不断更新的构建创建好了镜像([github][2] / [dockerhub][3]) - 但我不提供任何保证,因此你应该创建并管理自己的 Dockerhub。
|
||||
|
||||
### 内部依赖关系
|
||||
|
||||
我们完全有能力创建一个有公共依赖关系的项目。但是如果你的项目依赖于另一个私人 gitlab 仓库呢?
|
||||
|
||||
在本地运行 `dep ensure` 应该可以和你的 git 设置一起工作,但是一旦在 CI 上不适用,构建就会失败。
|
||||
|
||||
### Gitlab 权限模型
|
||||
|
||||
这是在[ Gitlab 8.12 中添加的][4],我们关心的最有用的功能是在构建期提供的 `CI_JOB_TOKEN` 环境变量。
|
||||
|
||||
这基本上意味着我们可以像这样克隆[依赖仓库][5]
|
||||
|
||||
```
|
||||
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/myuser/mydependentrepo
|
||||
|
||||
```
|
||||
|
||||
然而,我们希望使这更友好一点,因为 dep 在试图拉取代码时不会奇迹般地添加凭据。
|
||||
|
||||
我们将把这一行添加到 `.gitlab-ci.yml` 的 `before_script` 部分。
|
||||
|
||||
```
|
||||
before_script:
|
||||
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
|
||||
|
||||
```
|
||||
|
||||
使用 `.netrc` 文件可以指定哪个凭证用于哪个服务器。这种方法可以避免每次从 Git 中拉取(或推送)时输入用户名和密码。密码以明文形式存储,因此你不应在自己的计算机上执行此操作。这实际用于 Git 在背后使用 `cURL`。 [在这里阅读更多][6]。
|
||||
|
||||
项目文件
|
||||
============================================================
|
||||
|
||||
### Makefile
|
||||
|
||||
虽然这是可选的,但我发现它使事情变得更容易。
|
||||
|
||||
配置这些步骤意味着在 CI 脚本(和本地)中,我们可以运行 `make lint`、`make build` 等,而无需每次重复步骤。
|
||||
|
||||
```
|
||||
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
|
||||
GOPACKAGES = $(shell go list ./... | grep -v /vendor/)
|
||||
|
||||
default: build
|
||||
|
||||
workdir:
|
||||
mkdir -p workdir
|
||||
|
||||
build: workdir/scraper
|
||||
|
||||
workdir/scraper: $(GOFILES)
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o workdir/scraper .
|
||||
|
||||
test: test-all
|
||||
|
||||
test-all:
|
||||
@go test -v $(GOPACKAGES)
|
||||
|
||||
lint: lint-all
|
||||
|
||||
lint-all:
|
||||
@golint -set_exit_status $(GOPACKAGES)
|
||||
|
||||
```
|
||||
|
||||
### .gitlab-ci.yml
|
||||
|
||||
这是 Gitlab CI 魔术发生的地方。你可能想使用自己的镜像。
|
||||
|
||||
```
|
||||
image: sjdweb/go-docker-build:1.10
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- cd $GOPATH/src
|
||||
- mkdir -p gitlab.com/$CI_PROJECT_NAMESPACE
|
||||
- cd gitlab.com/$CI_PROJECT_NAMESPACE
|
||||
- ln -s $CI_PROJECT_DIR
|
||||
- cd $CI_PROJECT_NAME
|
||||
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
|
||||
- dep ensure -vendor-only
|
||||
|
||||
lint_code:
|
||||
stage: test
|
||||
script:
|
||||
- make lint
|
||||
|
||||
unit_tests:
|
||||
stage: test
|
||||
script:
|
||||
- make test
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- make
|
||||
|
||||
```
|
||||
|
||||
### 缺少了什么
|
||||
|
||||
我通常会用我的二进制文件构建 Docker 镜像,并将其推送到 Gitlab 容器注册器中。
|
||||
|
||||
你可以看到我正在构建二进制文件并退出,你至少需要将该二进制文件(例如生成文件)存储在某处。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://seandrumm.co.uk/blog/building-go-projects-with-docker-on-gitlab-ci/
|
||||
|
||||
作者:[ SEAN DRUMM][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://seandrumm.co.uk/
|
||||
[1]:https://github.com/golang/dep/blob/master/docs/FAQ.md#how-do-i-use-dep-with-docker
|
||||
[2]:https://github.com/sjdweb/go-docker-build/blob/master/Dockerfile
|
||||
[3]:https://hub.docker.com/r/sjdweb/go-docker-build/
|
||||
[4]:https://docs.gitlab.com/ce/user/project/new_ci_build_permissions_model.html
|
||||
[5]:https://docs.gitlab.com/ce/user/project/new_ci_build_permissions_model.html#dependent-repositories
|
||||
[6]:https://github.com/bagder/everything-curl/blob/master/usingcurl-netrc.md
|
Loading…
Reference in New Issue
Block a user