mirror of
				https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
				synced 2025-11-04 02:26:10 +00:00 
			
		
		
		
	applied changes from samicrusader <hi@samicrusader.me>
This commit is contained in:
		@@ -52,11 +52,7 @@ build:pamac:
 | 
				
			|||||||
    - 'echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers'
 | 
					    - 'echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers'
 | 
				
			||||||
    - chown -R build:build .
 | 
					    - chown -R build:build .
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - pwd
 | 
					    - sudo -u build makepkg -s
 | 
				
			||||||
    #- source PKGBUILD && pacman -Syu --noconfirm --needed --asdeps "${makedepends[@]}" "${depends[@]}"
 | 
					 | 
				
			||||||
    - ls -lah
 | 
					 | 
				
			||||||
    - ls -lah app/
 | 
					 | 
				
			||||||
    - sudo -u build makepkg -si
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
test:
 | 
					test:
 | 
				
			||||||
  image: python:3.10-slim-bullseye
 | 
					  image: python:3.10-slim-bullseye
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										55
									
								
								PKGBUILD
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								PKGBUILD
									
									
									
									
									
								
							@@ -1,27 +1,42 @@
 | 
				
			|||||||
 | 
					# Maintainer: samicrusader <hi@samicrusader.me>
 | 
				
			||||||
# Maintainer: Oscar Krause <oscar.krause@collinwebdesigns.de>
 | 
					# Maintainer: Oscar Krause <oscar.krause@collinwebdesigns.de>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pkgname=fastapi-dls
 | 
					pkgname=fastapi-dls
 | 
				
			||||||
pkgver=1.0.0
 | 
					pkgver=1.0
 | 
				
			||||||
pkgrel=1
 | 
					pkgrel=1
 | 
				
			||||||
pkgdesc="Minimal Delegated License Service (DLS)."
 | 
					pkgdesc='NVIDIA DLS server implementation with FastAPI'
 | 
				
			||||||
arch=('any')  # x86_64?
 | 
					arch=('any')
 | 
				
			||||||
url="https://git.collinwebdesigns.de/oscar.krause/fastapi-dls"
 | 
					url='https://git.collinwebdesigns.de/oscar.krause/fastapi-dls'
 | 
				
			||||||
#license=('MIT')
 | 
					license=('MIT')
 | 
				
			||||||
depends=('python3' 'python-fastapi' 'uvicorn' 'python-dotenv' 'python-dateutil' 'python-jose' 'python-sqlalchemy' 'python-pycryptodome' 'python-markdown' 'openssl')
 | 
					depends=('python' 'python-jose' 'python-starlette' 'python-httpx' 'python-fastapi' 'python-dotenv' 'python-dateutil' 'python-sqlalchemy' 'python-pycryptodome' 'uvicorn' 'python-markdown' 'openssl')
 | 
				
			||||||
source=('README.md' 'version.env' 'app/main.py' 'app/orm.py' 'app/util.py')
 | 
					provider=("$pkgname")
 | 
				
			||||||
