#!/bin/bash # #--- T2-COPYRIGHT-NOTE-BEGIN --- #T2 SDE: scripts/Create-Pkg #Copyright (C) 2004 - 2024 The T2 SDE Project #Copyright (C) 1998 - 2003 ROCK Linux Project # #This Copyright note is generated by scripts/Create-CopyPatch, #more information can be found in the files COPYING and README. # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- # usage() { cat <<-EOT Usage: $0 [ package/repository/packagename ] url < url-2 ... > EOT exit 1 } [ $# -lt 1 ] && usage info= text= url= author= category= license=GPL status=Beta code= maintainer='The T2 Project ' dir= if [ $# -gt 1 ]; then dir=${1#package/}; shift else case "$1" in -h|*-help) usage ;; -d|-r) dir="$2"; shift ;; *kde.org*) dir=${dir:-kde} category=extra/desktop/kde author="KDE Project" code=". \$base/package/*/*/kde-conf.in" ;; *gnome.org*) dir=${dir:-gnome} category=extra/desktop/gnome author="GNOME Project" code=". \$base/package/*/*/gnome-conf.in" ;; *github.com*) curl ${1/github.com/api.github.com/repos} > repotmpfile curl ${1/github.com/api.github.com/repos}/releases > releasetmpfile ver=$(jq -r '.[0].tag_name' releasetmpfile) dir=${dir:-contrib} info=$(jq -r .description repotmpfile) text="$info" author=$(jq -r .owner.login repotmpfile) license=$(jq -r .license.spdx_id repotmpfile) [[ "$ver" != 0* ]] && status=Stable url=$1 set -- "${url}/archive/${ver}/${url##*/}-${ver/v/}.tar.gz" rm -f repotmpfile releasetmpfile ;; *) dir=${dir:-contrib} ;; esac dir="$dir/${1##*/}" dir="${dir%-[0-9]*}" fi ver="${1%.tar.*}" ver="${ver##*-}" pkg=${dir##*/} if [ "$pkg" = "$dir" ]; then echo "Error: $dir must be /!" exit 1 fi rep="$(echo package/*/$pkg | cut -d'/' -f 2)" if [ "$rep" != "*" ]; then echo "Error: package $pkg belongs to $rep!" exit 1 fi rep=${dir/\/$pkg/} confdir="package/$dir" echo -n "Creating $confdir ... " if [ -e $confdir ]; then echo "Error: $confdir already exists!" exit fi if ! mkdir -p $confdir; then echo "Error: $confdir already exists!" exit 1 fi echo -n "Creating $pkg.desc ... " cat >$confdir/$pkg.desc <> $confdir/$pkg.desc for dl; do echo "[D] 0 ${dl##*/} ${dl%/*}/" >> $confdir/$pkg.desc done touch $confdir/$pkg.cache svn add $confdir/ echo "Remember to fill in the TODO's:" grep '^\[.\] $' $confdir/$pkg.desc scripts/Create-CopyPatch $confdir/$pkg.desc | patch -p1 scripts/Config -oldconfig scripts/Emerge-Pkg $pkg