Zacharia2 / SuperMemo18-ON-Wine

Linux/Mac SuperMemo18.05 WINE32 DEB安装包、渐进学习
https://zhuanlan.zhihu.com/p/554277420
37 stars 2 forks source link

fix pkgbuild #7

Closed asukaminato0721 closed 1 year ago

asukaminato0721 commented 1 year ago

这样修好后可以安装了,但还有问题。

krunner[2076]: QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
krunner[2076]: file:///usr/lib/qt/qml/org/kde/plasma/components.3/ToolTip.qml:57:9: QML Label: Binding loop detected for property>
krunner[3935]: /usr/bin/env: "sm-wine": 没有那个文件或目录

需要研究下怎么修。

Zacharia2 commented 1 year ago

@wuyudi 可以看这行:https://github.com/Zacharia2/SuperMemo18-ON-Wine/blob/4e19fb1b3cc6fcac5a055022a31f51096dd3a981/deb-package/DEBIAN/postinst#L6

Zacharia2 commented 1 year ago

我为wine-appimage创建了一个软链接

Zacharia2 commented 1 year ago

具体的封装DEB的步骤在这个文件夹中的两个脚本。非常简单。

deb-package/DEBIAN

https://github.com/Zacharia2/SuperMemo18-ON-Wine/blob/4e19fb1b3cc6fcac5a055022a31f51096dd3a981/deb-package/DEBIAN/postinst#L1-L24

https://github.com/Zacharia2/SuperMemo18-ON-Wine/blob/4e19fb1b3cc6fcac5a055022a31f51096dd3a981/deb-package/DEBIAN/postrm#L1-L12

asukaminato0721 commented 1 year ago

@wuyudi 可以看这行:

https://github.com/Zacharia2/SuperMemo18-ON-Wine/blob/4e19fb1b3cc6fcac5a055022a31f51096dd3a981/deb-package/DEBIAN/postinst#L6

