Saving ownKeepass

Here is what I did to build ownKeepass for aarch64.

I think the biggest problem people that want to repeat these steps will face is that I’m using my own build environment (Sailfish OS Builds in Docker). I will not go into the reasons why here, but I suggest first trying to repeat these steps in the same environment and then porting it to what most people use (which is the official Sailfish OS SDK I think).

ownKeepass depends on libargon2 and libsodium. In this example we’ll use the RPMs I already uploaded to my repository, but if you’re interested in building them yourself you can check out how I did it (thanks to @abranson for some clarifications!):

Preparing Sailfish OS Builds in Docker

  • mkdir ~/software (if it does not exist yet)
  • cd ~/software
  • git clone https://git.sr.ht/~aerique/sfosbid sfosbid-git
  • cd sfosbid-git
  • ./download.sh
  • ./build.sh -u
  • ./run.sh -u

Preparing the Build Environment

This section assumes you’ve run ./run.sh -u from the previous section and are
now in the Docker container.

  • sb2 -t SailfishOS-latest-aarch64 -m sdk-install -R
  • rpm --import https://sailfish.openrepos.net/openrepos.key
  • zypper addrepo -f https://sailfish.openrepos.net/aerique/personal-main.repo
  • zypper install libargon2-devel libsodium-devel libgcrypt-devel
  • exit
    • this exits the sb2 sdk-install environment from above, it does not exit the Docker container

Building ownKeepass

(This is still in the Docker container.)

We will not use the official repository but @samule’s slightly updated one that has already improved the libgcrypt situation for us:

  • cd projects
  • git clone https://github.com/24mu13/ownkeepass.git ownkeepass-git
  • cd ownkeepass-git
  • git submodule update --init --recursive
  • cd Sailfish
  • in ownKeepass.pro change ARCH_LIBS from armv7hl to aarch64
  • in rpm/harbour-ownkeepass.yaml remove - libargon2 in the PkgCongfigBR list
  • mb2 -t SailfishOS-latest-aarch64 build

If the build was successfull you’ll have an ownKeepass RPM in the RPMS
directory.

7 Likes

Thanks @aerique for the detailed instruction :smiley:

I only use Sailfish IDE and it’s build engine, I’ll see if I can replicate your instructions and compile a working RPM without using Docker and a specific build environment.

I have not tested anything, but looking at the commands I believe you could just replace sb2 -t SailfishOS-latest-aarch64 -m sdk-install -R with sfdk tools exec SailfishOS-4.1.0.23EA-aarch64 and mb2 -t SailfishOS-latest-aarch64 build with sfdk build. Please note however that this installs the build dependencies directly in the target. I’d prefer having them in shared output directory and installing them automatically in a target snapshot. So this might work better:

  • Download the dependencies and place them in /home/foobar/keepass-rpms
  • sfdk config target=SailfishOS-4.1.0.23EA-aarch64
  • sfdk config snapshot
  • sfdk config output-dir=/home/foobar/keepass-rpms
  • sfdk build
2 Likes

Very nice work @aerique, and everyone, thank you.

Myself I use coderus work from Docker Hub to build in docker.

I write Gitlab CI scripts to do that, because they can then be used both on a local machine using gitlab-runner, or using the CI feature on gitlab.

Anyway I have taken the recipe above and put it in a gitlab-ci file. Posting below in case anyone is interested in building that way.
Not too much interesting or new in there, but it stores the output rpms in a dir in docker, and creates a local repo for zypper to install from instead of using online repos.

stages:
  - build

image: "coderus/sailfishos-platform-sdk-${TARGET}:${SFOS_VERSION}"
tags:
  - docker

default:

variables:
  #SFOS_VERSION: "4.0.1.45"
  SFOS_VERSION: "4.1.0.23"
  GIT_SUBMODULE_STRATEGY: recursive
  OUTDIR: $CI_PROJECT_DIR/output
  #BLDDIR: ~/build # this does not work because ~ does not expand. use a shell variable instead
  YAMLNAME: ownkeepass.yaml
  SPECNAME: ownkeepass.spec
  TARGET: armv7hl # set this globally for local builds because gitlab-ci-runner can not deal with extends: foo

.build-local:
  stage: build
  script:
    # prep
    - BLDDIR=~/build
    - mkdir -p $OUTDIR/$SFOS_VERSION/
    - mkdir -p ${BLDDIR}
    - cp -r $CI_PROJECT_DIR/* $BLDDIR/
    - pushd $BLDDIR
    # argon
    - git clone https://git.sr.ht/~aerique/libargon2-spec libargon2-spec-git
    - pushd libargon2-spec-git
    - git submodule update --init --recursive
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build   | tee $OUTDIR/build.log
    - cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
    - popd
    # sodium
    - git clone https://git.sr.ht/~aerique/libsodium-spec libsodium-spec-git
    - pushd libsodium-spec-git
    - curl -o libsodium-1.0.18-stable.tar.gz https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
    - tar xvfz libsodium-1.0.18-stable.tar.gz
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build   | tee $OUTDIR/build.log
    - cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
    - popd
    # main
    - LR=~/myrepo
    - mkdir -p $LR
    - for f in $(find $OUTDIR/$SFOS_VERSION -type f -name *.rpm); do cp ${f} $LR; done
    - sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper ar --no-gpgcheck $LR localfiles
    - sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper ref
    - sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper --non-interactive install libgcrypt-devel
    - sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper --non-interactive install --from localfiles libargon2-devel libsodium-devel
    - git clone https://github.com/24mu13/ownkeepass.git ownkeepass
    - pushd ownkeepass
    - git submodule update --init --recursive
    - cd Sailfish
    - sed -i -e '/.*libargon2.*/d' rpm/harbour-ownkeepass.yaml
    - sed -i -e '/.*libargon2.*/d' rpm/harbour-ownkeepass.spec
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
    - mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build   | tee $OUTDIR/build.log
    - cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
    - rm -r $BLDDIR/
  artifacts:
      when: always
      paths:
        - "output/*.log"
        - "output/*.spec"
        - "output/*.yaml"
        - "output/$SFOS_VERSION"
  cache:
    key: ${CI_PROJECT_NAME}_${CI_JOB_NAME}
    paths:
      - $SRCNAME-$SRCTAG
      - /home/.zypp-cache
      - /srv/mer/targets/SailfishOS-$SFOS_VERSION-$TARGET/var/cache/zypp/
      - /var/cache/zypp/
      - /home/nemo/src

