Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PKGBUILD, example config, and example systemd service #572

Open
Lyamc opened this issue Nov 6, 2023 · 4 comments
Open

PKGBUILD, example config, and example systemd service #572

Lyamc opened this issue Nov 6, 2023 · 4 comments
Labels
S-needs-triage Status: Needs triage T-feature-request Type: Feature request

Comments

@Lyamc
Copy link

Lyamc commented Nov 6, 2023

See the following for a PKGBUILD that works with the current state of the master, so long as you use the dim binary from the releases https://github.com/Dusk-Labs/dim/releases/download/v0.3.0-rc6/release.zip .

Some of this may be useful for #569

# Maintainer: Your Name <[email protected]>
pkgname=dim-git
pkgver=1991.712b368c
pkgrel=1
pkgdesc="Dim Media Manager"
arch=('x86_64')
url="https://github.com/Dusk-Labs/dim"
license=('AGPLv3')
provides=('dim')
depends=('ffmpeg' 'rust' 'sqlite' 'nodejs>=16')
makedepends=('git' 'cargo' 'yarn')
optdepends=(
        'libva-intel-driver: for Intel GPU video acceleration support'
        'libva-vdpau-driver: for NVIDIA GPU video acceleration support'
        'libva-mesa-driver: for AMD GPU video acceleration support'
)
source=("${pkgname}::git+https://github.com/Dusk-Labs/dim.git")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${pkgname}"
  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd "${srcdir}/${pkgname}"
  yarn --cwd ui/
  yarn --cwd ui/ build

  cd "${srcdir}/${pkgname}"
  cargo build --features vaapi --release
}

package() {
  install -Dm755 "${srcdir}/${pkgname}/target/release/dim" "${pkgdir}/usr/bin/dim"
  install -dm755 "${pkgdir}/usr/bin/utils"
  ln -nfs "$(which ffmpeg)" "${pkgdir}/usr/bin/utils/ffmpeg"
  ln -nfs "$(which ffprobe)" "${pkgdir}/usr/bin/utils/ffprobe"

  install -Dm644 "${srcdir}/${pkgname}/target/dim_dev.db" "${pkgdir}/var/lib/dim/dim_dev.db"

  install -dm755 "${pkgdir}/etc/dim"
  install -dm755 "${pkgdir}/usr/share/dim"
  install -dm755 "${pkgdir}/var/cache/dim"
  install -dm755 "${pkgdir}/var/lib/dim"
  install -dm755 "${pkgdir}/var/lib/dim/metadata"

  install -Dm644 /dev/stdin "$pkgdir/etc/dim/dim.conf" <<EOF1
enable_ssl = false
port = 8000
cache_dir = '/var/cache/dim'
metadata_dir = '/var/lib/dim/metadata'
quiet_boot = false
disable_auth = false
verbose = false
EOF1

  # Create the systemd service file
  install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/system/dim.service" <<EOF2

[Unit]
Description=Dim Media Manager
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/dim -c /etc/dim/dim.conf
WorkingDirectory=/var/lib/dim
Restart=on-failure
Environment=RUST_BACKTRACE=full
Environment=RUST_LOG=info

[Install]
WantedBy=multi-user.target
EOF2

}

You can create the systemd service separately if you like as well
$ sudo nano /usr/lib/systemd/system/dim.service

[Unit]
Description=Dim Media Manager
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/dim -c /etc/dim/dim.conf
WorkingDirectory=/var/lib/dim
Restart=on-failure
Environment=RUST_BACKTRACE=full
Environment=RUST_LOG=info

[Install]
WantedBy=multi-user.target

And an example config:
$ sudo nano /etc/dim/dim.conf

enable_ssl = false
port = 8000
cache_dir = '/var/cache/dim'
metadata_dir = '/var/lib/dim/metadata'
quiet_boot = false
disable_auth = false
verbose = false
@Lyamc Lyamc added S-needs-triage Status: Needs triage T-feature-request Type: Feature request labels Nov 6, 2023
@Lyamc
Copy link
Author

Lyamc commented Nov 7, 2023

Having issues with a master version, I keep getting this error, which doesn't make sense:

Failed to run migrations (maybe you need to delete the old database?): VersionMismatch(20210619211347)

@a22sc
Copy link

a22sc commented Nov 20, 2023

thank you for the great work!

The problem with the database is probably, that it is created relative to the path of the dim-binary

I extended your PKGBUILD and created a seperate user for the service.
enable_hwaccel = true is also neccesary. otherwise the config-file is overwritten.

dim-pkgbuild.tar.gz

I'm open for improvements.

@a22sc
Copy link

a22sc commented Nov 21, 2023

if you run this on aarch64, you should use ffmpeg 5 in /usr/share/dim/utils as recommended in #554 or wait for the commit

@Lyamc
Copy link
Author

Lyamc commented Nov 22, 2023

Nice, just had to chown a few things and it worked just fine. I think for a proper deployment we'll need some post install and uninstall actions.

I think my original db issue was actually due to an issue that has since been fixed in the master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-triage Status: Needs triage T-feature-request Type: Feature request
Projects
None yet
Development

No branches or pull requests

2 participants