makepkg 5.65 KB
Newer Older
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/bash
# İnary paketi üreten clone makepkg (SulinOS topluluğu tarafından geliştirildi)
# Çok önemli uyarı: bu betik deneysel çalışmadır. sisteme zarar verebilir.
#
# Bu betik ile tüm archlinux/aur paketleri derlenememektedir.
arch-meson(){
	exec meson setup \
	  --prefix        /usr \
	  --libexecdir    lib \
	  --sbindir       bin \
	  --buildtype     plain \
	  --auto-features enabled \
	  --wrap-mode     nodownload \
	  -D              b_lto=true \
	  -D              b_pie=true \
	  "$@"

}
pwd=$(pwd)
export pkgdir=$pwd/install
export srcdir=.
export distrel=s19
. PKGBUILD
fetch_sources(){
sulincix's avatar
sulincix committed
25 26
	for src in ${source[@]} ${source_x86_64[@]} ; do
		echo -e "\033[44;1m$src\033[;0m"
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
27 28
		if echo "$src" | grep "git://" &>/dev/null ; then
			srcloc=$(echo $src | sed "s|^.*git://|git://|g")
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
29 30 31 32
			srcname=$(echo $src | sed "s|::git://.*$||g")
			echo $srcloc $srcname
			[ -d "$srcname" ] || git clone  --depth=1 $srcloc $srcname
		elif echo "$src" | grep "^git+" &>/dev/null ; then
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
33 34
			srcloc=$(echo $src | sed "s|^git+||g")
			git clone --depth=1 $srcloc || true
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
35 36 37 38 39 40
		elif echo "$src" | grep "::http" &>/dev/null ; then
                        srcloc=$(echo $src | sed "s|^.*::||g")
                        srcname=$(echo $src | sed "s|::http.*$||g")
			echo $srcloc
			wget -c $srcloc -O $srcname
			echo $srcname | grep ".tar.*" && tar -xf $srcname
sulincix's avatar
sulincix committed
41 42
		elif [ -f $src ] ; then
			touch $src
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
43
		else
sulincix's avatar
sulincix committed
44 45
			wget -c $src -O $(basename $src) || true
			basename $src | grep ".tar.*" && tar -xf $(basename $src) || true
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
46
		fi
sulincix's avatar
sulincix committed
47
	done
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
48 49 50 51 52 53 54 55
}
check_make_dep(){
	missdep=""
	for dep in ${makedepends[@]} ${depends[@]}
	do
		echo "checking $dep"
		LANG=C inary info $dep -s -N | grep "\[inst\]" >/dev/null
		if [ ! $? -eq 0 ] ; then
sulincix's avatar
sulincix committed
56 57 58 59
			if [ "$dep" != "hicolor-icon-theme" ] ; then
				export missdep="$missdep $dep"
			fi
			#exit 1
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
60 61
		fi
	done
sulincix's avatar
sulincix committed
62 63 64 65 66 67 68
	echo -e "\033[31;1mMissing: $missdep\033[;0m" > /dev/stderr
	if [ "$missdep" != "" ] ; then
		su -c "inary it $missdep" || {
			echo -e "\033[31;1mInary cannot install all dependencies.\nPress any key to continue or ctrl c to exit.\033[;0m"
			read -n 1 c
		}
	fi
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
69 70 71 72 73 74 75 76 77
}
function_exists() {
    declare -f -F $1 > /dev/null
    return $?
}
run(){
	cd $pwd
	if function_exists $1 ; then
		echo -e "\033[32;1m$2\033[;0m" > /dev/stderr
Your Name's avatar
Your Name committed
78 79 80 81
		if ! $1 ; then
			echo -e "\033[31;1m$1 failed\033[;0m" > /dev/stderr
			exit 1
		fi
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	fi
}
create_tar(){
cd install
[ -f ../install.tar.xz ] && rm -f ../install.tar.xz
tar --xz -cf ../install.tar.xz *
echo -e "<Files>" > ../files.xml
find | sed "s|^\./||g" | while read line
do
	if [ -f $line ] ; then
		echo -e "   <File>" >> ../files.xml
	        echo -e "      <Path>$line</Path>" >> ../files.xml
        	echo -e "      <Type>data</Type>" >> ../files.xml
        	echo -e "      <Size>$(du -b $line | awk '{print $1}')</Size>" >> ../files.xml
        	echo -e "      <Uid>0</Uid>" >> ../files.xml
        	echo -e "      <Gid>0</Gid>" >> ../files.xml
        	echo -e "      <Mode>0o755</Mode>" >> ../files.xml
        	echo -e "      <Hash>$(sha1sum $line | awk '{print $1}')</Hash>" >> ../files.xml
        	echo -e "   </File>" >> ../files.xml
	fi
done
echo -e "</Files>" >> ../files.xml
}
write_metadata(){
	export installtarhash="$(sha1sum install.tar.xz | awk '{print $1}')"
	echo -e "<INARY>"
	echo -e "    <Source>"
	echo -e "        <Name>$pkgname</Name>"
	echo -e "        <Homepage>$url</Homepage>"
	echo -e "        <Packager>"
	echo -e "            <Name>Auto generated</Name>"
	echo -e "            <Email>auto@generat.et</Email>"
	echo -e "        </Packager>"
	echo -e "    </Source>"
	echo -e "    <Package>"
	echo -e "    <RFP></RFP>"
	echo -e "    <PartOf>aur</PartOf>"	
	echo -e "        <Name>$pkgname</Name>"
	echo -e "        <Summary xml:lang=\"en\">$pkgdesc</Summary>"
	echo -e "        <Description xml:lang=\"en\">$pkgdesc</Description>"
	echo -e "        <IsA>app</IsA>"
	echo -e "        <License>$license</License>"
	echo -e "    <RuntimeDependencies>"
	for dep in ${depends[@]}
	do
		echo -e "        <Dependency>$dep</Dependency>"
	done
	echo -e "    </RuntimeDependencies>"
	echo -e "        <Files>"
	echo -e "            <Path fileType=\"data\">/usr</Path>"
	echo -e "            <Path fileType=\"data\">/etc</Path>"
	echo -e "            <Path fileType=\"data\">/bin</Path>"
	echo -e "            <Path fileType=\"data\">/var</Path>"
	echo -e "            <Path fileType=\"data\">/lib</Path>"
	echo -e "            <Path fileType=\"data\">/boot</Path>"
	echo -e "        </Files>"
	echo -e "        <History>"
	echo -e "            <Update release=\"1\">"
	echo -e "                <Date>2020-04-24</Date>"
	echo -e "                <Version>$pkgver</Version>"
	echo -e "                <Comment>Auto generated.</Comment>"
	echo -e "                <Name>Auto generated</Name>"
	echo -e "                <Email>auto@generat.et</Email>"
	echo -e "            </Update>"
	echo -e "        </History>"
	echo -e "        <BuildHost>uludag</BuildHost>"
	echo -e "        <Distribution>Sulin</Distribution>"
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
149
	echo -e "        <DistributionRelease>2019</DistributionRelease>"
Ali Rıza KESKİN's avatar
Ali Rıza KESKİN committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
	echo -e "        <Architecture>x86_64</Architecture>"
	echo -e "        <InstalledSize>1</InstalledSize>"
	echo -e "        <InstallTarHash>$installtarhash</InstallTarHash>"
	echo -e "        <PackageFormat>1.2</PackageFormat>"
	echo -e "    </Package>"
	echo -e "</INARY>"
}
create_inary(){
	zip $pkgname-$pkgver-$pkgrel-$distrel-$(uname -m).inary install.tar.xz metadata.xml files.xml
}
run fetch_sources "Downloading"
run check_make_dep "Checking dependency"
run pkgver "Runninn pkgver"
run prepare "Running prepare"
run build "Building"
run package "Installing"
run create_tar "Creating install.tar.xz"
run write_metadata "Generating metadata.xml" > $pwd/metadata.xml
run create_inary "Building inary file"