| 1 | #!/bin/bash |
| 2 | dscurl='http://ftp.de.debian.org/debian/pool/main/s/sash/sash_3.7-8.dsc'; |
| 3 | pkgurl=$(dirname "$dscurl"); |
| 4 | |
| 5 | #init |
| 6 | tmpdir="/tmp/debiarch-pid$$"; |
| 7 | rm -rf "$tmpdir"; |
| 8 | mkdir "$tmpdir" |
| 9 | |
| 10 | dscfile="${tmpdir}/desc.dsc"; |
| 11 | wget "$dscurl" -O "$dscfile" > /dev/null 2>&1 || exit 1; |
| 12 | |
| 13 | echo '# Contributor: Your Name youremail at domain dot com' |
| 14 | echo '# This PKGBUILD was automatically generated and it will probably need few manual fixes' |
| 15 | echo |
| 16 | |
| 17 | pkgname=$(cat "$dscfile" | grep '^Binary: ' | cut -d ' ' -f 2 | head -n 1) |
| 18 | echo "pkgname=$pkgname" |
| 19 | pkgver=$(cat "$dscfile" | grep '^Version: ' | cut -d ' ' -f 2 | head -n 1) |
| 20 | echo "pkgver=$pkgver" |
| 21 | stdver=$(cat "$dscfile" | grep '^Standards-Version: ' | cut -d ' ' -f 2 | head -n 1) |
| 22 | |
| 23 | #misc |
| 24 | echo 'pkgrel=1' |
| 25 | echo "pkgdesc='Port of Debian package $pkgname to ArchLinux'" |
| 26 | echo "arch=('i686' 'x86_64')" |
| 27 | echo "url='$dscurl'" |
| 28 | echo "license=('GPL')" |
| 29 | |
| 30 | echo '#ArchLinux packages will probably have different names to Debian packages:' |
| 31 | echo '#depends=() #check ${srcdir}/${pkgname}-${pkgver}/control for info about depends' |
| 32 | echo '#makedepends=(' $(cat "$dscfile" | grep '^Build-Depends\(\|-Indep\): ' | cut -d ' ' -f 2- ) ')' |
| 33 | echo '#install=debian.install #uncomment if needed' |
| 34 | |
| 35 | echo 'source=(' |
| 36 | cat "$dscfile" | grep '^ ' | cut -d ' ' -f 4 | sort -u | while read line; do echo -ne '\t'; echo "${pkgurl}/$line"; done; |
| 37 | echo ')' |
| 38 | |
| 39 | echo 'md5sums=(' |
| 40 | echo -e '\t#Make your own using md5sum *' |
| 41 | echo ')' |
| 42 | |
| 43 | |
| 44 | echo ' |
| 45 | build() { |
| 46 | srcsubdir=$(ls -1 --group-directories-first "$srcdir" | head -n 1) #guess it... ;) |
| 47 | |
| 48 | echo -e "\n-------------------------------------------" |
| 49 | echo "==> Note you can check ${srcdir}/${srcsubdir}/debian/control for more info and run-time dependencies" |
| 50 | echo "==> and ${srcdir}/${srcsubdir}/debian/README.debian for even more info" |
| 51 | echo "==> Short version follows:" |
| 52 | cat "${srcdir}/${srcsubdir}/debian/control" | grep -i "^\(Depends\|Conflicts\|Suggests\|Description\):" | sort -u |
| 53 | echo -e "-------------------------------------------\n" |
| 54 | |
| 55 | cd "${srcdir}" |
| 56 | |
| 57 | #Apply debian patch (which contains more patches lol) |
| 58 | #patch -p0 < ${pkgname}_${pkgver}.diff |
| 59 | patch -p0 < ${pkgname}*.diff #another ugly asterisk hack muhwahwa... |
| 60 | |
| 61 | #cd ${srcdir}/${pkgname}-${pkgver}/ |
| 62 | cd "${srcdir}/${srcsubdir}/" |
| 63 | |
| 64 | #Apply Debian patches (if any ;o) |
| 65 | for i in $(cat ./debian/patches/00list); do |
| 66 | bash "./debian/patches/$i.dpatch" -patch |
| 67 | done; |
| 68 | |
| 69 | #Debian install script (if any...) |
| 70 | cp ./debian/postinst "${startdir}/debian.install" |
| 71 | |
| 72 | #real build() work here (you will probably need to edit this): |
| 73 | cd "${srcdir}/${srcsubdir}" || return 1 |
| 74 | ./configure --prefix=/usr |
| 75 | make || return 1 |
| 76 | make DESTDIR=$pkgdir install || return 1 |
| 77 | } |
| 78 | ' |
| 79 | |
| 80 | #cleanup |
| 81 | rm -rf "$tmpdir"; |