rules.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. function formatter(fmt, ...)
  2. local args, order = {...}, {}
  3. fmt = fmt:gsub('%%(%d+)%$', function(i)
  4. table.insert(order, args[tonumber(i)])
  5. return '%'
  6. end)
  7. return string.format(fmt, table.unpack(order))
  8. end
  9. function file_content(filename)
  10. local f = assert(io.open(filename, "r"))
  11. local t = f:read('*all')
  12. f:close()
  13. return t
  14. end
  15. helper={}
  16. helper.scripts={
  17. strip=[===[
  18. PKG=%s
  19. STRIP_KARALISTE=%s
  20. pushd $PWD &>/dev/zero
  21. cd $PKG
  22. find . -type f -printf "%%P\n" | while read FILE; do
  23. if [ ! -z $STRIP_KARALISTE ];then
  24. kara=`echo "$STRIP_KARALISTE" | awk -v FILE="$FILE" '$1 ~ FILE {print $1}'`
  25. fi
  26. if [ -z $kara ];then
  27. case $(file -b "$FILE") in
  28. *ELF*executable*not\ stripped)
  29. strip --strip-all "$FILE"
  30. echo "$FILE +"
  31. ;;
  32. *ELF*shared\ object*not\ stripped)
  33. strip --strip-unneeded "$FILE"
  34. echo "$FILE +"
  35. ;;
  36. current\ ar\ archive)
  37. strip --strip-debug "$FILE"
  38. echo "$FILE +"
  39. esac
  40. else
  41. echo "$FILE -"
  42. fi
  43. done
  44. popd &>/dev/zero
  45. ]===],
  46. delete_files=[===[
  47. PKG=%s
  48. [ -z $PKG ] && exit 1
  49. [ ! -d $PKG ] && hata_olustu "paketleme dizini: $PKG bulunamadı!"
  50. pushd $PWD &>/dev/zero
  51. echo "istenmeyen dosya/dizinlerin silinmesi işlemi"
  52. cd $PKG
  53. # share/info/dir.gz
  54. infodirgz=$(find . -type f -printf "%%P\n" | grep share/info/dir.gz)
  55. [ ! -z $infodirgz ] && rm -rvf $infodirgz
  56. [ -d usr/share/doc ] && rm -rvf usr/share/doc
  57. [ -d usr/share/gtk-doc ] && rm -rvf usr/share/gtk-doc
  58. # todo!!!
  59. # INFO_SIL=1 ayarı değerlendirilecek
  60. [ -d usr/share/info ] && rm -rvf usr/share/info
  61. # todo!!!
  62. # LIBTOOL_SIL=1 ayarı değerlendirilecek
  63. # .la files deleting
  64. [ -d usr/lib ] && find usr/lib -name "*.la" ! -path "usr/lib/ImageMagick*" -exec rm -fv {} \;
  65. # perl gereksizleri
  66. if [ -d usr/lib/perl5 ];then
  67. find $PKG -iname 'TODO*' -or \
  68. -iname 'Change*' -or \
  69. -iname 'README*' -or \
  70. -name '*.bs' -or \
  71. -name .packlist -or \
  72. -name perllocal.pod | xargs rm -v
  73. fi
  74. # sbin altındakileri bin altına taşıma
  75. if [ -d $PKG/usr/sbin ] && [ ! -l $PKG/usr/sbin ];then
  76. mv -v $PKG/usr/sbin/* $PKG/usr/bin
  77. rm -rvf $PKG/usr/sbin
  78. fi
  79. if [ -d $PKG/sbin ] && [ ! -l $PKG/sbin ];then
  80. mv -v $PKG/sbin/* $PKG/usr/bin
  81. rm -rvf $PKG/sbin
  82. fi
  83. if [ -d $PKG/bin ] && [ ! -l $PKG/bin ];then
  84. mv -v $PKG/bin/* $PKG/usr/bin
  85. rm -rvf $PKG/bin
  86. fi
  87. if [ -d $PKG/lib ] && [ ! -l $PKG/lib ];then
  88. cp -rvf $PKG/lib/* $PKG/usr/lib/
  89. rm -rvf $PKG/lib
  90. fi
  91. # boş dizin sil
  92. [ -d usr/share ] && [ ! "$(ls -A usr/share)" ] && rm -rvf usr/share
  93. # systemd dizin sil
  94. [ -d usr/lib/systemd ] && rm -rvf usr/lib/systemd
  95. # var/run run dizini sistemle çakışıyor
  96. [ -d var/run ] && rm -rvf var/run
  97. [ -d run ] && rm -rvf run
  98. popd &>/dev/zero
  99. ]===],
  100. copy_scripts=[===[
  101. TALIMAT_DIZIN=%s
  102. [ -z $TALIMAT_DIZIN ] && exit 1
  103. PKG=%s
  104. META=%s
  105. [ -z $PKG ] && exit 1
  106. pushd $PWD &>/dev/zero
  107. echo "kosuk kopyalama"
  108. yeniad=""
  109. for _kosuk in kurkos.sh koskur.sh silkos.sh kossil.sh;do
  110. if [ -f ${TALIMAT_DIZIN}/${_kosuk} ];then
  111. yeniad=`printf ${_kosuk} | cut -d'.' -f1`
  112. cp -fv ${TALIMAT_DIZIN}/${_kosuk} $PKG/${META}/."${yeniad}"
  113. echo "${_kosuk} pakete eklendi."
  114. fi
  115. done
  116. # yururluk dosya kopyalama
  117. yururluk_dosya="/tmp/$(basename ${TALIMAT_DIZIN}).yur"
  118. [ -f ${yururluk_dosya} ] && cp ${yururluk_dosya} $PKG/${META}/
  119. popd &>/dev/zero
  120. ]===],
  121. libdepends=[===[
  122. PKG=%s
  123. META=%s
  124. if [ ! -d $PKG ];then
  125. echo "paketleme dizini: $PKG bulunamadı!"
  126. exit 1
  127. fi
  128. echo "libgerek analizi"
  129. templg=`mktemp`
  130. rm -f ${PKG}/libgerekler
  131. for libso in `find ${PKG} -name *.so -type f`;do
  132. LC_ALL=C objdump -x $libso | grep NEEDED | awk '{print $2}' >> $templg
  133. done
  134. for libso in `find ${PKG} -name *.so.* -type f`;do
  135. LC_ALL=C objdump -x $libso | grep NEEDED | awk '{print $2}' >> $templg
  136. done
  137. # sadece elf ikililerin dinamiklerini tespit etmek için
  138. for exec in `find $PKG -executable -type f | xargs -I {} file {} | grep ELF | cut -d':' -f1`;do
  139. LC_ALL=C objdump -x $exec | grep NEEDED | awk '{print $2}' >> $templg
  140. echo "$exec +"
  141. done
  142. awk '!/./ || !seen[$0]++' $templg > ${PKG}/${META}/libgerekler
  143. rm -f $templg
  144. cat ${PKG}/${META}/libgerekler | sort > $PWD/$isim.libgerekler
  145. ]===],
  146. pkglibs=[===[
  147. echo "pktlib analizi"
  148. temppl=`mktemp`
  149. rm -f ${PKG}/pktlibler
  150. for libso in `find $PKG -name *.so* -type f`;do
  151. # paket içerik so dosya isminin yazılması
  152. echo "`basename $libso`" >> $temppl
  153. echo "$libso +"
  154. done
  155. for libso in `find $PKG -name *.so* -type l`;do
  156. # paket içerik so dosya isminin yazılması
  157. echo "`basename $libso`" >> $temppl
  158. echo "$libso +"
  159. done
  160. # mükerrer kayıtların elenmesi.
  161. awk '!/./ || !seen[$0]++' $temppl > ${PKG}/${META}/pktlibler
  162. rm -f $temppl
  163. cat ${PKG}/${META}/pktlibler | sort > $PWD/$isim.pktlibler
  164. ]===],
  165. compress_manpages=[===[
  166. PKG=%s
  167. [ ! -d $PKG ] && hata_olustu "paketleme dizini: $PKG bulunamadı!"
  168. pushd $PWD &>/dev/zero
  169. cd $PKG
  170. echo "manpages(arşivleme) işlemi"
  171. find . -type f -path "*/share/man*/*" | while read FILE; do
  172. if [ "$FILE" = "${FILE%%.gz}" ]; then
  173. gzip -9 "$FILE"
  174. fi
  175. done
  176. find . -type l -path "*/share/man*/*" | while read FILE; do
  177. TARGET=`readlink -n "$FILE"`
  178. TARGET="${TARGET##*/}"
  179. TARGET="${TARGET%%.gz}.gz"
  180. rm -f "$FILE"
  181. FILE="${FILE%%.gz}.gz"
  182. DIR=`dirname "$FILE"`
  183. if [ -e "$DIR/$TARGET" ]; then
  184. ln -sf "$TARGET" "$FILE"
  185. fi
  186. done
  187. find . -type f -path "*/share/info/*" | while read FILE; do
  188. if [ "$FILE" = "${FILE%%.gz}" ]; then
  189. gzip -9 "$FILE"
  190. fi
  191. done
  192. find . -type l -path "*/share/info/*" | while read FILE; do
  193. TARGET=`readlink -n "$FILE"`
  194. TARGET="${TARGET##*/}"
  195. TARGET="${TARGET%%.gz}.gz"
  196. rm -f "$FILE"
  197. FILE="${FILE%%.gz}.gz"
  198. DIR=`dirname "$FILE"`
  199. if [ -e "$DIR/$TARGET" ]; then
  200. ln -sf "$TARGET" "$FILE"
  201. fi
  202. done
  203. popd &>/dev/zero
  204. ]===],
  205. meta_info=[===[
  206. PKG=%s
  207. META=%s
  208. boyut=%s
  209. thash=%s
  210. USTBILGI=".ustbilgi"
  211. mimari=`uname -m`
  212. derzaman=`date +%%s`
  213. rm -f ${PKG}/${META}/${USTBILGI}
  214. # meta bilgilerin oluşturulması
  215. cat <<EOF > ${PKG}/${META}/${USTBILGI}
  216. isim=$isim
  217. surum=$surum
  218. devir=$devir
  219. tanim=$tanim
  220. url=$url
  221. paketci=$paketci
  222. derzaman=$derzaman
  223. mimari=$mimari
  224. grup=$grup
  225. boyut=$boyut
  226. thash=$thash
  227. EOF
  228. echo "paket üstbilgileri ${PKG}/${USTBILGI} dosyasına yazıldı."
  229. ]===],
  230. content_info=[===[
  231. PKG=%s
  232. BSDTAR=$(which bsdtar)
  233. if [ ! -d $PKG ];then
  234. echo "paketleme dizini: $PKG bulunamadı!"
  235. exit 1
  236. fi
  237. pushd $PWD &>/dev/zero
  238. cd $PKG
  239. ICBILGI=".icbilgi"
  240. rm -f ${ICBILGI}
  241. # yöntem 1
  242. #LANG=C mtree -c -K sha256digest > ${ICBILGI}.k
  243. # yöntem 2
  244. LANG=C \
  245. $BSDTAR --preserve-permissions --format=mtree \
  246. --options='!all,use-set,type,uid,gid,mode,time,size,sha256,link' \
  247. -czf - * ${META} > ${ICBILGI}
  248. popd &>/dev/zero
  249. echo "paket içbilgileri ${PKG}/${ICBILGI} dosyasına yazıldı."
  250. ]===],
  251. generate_package=[===[
  252. PKG=%s
  253. META=%s
  254. BSDTAR=$(which bsdtar)
  255. SUFFIX="mps.lz"
  256. if [ ! -d $PKG ];then
  257. echo "paketleme dizini: $PKG bulunamadı!"
  258. exit 1
  259. fi
  260. urpkt="$PWD/${isim}#${surum}-${devir}-$(uname -m)"
  261. ICBILGI=".icbilgi"
  262. pushd $PWD &>/dev/zero
  263. cd $PKG
  264. set -x
  265. LANG=C \
  266. $BSDTAR --preserve-permissions \
  267. -cf ${urpkt}.mps * ${META} ${ICBILGI}
  268. rm -f ${urpkt}.${SUFFIX}
  269. #xz -4 --threads=0 ${urpkt}
  270. set +x
  271. #mv ${urpkt}.xz ${urpkt}.mps
  272. lzip -9 ${urpkt}.mps
  273. echo "paket arşivi: ${urpkt}.${SUFFIX} +"
  274. echo "\n"
  275. if [ -z ${urpkt} ];then
  276. echo "mps paketi tanımlı değil!"
  277. exit 1
  278. fi
  279. if [ ! -f ${urpkt}.${SUFFIX} ];then
  280. echo "mps paketi bulunamadı!"
  281. exit 1
  282. fi
  283. echo "paket arşiv bilgisi"
  284. pakboyut=`du -sb ${urpkt}.${SUFFIX} | awk '{print $1}'`
  285. if [ "$pakboyut" -lt "2000" ]; then
  286. echo "${urpkt}.${SUFFIX}.bilgi -"
  287. rm -f ${urpkt}
  288. echo "paket oluşturmada hata, yetersiz boyut. Pakur aşamasını kontrol ediniz!!!"
  289. exit 1
  290. else
  291. # paket arşiv boyut hesaplama
  292. kurboyut=`du -sb ${PKG}| awk '{print $1}'`
  293. pakhash=`sha256sum ${urpkt}.${SUFFIX} | awk '{print $1}'`
  294. mimari=`uname -m`
  295. echo "$isim $surum $devir $mimari $pakboyut $kurboyut $pakhash" > "${urpkt}.${SUFFIX}.bilgi"
  296. echo "${urpkt}.${SUFFIX}.bilgi +"
  297. fi
  298. popd &>/dev/zero
  299. ]===],
  300. wget=[===[
  301. kaynak=%s
  302. indirilen=%s
  303. wget_genel_param=" --progress=bar:force"
  304. wget_sertifika_ayar=""
  305. indirme_iptal=0
  306. [ ! -f /etc/ssl/certs/ca-certificates.crt ] && wget_sertifika_ayar="--no-check-certificate"
  307. if [ -z $kaynak ];then
  308. echo "kaynak parametresi eksik"
  309. exit 1
  310. fi
  311. if [ -z $indirilen ];then
  312. echo "indirilen parametresi eksik"
  313. exit 1
  314. fi
  315. # kaynak var ise
  316. if [ -f ${indirilen} ];then
  317. if [ ! -s ${indirilen} ];then
  318. echo "boş kaynak dosyası"
  319. rm -rfv ${indirilen}
  320. # eğer linkte bir hata varsa sürekli döngüye girebilir, hata atıyoruz.
  321. exit 1
  322. else
  323. echo "${indirilen} Dosya zaten mevcut"
  324. indirme_iptal=1
  325. fi
  326. fi
  327. # kaynak dosyası yoksa indirilecek
  328. if [ $indirme_iptal -eq 0 ];then
  329. kismi_indirilen="${indirilen}.partial"
  330. indirme_param="${wget_sertifika_ayar} --passive-ftp --no-directories --tries=3 -O $indirilen --output-document=$kismi_indirilen ${wget_genel_param}"
  331. [ -f "$kismi_indirilen" ] && kismi_indirme="-c"
  332. komut="wget ${kismi_indirme} ${indirme_param} $kaynak"
  333. hata=1
  334. if [ $hata != 0 ]; then
  335. while true; do
  336. LC_ALL=C wget ${kismi_indirme} ${indirme_param} $kaynak
  337. hata=$?
  338. if [ $hata != 0 ] && [ "$kismi_indirme" ]; then
  339. echo "Kısmi indirme hata oluştu,tekrar başlatılıyor"
  340. rm -f "$kismi_indirilen"
  341. kismi_indirme=""
  342. else
  343. break
  344. fi
  345. done
  346. fi
  347. if [ $hata != 0 ]; then
  348. echo "İndiriliyor '$kaynak' başarısız."
  349. exit 1
  350. fi
  351. mv -f "${kismi_indirilen}" "${indirilen}"
  352. fi
  353. ]===],
  354. }
  355. -- Rules of Talimat
  356. rules={
  357. dirs={
  358. -- don't forget last slash
  359. src = "/tmp/work/src/",
  360. pkg = "/tmp/work/pkg/",
  361. pkg_meta= ".meta",
  362. archive = "/sources/",
  363. },
  364. export={
  365. me = function(key,default,val) if val ~=nil then return 'export '..key..'="'..val..'"' else return 'export '..key..'="'..default..'"' end end,
  366. talimat=function (pmeta)
  367. exports={}
  368. for key,val in pairs(pmeta) do
  369. table.insert(exports,("export "..key.."="..'"'..val..'"'))
  370. end
  371. return exports
  372. end,
  373. dirs=function ()
  374. exports={}
  375. table.insert(exports,("export ".."PKG".."="..'"'..rules.dirs.pkg..'"'))
  376. table.insert(exports,("export ".."SRC".."="..'"'..rules.dirs.src..'"'))
  377. table.insert(exports,("export ".."META".."="..'"'..rules.dirs.pkg_meta..'"'))
  378. table.insert(exports,("export ".."KAYNAK_DIZIN".."="..'"'..rules.dirs.archive..'"'))
  379. return exports
  380. end,
  381. source_aliases=[===[
  382. KERNEL_SITE="https://www.kernel.org/pub/linux/"
  383. GNU_SITE="https://ftp.gnu.org/gnu/"
  384. GNOME_SITE="https://download.gnome.org/sources"
  385. PYPI_SITE="https://files.pythonhosted.org/packages/source"
  386. XFCE4_SITE="https://archive.xfce.org/src"
  387. CPAN_SITE="https://www.cpan.org/modules/by-module"
  388. SOURCEFORGE_SITE="https://downloads.sourceforge.net/sourceforge"
  389. FREEDESKTOP_SITE="https://www.freedesktop.org/software/"
  390. DEBIAN_SITE="http://ftp.debian.org/debian/pool/"
  391. KDE_SITE="https://download.kde.org/stable/"
  392. XORG_SITE="https://www.x.org/releases/individual"
  393. ]===],
  394. },
  395. make_dirs={
  396. src = function() return "rm -rf "..rules.dirs.src..";mkdir -pv "..rules.dirs.src end,
  397. pkg = function() return "rm -rf "..rules.dirs.pkg..";mkdir -pv "..rules.dirs.pkg end,
  398. pkg_meta= function() return "mkdir -pv "..rules.dirs.pkg..rules.dirs.pkg_meta end,
  399. archive = function() return "mkdir -pv "..rules.dirs.archive end,
  400. },
  401. package={
  402. archive="$isim-$surum"
  403. },
  404. source={
  405. gz = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.gz" end,
  406. xz = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.xz" end,
  407. bz2 = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.bz2" end,
  408. tgz = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tgz" end,
  409. github = function(t,v) return "https://github.com/"..v.."/archive/v"..t.paket.surum..".tar.gz::"..t.paket.isim.."-"..t.paket.surum..".tar.gz" end
  410. },
  411. fetch={
  412. --url = function(f) return rules.wget.bin..rules.wget.params..f.address.." -O "..f.store end,
  413. url = function(f) return helper.scripts.wget:format(f.address,f.store) end,
  414. git = function(f)
  415. return ("([ -d %s ] && (cd %s;git pull) || git clone %s %s ) && cp -r %s %s")
  416. :format(f.store,f.store,f.address,f.store,f.store,rules.dirs.src)
  417. end,
  418. svn = function(f)
  419. return ("([ -d %s ] && (cd %s;svn up) || svn co %s %s ) && cp -r %s %s")
  420. :format(f.store,f.store,f.address,f.store,f.store,rules.dirs.src)
  421. end,
  422. --file = function(f) return "cp -f "..f.address.." "..rules.dirs.src..f.store end,
  423. dir = function(f) return "cp -frv "..f.address.." "..f.store end,
  424. file = function(f) return "cp -fv "..f.address.." "..f.store end,
  425. check = function(f) return ("[ -f %s ] && exit 0"):format(f.store) end,
  426. },
  427. hash={
  428. sha256 = function(file,hash) return ('set -x;echo "%s %s" | sha256sum --check'):format(hash,file) end,
  429. sha512 = function(file,hash) return ('set -x;echo "%s %s" | sha512sum --check'):format(hash,file) end,
  430. },
  431. extract={
  432. bsdtar = function(dir,archive) return ("set -x;bsdtar -p -o -C %s -xf %s"):format(dir,archive) end,
  433. },
  434. build_type={
  435. autogen = "./autogen.sh && ./configure ${CONF_OPT} ${EXT_OPT} && make ${MAKEJOBS}",
  436. gnu = "./configure ${CONF_OPT} ${EXT_OPT} && make ${MAKEJOBS}",
  437. cmake = "mkdir -p build;cd build;cmake ${CMAKE_OPT} ${EXT_OPT} ../ && make ${MAKEJOBS}",
  438. py3 = "python3 setup.py build",
  439. py2 = "python2 setup.py build",
  440. perl = "perl Makefile.PL INSTALLDIRS=vendor && make",
  441. meson = "[ -z $ARCHIVE_DIR ] && ARCHIVE_DIR=$isim-$surum ; cd $SRC && milis-meson $ARCHIVE_DIR build ${EXT_OPT}",
  442. ninja = "mkdir -p build && ninja -C build",
  443. waf = "python3 waf configure --prefix=/usr ${EXT_OPT} && python3 waf build",
  444. qmake = "qmake-qt5 CONFIG+=release PREFIX=/usr ${EXT_OPT} && make ${MAKEJOBS}",
  445. go = "go build -o $isim",
  446. },
  447. build_env={
  448. carch = function(v) return rules.export.me("CARCH","x86_64",v) end,
  449. chost = function(v) return rules.export.me("CHOST","x86_64-pc-linux-gnu",v) end,
  450. cppflags = function(v) return rules.export.me("CPPFLAGS","-D_FORTIFY_SOURCE=2",v) end,
  451. cflags = function(v) return rules.export.me("CFLAGS","-march=x86-64 -mtune=generic -O2 -pipe -fno-plt",v) end,
  452. cxxflags = function(v) return rules.export.me("CXXFLAGS","-march=x86-64 -mtune=generic -O2 -pipe -fno-plt",v) end,
  453. ldflags = function(v) return rules.export.me("LDFLAGS","-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now",v) end,
  454. jobs = function(v) if v == nil then return rules.export.me("MAKEJOBS","-j$((`nproc`+1))",nil)
  455. else return rules.export.me("MAKEJOBS","-j$((`nproc`+1))","-j"..tostring(v)) end
  456. end,
  457. confopt = function(v) return rules.export.me("CONF_OPT","--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --bindir=/usr/bin --sbindir=/usr/bin --sysconfdir=/etc --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --localstatedir=/var --disable-static",v) end,
  458. cmakeopt = function(v) return rules.export.me("CMAKE_OPT"," -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib ",v) end,
  459. },
  460. build={
  461. cd = function(t,v) return rules.change.dir(rules.dir.src..v) end,
  462. tip = function(t,v) return rules.build_type[v] end,
  463. betik = function(t,v) return v end,
  464. dosya = function(t,v) return "set -e \n"..file_content(t.dir.."/"..v).."set +e \n" end,
  465. ekconf= function(t,v) return rules.export.me("EXT_OPT",nil,v) end,
  466. yama = function(t,v) return ("[ ! -f $SRC/%s ] && cp %s $SRC/ ; patch -Np1 -i $SRC/%s"):format(v,rules.dirs.archive..v,v)
  467. end,
  468. yama0 = function(t,v) return "patch -Np0 -i $SRC/"..v end,
  469. bayrak= function(t,v) if v == "yok" or v == "0" then return "unset CPPFLAGS;unset CFLAGS;unset CXXFLAGS;unset LDFLAGS" end
  470. end,
  471. },
  472. install_type={
  473. gnu = "make DESTDIR=$PKG install $EXT_OPT",
  474. cmake = "cd build;make DESTDIR=$PKG install",
  475. py3 = "python3 setup.py install --root=${PKG} --optimize=1 --skip-build $EXT_OPT",
  476. py2 = "python2 setup.py install --root=${PKG} --optimize=1 --skip-build $EXT_OPT",
  477. ninja = "DESTDIR=$PKG ninja -C build install",
  478. meson = "cd $SRC && DESTDIR=$PKG ninja -C build install",
  479. waf = "python3 waf install --destdir=$PKG",
  480. bin = "install -Dm755 $isim -t $PKG/usr/bin/",
  481. qmake = [===[make INSTALL_ROOT=${PKG} install && [ -d $PKG/usr/lib ] \
  482. && find $PKG/usr/lib -type f -name '*.prl' -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;]===],
  483. },
  484. install={
  485. cd = function(t,v) return rules.change.dir(rules.dir.src..v) end,
  486. tip = function(t,v) return rules.install_type[v] end,
  487. betik = function(t,v) return v end,
  488. dosya = function(t,v) return "set -e \n"..file_content(t.dir.."/"..v).."set +e \n" end,
  489. strip = function(t,v) if v == "yok" or v == "0" then rules.strip.status=false end; end,
  490. nostrip = function(t,v) rules.strip.blacklist=v end,
  491. servis = function(t,v) return ("cd /usr/milis/ayarlar/servisler\nmake DESTDIR=$PKG kur-%s\ncd -"):format(v) end,
  492. },
  493. strip={
  494. status = true,
  495. blacklist = '""',
  496. files = function(pkg,blacklist) return helper.scripts.strip:format(pkg,blacklist) end,
  497. },
  498. compress={
  499. man=function(pkg) return helper.scripts.compress_manpages:format(pkg) end,
  500. },
  501. delete={
  502. -- it will just files=
  503. files_un=function(path) return helper.scripts.delete_files:format(path) end,
  504. files=function(path,pattern,ignore) return
  505. "find "..path..' -name "'..pattern..'" ! -path "'..ignore..'" -type f -exec rm -rfv {} + &>/dev/null' end,
  506. dir=function(path) return "rm -rf "..path end,
  507. },
  508. copy={
  509. -- it will just files=
  510. scripts=function(talimatdir,pkg,meta) return helper.scripts.copy_scripts:format(talimatdir,pkg,meta) end,
  511. },
  512. generate={
  513. meta_info=function(pkg,meta,size,thash) return helper.scripts.meta_info:format(pkg,meta,size,thash) end,
  514. content_info=function(pkg) return helper.scripts.content_info:format(pkg) end,
  515. package=function(pkg,meta) return helper.scripts.generate_package:format(pkg,meta) end,
  516. },
  517. calculate={
  518. size=function(path) return "`du -sb "..path.."| awk '{print $1}'`" end,
  519. },
  520. find={
  521. libdepends=function(pkg,meta) return helper.scripts.libdepends:format(pkg,meta) end,
  522. -- if they call one by one so pass parameters
  523. pkglibs=function() return helper.scripts.pkglibs end,
  524. },
  525. change={
  526. dir = function(dir)
  527. local changedir="[ -d %s ] && cd %s"
  528. if dir then return changedir:format(dir,dir) end
  529. end,
  530. }
  531. }-- end of rules
  532. return rules;