build-arm64:
  stage: build
  extends: .build-local
  variables:
    TARGET: aarch64

build-arm:
  stage: build
  extends: .build-local
  variables:
    TARGET: armv7hl

build-x86:
  stage: build
  extends: .build-local
  variables:
    TARGET: i486

If you have gitlab-runner instaled locally, this will run the build:

#!/usr/bin/env bash

BASE_DIR=$PWD
BUILD_DIR=$BASE_DIR/build
CACHE_DIR=${HOME}/.cache/gitlab-runner-cache
mkdir -p $BUILD_DIR
builder="$1"
if [[ x"$1" = x"" ]]; then
  builder='.build-local'
fi
case $1 in
  '-h'|'list'|'help')
	echo these local builders exist:
	grep '^\..*local' .gitlab-ci.yml
	exit 0
	;;
esac

DOPTS="--docker-pull-policy=never --docker-volumes "$BUILD_DIR/:/builds:rw" --docker-cache-dir $CACHE_DIR "
[[ -e $BASE_DIR/build.log ]] && mv $BASE_DIR/build.log $BASE_DIR/build.log.old
gitlab-ci-multi-runner -l warn exec docker $DOPTS $builder 2>&1 | tee $BASE_DIR/build.log  |  grep -v 'ERROR: Could not create cache adapter'
2 Likes

Now that SailSync ownCloud have a 64bit version, and thanks to @aerique build of ownkeepass, my workflow to sync (through nextcloud) and use my keepass passwords is working fully again natively.
Thank you all.

4 Likes

ownKeepass is now available at OBS via sailfishos:chum repositories. Currently, builds are available for all architectures and released SFOS versions starting from 3.4.0.24 till 4.1.0.24.

To make it possible, I have used @aerique work, adjusted his packaging scripts for libargon2 and libsodium that got also published in Chum repos.

ownKeepass had some libs bundled in binary format within the sources to simplify packaging. Those got removed. I also dropped generation of SPEC from YAML, SPEC got cleaned up and now the application is built from the root of the project.

When someone gets to develop ownKeepass further, please look into the changes made at sailfishos-chum/ownkeepass. Had to remove forking as it leads to submitting of local PRs into other repositories upstream of the forking tree.

Note that testing is limited, seems to work for my database and allowed to create new one as well which I successfully opened on PC. That’s on 4.1.0.24/aarch64.

@aerique mentioned something regarding libgcrypt - I have not used any updated version of the lib. It looks to be available in SFOS repos and I don’t know whether it needs to be updated for earlier SFOS versions. Please chip in and let me know. In that case we may have to add that to Chum repos as well.

Enjoy, hopefully all works with this build.

11 Likes

Excellent, it seems the original topic now has git its solution, and it’s excatly what OBS/Chum appears to be about.

Thanks to all involved!

Thanks for the work @rinigus (and others!). At the moment I’m on GrapheneOS (I switch between SFOS and degoogled Android every 6 months or so, I’ll be back :wink: ) so I haven’t followed: can I remove my ownKeepass repo from OpenRepos now?

Maybe you should keep it for a bit. We don’t have yet Chum and OpenRepos integration ready and some would prefer to install via OpenRepos from your build.

Alright, will do!

20

@rinigus I apologize if you’ve already answered in the discussion as I was unable to find it: do you intend to also restart publishing ownKeepass in OpenRepos (or Jolla Store) and how can we help you do so?

No, I don’t have intention for publishing it outside Chum repos. If we get OpenRepos / Chum integration working, it should be made available at OpenRepos automatically then.

But note that I am not really considering myself as ownKeepass maintainer either. I adjusted packaging scripts to make it build at OBS, but nothing further.

Good to know, thank you. Also, it makes no difference to me whether it’s manual or automatic so I hope this integration isn’t hard to add.

1 Like

You could follow it here: OpenRepos and Chum integration

Is there a workaround or some fix to make ownKeepass access SD-card? As I’m not a developer I really need help with this.

1 Like

And another question (i’m not a developper also) : this app does not receive evolutions or corrections since more 2 years. Is it always safe or is it better to use the android app keepassDX ?

I don’t have a working SD-card right now so I can’t test this, but I believe creating a symlink in $HOME (or in any accessible location) to your SD-card could be a workaround. I’m going to buy a new SD-card today, so I’ll be able to verify this later tonight.

2 Likes

It does work, 100%ly. I do that for the Music folder.

No, the format is still kbdx4 and hasn’t changed, so the except for bugs & features keepassxc on other platforms isn’t better.

Thanks @tuplasuhveli, it worked perfect.

1 Like