[995] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | SPECDIR=`rpm -E '%_specdir'` |
---|
| 4 | SOURCEDIR=`rpm -E '%_sourcedir'` |
---|
| 5 | |
---|
[1009] | 6 | # |
---|
[995] | 7 | # check scheme |
---|
[1009] | 8 | # |
---|
[995] | 9 | CheckScheme() |
---|
| 10 | { |
---|
| 11 | case $ARCHIVE in |
---|
| 12 | http://* | ftp://*) |
---|
| 13 | if wget -P $SOURCEDIR -nc $ARCHIVE ;then # download |
---|
| 14 | SOURCE=$ARCHIVE |
---|
| 15 | else |
---|
| 16 | exit 1 # exit when failed download |
---|
| 17 | fi |
---|
| 18 | ;; |
---|
| 19 | *) |
---|
| 20 | if [ -f $ARCHIVE ];then |
---|
| 21 | echo "move $ARCHIVE to $SOURCEDIR." |
---|
| 22 | mv $ARCHIVE $SOURCEDIR |
---|
| 23 | SOURCE=`basename $ARCHIVE` |
---|
| 24 | else |
---|
| 25 | echo "$ARCHIVE is not file." 1>&2 |
---|
| 26 | exit 1 |
---|
| 27 | fi |
---|
| 28 | ;; |
---|
| 29 | esac |
---|
| 30 | } |
---|
| 31 | |
---|
[1009] | 32 | # |
---|
[995] | 33 | # check suffix |
---|
[1009] | 34 | # |
---|
[995] | 35 | CheckSuffix() |
---|
| 36 | { |
---|
| 37 | case $ARCHIVE in |
---|
| 38 | *.tar.gz) |
---|
| 39 | BASENAME=`basename $ARCHIVE .tar.gz` |
---|
[1009] | 40 | SUFFIX=".tar.gz" |
---|
[995] | 41 | ;; |
---|
| 42 | *.tar.bz2) |
---|
| 43 | BASENAME=`basename $ARCHIVE .tar.bz2` |
---|
[1009] | 44 | SUFFIX=".tar.bz2" |
---|
[995] | 45 | ;; |
---|
| 46 | *.zip) |
---|
| 47 | BASENAME=`basename $ARCHIVE .zip` |
---|
[1009] | 48 | SUFFIX=".zip" |
---|
[995] | 49 | ;; |
---|
| 50 | *) |
---|
| 51 | echo "Unknown format." 1>&2 |
---|
| 52 | exit 1 |
---|
| 53 | ;; |
---|
| 54 | esac |
---|
| 55 | } |
---|
| 56 | |
---|
[1009] | 57 | # |
---|
| 58 | # output basic information |
---|
| 59 | # |
---|
| 60 | OutputBasicInfo() |
---|
| 61 | { |
---|
| 62 | cat > $SPECFILE << EOL |
---|
| 63 | # Basic Information |
---|
| 64 | Name: $PKGNAME |
---|
| 65 | Version: $PKGVERSION |
---|
| 66 | Release: 1%{?_dist_release} |
---|
| 67 | License: $LICENSE |
---|
| 68 | Group: ここにグループ名を記述してください(/usr/share/doc/rpm-`rpm --version | awk '{ print $3 }'`/GROUPS_for_vine.txt参照) |
---|
| 69 | Source0: $SOURCE |
---|
| 70 | BuildRoot: %{_tmppath}/%{name}-%{version}-root |
---|
| 71 | |
---|
| 72 | Vendor: Project Vine |
---|
| 73 | Distribution: Vine Linux |
---|
| 74 | Packager: ここにtracのidを記述してください |
---|
| 75 | |
---|
| 76 | Summary: $SUMMARY |
---|
| 77 | Summary(ja): ここに日本語で概要を記述してください |
---|
| 78 | |
---|
| 79 | %description |
---|
| 80 | |
---|
| 81 | %description -l ja |
---|
| 82 | ここに日本語で詳細を記述してください。 |
---|
| 83 | |
---|
| 84 | EOL |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | # |
---|
| 88 | # Output dependency |
---|
| 89 | # |
---|
| 90 | OutputDependency() |
---|
| 91 | { |
---|
| 92 | cat >> $SPECFILE << EOL |
---|
| 93 | # Dependency |
---|
| 94 | |
---|
| 95 | EOL |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | # |
---|
| 99 | # Output prep section |
---|
| 100 | # |
---|
| 101 | OutputPrep() |
---|
| 102 | { |
---|
| 103 | echo '%prep' >> $SPECFILE |
---|
| 104 | |
---|
| 105 | # setup corresponding to suffix |
---|
| 106 | case $SUFFIX in |
---|
| 107 | .tar.gz | .tar.bz2) |
---|
| 108 | echo '%setup -q' >> $SPECFILE |
---|
| 109 | ;; |
---|
| 110 | .zip) |
---|
| 111 | echo '%setup -T %{name}-%{version}' >> $SPECFILE |
---|
| 112 | echo 'unzip -xq %{SOURCE0}' >> $SPECFILE |
---|
| 113 | ;; |
---|
| 114 | esac |
---|
| 115 | |
---|
| 116 | echo '' >> $SPECFILE |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | # |
---|
| 120 | # Output build section |
---|
| 121 | # |
---|
| 122 | OutputBuild() |
---|
| 123 | { |
---|
| 124 | echo '%build' >> $SPECFILE |
---|
| 125 | echo '%configure' >> $SPECFILE # ToDo: check configure |
---|
| 126 | echo '%{__make} %{?_smp_mflags}' >> $SPECFILE |
---|
| 127 | |
---|
| 128 | echo '' >> $SPECFILE |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | # |
---|
| 132 | # Output install section |
---|
| 133 | # |
---|
| 134 | OutputInstall() |
---|
| 135 | { |
---|
| 136 | cat >> $SPECFILE << EOL |
---|
| 137 | %install |
---|
[1180] | 138 | %{__rm} -rf \${RPM_BUILD_ROOT} |
---|
| 139 | %{__make} install DESTDIR=\${RPM_BUILD_ROOT} |
---|
[1009] | 140 | |
---|
| 141 | %find_lang %{name} |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | %clean |
---|
[1180] | 145 | %{__rm} -rf \${RPM_BUILD_ROOT} |
---|
[1009] | 146 | |
---|
| 147 | |
---|
| 148 | EOL |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | # |
---|
| 152 | # Output file list |
---|
| 153 | # |
---|
| 154 | OutputFileList() |
---|
| 155 | { |
---|
| 156 | # ToDo: check file exists |
---|
| 157 | cat >> $SPECFILE << EOL |
---|
| 158 | %files -f %{name}.lang |
---|
| 159 | %defattr(-,root,root) |
---|
| 160 | %doc COPYING ChangeLog NEWS README |
---|
| 161 | |
---|
| 162 | EOL |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | # |
---|
| 166 | # Output ChangeLog |
---|
| 167 | # |
---|
| 168 | OutputChangeLog() |
---|
| 169 | { |
---|
| 170 | cat >> $SPECFILE << EOL |
---|
| 171 | %changelog |
---|
| 172 | * `LANG=C LANGUAGE=C LC_ALL=C date '+%a %b %d %Y'` Your Name <name@yours.example.com> $PKGVERSION-1`rpm -E '%{?_dist_release}'` |
---|
| 173 | - initial build for Vine Linux |
---|
| 174 | EOL |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | # |
---|
| 178 | # main |
---|
| 179 | # |
---|
| 180 | |
---|
[995] | 181 | # check arguments |
---|
| 182 | if [ -z "$*" ]; then |
---|
| 183 | echo "Usage: `basename $0` source-archive" |
---|
| 184 | exit 1 |
---|
| 185 | fi |
---|
| 186 | |
---|
| 187 | ARCHIVE=$1 |
---|
| 188 | |
---|
| 189 | CheckScheme |
---|
| 190 | CheckSuffix |
---|
| 191 | |
---|
[1194] | 192 | PKGNAME=`echo $BASENAME | sed -e 's/-[0-9][0-9]*.*//'` |
---|
| 193 | PKGVERSION=`echo $BASENAME | sed -e 's/^.*-\([0-9][0-9]*.*\)/\1/'` |
---|
[995] | 194 | SOURCE=`echo $SOURCE | sed -e "s/$PKGNAME/%{name}/g" | sed -e "s/$PKGVERSION/%{version}/g"` |
---|
| 195 | |
---|
| 196 | SPECFILE=${SPECDIR}/${PKGNAME}-vl.spec |
---|
| 197 | |
---|
| 198 | # Output SPEC file. |
---|
[1009] | 199 | OutputBasicInfo |
---|
| 200 | OutputDependency |
---|
| 201 | OutputPrep |
---|
| 202 | OutputBuild |
---|
| 203 | OutputInstall |
---|
| 204 | OutputFileList |
---|
| 205 | OutputChangeLog |
---|
[995] | 206 | |
---|
[1009] | 207 | # Output result |
---|
[995] | 208 | echo "made $SPECFILE" |
---|