From edd124e9a2bc9936f9dfed74eeb7618ab025a59e Mon Sep 17 00:00:00 2001 From: ytshih Date: Tue, 11 Feb 2025 16:19:33 +0800 Subject: [PATCH] Initial commit --- .SRCINFO | 20 +++++++++++++++ .gitea/workflows/build.yml | 52 ++++++++++++++++++++++++++++++++++++++ .gitignore | 8 ++++++ PKGBUILD | 47 ++++++++++++++++++++++++++++++++++ fix_open_context.patch | 11 ++++++++ target.service | 14 ++++++++++ 6 files changed, 152 insertions(+) create mode 100644 .SRCINFO create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitignore create mode 100644 PKGBUILD create mode 100644 fix_open_context.patch create mode 100644 target.service diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..6cc9777 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,20 @@ +pkgbase = python-rtslib-fb + pkgdesc = free branch version of the LIO target API + pkgver = 2.1.76 + pkgrel = 1 + url = https://github.com/open-iscsi/rtslib-fb + arch = any + license = Apache + makedepends = python-setuptools + makedepends = python-pyudev + depends = python + depends = python-six + depends = python-pyudev + conflicts = python2-rtslib + conflicts = targetcli-fb<=2.1.fb31 + source = https://github.com/open-iscsi/rtslib-fb/archive/v2.1.76.tar.gz + source = target.service + sha512sums = 50bc9f4ebff71cc87fd62036ff9d929fb1e5989be6251b1111904e76a7c026215692dc8930b90552a4ff850c6252338e420fe710993b8c8a0c737b65590a520d + sha512sums = 3c634f1c466d0a8c3dd2b57a230438aaeeb0e66324863a2ded57dd69a2ca5946f83c4ab511766f510f3e63b43aedcf7e368bcf5bc325ee69c016bb0bb2612de5 + +pkgname = python-rtslib-fb diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..c398bd7 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,52 @@ +name: Build package +on: [push] + +jobs: + build-package: + runs-on: imgbuilder + container: + image: gitea.konchin.com/image/archmakepkg + credentials: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + options: --dns 172.20.10.253 --dns-search konchin.com --dns-option ndots:15 + env: + REPO_NAME: custom + MINIO_BUCKET: archrepo + MINIO_ENDPOINT: https://minio.konchin.com + MINIO_ACCESSKEY: ${{ secrets.MINIO_ACCESSKEY }} + MINIO_SECRETKEY: ${{ secrets.MINIO_SECRETKEY }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build package + run: | + chown -R builder . + sudo -u builder makepkg -sc --needed --noconfirm + + - name: Setup MinIO + run: | + mcli alias set m "${{ env.MINIO_ENDPOINT }}" \ + "${{ env.MINIO_ACCESSKEY }}" "${{ env.MINIO_SECRETKEY }}" + echo "Set endpoint to ${{ env.MINIO_ENDPOINT }}" + + - name: Copy repo db from MinIO + run: | + mkdir repo + mcli cp "m/${{ env.MINIO_BUCKET }}/${{ env.REPO_NAME }}.db" "repo/${{ env.REPO_NAME }}.db.tar.zst" + mcli cp "m/${{ env.MINIO_BUCKET }}/${{ env.REPO_NAME }}.files" "repo/${{ env.REPO_NAME }}.files.tar.zst" + echo "Copy ${{ env.REPO_NAME }}.db and ${{ env.REPO_NAME }}.files from MinIO" + + - name: Add pkgs to repo db + run: | + repo-add "repo/${{ env.REPO_NAME }}.db.tar.zst" *.pkg.tar.zst + mv *.pkg.tar.zst repo + echo "Add $(ls *.pkg.tar.zst) to repo" + + - name: Update repo to MinIO + run: | + mcli mv repo/${{ env.REPO_NAME }}.db.tar.zst "m/${{ env.MINIO_BUCKET }}/${{ env.REPO_NAME }}.db" + mcli mv repo/${{ env.REPO_NAME }}.files.tar.zst "m/${{ env.MINIO_BUCKET }}/${{ env.REPO_NAME }}.files" + mcli mv repo/*.pkg.tar.zst "m/${{ env.MINIO_BUCKET }}" + echo "Update ${{ env.REPO_NAME }}.db adn ${{ env.REPO_NAME }}.files to MinIO" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd9b4a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.tar.gz +*.tar.xz +*.tgz +*.rpm +*.zip +*.bz2 +src/ +pkg/ diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..2ff9c52 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,47 @@ +# Maintainer: Rigo Reddig +pkgname='python-rtslib-fb' +_pkgname=rtslib-fb +pkgver=2.2.0 +pkgrel=1 +pkgdesc="Free branch version of the LIO target API" +arch=('any') +url="https://github.com/open-iscsi/$_pkgname" +license=('Apache') +depends=('python' 'python-six' 'python-pyudev') +conflicts=('python2-rtslib' 'targetcli-fb<=2.1.fb31') +makedepends=('python-setuptools' 'python-pyudev') +source=( + "https://github.com/open-iscsi/$_pkgname/archive/v${pkgver}.tar.gz" + target.service + fix_open_context.patch +) +sha512sums=('8a321be004fabdd4abb479a1900bc27103000ea15712cbcc855fdaa762dca1658e1f3528e1e1976a56a99e57a60c0d69e3bdede5323a2f1a3a6bf419a5ddc6d4' + '3c634f1c466d0a8c3dd2b57a230438aaeeb0e66324863a2ded57dd69a2ca5946f83c4ab511766f510f3e63b43aedcf7e368bcf5bc325ee69c016bb0bb2612de5' + '312e380deb60f082238389bcd455309283935d039e2d1404be25f12546ebaaf46d8e2d0dcaa05ecab4f97014c40dfb351ba082e07c6e8a2ee20004dd149d6431') + +prepare() { + cd "$srcdir/$_pkgname-$pkgver" + patch -Np1 -i "$srcdir/fix_open_context.patch" +} + +build() { + cd "$srcdir/$_pkgname-$pkgver" + SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation +} + +package() { + cd "$srcdir/$_pkgname-$pkgver" + python -m installer --destdir="$pkgdir" dist/*.whl + install -Dm644 doc/targetctl.8 "$pkgdir/usr/share/man/man8/targetctl.8" + install -Dm644 doc/saveconfig.json.5 "$pkgdir/usr/share/man/man5/saveconfig.json.5" + + install -dm755 "$pkgdir/etc/target/backup" + install -Dm644 "$srcdir/target.service" "$pkgdir/usr/lib/systemd/system/target.service" + + # Install targetctl script to /usr/bin + install -Dm755 scripts/targetctl "$pkgdir/usr/bin/targetctl" + + # Create symlink for rtslib_fb to rtslib + #install -dm755 "$pkgdir/usr/lib/python3.13/site-packages/rtslib" + ln -s ./rtslib "$pkgdir/usr/lib/python3.13/site-packages/rtslib_fb" +} diff --git a/fix_open_context.patch b/fix_open_context.patch new file mode 100644 index 0000000..5d3376d --- /dev/null +++ b/fix_open_context.patch @@ -0,0 +1,11 @@ +--- rtslib-fb-2.2.0/rtslib/root.py.orig 2025-01-17 21:43:22.992672648 +0200 ++++ rtslib-fb-2.2.0/rtslib/root.py 2025-01-17 21:53:20.492076362 +0200 +@@ -487,7 +487,7 @@ + if not restore_file: + restore_file = default_save_file + +- with Path(restore_file).open as f: ++ with Path(restore_file).open() as f: + config = json.loads(f.read()) + return self.restore(config, target, storage_object, + clear_existing=clear_existing, diff --git a/target.service b/target.service new file mode 100644 index 0000000..400284e --- /dev/null +++ b/target.service @@ -0,0 +1,14 @@ +[Unit] +Description=Restore LIO kernel target configuration +Requires=sys-kernel-config.mount +After=sys-kernel-config.mount network.target local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/targetctl restore +ExecStop=/usr/bin/targetctl clear +SyslogIdentifier=target + +[Install] +WantedBy=multi-user.target