Linux 常用工具之 Typora

Typora

Typora

Ubuntu 安装 Typora

安装

参考 Typora for LinuxInstall Typora on Linux

1
2
3
4
5
6
7
8
9
# optional, but recommended
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
# add Typora's repository
sudo add-apt-repository 'deb https://typora.io ./linux/'
sudo apt-get update
# install typora
sudo apt-get install typora

安装过程记录如下:

1
2
3
huzhifeng@Ubuntu16041:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
huzhifeng@Ubuntu16041:~$ sudo add-apt-repository 'deb https://typora.io ./linux/'
huzhifeng@Ubuntu16041:~$ sudo apt-get update && sudo apt-get install typora

桌面快捷图标

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
huzhifeng@Ubuntu16041:~$ dpkg --listfiles typora | grep desktop
/usr/share/applications/typora.desktop
huzhifeng@Ubuntu16041:~$ cp /usr/share/applications/typora.desktop ~/Desktop/
huzhifeng@Ubuntu16041:~$ vim ~/Desktop/typora.desktop
huzhifeng@Ubuntu16041:~$ chmod +x ~/Desktop/typora.desktop
huzhifeng@Ubuntu16041:~$ cat ~/Desktop/typora.desktop
[Desktop Entry]
Name=Typora
Version=1.0
Exec=typora %U
Icon=typora
Type=Application
Terminal=false
huzhifeng@Ubuntu16041:~$

CentOS 安装 Typora

参考 Install Typora on Linux

1
2
3
4
5
6
7
8
9
10
There’s no rpm package for Typora yet, so there’s two way.
One way is to yum install apt, then use apt-get like Debian/Ubuntu to install.
Another way is to alien to install Typora’s deb, but you need to manually upgrade Typora when new version is avaible, therefore, this way is not recommended. To get the deb package of Typora:
Open https://www.typora.io/linux/Packages.
Find the value for key Filename in the section of correspond Archiecture, it should look like ./linux/typora_0.9.19_amd64.deb.
Prepend the filename with https://typora.io/ to get the url of latest deb package, for example https://typora.io/./linux/typora_0.9.19_amd64.deb
Download it, then install the deb with alien.

Typora 并没有提供相应的 RPM 安装包,所以需要曲线救国的方式,通过 Alien 转换后安装

安装 Alien

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[huzhifeng@CentOS72 ~]$ sudo yum install epel-release
[huzhifeng@CentOS72 ~]$ sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
[huzhifeng@CentOS72 ~]$ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
[huzhifeng@CentOS72 ~]$ sudo yum update && sudo yum install alien
[huzhifeng@CentOS72 ~]$ rpm -q alien
alien-8.90-3.el7.nux.noarch
[huzhifeng@CentOS72 ~]$ rpm -ql alien
/usr/bin/alien
/usr/share/alien
/usr/share/alien/patches
/usr/share/doc/alien-8.90
/usr/share/doc/alien-8.90/GPL
/usr/share/doc/alien-8.90/README
/usr/share/doc/alien-8.90/changelog
/usr/share/man/man1/alien.1.gz
/usr/share/man/man3/Alien::Package.3pm.gz
/usr/share/man/man3/Alien::Package::Deb.3pm.gz
/usr/share/man/man3/Alien::Package::Lsb.3pm.gz
/usr/share/man/man3/Alien::Package::Pkg.3pm.gz
/usr/share/man/man3/Alien::Package::Rpm.3pm.gz
/usr/share/man/man3/Alien::Package::Slp.3pm.gz
/usr/share/man/man3/Alien::Package::Tgz.3pm.gz
/usr/share/perl5/vendor_perl/Alien
/usr/share/perl5/vendor_perl/Alien/Package
/usr/share/perl5/vendor_perl/Alien/Package.pm
/usr/share/perl5/vendor_perl/Alien/Package/Deb.pm
/usr/share/perl5/vendor_perl/Alien/Package/Lsb.pm
/usr/share/perl5/vendor_perl/Alien/Package/Pkg.pm
/usr/share/perl5/vendor_perl/Alien/Package/Rpm.pm
/usr/share/perl5/vendor_perl/Alien/Package/Slp.pm
/usr/share/perl5/vendor_perl/Alien/Package/Tgz.pm
/var/lib/alien
[huzhifeng@CentOS72 ~]$

Alien 安装 Typora

下载 DEB 安装包 typora_0.9.23_amd64.deb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[huzhifeng@CentOS72 ~]$ curl https://typora.io/linux/Packages
Package: typora
Version: 0.9.23-1
Architecture: amd64
Maintainer: typora<hi@typora.io>
Installed-Size: 132186
Recommends: lsb-release
Suggests: gir1.2-gnomekeyring-1.0, libgnome-keyring0
Filename: ./linux/typora_0.9.23_amd64.deb
Size: 37487388
MD5sum: bdd6b9a180ccdcc2cc91fb5347b356d8
SHA1: 89c2004792b035be356bb28b98d13e602cdbd9d3
SHA256: e50daf2f057284809f1e7a7fd8f0198f5407aa49a89df84b8003946367f352af
Section: editors
Priority: optional
Homepage: http://typora.io
Description: a minimal Markdown reading & writing app.
A minimal markdown editor
[huzhifeng@CentOS72 ~]$ wget https://typora.io/linux/typora_0.9.23_amd64.deb
[huzhifeng@CentOS72 ~]$ md5sum typora_0.9.23_amd64.deb
bdd6b9a180ccdcc2cc91fb5347b356d8 typora_0.9.23_amd64.deb
[huzhifeng@CentOS72 ~]$

