-
Notifications
You must be signed in to change notification settings - Fork 4
/
create_source.sh
executable file
·48 lines (40 loc) · 1.77 KB
/
create_source.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
destdir=$1
cwd=$(pwd)
dir=$(dirname ${cwd}/$(dirname $0))
[ "$destdir" = "" ] && destdir=$cwd
packagename=$(basename rpm/*.spec .spec)
version=$(head -n1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f1)
release=$(head -n1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f2)
tmpdir=/tmp/${packagename}-${version}
cd $dir
rm ${destdir}/${packagename}*.tar.gz 2>/dev/null || true
rm ${destdir}/${packagename}*.dsc 2>/dev/null || true
rm ${destdir}/${packagename}*.spec 2>/dev/null || true
cp rpm/${packagename}.spec /tmp/
cat /tmp/${packagename}.spec \
| sed "s/^Version:.*/Version: ${version}/" \
| sed "s/^Release:.*/Release: ${release}/" \
| sed "s/^Source:.*/Source: ${packagename}_${version}-${release}.tar.gz/" \
| sed -ne '1,/%changelog/p' \
> rpm/${packagename}.spec
rm /tmp/${packagename}.spec
cp rpm/${packagename}.spec $destdir/
test -e $tmpdir && rm -rf $tmpdir
mkdir $tmpdir
cp -r . ${tmpdir}/
find ${tmpdir} -iname "*.pyc" -exec rm "{}" \;
find ${tmpdir} -iname "*.marks" -exec rm "{}" \;
find ${tmpdir} -iname "*~" -exec rm "{}" \;
find ${tmpdir} -iname "*.svn" -exec rm -rf "{}" \; 2>/dev/null
cd ${tmpdir}/
dpkg-buildpackage -S
mv ${tmpdir}/../${packagename}_${version}-${release}.tar.gz $destdir/
mv ${tmpdir}/../${packagename}_${version}-${release}.dsc $destdir/
rm -rf $tmpdir
echo "============================================================================================="
echo "source archive: ${destdir}/${packagename}_${version}-${release}.tar.gz"
echo "dsc file: ${destdir}/${packagename}_${version}-${release}.dsc"
echo "spec file: ${destdir}/${packagename}.spec"
echo "============================================================================================="
cd $cwd