《花姐 Error 遊》第 14 集截圖


I’ll be brief about the issue:

  1. Android SDK depends on an old standard library java.se.ee, but it was deprecated in Java 9 and 10 and was finally removed in Java 11.
  2. Modern Linux distribution comes with OpenJDK Java 11.
  3. Your Android / Flutter command tools (e.g. sdkmanager, flutter) would run on the default-installed version of Java, which do not have java.se.ee at all.

As a result, your command tools would sometimes run into error like this:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at…

修改自 Mastodon 官方介紹的藝術圖片


If you are a programmer who occasionally work with bash script, it might have bothered you that bash function doesn’t return anything except for an integer of 0–255.

Let’s consider if you wrote a function that returns a string, like this:

#!/bin/bashfunction hello() {
return "Hello $1"
}
echo $(hello world)

The return statement doesn’t work:

The return statement doesn’t work:test.sh: line 5: return: Hello world: numeric argument required

This is because of the fact that bash’s return keyword is for function to return exit status. But how do you “return” anything meaningful from a bash function? …


Photo by Olav Ahrens Røtne on Unsplash

I encountered a file format like this. And I need to print the 2nd column:

AAA "BBB CCC" DDD
EEE FFF GGG

The expected output:

BBB CCC
FFF

How short can my code be?

The format might look very random. You can certainly create a custom reader for the specific file format. But if you think about it, its just like a CSV file but use space, instead of comma, as the delimiter.

Don’t know if you noticed before. PHP’s built-in CSV reading function fgetcsv() is very flexible.


上一篇文章談到,如何將示範的 tick5 程式變成 systemd 長駐服務,這次我們談談 rpm 的變量和巨集 (macro) 功能。

讓我們重新看看先前的 tick5.spec 檔案︰

其實 SPEC 檔中的數值、文字,我們有可能想在打包時才決定的,比如︰

  • 版本號應該可以在打包時才決定吧?
  • 安裝程式的位置。雖然說 /usr 是正常套件的安裝地,但也許我想安裝在 /usr/local 的啊。
  • 安裝 tick5.service 的地點,我也有機會修改的啊。有些分發版本傾向讓你安裝在 /etc/lib/sysmted/system ,也有可能放在其他資料匣。
  • tick5.service 裏的 “come on, James” 我不喜歡,我想每次打包都能重新決定啊。

那該怎麼做呢?用變量吧。

在 SPEC 中使用變量和巨集

先前一直談,SPEC 支援 …


你試過在 GNOME 上用倉頡中文輸入法打字,卻打出英文字母嗎?


上一篇文章教過大家打包一個沒甚麼營養的程式,這篇文章教大家怎樣理解 SPEC 檔,令它進化,變成沒甚麼營養的 systemd 長駐程式(喂)。

上一篇文章tick5 程式打包,使用這一個 SPEC 檔案︰

​tick5.spec

到底這檔案各部份是甚麼意思?我們來解剖一下。

SPEC 檔的基本結構


Linux 世界除了 .tar 之外,有兩大主流打包格式,就⃟是⃟倚⃟天⃟劍⃟和⃟屠⃟龍⃟刀⃟ 就是 .deb.rpm,由於最近工作關係,學了一點點這兩個格式的打包技巧,希望和大家分享一下。

這篇文我們來談一下 .rpm 格式。

有興趣請跟着本文動手,打包你人生第一個 .rpm 檔吧!

簡介

rpm 是 1997 年 Erik Troan 和 Marc Ewing 為紅帽 (RedHat Linux) 設計的包裝格式,設計參考一些更早的打包工具(pm、pms),名字 rpm 的全寫是「RPM Package Manager」(對,是自我指涉的命名,總之別再問了)。

Koala Yeung

An FOSS enthusiast. Lives in Hong Kong. Writes Go, Javascript, PHP and occasionally fictions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store