通过 Alien 把 DEB 包转换成 RPM 包
注意:

  1. 建议使用 root 权限转换
  2. 转换后的版本后默认会累加一位,使用参数 “–keep-version” 保留版本一致
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [huzhifeng@CentOS72 ~]$ alien --to-rpm --scripts typora_0.9.23_amd64.deb
    Warning: alien is not running as root!
    Warning: Ownerships of files in the generated packages will probably be wrong.
    typora-0.9.23-2.x86_64.rpm generated
    [huzhifeng@CentOS72 ~]$ sudo alien --to-rpm --scripts typora_0.9.23_amd64.deb
    typora-0.9.23-2.x86_64.rpm generated
    [huzhifeng@CentOS72 ~]$ sudo alien --to-rpm --scripts --keep-version typora_0.9.23_amd64.deb
    typora-0.9.23-1.x86_64.rpm generated
    [huzhifeng@CentOS72 ~]$ ls -lh typora*
    -rw-r--r--. 1 root root 40M Feb 12 19:20 typora-0.9.23-1.x86_64.rpm
    -rw-r--r--. 1 root root 40M Feb 12 19:18 typora-0.9.23-2.x86_64.rpm
    -rw-rw-r--. 1 huzhifeng huzhifeng 36M Jan 20 21:03 typora_0.9.23_amd64.deb
    [huzhifeng@CentOS72 ~]$

安装 RPM 包提示缺少动态库 libXss.so.1libffmpeg.so,其中 libXss.so.1 由包 libXScrnSaver 提供,而 libffmpeg.so 则是 Typora 自带的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[huzhifeng@CentOS72 ~]$ sudo rpm -Uvh typora-0.9.23-1.x86_64.rpm
error: Failed dependencies:
libXss.so.1()(64bit) is needed by typora-0.9.23-1.x86_64
libffmpeg.so()(64bit) is needed by typora-0.9.23-1.x86_64
[huzhifeng@CentOS72 ~]$ yum provides libXss.so.1
libXScrnSaver-1.2.2-6.1.el7.i686 : X.Org X11 libXss runtime library
Repo : base
Matched from:
Provides : libXss.so.1
[huzhifeng@CentOS72 ~]$ yum provides libffmpeg.so
No matches found
[huzhifeng@CentOS72 ~]$ rpm -qpl typora-0.9.23-1.x86_64.rpm | grep libffmpeg
/usr/share/typora/libffmpeg.so
[huzhifeng@CentOS72 ~]$
[huzhifeng@CentOS72 ~]$ sudo yum install libXScrnSaver

强制安装仍然提示有诸多冲突

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[huzhifeng@CentOS72 ~]$ sudo rpm -Uvh --nodeps typora-0.9.23-1.x86_64.rpm
Preparing... ################################# [100%]
file /usr/share/icons/hicolor from install of typora-0.9.23-1.x86_64 conflicts with file from package centos-logos-70.0.6-3.el7.centos.noarch
file /usr/share/icons/hicolor/256x256/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package centos-logos-70.0.6-3.el7.centos.noarch
file /usr/share/icons/hicolor/32x32/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package centos-logos-70.0.6-3.el7.centos.noarch
file /usr/share/icons/hicolor/256x256 from install of typora-0.9.23-1.x86_64 conflicts with file from package centos-logos-70.0.6-3.el7.centos.noarch
file /usr/share/icons/hicolor/32x32 from install of typora-0.9.23-1.x86_64 conflicts with file from package centos-logos-70.0.6-3.el7.centos.noarch
file / from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/bin from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/share from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/share/applications from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/share/doc from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/share/icons from install of typora-0.9.23-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
file /usr/share/icons/hicolor from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/128x128 from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/128x128/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/256x256/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/32x32/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/64x64/apps from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/256x256 from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/32x32 from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
file /usr/share/icons/hicolor/64x64 from install of typora-0.9.23-1.x86_64 conflicts with file from package hicolor-icon-theme-0.12-7.el7.noarch
[huzhifeng@CentOS72 ~]$

参考
How to Convert From RPM to DEB and DEB to RPM Package Using Alien
How To Convert DEB To RPM & RPM To DEB Package - Alien
重新打包,把有冲突的目录全部删除掉

1
2
3
4
5
6
[huzhifeng@CentOS72 ~]$ sudo yum --enablerepo=epel-testing install rpmrebuild
[huzhifeng@CentOS72 ~]$ rpmrebuild -pe typora-0.9.23-1.x86_64.rpm
Do you want to continue ? (y/N) y
warning: Explicit %attr() mode not applicaple to symlink: /home/huzhifeng/.tmp/rpmrebuild.13932/work/root/usr/bin/typora
result: /home/huzhifeng/rpmbuild/RPMS/x86_64/typora-0.9.23-1.x86_64.rpm
[huzhifeng@CentOS72 ~]$ sudo rpm -Uvh --nodeps /home/huzhifeng/rpmbuild/RPMS/x86_64/typora-0.9.23-1.x86_64.rpm

创建桌面快捷图标

1
2
3
4
5
6
7
8
9
10
11
[huzhifeng@CentOS72 ~]$ cp /usr/share/applications/typora.desktop ~/Desktop/
[huzhifeng@CentOS72 ~]$ vim ~/Desktop/typora.desktop
[huzhifeng@CentOS72 ~]$ cat ~/Desktop/typora.desktop
[Desktop Entry]
Version=0.9.23
Name=Typora
Exec=typora %U
Icon=/usr/share/icons/hicolor/128x128/apps/typora.png
Type=Application
Terminal=false
[huzhifeng@CentOS72 ~]$ chmod +x ~/Desktop/typora.desktop

EOF