ok, 我知道怎么修了。(这个 Appimage 里的 wine 的版本是 3.10 吗,感觉好老

Zacharia2 commented 1 year ago

是的,但我不会封装新版的wine.appimage,看了很多遍,都没搞明白。

Zacharia2 commented 1 year ago

要不,你把那安装后与卸载后两个脚本的代码写进配置文件?

asukaminato0721 commented 1 year ago

似乎。。可以直接用系统的 wine, 刚刚试了下,似乎没问题。

Zacharia2 commented 1 year ago

确实用哪个wine都可以。不过有的人们系统里面没有wine。。。

asukaminato0721 commented 1 year ago

确实用哪个 wine 都可以。不过有的人们系统里面没有 wine。。。

写进 deps 里面就行了x

Zacharia2 commented 1 year ago

也是吼!不过要注意修改desktop文件(如果要这样做的话),deb-package/usr/share/applications/

我在构建deb包的时候是手动把SM18.05-WINE-Vessel、wine-appimag以及懒人包放进deb-package对应文件夹中的。

Zacharia2 commented 1 year ago

@wuyudi 有空修嘛?没空的话我先合并啦?

asukaminato0721 commented 1 year ago

重写 PKGBUILD 中,正在修权限。

这个 deb tar 解压后是 user 权限,但是默认放的位置应该都是 root, 所以修完

find "$pkgdir"/usr/share -type f -exec chmod 644 "{}" \;
find "$pkgdir"/usr/share -type d -exec chmod 755 "{}" \;

反而会报 https://ubuntuforums.org/showthread.php?t=700801 错误。

asukaminato0721 commented 1 year ago

跑起来了,但是有无法理解的 bug

/usr/share/applications/SuperMemo18.05.desktop:行 3: 100541 段错误               (核心已转储)Exec=env WINEARCH=win32 WINEPREFIX="$HOME/.local/share/wineprefixes/SM18.05-WINE-Vessel" wine $HOME/.local/share/wineprefixes/SM18.05-WINE-Vessel/drive_c/SuperMemo/sm18.exe

wine 的版本已经最新了。

image

算了,有 warning 又不影响使用

PKGBUILD 存个档,就放着吧。 ```sh pkgname=supermemo-18.05 pkgver=1.4.0 pkgrel=1 pkgdesc="A program that makes learning fun and easy." arch=('x86_64') url="https://github.com/Zacharia2/SuperMemo18-ON-Wine/" license=('proprietary') depends=('wine') options=('!strip') # appimage can't strip source=("${pkgname}-${pkgver}-${arch}.deb::https://github.com/Zacharia2/SuperMemo18-ON-Wine/releases/download/v1.4.0/SuperMemo18.05-lazy-wine32-package.v1.4.0.deb") sha512sums=('ed960be944258023a4be546808235ee2358d6ecdea827974a7e4c1b94259ee15dc3a4c6c435f47a4b062622c3f4fbf442e916333e685422e39d8ecc77cf62eaa') prepare() { cd "${srcdir}" tar xpf data.tar.zst pushd usr/share/applications sed -i 's|/usr/share/|$HOME/.local/share/wineprefixes/|g' SuperMemo18.05.desktop sed -i 's|/usr/share/|$HOME/.local/share/wineprefixes/|g' SuperMemo18.05-winecfg.desktop sed -i 's/ sm-wine / wine /' SuperMemo18.05.desktop sed -i 's/ sm-wine / wine /' SuperMemo18.05-winecfg.desktop popd pushd usr/share/SM18.05-WINE-Vessel rm Wine-x86_64-ubuntu.latest.AppImage popd } package() { mkdir -p "${pkgdir}/$HOME/.local/share/wineprefixes/SM18.05-WINE-Vessel/" cp -a ${srcdir}/usr/share/SM18.05-WINE-Vessel/* "${pkgdir}/$HOME/.local/share/wineprefixes/SM18.05-WINE-Vessel/" find "$pkgdir"/$HOME/.local/share/wineprefixes -type f -exec chmod 600 "{}" \; find "$pkgdir"/$HOME/.local/share/wineprefixes -type d -exec chmod 700 "{}" \; install -Dm755 "${srcdir}/usr/share/applications/SuperMemo18.05.desktop" "$pkgdir/usr/share/applications/SuperMemo18.05.desktop" install -Dm755 "${srcdir}/usr/share/applications/SuperMemo18.05-winecfg.desktop" "$pkgdir/usr/share/applications/SuperMemo18.05-winecfg.desktop" } ```

就继续原来的吧。

asukaminato0721 commented 1 year ago

我找到 bug 了,假如直接用 wine, 会报错

image

但是用 Appimage 打开过一次后,再用 Appimage or wine 都不会报错了。

image

那就直接在一开始的 desktop 里把 sm-wine 改成 /usr/share/SM18.05-WINE-Vessel/Wine-x86_64-ubuntu.latest.AppImage

Zacharia2 commented 1 year ago

好的

Zacharia2 commented 1 year ago

@wuyudi 所以我要重新建构一个deb包对嘛?

asukaminato0721 commented 1 year ago

@wuyudi 所以我要重新建构一个 deb 包对嘛?

是的,构建完就不需要那个 sm-wine 的 ln 了。

Zacharia2 commented 1 year ago

OK,了解这就做。

Zacharia2 commented 1 year ago

@wuyudi 重新打包好了,已经替换掉原来的DEB包了。

Zacharia2 commented 1 year ago

现在还有问题嘛?@wuyudi

asukaminato0721 commented 1 year ago

现在还有问题嘛?@wuyudi

打包安装本身没问题了


权限问题(不妨碍使用)

warning: directory permissions differ on /usr/
filesystem: 755  package: 775
warning: directory permissions differ on /usr/share/
filesystem: 755  package: 775
warning: directory permissions differ on /usr/share/applications/
filesystem: 755  package: 775

要整体大改,那就不改了。

有几种方法:

  1. 修改 permissions, 那 owner 就变成 root 了,user 没法用。/usr/share/ 里面都是 root 的
  2. 移到 ~/.local/share/wineprefixes/ 里面,写起来非常麻烦(上面我写了一份半成品)。因为这个 deb 包里面带了 Appimage(wine) + wineprefix + 软件本体(数据是写到 prefix 里面的),所以相近的可以参见 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=deepin-wine-tim 这一堆。
  3. 不管了(目前的解决方案)

wine 本身的问题和打包无关(比如多媒体这种常见问题,毕竟 wine 不是 windows)

Zacharia2 commented 1 year ago

okk,目前deb的打包比较顺利,也没遇到啥问题(ps:感觉还是不折腾的系统好用,mint大薄荷,你值得拥有。)

Zacharia2 commented 1 year ago

关于自己的家目录,我不会获取到自己的家目录,因为当使用sudo家目录就变成root的了。还有其它情况,我自己都不知道咋获得自己的家目录。。。

asukaminato0721 commented 1 year ago

其实吧。。

ls -al /usr/share

...
drwxr-xr-x root        root          80 B  Tue Nov 15 19:12:17 2022  slimbookamdcontroller                                                                   
drwxr-xr-x root        root         820 B  Thu Sep 15 16:37:42 2022  slsh                                                                                    
drwxrwxr-x asukaminato asukaminato  288 B  Mon Jan  9 00:14:51 2023  SM18.05-WINE-Vessel                                                                     
drwxr-xr-x root        root          84 B  Thu Sep 15 16:35:08 2022  smartmontools                                                                           
drwxr-xr-x root        root        1014 B  Tue Nov 15 19:09:05 2022  snmp 
...

这里权限是有问题的。。。 你的电脑上应该也是这样的


除非自己写这种 PKGBUILD, 不然日常装东西只一行。 paru -S pkg

即使需要手动打包,只需要写 PKGBUILD 文件(假如是拆 deb 包,就 tar xpf data.xxxxx -C $pkgdir ,而且可以自由调整,比如这个包里面 sed desktop 文件再 cp 到指定位置)。

Zacharia2 commented 1 year ago

确实,安装软件很方便,最喜欢arch系的这个特点啦,如果有个融合怪就好了,稳定发行版➕aur。感觉yyds。系统我感觉不就是稳定加丰富可快速安装的软件嘛。哈哈哈

这应该与个人喜好有关系,我更喜欢开箱即用的且省时省力的Linux发行版。之前用过红帽,红帽的社区版,Ubuntu,arch,manjaro等等。最后还是mint让我省心。

asukaminato0721 commented 1 year ago

archinstall 脚本非常开箱即用(官方支持),或者 archfi

asukaminato0721 commented 1 year ago

关于自己的家目录,我不会获取到自己的家目录,因为当使用 sudo 家目录就变成 root 的了。还有其它情况,我自己都不知道咋获得自己的家目录。。。

$HOME 家目录 ~ 也是

Zacharia2 commented 1 year ago

$HOME 家目录 ~ 也是

我知道这个,只不过提权后就变成root了。。。 我需要的是在一台机器上绝对的家目录。

asukaminato0721 commented 1 year ago

$HOME 家目录 ~ 也是

我知道这个,只不过提权后就变成 root 了。。。 我需要的是在一台机器上绝对的家目录。

问题是一台机器上可能有一堆 $HOME 比如 /home/a, /home/b, /root

arch 的 build 是 fakeroot(或者 chroot), 在一个 fake 的环境下构建, 避免提权,构建完成后由 pacman 处理产物(sudo 只给 pacman)。不然在 /usr/bin 等目录下放东西需要 root。

Zacharia2 commented 1 year ago

明白啦,我大概知道如何解决权限问题了。执行打包时去掉sudo。

Zacharia2 commented 1 year ago

我在重新打包一下

Zacharia2 commented 1 year ago

dpkg: 错误: 所请求的操作需要超级用户权限

asukaminato0721 commented 1 year ago

这个 deb 包里有 2 个部分,appimage 和 prefix.

可以考虑把 prefix 放到 wineprefix 里面,像 deepin-wine 那样,deepin-wine 和软件本体分开。

appimage 是可执行对象,单独存放到 bin 里 rename 或者 ln -s 一个 sm-wine

感觉其实一个 shell 脚本就解决了。

Zacharia2 commented 1 year ago

好像没办法创建用户的家目录。。。

DEBIAN目录下存放的是控制信息control、以及软件包安装前后自动运行的可执行脚本preinst、postinst、prerm、postrm(后续介绍)。其他目录为软件具体的安装路径,而在安装过程中,包里的数据会被直接解压到根目录(即/),因此在打包之前需要根据文件所在位置设置好相应的文件/目录树。

asukaminato0721 commented 1 year ago

试着写了一下 -git 版的 PKGBUILD, 才注意到仓库里是没有 exe 的。

pkgname=supermemo18-git
pkgver=18.05
pkgrel=1
pkgdesc='memory tool'
arch=('x86_64')
url='https://supermemopedia.com/wiki/Main_Page'
license=('proprietary')
depends=('wine')
sha512sums=('SKIP')
source=('git+https://github.com/Zacharia2/SuperMemo18-ON-Wine.git')

package() {
        mkdir -p $pkgdir/$HOME/.local/share/wineprefixes/
        echo "put wineprefix"
        cp --archive $srcdir/SuperMemo18-ON-Wine/SM18.05-WINE-Vessel $pkgdir/$HOME/.local/share/wineprefixes/
        echo "done wineprefix"
        echo "put desktop file"
        # Desktop file
        for i in SuperMemo18.05-winecfg SuperMemo18.05
        do
                desktop="${srcdir}/SuperMemo18-ON-Wine/deb-package/usr/share/applications/$i.desktop"
                sed -i 's|/usr/share/SM18.05-WINE-Vessel/Wine-x86_64-ubuntu.latest.AppImage|wine|g' $desktop
                echo "change wine"
                sed -i 's|/usr/share/|$HOME/.local/share/wineprefixes/|g' $desktop
                echo "change position"
                install -Dm644 $desktop -t "${pkgdir}/usr/share/applications/"
        done
        echo "done"
}

理论上有 exe 的话可以直接用了。(改改就是 shell 安装脚本)。

Zacharia2 commented 1 year ago

可以从叶哥的仓库下载一下,将SM非bin目录复制到容器的SuperMemo目录中。

Zacharia2 commented 1 year ago

我增加了SuperMemo懒人包的子模块。不知道source() 会不会下载下来。

Zacharia2 commented 1 year ago

source() 好像可以引用多个列表,怎么引用呢?

asukaminato0721 commented 1 year ago

解决了,但是因为 wine or sm 本身的 bug, 启动是有问题的。但是把 run.sh 和 config.sh 里的 wine 替换成合适的对象(比如 Appimage) 就可以跑了。

pkgname=supermemo18-git
pkgver=18.05
pkgrel=1
pkgdesc='memory tool'
arch=('x86_64')
url='https://supermemopedia.com/wiki/Main_Page'
license=('proprietary')
depends=('wine')
sha512sums=('SKIP'
            'SKIP')
source=('git+https://github.com/Zacharia2/SuperMemo18-ON-Wine.git' # wineprefix
        'git+https://github.com/L-M-Sherlock/sm18-lazy-package.git' # software
        )

package() {
        local prefix=$pkgdir/$HOME/.local/share/wineprefixes/
        mkdir -p $prefix

        echo "put wineprefix"
        # https://stackoverflow.com/questions/8488253/how-to-force-cp-to-overwrite-without-confirmation
        yes | cp -rf $srcdir/SuperMemo18-ON-Wine/SM18.05-WINE-Vessel $prefix

        echo "put binary"
        yes | cp -rf $srcdir/sm18-lazy-package/sm18/* $prefix/SM18.05-WINE-Vessel/drive_c/SuperMemo/

        echo "put desktop file"

        chown -R $USER:$USER $prefix/SM18.05-WINE-Vessel/

        local desktop="${srcdir}/SuperMemo18-ON-Wine/deb-package/usr/share/applications/SuperMemo18.05-winecfg.desktop"
        # https://stackoverflow.com/questions/16440377/replace-whole-line-when-match-found-with-sed
        sed -i '/Exec/s/.*/Exec=\/opt\/apps\/supermemo18\/config.sh/' $desktop
        echo "change to sh launch"
        install -Dm644 $desktop -t "${pkgdir}/usr/share/applications/"

        desktop="${srcdir}/SuperMemo18-ON-Wine/deb-package/usr/share/applications/SuperMemo18.05.desktop"
        sed -i '/Exec/s/.*/Exec=\/opt\/apps\/supermemo18\/run.sh/' $desktop
        echo "change to sh launch"
        install -Dm644 $desktop -t "${pkgdir}/usr/share/applications/"

        echo "put launch file"
        mkdir -p $pkgdir/opt/apps/supermemo18

        echo "#!/bin/sh" > $pkgdir/opt/apps/supermemo18/run.sh
        echo 'env WINEARCH=win32 WINEPREFIX=/home/$USER/.local/share/wineprefixes/SM18.05-WINE-Vessel wine /home/$USER/.local/share/wineprefixes/SM18.05-WINE-Vessel/drive_c/SuperMemo/sm18.exe' >> $pkgdir/opt/apps/supermemo18/run.sh

        echo "#!/bin/sh" > $pkgdir/opt/apps/supermemo18/config.sh
        echo 'env WINEARCH=win32 WINEPREFIX=/home/$USER/.local/share/wineprefixes/SM18.05-WINE-Vessel winecfg' >> $pkgdir/opt/apps/supermemo18/config.sh

        chmod +x $pkgdir/opt/apps/supermemo18/*.sh
        echo "done"
}
Zacharia2 commented 1 year ago

@wuyudi 那我放进去啦?

Zacharia2 commented 1 year ago

也许是wine版本差异太大了?