* rebased llvm/hotfix-sparcv9-not-64.diff
[t2sde.git] / scripts / Create-Pkg
blob328808ae5dcec70d8f169cfb093dfb500a31586e
1 #!/bin/bash
3 #--- T2-COPYRIGHT-NOTE-BEGIN ---
4 #T2 SDE: scripts/Create-Pkg
5 #Copyright (C) 2004 - 2024 The T2 SDE Project
6 #Copyright (C) 1998 - 2003 ROCK Linux Project
8 #This Copyright note is generated by scripts/Create-CopyPatch,
9 #more information can be found in the files COPYING and README.
11 #This program is free software; you can redistribute it and/or modify
12 #it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
16 usage() {
17 cat <<-EOT
18 Usage:
19 $0 [ package/repository/packagename ] url < url-2 ... >
21 EOT
22 exit 1
25 [ $# -lt 1 ] && usage
27 info= text= url= author= category= license=GPL status=Beta code=
28 maintainer='The T2 Project <t2@t2-project.org>'
30 dir=
32 if [ $# -gt 1 ]; then
33 dir=${1#package/}; shift
34 else
35 case "$1" in
36 -h|*-help)
37 usage
39 -d|-r)
40 dir="$2"; shift
42 *kde.org*)
43 dir=${dir:-kde} category=extra/desktop/kde author="KDE Project"
44 code=". \$base/package/*/*/kde-conf.in"
46 *gnome.org*)
47 dir=${dir:-gnome} category=extra/desktop/gnome author="GNOME Project"
48 code=". \$base/package/*/*/gnome-conf.in"
50 *github.com*)
51 curl ${1/github.com/api.github.com/repos} > repotmpfile
52 curl ${1/github.com/api.github.com/repos}/releases > releasetmpfile
54 ver=$(jq -r '.[0].tag_name' releasetmpfile)
55 dir=${dir:-contrib}
56 info=$(jq -r .description repotmpfile)
57 text="$info"
58 author=$(jq -r .owner.login repotmpfile)
59 license=$(jq -r .license.spdx_id repotmpfile)
61 [[ "$ver" != 0* ]] && status=Stable
63 url=$1
64 set -- "${url}/archive/${ver}/${url##*/}-${ver/v/}.tar.gz"
65 rm -f repotmpfile releasetmpfile
68 dir=${dir:-contrib}
70 esac
72 dir="$dir/${1##*/}"
73 dir="${dir%-[0-9]*}"
76 ver="${1%.tar.*}"
77 ver="${ver##*-}"
79 pkg=${dir##*/}
80 if [ "$pkg" = "$dir" ]; then
81 echo "Error: $dir must be <rep>/<pkg>!"
82 exit 1
85 rep="$(echo package/*/$pkg | cut -d'/' -f 2)"
86 if [ "$rep" != "*" ]; then
87 echo "Error: package $pkg belongs to $rep!"
88 exit 1
91 rep=${dir/\/$pkg/}
92 confdir="package/$dir"
94 echo -n "Creating $confdir ... "
95 if [ -e $confdir ]; then
96 echo "Error: $confdir already exists!"
97 exit
99 if ! mkdir -p $confdir; then
100 echo "Error: $confdir already exists!"
101 exit 1
104 echo -n "Creating $pkg.desc ... "
105 cat >$confdir/$pkg.desc <<EOT
106 [I] ${info}
108 [T] ${text}
110 [U] ${url}
112 [A] ${author}
113 [M] ${maintainer}
115 [C] ${category}
116 [F] CROSS
118 [L] ${license}
119 [S] ${status}
120 [V] ${ver}
121 [P] X -----5---9 400.000
125 [ "$code" ] &&
126 echo "[O] $code
127 " >> $confdir/$pkg.desc
129 for dl; do
130 echo "[D] 0 ${dl##*/} ${dl%/*}/" >> $confdir/$pkg.desc
131 done
133 touch $confdir/$pkg.cache
134 svn add $confdir/
136 echo "Remember to fill in the TODO's:"
137 grep '^\[.\] $' $confdir/$pkg.desc
139 scripts/Create-CopyPatch $confdir/$pkg.desc | patch -p1
141 scripts/Config -oldconfig
142 scripts/Emerge-Pkg $pkg