sha512sums=("SKIP")
 | 
					install="$pkgname.install"
 | 
				
			||||||
 | 
					source=('git+https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git#commit=3d5203dae054020e6f56e5f457fac1fbacc6f05d' # https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
 | 
				
			||||||
 | 
					        "$pkgname.default"
 | 
				
			||||||
 | 
					        "$pkgname.service")
 | 
				
			||||||
 | 
					sha256sums=('SKIP'
 | 
				
			||||||
 | 
					            'd8b2216b67a2f8f35ad6f07c825839794f7c34456a72caadd9fc110810348d90'
 | 
				
			||||||
 | 
					            '10cb98d64f8bf37b11a60510793c187cc664e63c895d1205781c21fa2e703f32')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package() {
 | 
					check() {
 | 
				
			||||||
  mkdir -p "${pkgdir}/usr/share"
 | 
					    cd "$srcdir/$pkgname/test"
 | 
				
			||||||
 | 
					    mkdir "$srcdir/$pkgname/app/cert"
 | 
				
			||||||
  echo "pkgdir: ${pkgdir}"
 | 
					    openssl genrsa -out "$srcdir/$pkgname/app/cert/instance.private.pem" 2048
 | 
				
			||||||
  echo "srcdir: ${srcdir}"
 | 
					    openssl rsa -in "$srcdir/$pkgname/app/cert/instance.private.pem" -outform PEM -pubout -out "$srcdir/$pkgname/app/cert/instance.public.pem"
 | 
				
			||||||
  echo "startDir: ${startDir}"
 | 
					    python "$srcdir/$pkgname/test/main.py"
 | 
				
			||||||
 | 
					    rm -rf "$srcdir/$pkgname/app/cert"
 | 
				
			||||||
  cp "${srcdir}/README.md" "${pkgdir}/usr/share/README.md"
 | 
					 | 
				
			||||||
  cp "${srcdir}/version.env" "${pkgdir}/usr/share/version.env"
 | 
					 | 
				
			||||||
  cp -r "${srcdir}/app" "${pkgdir}/usr/share"
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package() {
 | 
				
			||||||
 | 
					    install -d "$pkgdir/usr/share/doc/$pkgname"
 | 
				
			||||||
 | 
					    install -d "$pkgdir/var/lib/$pkgname/cert"
 | 
				
			||||||
 | 
					    cp -r "$srcdir/$pkgname/doc"/* "$pkgdir/usr/share/doc/$pkgname/"
 | 
				
			||||||
 | 
					    install -Dm644 "$srcdir/$pkgname/README.md" "$pkgdir/usr/share/doc/$pkgname/README.md"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# https://bbs.archlinux.org/viewtopic.php?id=213287
 | 
					    sed -i "s/README.md/\/usr\/share\/doc\/$pkgname\/README.md/g" "$srcdir/$pkgname/app/main.py"
 | 
				
			||||||
# https://itsfoss.com/create-pkgbuild/
 | 
					    sed -i "s/join(dirname(__file__), 'cert\//join('\/var\/lib\/$pkgname', 'cert\//g" "$srcdir/$pkgname/app/main.py"
 | 
				
			||||||
 | 
					    install -Dm755 "$srcdir/$pkgname/app/main.py" "$pkgdir/opt/$pkgname/main.py"
 | 
				
			||||||
 | 
					    install -Dm755 "$srcdir/$pkgname/app/orm.py" "$pkgdir/opt/$pkgname/orm.py"
 | 
				
			||||||
 | 
					    install -Dm644 "$srcdir/$pkgname.default" "$pkgdir/etc/default/$pkgname"
 | 
				
			||||||
 | 
					    install -Dm644 "$srcdir/$pkgname.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								fastapi-dls.default
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								fastapi-dls.default
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					# Toggle FastAPI debug mode
 | 
				
			||||||
 | 
					DEBUG=false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Where the client can find the DLS server
 | 
				
			||||||
 | 
					## DLS_URL should be a hostname
 | 
				
			||||||
 | 
					DLS_URL="localhost.localdomain"
 | 
				
			||||||
 | 
					DLS_PORT=8443
 | 
				
			||||||
 | 
					CORS_ORIGINS="https://$DLS_URL:$DLS_PORT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Lease expiration in days
 | 
				
			||||||
 | 
					LEASE_EXPIRE_DAYS=90
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Database location
 | 
				
			||||||
 | 
					## See https://dataset.readthedocs.io/en/latest/quickstart.html for details
 | 
				
			||||||
 | 
					DATABASE="sqlite:////var/lib/fastapi-dls/db.sqlite"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# UUIDs for identifying the instance
 | 
				
			||||||
 | 
					SITE_KEY_XID="<<sitekey>>"
 | 
				
			||||||
 | 
					INSTANCE_REF="<<instanceref>>"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Site-wide signing keys
 | 
				
			||||||
 | 
					INSTANCE_KEY_RSA="/var/lib/fastapi-dls/instance.private.pem"
 | 
				
			||||||
 | 
					INSTANCE_KEY_PUB="/var/lib/fastapi-dls/instance.public.pem"
 | 
				
			||||||
							
								
								
									
										14
									
								
								fastapi-dls.install
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								fastapi-dls.install
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					post_install() {
 | 
				
			||||||
 | 
					    sed -i "s/<<sitekey>>/$(uuidgen)/" /etc/default/fastapi-dls
 | 
				
			||||||
 | 
					    sed -i "s/<<instanceref>>/$(uuidgen)/" /etc/default/fastapi-dls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    echo 'The environment variables for this server can be edited at: /etc/default/fastapi-dls'
 | 
				
			||||||
 | 
					    echo 'The server can be started with: systemctl start fastapi-dls.service'
 | 
				
			||||||
 | 
					    echo
 | 
				
			||||||
 | 
					    echo 'A valid HTTPS certificate needs to be installed to /var/lib/fastapi-dls/cert/webserver.{crt,key}'
 | 
				
			||||||
 | 
					    echo 'A self-signed certificate can be generated with: openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /var/lib/fastapi-dls/cert/webserver.key -out /var/lib/fastapi-dls/cert/webserver.crt'
 | 
				
			||||||
 | 
					    echo
 | 
				
			||||||
 | 
					    echo 'The signing keys for your instance need to be generated as well. Generate them with these commands:'
 | 
				
			||||||
 | 
					    echo 'openssl genrsa -out /var/lib/fastapi-dls/instance.private.pem 2048'
 | 
				
			||||||
 | 
					    echo 'openssl rsa -in /var/lib/fastapi-dls/instance.private.pem -outform PEM -pubout -out /var/lib/fastapi-dls/instance.public.pem'
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										15
									
								
								fastapi-dls.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								fastapi-dls.service
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=FastAPI-DLS
 | 
				
			||||||
 | 
					Documentation=https://git.collinwebdesigns.de/oscar.krause/fastapi-dls
 | 
				
			||||||
 | 
					After=network.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=forking
 | 
				
			||||||
 | 
					EnvironmentFile=/etc/default/fastapi-dls
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/python /opt/fastapi-dls/main.py
 | 
				
			||||||
 | 
					WorkingDir=/opt/fastapi-dls
 | 
				
			||||||
 | 
					Restart=on-abort
 | 
				
			||||||
 | 
					User=root
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
		Reference in New Issue
	
	Block a user