#!/bin/sh
#
# Univention Admin Modules
#  create cups model syntax file
#
# SPDX-FileCopyrightText: 2004-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only


printf "class cupsModel(univention.admin.syntax.select):\n"
printf "\tname='cupsModel'\n"
printf "\tchoices=[\n"

find /usr/share/cups/model -name '*.ppd' -o -name '*.ppd.gz' | while read f; do
	n=$(zcat --force $f | sed -ne 's/^\*NickName:[[:space:]]*"\(.*\)"/\1/p')
	if [ -z "$n" ]; then
		echo "No name for $f. Skipping." >&2
		continue
	fi
	#b=$(basename $f)
	b=$(echo $f | sed s,/usr/share/cups/model/,,)
	printf "\t\t('%s', '%s'),\n" "$b" "$n"
done

printf "\t]\n"
