简体   繁体   English

如何将静态数据文件包含到Archlinux AUR软件包中?

[英]How to include static data files into Archlinux AUR package?

I have a small script that uses some static text files as data source. 我有一个使用一些静态文本文件作为数据源的小脚本。 I want to make Archlinux AUR package for this script. 我想为此脚本制作Archlinux AUR软件包。 I plan to install the script into /usr/bin/ and static text files somewhere locally ~/.data_files 我计划将脚本安装到/usr/bin/和本地~/.data_files静态文本文件中

I have several static files: data1.txt, data2.txt, data3.txt. 我有几个静态文件:data1.txt,data2.txt,data3.txt。 Basically, I need the package manager to install the script into /usr/bin/ , create ~/.data_files directory and copy the static files there. 基本上,我需要软件包管理器将脚本安装到/usr/bin/ ,创建~/.data_files目录并在其中复制静态文件。

How should I configure my PKGBUILD in such case? 在这种情况下如何配置PKGBUILD?

Here is my current version: 这是我当前的版本:

# Maintainer: john doe
pkgname=myscript
pkgver=1.0
pkgrel=1
pkgdesc="test script"
arch=(any)
url="https://github.com/me/myscript"
license=('MIT')
depends=('file')
source=('https://raw.githubusercontent.com/me/myscript/master/myscript')
md5sums=('1fa410f1647700a6da3ab0ebyc52465d')

package() {
  install -D -m 755 myscript ${pkgdir}/usr/bin/myscript
}

Let me quote one of the most active moderator of Archlinux Forum when he said here : 让我引用的Archlinux论坛的时候,他说,最有效的监督者之一在这里

Do not touch the users home directory in a PKGBUILD, especially do not delete things because weird bugs can do bad things . 请勿触摸PKGBUILD中的用户主目录,尤其不要删除内容,因为奇怪的错误可能会导致不良后果

Now as a maintainer in AUR, I would suggest to add your statics files in the folder /usr/share/${pkgname}/ as it's also suggested in Arch Packaging Standards 现在作为AUR的维护者,我建议将您的静态文件添加到/usr/share/${pkgname}/文件夹中,正如Arch Packaging Standards中所建议的那样

Here's my suggestion (open for editions, suggestions, advices...) : 这是我的建议(适用于版本,建议,建议...)

# Maintainer: john doe <john at doe dot com>
pkgname=myscript
pkgver=1.0
pkgrel=1
pkgdesc="test script"
arch=(any)
url="https://github.com/me/myscript"
license=('MIT')
depends=('file')
source=('https://raw.githubusercontent.com/me/myscript/master/myscript'
      'data1.txt'
      'data2.txt'
      'data3.txt')
sha256sums=('77eff738ea7fdeee5f5707cafdf34f74e3bf8df3b8b656a08a8740a45a7e22c45a7e60c31b13c71f5ee04aff9c82ac43abb39c37b2ea6b02a6454e262f336f73'
       'sha256Ofdata1.txt'
       'sha256Ofdata2.txt'
       'sha256Ofdata3.txt')

package() {
  install -Dm755 myscript "${pkgdir}/usr/share/${pkgname}/myscript"
  install -Dm644 data1.txt "${pkgdir}/usr/share/${pkgname}/data1.txt"
  install -Dm644 data2.txt "${pkgdir}/usr/share/${pkgname}/data2.txt"
  install -Dm644 data3.txt "${pkgdir}/usr/share/${pkgname}/data3.txt"
}

Because of md5 known vulnerabilities, I used sha256 but you can choose to use other sha* for integrity check. 由于已知的md5漏洞,我使用了sha256,但是您可以选择使用其他sha *进行完整性检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM