rules.lua 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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 exec in `find $PKG -executable -type f`;do
  135. # sadece elf ikililerin dinamiklerini tespit etmek için
  136. for exec in `find $PKG -executable -type f | xargs -I {} file {} | grep ELF | cut -d':' -f1`;do
  137. LC_ALL=C objdump -x $exec | grep NEEDED | awk '{print $2}' >> $templg
  138. echo "$exec +"
  139. done
  140. awk '!/./ || !seen[$0]++' $templg > ${PKG}/${META}/libgerekler
  141. rm -f $templg
  142. cp -v ${PKG}/${META}/libgerekler $PWD/$isim.libgerekler
  143. ]===],
  144. pkglibs=[===[
  145. echo "pktlib analizi"
  146. temppl=`mktemp`
  147. rm -f ${PKG}/pktlibler
  148. for libso in `find $PKG -name *.so* -type f`;do
  149. # paket içerik so dosya isminin yazılması
  150. echo "`basename $libso`" >> $temppl
  151. echo "$libso +"
  152. done
  153. for libso in `find $PKG -name *.so* -type l`;do
  154. # paket içerik so dosya isminin yazılması
  155. echo "`basename $libso`" >> $temppl
  156. echo "$libso +"
  157. done
  158. # mükerrer kayıtların elenmesi.
  159. awk '!/./ || !seen[$0]++' $temppl > ${PKG}/${META}/pktlibler
  160. rm -f $temppl
  161. cp -v ${PKG}/${META}/pktlibler $PWD/$isim.pktlibler
  162. ]===],
  163. compress_manpages=[===[
  164. PKG=%s
  165. [ ! -d $PKG ] && hata_olustu "paketleme dizini: $PKG bulunamadı!"
  166. pushd $PWD &>/dev/zero
  167. cd $PKG
  168. echo "manpages(arşivleme) işlemi"
  169. find . -type f -path "*/share/man*/*" | while read FILE; do
  170. if [ "$FILE" = "${FILE%%.gz}" ]; then
  171. gzip -9 "$FILE"
  172. fi
  173. done
  174. find . -type l -path "*/share/man*/*" | while read FILE; do
  175. TARGET=`readlink -n "$FILE"`
  176. TARGET="${TARGET##*/}"
  177. TARGET="${TARGET%%.gz}.gz"
  178. rm -f "$FILE"
  179. FILE="${FILE%%.gz}.gz"
  180. DIR=`dirname "$FILE"`
  181. if [ -e "$DIR/$TARGET" ]; then
  182. ln -sf "$TARGET" "$FILE"
  183. fi
  184. done
  185. find . -type f -path "*/share/info/*" | while read FILE; do
  186. if [ "$FILE" = "${FILE%%.gz}" ]; then
  187. gzip -9 "$FILE"
  188. fi
  189. done
  190. find . -type l -path "*/share/info/*" | while read FILE; do
  191. TARGET=`readlink -n "$FILE"`
  192. TARGET="${TARGET##*/}"
  193. TARGET="${TARGET%%.gz}.gz"
  194. rm -f "$FILE"
  195. FILE="${FILE%%.gz}.gz"
  196. DIR=`dirname "$FILE"`
  197. if [ -e "$DIR/$TARGET" ]; then
  198. ln -sf "$TARGET" "$FILE"
  199. fi
  200. done
  201. popd &>/dev/zero
  202. ]===],
  203. meta_info=[===[
  204. PKG=%s
  205. META=%s
  206. boyut=%s
  207. thash=%s
  208. USTBILGI=".ustbilgi"
  209. mimari=`uname -m`
  210. derzaman=`date +%%s`
  211. rm -f ${PKG}/${META}/${USTBILGI}
  212. # meta bilgilerin oluşturulması
  213. cat <<EOF > ${PKG}/${META}/${USTBILGI}
  214. isim=$isim
  215. surum=$surum
  216. devir=$devir
  217. tanim=$tanim
  218. url=$url
  219. paketci=$paketci
  220. derzaman=$derzaman
  221. mimari=$mimari
  222. grup=$grup
  223. boyut=$boyut
  224. thash=$thash
  225. EOF
  226. echo "paket üstbilgileri ${PKG}/${USTBILGI} dosyasına yazıldı."
  227. ]===],
  228. content_info=[===[
  229. PKG=%s
  230. BSDTAR=$(which bsdtar)
  231. if [ ! -d $PKG ];then
  232. echo "paketleme dizini: $PKG bulunamadı!"
  233. exit 1
  234. fi
  235. pushd $PWD &>/dev/zero
  236. cd $PKG
  237. ICBILGI=".icbilgi"
  238. rm -f ${ICBILGI}
  239. # yöntem 1
  240. #LANG=C mtree -c -K sha256digest > ${ICBILGI}.k
  241. # yöntem 2
  242. LANG=C \
  243. $BSDTAR --preserve-permissions --format=mtree \
  244. --options='!all,use-set,type,uid,gid,mode,time,size,sha256,link' \
  245. -czf - * ${META} > ${ICBILGI}
  246. popd &>/dev/zero
  247. echo "paket içbilgileri ${PKG}/${ICBILGI} dosyasına yazıldı."
  248. ]===],
  249. generate_package=[===[
  250. PKG=%s
  251. META=%s
  252. BSDTAR=$(which bsdtar)
  253. SUFFIX="mps.lz"
  254. if [ ! -d $PKG ];then
  255. echo "paketleme dizini: $PKG bulunamadı!"
  256. exit 1
  257. fi
  258. urpkt="$PWD/${isim}#${surum}-${devir}-$(uname -m)"
  259. ICBILGI=".icbilgi"
  260. pushd $PWD &>/dev/zero
  261. cd $PKG
  262. set -x
  263. LANG=C \
  264. $BSDTAR --preserve-permissions \
  265. -cf ${urpkt}.mps * ${META} ${ICBILGI}
  266. rm -f ${urpkt}.${SUFFIX}
  267. #xz -4 --threads=0 ${urpkt}
  268. set +x
  269. #mv ${urpkt}.xz ${urpkt}.mps
  270. lzip -9 ${urpkt}.mps
  271. echo "paket arşivi: ${urpkt}.${SUFFIX} +"
  272. echo "\n"
  273. if [ -z ${urpkt} ];then
  274. echo "mps paketi tanımlı değil!"
  275. exit 1
  276. fi
  277. if [ ! -f ${urpkt}.${SUFFIX} ];then
  278. echo "mps paketi bulunamadı!"
  279. exit 1
  280. fi
  281. echo "paket arşiv bilgisi"
  282. pakboyut=`du -sb ${urpkt}.${SUFFIX} | awk '{print $1}'`
  283. if [ "$pakboyut" -lt "2000" ]; then
  284. echo "${urpkt}.${SUFFIX}.bilgi -"
  285. rm -f ${urpkt}
  286. echo "paket oluşturmada hata, yetersiz boyut. Pakur aşamasını kontrol ediniz!!!"
  287. exit 1
  288. else
  289. # paket arşiv boyut hesaplama
  290. kurboyut=`du -sb ${PKG}| awk '{print $1}'`
  291. pakhash=`sha256sum ${urpkt}.${SUFFIX} | awk '{print $1}'`
  292. mimari=`uname -m`
  293. echo "$isim $surum $devir $mimari $pakboyut $kurboyut $pakhash" > "${urpkt}.${SUFFIX}.bilgi"
  294. echo "${urpkt}.${SUFFIX}.bilgi +"
  295. fi
  296. popd &>/dev/zero
  297. ]===],
  298. wget=[===[
  299. kaynak=%s
  300. indirilen=%s
  301. wget_genel_param=" --progress=bar:force"
  302. wget_sertifika_ayar=""
  303. indirme_iptal=0
  304. [ ! -f /etc/ssl/certs/ca-certificates.crt ] && wget_sertifika_ayar="--no-check-certificate"
  305. if [ -z $kaynak ];then
  306. echo "kaynak parametresi eksik"
  307. exit 1
  308. fi
  309. if [ -z $indirilen ];then
  310. echo "indirilen parametresi eksik"
  311. exit 1
  312. fi
  313. # kaynak var ise
  314. if [ -f ${indirilen} ];then
  315. if [ ! -s ${indirilen} ];then
  316. echo "boş kaynak dosyası"
  317. rm -rfv ${indirilen}
  318. # eğer linkte bir hata varsa sürekli döngüye girebilir, hata atıyoruz.
  319. exit 1
  320. else
  321. echo "${indirilen} Dosya zaten mevcut"
  322. indirme_iptal=1
  323. fi
  324. fi
  325. # kaynak dosyası yoksa indirilecek
  326. if [ $indirme_iptal -eq 0 ];then
  327. kismi_indirilen="${indirilen}.partial"
  328. indirme_param="${wget_sertifika_ayar} --passive-ftp --no-directories --tries=3 -O $indirilen --output-document=$kismi_indirilen ${wget_genel_param}"
  329. [ -f "$kismi_indirilen" ] && kismi_indirme="-c"
  330. komut="wget ${kismi_indirme} ${indirme_param} $kaynak"
  331. hata=1
  332. if [ $hata != 0 ]; then
  333. while true; do
  334. wget ${kismi_indirme} ${indirme_param} $kaynak
  335. hata=$?
  336. if [ $hata != 0 ] && [ "$kismi_indirme" ]; then
  337. echo "Kısmi indirme hata oluştu,tekrar başlatılıyor"
  338. rm -f "$kismi_indirilen"
  339. kismi_indirme=""
  340. else
  341. break
  342. fi
  343. done
  344. fi
  345. if [ $hata != 0 ]; then
  346. echo "İndiriliyor '$kaynak' başarısız."
  347. exit 1
  348. fi
  349. mv -f "${kismi_indirilen}" "${indirilen}"
  350. fi
  351. ]===],
  352. }
  353. -- Rules of Talimat
  354. rules={
  355. dirs={
  356. -- don't forget last slash
  357. src = "/tmp/work/src/",
  358. pkg = "/tmp/work/pkg/",
  359. pkg_meta= ".meta",
  360. archive = "/sources/",
  361. },
  362. export={
  363. me = function(key,default,val) if val ~=nil then return 'export '..key..'="'..val..'"' else return 'export '..key..'="'..default..'"' end end,
  364. talimat=function (pmeta)
  365. exports={}
  366. for key,val in pairs(pmeta) do
  367. table.insert(exports,("export "..key.."="..'"'..val..'"'))
  368. end
  369. return exports
  370. end,
  371. dirs=function ()
  372. exports={}
  373. table.insert(exports,("export ".."PKG".."="..'"'..rules.dirs.pkg..'"'))
  374. table.insert(exports,("export ".."SRC".."="..'"'..rules.dirs.src..'"'))
  375. table.insert(exports,("export ".."META".."="..'"'..rules.dirs.pkg_meta..'"'))
  376. table.insert(exports,("export ".."KAYNAK_DIZIN".."="..'"'..rules.dirs.archive..'"'))
  377. return exports
  378. end,
  379. source_aliases=[===[
  380. KERNEL_SITE="https://www.kernel.org/pub/linux/"
  381. GNU_SITE="https://ftp.gnu.org/gnu/"
  382. GNOME_SITE="https://download.gnome.org/sources"
  383. PYPI_SITE="https://files.pythonhosted.org/packages/source"
  384. XFCE4_SITE="https://archive.xfce.org/src"
  385. CPAN_SITE="https://www.cpan.org/modules/by-module"
  386. SOURCEFORGE_SITE="https://downloads.sourceforge.net/sourceforge"
  387. FREEDESKTOP_SITE="https://www.freedesktop.org/software/"
  388. ]===],
  389. },
  390. make_dirs={
  391. src = function() return "rm -rf "..rules.dirs.src..";mkdir -pv "..rules.dirs.src end,
  392. pkg = function() return "rm -rf "..rules.dirs.pkg..";mkdir -pv "..rules.dirs.pkg end,
  393. pkg_meta= function() return "mkdir -pv "..rules.dirs.pkg..rules.dirs.pkg_meta end,
  394. archive = function() return "mkdir -pv "..rules.dirs.archive end,
  395. },
  396. package={
  397. archive="$isim-$surum"
  398. },
  399. source={
  400. gz = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.gz" end,
  401. xz = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.xz" end,
  402. bz2 = function(t,v) return v.."/"..t.paket.isim.."-"..t.paket.surum..".tar.bz2" end,
  403. 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
  404. },
  405. fetch={
  406. --url = function(f) return rules.wget.bin..rules.wget.params..f.address.." -O "..f.store end,
  407. url = function(f) return helper.scripts.wget:format(f.address,f.store) end,
  408. git = function(f) return "git clone "..f.address.." "..f.store end,
  409. --file = function(f) return "cp -f "..f.address.." "..rules.dirs.src..f.store end,
  410. file = function(f) return "cp -fv "..f.address.." "..f.store end,
  411. check = function(f) return ("[ -f %s ] && exit 0"):format(f.store) end,
  412. },
  413. hash={
  414. sha256 = function(file,hash) return ('set -x;echo "%s %s" | sha256sum --check'):format(hash,file) end,
  415. sha512 = function(file,hash) return ('set -x;echo "%s %s" | sha512sum --check'):format(hash,file) end,
  416. },
  417. extract={
  418. bsdtar = function(dir,archive) return ("set -x;bsdtar -p -o -C %s -xf %s"):format(dir,archive) end,
  419. },
  420. build_type={
  421. gnu = "./configure ${CONF_OPT} ${EXT_OPT} && make ${MAKEJOBS}",
  422. cmake = "mkdir -p build;cd build;cmake ${CMAKE_OPT} $extopt ../ && make ${MAKEJOBS}",
  423. py3 = "python3 setup.py build",
  424. py2 = "python2 setup.py build",
  425. perl = "perl Makefile.PL INSTALLDIRS=vendor && make",
  426. meson = "cd $SRC && milis-meson $isim-$surum build ${EXT_OPT}",
  427. ninja = "mkdir -p build && ninja -C build",
  428. waf = "python3 waf configure --prefix=/usr ${EXT_OPT} && python3 waf build",
  429. },
  430. build_env={
  431. carch = function(v) return rules.export.me("CARCH","x86_64",v) end,
  432. chost = function(v) return rules.export.me("CHOST","x86_64-pc-linux-gnu",v) end,
  433. cppflags = function(v) return rules.export.me("CPPFLAGS","-D_FORTIFY_SOURCE=2",v) end,
  434. cflags = function(v) return rules.export.me("CFLAGS","-march=x86-64 -mtune=generic -O2 -pipe -fno-plt",v) end,
  435. cxxflags = function(v) return rules.export.me("CXXFLAGS","-march=x86-64 -mtune=generic -O2 -pipe -fno-plt",v) end,
  436. ldflags = function(v) return rules.export.me("LDFLAGS","-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now",v) end,
  437. jobs = function(v) return rules.export.me("MAKEJOBS","-j$((`nproc`+1))",v) end,
  438. 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,
  439. 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,
  440. },
  441. build={
  442. cd = function(t,v) return rules.change.dir(rules.dir.src..v) end,
  443. tip = function(t,v) return rules.build_type[v] end,
  444. betik = function(t,v) return v end,
  445. dosya = function(t,v) return file_content(t.dir.."/"..v) end,
  446. ekconf= function(t,v) return rules.export.me("EXT_OPT",nil,v) end,
  447. yama = function(t,v) return "patch -Np1 -i $SRC/"..v end,
  448. yama0 = function(t,v) return "patch -Np0 -i $SRC/"..v end,
  449. },
  450. install_type={
  451. gnu = "make DESTDIR=$PKG install $EXT_OPT",
  452. cmake = "cd build;make DESTDIR=$PKG install",
  453. py3 = "python3 setup.py install --root=${PKG} --optimize=1 --skip-build $EXT_OPT",
  454. py2 = "python2 setup.py install --root=${PKG} --optimize=1 --skip-build $EXT_OPT",
  455. ninja = "DESTDIR=$PKG ninja -C build install",
  456. meson = "cd $SRC && DESTDIR=$PKG ninja -C build install",
  457. waf = "python3 waf install --destdir=$PKG",
  458. },
  459. install={
  460. cd = function(t,v) return rules.change.dir(rules.dir.src..v) end,
  461. tip = function(t,v) return rules.install_type[v] end,
  462. betik = function(t,v) return v end,
  463. dosya = function(t,v) return file_content(t.dir.."/"..v) end,
  464. strip = function(t,v) if v == "0" then rules.strip.status=false end; end,
  465. nostrip = function(t,v) rules.strip.blacklist=v end,
  466. },
  467. strip={
  468. status = true,
  469. blacklist = '""',
  470. files = function(pkg,blacklist) return helper.scripts.strip:format(pkg,blacklist) end,
  471. },
  472. compress={
  473. man=function(pkg) return helper.scripts.compress_manpages:format(pkg) end,
  474. },
  475. delete={
  476. -- it will just files=
  477. files_un=function(path) return helper.scripts.delete_files:format(path) end,
  478. files=function(path,pattern,ignore) return
  479. "find "..path..' -name "'..pattern..'" ! -path "'..ignore..'" -type f -exec rm -rfv {} + &>/dev/null' end,
  480. dir=function(path) return "rm -rf "..path end,
  481. },
  482. copy={
  483. -- it will just files=
  484. scripts=function(talimatdir,pkg,meta) return helper.scripts.copy_scripts:format(talimatdir,pkg,meta) end,
  485. },
  486. generate={
  487. meta_info=function(pkg,meta,size,thash) return helper.scripts.meta_info:format(pkg,meta,size,thash) end,
  488. content_info=function(pkg) return helper.scripts.content_info:format(pkg) end,
  489. package=function(pkg,meta) return helper.scripts.generate_package:format(pkg,meta) end,
  490. },
  491. calculate={
  492. size=function(path) return "`du -sb "..path.."| awk '{print $1}'`" end,
  493. },
  494. find={
  495. libdepends=function(pkg,meta) return helper.scripts.libdepends:format(pkg,meta) end,
  496. -- if they call one by one so pass parameters
  497. pkglibs=function() return helper.scripts.pkglibs end,
  498. },
  499. change={
  500. dir = function(dir)
  501. local changedir="[ -d %s ] && cd %s"
  502. if dir then return changedir:format(dir,dir) end
  503. end,
  504. }
  505. }-- end of rules
  506. return rules;