mpsd01112017 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441
  1. #!/bin/bash
  2. # error codes
  3. E_GENERAL=1
  4. E_TALIMAT=2 # hatalı talimat
  5. E_DIR_PERM=3 # (source/build) directory missing or missing read/write permission
  6. E_DOWNLOAD=4 # error during download
  7. E_UNPACK=5 # error during unpacking of source file(s)
  8. E_MD5=6 # md5sum verification failed
  9. E_FOOTPRINT=7 # footprint check failure
  10. E_BUILD=8 # error while running 'derle()'
  11. E_INSTALL=9 # paket kurulum hatası (mps -k)
  12. info() {
  13. echo "=======> $1"
  14. }
  15. warning() {
  16. info "UYARI: $1" >&2
  17. }
  18. error() {
  19. info "HATA: $1" >&2
  20. }
  21. abort_on_build() {
  22. error $1
  23. exit $E_BUILD
  24. }
  25. get_filename() {
  26. if [[ "$1" =~ "::"(.+) ]] ;then
  27. echo "$DERLEME_KAYNAKDIZIN/${BASH_REMATCH[1]}"
  28. elif [[ $1 =~ ^(http|https|ftp|file)://.*/(.+) ]]; then
  29. echo "$DERLEME_KAYNAKDIZIN/${BASH_REMATCH[2]}"
  30. else
  31. echo $1
  32. fi
  33. }
  34. get_basename() {
  35. local FILE="`echo $1 | sed 's|^.*://.*/||g'`"
  36. echo $FILE
  37. }
  38. check_pkgfile() {
  39. local ISIM_TEST
  40. if [ "${isim}" == "" ]; then
  41. error "$PKGMK_PKGFILE dosyası içinde 'isim' değişkeni bulunamadı."
  42. exit $E_TALIMAT
  43. elif [ "`type -t derle`" != "function" ]; then
  44. error "$PKGMK_PKGFILE dosyası içinde 'derle' fonksiyonu bulunamadı."
  45. exit $E_TALIMAT
  46. fi
  47. ISIM_TEST=`echo "${isim}" | sed 's@[[a-z0-9]*[-_+]*]*@@g'`
  48. if [ "$ISIM_TEST" != "" ]; then
  49. error " 'isim' tanımlı değil veya değişkeni geçersiz karakter barındırıyor: $ISIM_TEST"
  50. exit $E_TALIMAT
  51. fi
  52. if [ ${#isim} -gt 30 ];then
  53. error " 'isim' değişkeni 30 karakterden büyük olamaz."
  54. exit $E_TALIMAT
  55. fi
  56. if [ "${surum}" == "" ]; then
  57. error "'versiyon' degeri $PKGMK_PKGFILE dosyası içinde yok veya tanımlı degil."
  58. exit $E_TALIMAT
  59. fi
  60. if [ "$DEVIR_YOKSAY" = "yok" ]; then
  61. if [ "${devir}" == "" ]; then
  62. error " 'devir' degeri $PKGMK_PKGFILE dosyası içinde yok veya tanımlı degil."
  63. exit $E_TALIMAT
  64. fi
  65. fi
  66. }
  67. get_package_name() {
  68. local NAME EXT
  69. if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
  70. EXT=$PKT_UZANTISI
  71. else
  72. EXT=$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
  73. fi
  74. NAME=`echo "$1" | cut -d'#' -f1`
  75. echo "$NAME"
  76. }
  77. get_package_builddate() {
  78. local NAME BUILD_DATE EXT
  79. if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
  80. EXT=$PKT_UZANTISI
  81. else
  82. EXT=$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
  83. fi
  84. NAME="`get_package_name $1`"
  85. BUILD_DATE=`echo $1|sed "s/i686.$EXT//"|sed "s/x86_64.$EXT//"|sed "s/any.$EXT//"`
  86. echo "${BUILD_DATE:$((${#NAME}))}"
  87. }
  88. get_package_extension() {
  89. local EXTENSION
  90. if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
  91. EXTENSION=".$PKT_UZANTISI"
  92. else
  93. EXTENSION=".$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU"
  94. fi
  95. echo $EXTENSION
  96. }
  97. get_package_arch() {
  98. local NAME BUILD_DATE EXTENSION
  99. NAME=`get_package_name $1`
  100. BUILD_DATE=`get_package_builddate $1`
  101. EXTENSION=`get_package_extension $1`
  102. echo $1|sed "s/$NAME$BUILD_DATE//"|sed "s/$EXTENSION//"
  103. }
  104. check_directory() {
  105. if [ ! -d $1 ]; then
  106. error "Directory '$1' does not exist."
  107. exit $E_DIR_PERM
  108. elif [ ! -w $1 ]; then
  109. error "Directory '$1' not writable."
  110. exit $E_DIR_PERM
  111. elif [ ! -x $1 ] || [ ! -r $1 ]; then
  112. error "Directory '$1' not readable."
  113. exit $E_DIR_PERM
  114. fi
  115. }
  116. check_file() {
  117. if [ -e $1 ] && [ ! -w $1 ]; then
  118. error "File '$1' is not writable."
  119. exit $E_GENERAL
  120. fi
  121. }
  122. downloads_file_with_curl() {
  123. if [ ! "`type -p curl`" ]; then
  124. error "Command 'curl' not found."
  125. exit $E_GENERAL
  126. fi
  127. DOWNLOAD_OPTS="--ftp-pasv --retry 3 --retry-delay 3 \
  128. -R -o $1 --fail -#"
  129. error=1
  130. curl $DOWNLOAD_OPTS $2
  131. error=$?
  132. if [ $error != 0 ]; then
  133. error "İndiriliyor '$2' başarısız."
  134. exit $E_DOWNLOAD
  135. fi
  136. }
  137. download_file() {
  138. if [[ "$1" =~ (.+)"::" ]] ;then
  139. adres="${BASH_REMATCH[0]}"
  140. adres=`echo $adres | sed s'/..$//' `
  141. else
  142. adres="$1"
  143. fi
  144. info "İndiriliyor $adres"
  145. LOCAL_FILENAME=`get_filename $1`
  146. info "kayıt:$LOCAL_FILENAME"
  147. if [ ! "`type -p wget`" ]; then
  148. warning "Command 'wget' not found."
  149. info "You should install 'wget' as soon as possible, trying with curl ..."
  150. downloads_file_with_curl $LOCAL_FILENAME $1
  151. else
  152. LOCAL_FILENAME_PARTIAL="$LOCAL_FILENAME.partial"
  153. DOWNLOAD_OPTS="--passive-ftp --no-directories --tries=3 --waitretry=3 \
  154. -O $LOCAL_FILENAME \
  155. --output-document=$LOCAL_FILENAME_PARTIAL --no-check-certificate"
  156. if [ -f "$LOCAL_FILENAME_PARTIAL" ]; then
  157. info "Kısmi indirme var,tamamlanmaya çalışılacak"
  158. RESUME_CMD="-c"
  159. fi
  160. error=1
  161. BASENAME=`get_basename $adres`
  162. for REPO in ${PKGMK_SOURCE_MIRRORS[@]}; do
  163. REPO="`echo $REPO | sed 's|/$||'`"
  164. wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $REPO/$BASENAME
  165. error=$?
  166. if [ $error == 0 ]; then
  167. break
  168. fi
  169. done
  170. if [ $error != 0 ]; then
  171. while true; do
  172. wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $adres
  173. error=$?
  174. if [ $error != 0 ] && [ "$RESUME_CMD" ]; then
  175. info "Partial download failed, restarting"
  176. rm -f "$LOCAL_FILENAME_PARTIAL"
  177. RESUME_CMD=""
  178. else
  179. break
  180. fi
  181. done
  182. fi
  183. if [ $error != 0 ]; then
  184. error "İndiriliyor '$adres' başarısız."
  185. exit $E_DOWNLOAD
  186. fi
  187. mv -f "$LOCAL_FILENAME_PARTIAL" "$LOCAL_FILENAME"
  188. fi
  189. }
  190. kaynak_indir() {
  191. local FILE LOCAL_FILENAME
  192. for FILE in ${kaynak[@]}; do
  193. LOCAL_FILENAME=`get_filename $FILE`
  194. if [ ! -e $LOCAL_FILENAME ]; then
  195. if [ "$LOCAL_FILENAME" = "$FILE" ]; then
  196. error " '$LOCAL_FILENAME' dosyası içinde 'kaynak' değişkeni tanımsız veya yok."
  197. exit $E_DOWNLOAD
  198. else
  199. if [ "$PKGMK_DOWNLOAD" = "evet" ]; then
  200. download_file $FILE
  201. else
  202. error " '$LOCAL_FILENAME' kaynak dosyası bulunamadı."
  203. exit $E_DOWNLOAD
  204. fi
  205. fi
  206. fi
  207. done
  208. }
  209. remove_source() {
  210. local FILE LOCAL_FILENAME
  211. for FILE in ${kaynak[@]}; do
  212. LOCAL_FILENAME=`get_filename $FILE`
  213. if [ -e $LOCAL_FILENAME ] && [ "$LOCAL_FILENAME" != "$FILE" ]; then
  214. info "Removing $LOCAL_FILENAME"
  215. rm -f $LOCAL_FILENAME
  216. fi
  217. done
  218. }
  219. unpack_source() {
  220. local FILE LOCAL_FILENAME COMMAND
  221. for FILE in ${kaynak[@]}; do
  222. LOCAL_FILENAME=`get_filename $FILE`
  223. case $LOCAL_FILENAME in
  224. *.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
  225. if [ "$PKGMK_IGNORE_UNPACK" != "evet" ];then
  226. COMMAND="bsdtar -p -o -C $SRC -xf $LOCAL_FILENAME"
  227. else
  228. COMMAND="cp $LOCAL_FILENAME $SRC"
  229. fi ;;
  230. *)
  231. COMMAND="cp $LOCAL_FILENAME $SRC" ;;
  232. esac
  233. echo "$COMMAND"
  234. $COMMAND
  235. if [ $? != 0 ]; then
  236. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  237. rm -rf $DERLEME_SANTIYE
  238. fi
  239. error "'$TARGET' derlenmesi basarisiz."
  240. exit $E_UNPACK
  241. fi
  242. done
  243. }
  244. get_package_list() {
  245. local ARCH FILE i
  246. i=0
  247. for ARCH in x86_64 i686 any; do
  248. for FILE in `find $PAKETLEME_DIZIN -name "${isim}*$ARCH.$PKT_UZANTISI*"`; do
  249. TARGETS[i]=`basename $FILE`
  250. i=$((i+1))
  251. done
  252. done
  253. }
  254. make_md5sum() {
  255. local FILE LOCAL_FILENAMES
  256. if [ "$kaynak" ]; then
  257. for FILE in ${kaynak[@]}; do
  258. LOCAL_FILENAMES="$LOCAL_FILENAMES `get_filename $FILE`"
  259. done
  260. md5sum $LOCAL_FILENAMES | sed -e 's| .*/| |' | sort -k 2
  261. fi
  262. }
  263. make_footprint() {
  264. if ! (echo $TARGET| grep "kernel" >/dev/null); then
  265. pkginfo --footprint $TARGET | \
  266. sed "s|\tlib/modules/`uname -r`/|\tlib/modules/<kernel-version>/|g" | \
  267. sort -k 3
  268. else
  269. pkginfo --footprint $TARGET | sort -k 3
  270. fi
  271. }
  272. check_md5sum() {
  273. local FILE="$DERLEME_SANTIYE/.tmp"
  274. cd $PKGMK_ROOT
  275. if [ -f $PKGMK_MD5SUM ]; then
  276. make_md5sum > $FILE.md5sum
  277. sort -k 2 $PKGMK_MD5SUM > $FILE.md5sum.orig
  278. diff -w -t -U 0 $FILE.md5sum.orig $FILE.md5sum | \
  279. sed '/^@@/d' | \
  280. sed '/^+++/d' | \
  281. sed '/^---/d' | \
  282. sed 's/^+/NEW /g' | \
  283. sed 's/^-/MISSING /g' > $FILE.md5sum.diff
  284. if [ -s $FILE.md5sum.diff ]; then
  285. error "Md5sum mismatch found:"
  286. cat $FILE.md5sum.diff >&2
  287. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  288. rm -rf $DERLEME_SANTIYE
  289. fi
  290. if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
  291. error "Md5sum not ok."
  292. exit $E_MD5
  293. fi
  294. error "'$TARGET' derleme basarisiz."
  295. exit $E_MD5
  296. fi
  297. else
  298. if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
  299. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  300. rm -rf $DERLEME_SANTIYE
  301. fi
  302. info "Md5sum not found."
  303. exit $E_MD5
  304. fi
  305. warning "Md5sum not found, creating new."
  306. make_md5sum > $PKGMK_MD5SUM
  307. fi
  308. if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
  309. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  310. rm -rf $DERLEME_SANTIYE
  311. fi
  312. info "Md5sum ok."
  313. exit 0
  314. fi
  315. }
  316. hash_kontrol() {
  317. _hata_deger="FAILED"
  318. if [ $LC_ALL = "tr_TR.UTF-8" ];then
  319. _hata_deger="BAŞARISIZ"
  320. fi
  321. cd $DERLEME_KAYNAKDIZIN
  322. cp $PKGMK_ROOT/$isim.hash $DERLEME_KAYNAKDIZIN/
  323. sha256sum -c $DERLEME_KAYNAKDIZIN/$isim.hash > /tmp/$isim.hash.kontrol 2> /dev/null
  324. sha512sum -c $DERLEME_KAYNAKDIZIN/$isim.hash >> /tmp/$isim.hash.kontrol 2> /dev/null
  325. if [[ $(cat /tmp/$isim.hash.kontrol | grep $_hata_deger) ]];then
  326. echo "shasum uyuşmayan kaynak kod var"
  327. exit 1
  328. fi
  329. [ -f $DERLEME_KAYNAKDIZIN/$isim.hash ] && rm $DERLEME_KAYNAKDIZIN/$isim.hash
  330. #[ -f /tmp/$isim.hash.kontrol ] && rm /tmp/$isim.hash.kontrol
  331. }
  332. strip_files() {
  333. local FILE FILTER
  334. cd $PKG
  335. if [ -f $PKGMK_ROOT/$PKGMK_NOSTRIP ]; then
  336. FILTER="grep -v -f $PKGMK_ROOT/$PKGMK_NOSTRIP"
  337. else
  338. FILTER="cat"
  339. fi
  340. find . -type f -printf "%P\n" | $FILTER | while read FILE; do
  341. case $(file -b "$FILE") in
  342. *ELF*executable*not\ stripped)
  343. strip --strip-all "$FILE"
  344. ;;
  345. *ELF*shared\ object*not\ stripped)
  346. strip --strip-unneeded "$FILE"
  347. ;;
  348. current\ ar\ archive)
  349. strip --strip-debug "$FILE"
  350. esac
  351. done
  352. }
  353. compress_manpages() {
  354. local FILE DIR TARGET
  355. cd $PKG
  356. find . -type f -path "*/share/man*/*" | while read FILE; do
  357. if [ "$FILE" = "${FILE%%.gz}" ]; then
  358. gzip -9 "$FILE"
  359. fi
  360. done
  361. find . -type l -path "*/share/man*/*" | while read FILE; do
  362. TARGET=`readlink -n "$FILE"`
  363. TARGET="${TARGET##*/}"
  364. TARGET="${TARGET%%.gz}.gz"
  365. rm -f "$FILE"
  366. FILE="${FILE%%.gz}.gz"
  367. DIR=`dirname "$FILE"`
  368. if [ -e "$DIR/$TARGET" ]; then
  369. ln -sf "$TARGET" "$FILE"
  370. fi
  371. done
  372. find . -type f -path "*/share/info/*" | while read FILE; do
  373. if [ "$FILE" = "${FILE%%.gz}" ]; then
  374. gzip -9 "$FILE"
  375. fi
  376. done
  377. find . -type l -path "*/share/info/*" | while read FILE; do
  378. TARGET=`readlink -n "$FILE"`
  379. TARGET="${TARGET##*/}"
  380. TARGET="${TARGET%%.gz}.gz"
  381. rm -f "$FILE"
  382. FILE="${FILE%%.gz}.gz"
  383. DIR=`dirname "$FILE"`
  384. if [ -e "$DIR/$TARGET" ]; then
  385. ln -sf "$TARGET" "$FILE"
  386. fi
  387. done
  388. }
  389. check_footprint() {
  390. local TARGET FILE="$DERLEME_SANTIYE/.tmp"
  391. cd $PAKETLEME_DIZIN
  392. if [ -z $TARGETS ]; then
  393. get_package_list
  394. if [ -z $TARGETS ]; then
  395. error "Unable to update footprint"
  396. fi
  397. fi
  398. for TARGET in ${TARGETS[@]}; do
  399. if [ -f $TARGET ]; then
  400. PKGMK_FOOTPRINT="`get_package_name $TARGET`".footprint
  401. make_footprint > $FILE.footprint
  402. if [ -f $PKGMK_FOOTPRINT ]; then
  403. sort -k 3 $PKGMK_FOOTPRINT > $FILE.footprint.orig
  404. diff -w -t -U 0 $FILE.footprint.orig $FILE.footprint | \
  405. sed '/^@@/d' | \
  406. sed '/^+++/d' | \
  407. sed '/^---/d' | \
  408. sed 's/^+/NEW /g' | \
  409. sed 's/^-/MISSING /g' > $FILE.footprint.diff
  410. if [ -s $FILE.footprint.diff ]; then
  411. if [ "$PKGMK_IGNORE_NEW" = "evet" ]; then
  412. mv $FILE.footprint $PKGMK_FOOTPRINT
  413. warning "Footprint mismatch found:"
  414. else
  415. error "Footprint mismatch found:"
  416. BUILD_SUCCESSFUL="yok"
  417. fi
  418. cat $FILE.footprint.diff >&2
  419. fi
  420. else
  421. warning "Footprint not found, creating new."
  422. mv $FILE.footprint $PKGMK_FOOTPRINT
  423. fi
  424. else
  425. error "Package '$TARGET' was not found."
  426. BUILD_SUCCESSFUL="yok"
  427. fi
  428. done
  429. }
  430. make_work_dir() {
  431. export PKG="$DERLEME_SANTIYE/pkg"
  432. export SRC="$DERLEME_SANTIYE/src"
  433. umask 022
  434. cd $PKGMK_ROOT
  435. remove_work_dir
  436. mkdir -p $SRC $PKG
  437. if [ -f $PKGMK_ROOT/$HASH_KONTROL_DOSYA ]; then
  438. echo "hash kontrol dosyası var"
  439. if [ "$HASH_KONTROL_YAP" = "evet" ]; then
  440. echo "hash kontrolü yapılacak"
  441. hash_kontrol
  442. else
  443. echo "hash kontrolü yapılmayacak."
  444. fi
  445. else
  446. echo "hash kontrol dosyası yok-hash kontrolü yapılmayacak."
  447. fi
  448. }
  449. remove_work_dir() {
  450. rm -rf $DERLEME_SANTIYE
  451. }
  452. pack_devel() {
  453. local DIR SUBDIR
  454. for DIR in usr opt/*; do
  455. for SUBDIR in include lib/pkgconfig; do
  456. if [ -d $DIR/$SUBDIR ]; then
  457. bsdtar -r -f \
  458. $PAKETLEME_DIZIN/${isim}.${group}#$surum-any.${PKT_UZANTISI} \
  459. $DIR/$SUBDIR || BUILD_SUCCESSFUL="yok"
  460. rm -r $DIR/$SUBDIR
  461. j=1
  462. fi
  463. done
  464. done
  465. }
  466. remove_devel() {
  467. local DIR SUBDIR
  468. for DIR in usr opt/*; do
  469. for SUBDIR in include lib/pkgconfig; do
  470. if [ -d $DIR/$SUBDIR ]; then
  471. rm -r $DIR/$SUBDIR
  472. fi
  473. done
  474. done
  475. }
  476. add_meta_files() {
  477. local NAME
  478. NAME="`get_package_name $1`"
  479. cd $PKG
  480. if [ -f $PKGMK_ROOT/${NAME}.okubeni ]; then
  481. cp $PKGMK_ROOT/${NAME}.okubeni .README
  482. fi
  483. if [ -f $PKGMK_ROOT/${NAME}.kos-kur ]; then
  484. cp $PKGMK_ROOT/${NAME}.kos-kur .PRE
  485. fi
  486. if [ -f $PKGMK_ROOT/${NAME}.kur-kos ]; then
  487. cp $PKGMK_ROOT/${NAME}.kur-kos .POST
  488. fi
  489. for file in .README .PRE .POST; do
  490. if [ -f $file ]; then
  491. bsdtar -r -f $PAKETLEME_DIZIN/$1 \
  492. $file
  493. rm $file
  494. fi
  495. done
  496. }
  497. add_meta_to_archive() {
  498. local NAME TAR SIZE_I DESC URL PACK MAINT ARCH GRUP
  499. NAME="`get_package_name $1`"
  500. ARCH="`get_package_arch $1`"
  501. info "$NAME arşivine üstbilgiler ekleniyor."
  502. TAR="$DERLEME_SANTIYE/tar"
  503. mkdir -p $TAR
  504. cd $TAR
  505. bsdtar xf $PAKETLEME_DIZIN/$1
  506. # üstbaşlık bilgilerinin türkçe harf desteği için
  507. LC_ALL="tr_TR.UTF-8"
  508. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tanım|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  509. DESC="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tanım|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
  510. else
  511. DESC="belirsiz"
  512. fi
  513. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Paketçi|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  514. PACK="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Paketçi|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
  515. else
  516. PACK="belirsiz"
  517. fi
  518. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tamirci|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  519. MAINT="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tamirci|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
  520. else
  521. MAINT="belirsiz"
  522. fi
  523. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^url|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  524. URL="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^url|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
  525. else
  526. URL="belirsiz"
  527. fi
  528. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Grup|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  529. GRUP="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Grup|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
  530. else
  531. GRUP="belirsiz"
  532. fi
  533. SIZE_I="`du -b $PAKETLEME_DIZIN/$1|sed "s/\t/ /"|cut -d " " -f1`"
  534. echo "N$NAME" > .META
  535. echo "D$DESC" >> .META
  536. echo "U$URL" >> .META
  537. echo "M$MAINT" >> .META
  538. echo "P$PACK" >> .META
  539. echo "S$SIZE_I" >> .META
  540. echo "V$surum" >> .META
  541. echo "r$devir" >> .META
  542. echo "B$PKGMK_BUILDVER" >> .META
  543. echo "a$ARCH" >> .META
  544. echo "G$GRUP" >> .META
  545. bsdtar -tf $PAKETLEME_DIZIN/$1 > .MTREE
  546. rm $PAKETLEME_DIZIN/$1
  547. for file in .META .MTREE .README .PRE .POST .INFO; do
  548. if [ -f $file ]; then
  549. bsdtar -r -f $PAKETLEME_DIZIN/$1 \
  550. $file
  551. fi
  552. done
  553. bsdtar -r -f $PAKETLEME_DIZIN/$1 *
  554. cd ..
  555. rm -rf $TAR
  556. }
  557. compress_archive() {
  558. info "$1 sıkıştırılıyor."
  559. case $PKT_SIKISTIRMA_MODU in
  560. lz) lzip -9 $1;;
  561. gz) gzip -9 $1;;
  562. bz2) bzip2 -9 $1;;
  563. xz) xz -z -9 $1;;
  564. esac
  565. }
  566. derleme_yap() {
  567. if [ "$PAKETSIZ_DERLEME" = "evet" ]; then
  568. paketsiz_derle
  569. else
  570. build_package
  571. fi
  572. }
  573. paketsiz_derle() {
  574. local BUILD_SUCCESSFUL="yok"
  575. export PKG="/"
  576. export SRC="$DERLEME_SANTIYE/src"
  577. umask 022
  578. cd $PKGMK_ROOT
  579. rm -rf $DERLEME_SANTIYE
  580. mkdir -p $SRC
  581. info "derleniyor... '$TARGET'"
  582. if [ "$PKGMK_DOWNLOAD" = "evet" ]; then
  583. kaynak_indir
  584. fi
  585. unpack_source
  586. cd $SRC
  587. (set -e -x ; derle)
  588. # cd $PKG
  589. if [ $? = 0 ]; then
  590. BUILD_SUCCESSFUL="evet"
  591. fi
  592. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  593. rm -rf $DERLEME_SANTIYE
  594. fi
  595. if [ "$BUILD_SUCCESSFUL" = "evet" ]; then
  596. info " '$TARGET' derleme basarili"
  597. else
  598. if [ -f $TARGET ]; then
  599. touch -r $PKGMK_ROOT/$PKGMK_PKGFILE $TARGET &> /dev/null
  600. fi
  601. error " '$TARGET' derleme basarisiz"
  602. exit 1
  603. fi
  604. }
  605. build_package() {
  606. # TODO find a better solution for the hardcoded folders
  607. local BUILD_SUCCESSFUL="yok"
  608. if [ "$1" != "$TARGET" ]; then
  609. if [ ! -z $TARGETS ]; then
  610. for TARGET in ${TARGETS[@]}; do
  611. error "$TARGET should be remove"
  612. done
  613. error "Remove the binaries first..."
  614. exit $E_BUILD
  615. fi
  616. fi
  617. check_file "$TARGET"
  618. make_work_dir
  619. if [ "$UID" != "0" ]; then
  620. warning "Paketler root olarak derlenmeli."
  621. fi
  622. info "Derleniyor '$TARGET'."
  623. unpack_source
  624. cd $SRC
  625. (set -e -x ; derle)
  626. if [ $? = 0 ]; then
  627. if [ "$PKGMK_NO_STRIP" = "yok" ]; then
  628. strip_files
  629. fi
  630. compress_manpages
  631. cd $PKG
  632. i=0
  633. j=0
  634. for group in ${PAKET_GRUPLAR[@]}; do
  635. BUILD_SUCCESSFUL="evet"
  636. if [ "`type -t ${group}`" == "function" ]; then
  637. (set -e -x ;${group})
  638. j=1
  639. if [ $? = 0 ]; then
  640. BUILD_SUCCESSFUL="evet"
  641. else
  642. error "Building '$TARGET' failed."
  643. exit $E_BUILD
  644. fi
  645. else
  646. if [ "$1" != "$TARGET" ]; then
  647. if [ -f $PAKETLEME_DIZIN/${isim}.${group}#$surum-* ]; then
  648. rm $PAKETLEME_DIZIN/${isim}.${group}#$surum-}*
  649. fi
  650. pack_${group}
  651. fi
  652. remove_${group}
  653. if [ "$BUILD_SUCCESSFUL" == "yok" ]; then
  654. error "Building '$TARGET' failed."
  655. exit $E_BUILD
  656. fi
  657. fi
  658. # Add the meta in each package
  659. if [ $j == 1 ]; then
  660. if [ "$BUILD_SUCCESSFUL" == "yok" ]; then
  661. error "Building '$TARGET' failed."
  662. exit $E_BUILD
  663. fi
  664. j=0
  665. fi
  666. j=0
  667. done
  668. #dil desteginin eklenmesi-geri kalanın temizlenmesi
  669. #if [ ! "$PAKET_LOKAL" == "hepsi" ];then
  670. # local lokaldizin
  671. # if [ -d usr/share/locale ];then
  672. # lokaldizin="usr/share/locale"
  673. # fi
  674. # if [ -d opt/*/usr/share/locale ];then
  675. # lokaldizin="opt/*/usr/share/locale"
  676. # fi
  677. # for DIR in `ls $lokaldizin` ; do
  678. # if [[ "$PAKET_LOKAL" == *"$DIR"* ]]; then
  679. # echo $DIR "dil paketi ekleniyor"
  680. # else
  681. # rm -rf $lokaldizin/$DIR
  682. # fi
  683. # done
  684. #fi
  685. if [ "`ls|wc -l`" != "0" ]; then
  686. bsdtar -r -f $PAKETLEME_DIZIN/${isim}#$surum-${MIMARI}.${PKT_UZANTISI} *
  687. else
  688. error "No files found in $PKG..."
  689. exit $E_BUILD
  690. fi
  691. if [ $? = 0 ]; then
  692. BUILD_SUCCESSFUL="evet"
  693. if [ "$DOSYAIZLEME_YOKSAY" == "evet" ]; then
  694. warning "dosyaizleme pas gecildi."
  695. else
  696. check_footprint
  697. fi
  698. fi
  699. fi
  700. if [ "$BUILD_SUCCESSFUL" = "evet" ]; then
  701. if [ "$1" != "$TARGET" ]; then
  702. get_package_list
  703. if [ -z $TARGETS ]; then
  704. error "Paket(ler) bulunamadı..."
  705. exit $E_BUILD
  706. fi
  707. for TARGET in ${TARGETS[@]}; do
  708. add_meta_files $TARGET
  709. add_meta_to_archive $TARGET
  710. done
  711. else
  712. add_meta_files `basename $TARGET`
  713. add_meta_to_archive `basename $TARGET`
  714. fi
  715. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  716. remove_work_dir
  717. fi
  718. else
  719. if [ -f $TARGET ]; then
  720. touch -r $PKGMK_ROOT/$PKGMK_PKGFILE $TARGET &> /dev/null
  721. fi
  722. error "'$TARGET' derlenmesi başarısız."
  723. exit $E_BUILD
  724. fi
  725. }
  726. install_package() {
  727. local COMMAND
  728. get_package_list
  729. if [ -z $TARGETS ]; then
  730. error "kurulacak paket bulunamadı..."
  731. exit $E_INSTALL
  732. fi
  733. for TARGET in ${TARGETS[@]}; do
  734. if [ "`get_package_arch $TARGET`" = "$MIMARI" ] || [ "`get_package_arch $TARGET`" = "any" ]; then
  735. info "kuruluyor '$TARGET'."
  736. if [ "$DERLE_KUR" = "kur" ]; then
  737. COMMAND="mps -k $PAKETLEME_DIZIN/$TARGET"
  738. else
  739. COMMAND="mps -k $PAKETLEME_DIZIN/$TARGET"
  740. fi
  741. cd $PKGMK_ROOT
  742. echo "$COMMAND"
  743. $COMMAND
  744. if [ $? = 0 ]; then
  745. info " '$TARGET' basarili sekilde kuruldu."
  746. else
  747. error " '$TARGET' kurulum basarisiz."
  748. exit $E_INSTALL
  749. fi
  750. fi
  751. done
  752. }
  753. paket_kur() {
  754. local COMMAND
  755. get_package_list
  756. if [ -z $TARGETS ]; then
  757. error "kurulacak paket bulunamadı..."
  758. exit $E_INSTALL
  759. fi
  760. for TARGET in ${TARGETS[@]}; do
  761. if [ "`get_package_arch $TARGET`" = "$MIMARI" ] || [ "`get_package_arch $TARGET`" = "any" ]; then
  762. info "kuruluyor '$TARGET'."
  763. #paket_kurulum
  764. if [ "$PAKET_KURMA" = "evet" ]; then
  765. COMMAND2="echo :::::::::::::::::::::::: $PAKETLEME_DIZIN/$TARGET"
  766. fi
  767. echo "$COMMAND2"
  768. $COMMAND2
  769. cd $PKGMK_ROOT
  770. echo "$COMMAND"
  771. $COMMAND
  772. if [ $? = 0 ]; then
  773. info " '$TARGET' basarili sekilde kuruldu."
  774. else
  775. error " '$TARGET' kurulum basarisiz."
  776. exit $E_INSTALL
  777. fi
  778. fi
  779. done
  780. }
  781. recursive() {
  782. local ARGS FILE DIR
  783. [ -f $REPO_DOSYASI ] && rm -v $REPO_DOSYASI
  784. ARGS=`echo "$@" | sed -e "s/--recursive//g" -e "s/-r//g"`
  785. for FILE in `find $PKGMK_ROOT -name $PKGMK_PKGFILE | sort`; do
  786. DIR="`dirname $FILE`/"
  787. if [ -d $DIR ]; then
  788. info "Entering directory '$DIR'."
  789. (cd $DIR && $PKGMK_COMMAND $ARGS)
  790. info "Leaving directory '$DIR'."
  791. fi
  792. done
  793. }
  794. clean() {
  795. unset TARGETS
  796. get_package_list
  797. if [ ! -z $TARGETS ]; then
  798. for TARGET in ${TARGETS[@]}; do
  799. if [ -f $PAKETLEME_DIZIN/$TARGET ]; then
  800. info "Removing $TARGET"
  801. rm -f $PAKETLEME_DIZIN/$TARGET
  802. fi
  803. done
  804. else
  805. warning "$TARGETS bulunamadı"
  806. fi
  807. find $PKGMK_ROOT -name "*.md5sum" -exec rm -v {} \; 2> /dev/null
  808. find $PKGMK_ROOT -name "*.footprint" -exec rm -v {} \; 2> /dev/null
  809. unset TARGETS
  810. }
  811. update_footprint() {
  812. cd $PAKETLEME_DIZIN
  813. if [ -z $TARGETS ]; then
  814. get_package_list
  815. if [ -z $TARGETS ]; then
  816. error "Package(s) not found(s), unable to update footprint."
  817. exit $E_FOOTPRINT
  818. fi
  819. fi
  820. for TARGET in ${TARGETS[@]}; do
  821. if [ ! -f $TARGET ]; then
  822. error "Unable to update footprint. File '$TARGET' not found."
  823. exit $E_FOOTPRINT
  824. fi
  825. PKGMK_FOOTPRINT="`get_package_name $TARGET`".footprint
  826. check_file "$PKGMK_FOOTPRINT"
  827. make_footprint > $PKGMK_FOOTPRINT
  828. touch $TARGET
  829. info "Footprint updated for $TARGET"
  830. done
  831. }
  832. build_needed() {
  833. local FILE RESULT
  834. RESULT="evet"
  835. if [ -f $TARGET ]; then
  836. RESULT="yok"
  837. FILE=`get_filename $PKGMK_PKGFILE`
  838. if [ ! -e $FILE ] || [ ! $TARGET -nt $FILE ]; then
  839. RESULT="evet"
  840. break
  841. fi
  842. fi
  843. echo $RESULT
  844. }
  845. update_repo()
  846. {
  847. local FILE MD5SUM EXT
  848. cd $PKGMK_ROOT
  849. get_package_list
  850. if [ ! -z $TARGETS ]; then
  851. EXT="`get_package_extension $TARGETS`"
  852. echo -n "`get_package_builddate $TARGETS`#$EXT##$surum-#$devir" > $REPO_DOSYASI
  853. for string in desc url maint pack; do
  854. if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^$string|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
  855. echo -n "#"`cat $PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^$string|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"" \
  856. >> .PKGREPO
  857. else
  858. echo -n "#n.a" >> .PKGREPO
  859. fi
  860. done
  861. printf "\n" >> .PKGREPO
  862. for TARGET in ${TARGETS[@]}; do
  863. FILE=`basename $TARGET`
  864. MD5SUM=`md5sum $TARGET|cut -d " " -f1`
  865. echo "$MD5SUM#`get_package_name $TARGET`#`get_package_arch $TARGET|sed "s/-//"`" >> $REPO_DOSYASI
  866. done
  867. for FILE in ${isim}*
  868. do
  869. [ ! -f "$FILE" ] && break
  870. if [ "${FILE:$((${#FILE} - ${#EXT} ))}" != "$EXT" ]; then
  871. echo "`md5sum $FILE|cut -d " " -f1`#$FILE" >> $REPO_DOSYASI
  872. fi
  873. done
  874. else
  875. rm -f $REPO_DOSYASI
  876. fi
  877. echo "`md5sum $PKGMK_PKGFILE|cut -d " " -f1`#$PKGMK_PKGFILE" >> $REPO_DOSYASI
  878. }
  879. clean_repo_files()
  880. {
  881. cd $PKGMK_ROOT
  882. if [ -f $REPO_DOSYASI ]; then
  883. rm $REPO_DOSYASI
  884. info "siliniyor $REPO_DOSYASI"
  885. fi
  886. if [ -f MD5SUM ]; then
  887. rm MD5SUM
  888. info "siliniyor MD5SUM"
  889. fi
  890. }
  891. interrupted() {
  892. echo ""
  893. error "Interrupted."
  894. if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
  895. rm -rf $DERLEME_SANTIYE
  896. fi
  897. exit $E_GENERAL
  898. }
  899. print_help() {
  900. echo "usage: `basename $PKGMK_COMMAND` [options]"
  901. echo "options:"
  902. echo " -i, --install build and install packages"
  903. echo " -u, --upgrade build and install packages (as upgrade)"
  904. echo " -r, --recursive search for and build packages recursively"
  905. echo " -d, --download download missing source file(s)"
  906. echo " -cv, --show-version-only do not build, only show the version of the port and exit"
  907. echo " -do, --download-only do not build, only download missing source file(s)"
  908. echo " -eo, --extract-only do not build, only extract source file(s)"
  909. echo " -utd, --up-to-date do not build, only check if package is up to date"
  910. echo " -ur, --update-repo do not build, only update the $REPO_DOSYASI file"
  911. echo " -uf, --update-footprint update footprint using result from last build"
  912. echo " -ic, --ignore-collection build packages without update the $REPO_DOSYASI file of the collection means from the parent directory"
  913. echo " -if, --ignore-footprint build packages without checking footprint"
  914. echo " -in, --ignore-new build packages, ignore new files in a footprint missmatch"
  915. echo " -um, --update-md5sum update md5sum"
  916. echo " -im, --ignore-md5sum build packages without checking md5sum"
  917. echo " -cm, --check-md5sum do not build, only check md5sum"
  918. echo " -ns, --no-strip do not strip executable binaries or libraries"
  919. echo " -f, --force build packages even if it appears to be up to date"
  920. echo " -co, --clean-only do not build, only remove packages and downloaded files, update $REPO_DOSYASI file"
  921. echo " -kw, --keep-work keep temporary working directory"
  922. echo " -cf, --config-file <file> use alternative configuration file"
  923. echo " -v, --version print version and exit "
  924. echo " -h, --help print help and exit"
  925. }
  926. parse_options() {
  927. while [ "$1" ]; do
  928. case $1 in
  929. -i|--install)
  930. DERLE_KUR="kur" ;;
  931. -pk|--pkur)
  932. PAKET_KURMA="evet" ;;
  933. -u|--upgrade)
  934. DERLE_KUR="guncelle" ;;
  935. -r|--recursive)
  936. PKGMK_RECURSIVE="evet" ;;
  937. -d|--download)
  938. PKGMK_DOWNLOAD="evet" ;;
  939. -do|--download-only)
  940. PKGMK_DOWNLOAD="evet"
  941. PKGMK_DOWNLOAD_ONLY="evet" ;;
  942. -eo|--extract-only)
  943. PKGMK_EXTRACT_ONLY="evet" ;;
  944. -cv|--show-version-only)
  945. PKGMK_SHOW_VERSION="evet";;
  946. -utd|--up-to-date)
  947. PKGMK_UP_TO_DATE="evet" ;;
  948. -sk|--sd-kontrol)
  949. SOZDIZIM_KONTROL="evet" ;;
  950. -ur|--update-repo)
  951. PKGMK_UPDATE_REPO="evet" ;;
  952. -uf|--update-footprint)
  953. PKGMK_UPDATE_FOOTPRINT="evet" ;;
  954. -if|--ignore-footprint)
  955. DOSYAIZLEME_YOKSAY="evet" ;;
  956. -in|--ignore-new)
  957. PKGMK_IGNORE_NEW="evet" ;;
  958. -um|--update-md5sum)
  959. PKGMK_UPDATE_MD5SUM="evet" ;;
  960. -im|--ignore-md5sum)
  961. MD5SUM_YOKSAY="evet" ;;
  962. -ic|--ignore-collection)
  963. KOLEKSIYON_YOKSAY="evet" ;;
  964. -ir|--ignore-repo)
  965. REPO_YOKSAY="evet" ;;
  966. -cm|--check-md5sum)
  967. PKGMK_CHECK_MD5SUM="evet" ;;
  968. -ns|--no-strip)
  969. PKGMK_NO_STRIP="evet" ;;
  970. -f|--force)
  971. PKGMK_FORCE="evet" ;;
  972. -co|--clean-only)
  973. PKGMK_CLEAN_ONLY="evet" ;;
  974. -kw|--keep-work)
  975. PKGMK_KEEP_WORK="evet" ;;
  976. -cf|--config-file)
  977. if [ ! "$2" ]; then
  978. echo "`basename $PKGMK_COMMAND`: option $1 requires an argument"
  979. exit 1
  980. fi
  981. DERLEME_AYARDOSYASI="$2"
  982. shift ;;
  983. -v|--version)
  984. echo "`basename $PKGMK_COMMAND` $PKGMK_VERSION"
  985. exit 0 ;;
  986. -h|--help)
  987. print_help
  988. exit 0 ;;
  989. *)
  990. echo "`basename $PKGMK_COMMAND`: invalid option $1"
  991. exit 1 ;;
  992. esac
  993. shift
  994. done
  995. }
  996. main() {
  997. if [ -f /etc/noprofile ]; then
  998. source /etc/noprofile
  999. fi
  1000. parse_options "$@"
  1001. if [ "$(md5sum $DERLEME_AYARDOSYASI | cut -d' ' -f1)" = "$(md5sum $ANADERLEME_AYARDOSYASI | cut -d' ' -f1)" ];then
  1002. shift
  1003. else
  1004. echo "mpsd.conf dosyası farklı!"
  1005. while true; do
  1006. echo "mpsd.conf güncel sürümü ile değiştirilsin mi?";read -p "e veya h-> " eh
  1007. case $eh in
  1008. [Ee]* ) cp -f $ANADERLEME_AYARDOSYASI $DERLEME_AYARDOSYASI; break;;
  1009. [Hh]* ) break;;
  1010. * ) echo "e veya h";;
  1011. esac
  1012. done
  1013. fi
  1014. if [ ! -f $DERLEME_AYARDOSYASI ]; then
  1015. error " '$DERLEME_AYARDOSYASI' dosyası bulunamadı."
  1016. exit $E_GENERAL
  1017. fi
  1018. . $DERLEME_AYARDOSYASI
  1019. MIMARI=`uname -m`
  1020. DOSYAIZLEME_YOKSAY="evet"
  1021. local FILE TARGET
  1022. isim=`basename $PKGMK_ROOT`
  1023. if [ "$PKGMK_RECURSIVE" = "evet" ]; then
  1024. recursive "$@"
  1025. exit 0
  1026. fi
  1027. if [ ! -f $PKGMK_PKGFILE ]; then
  1028. error " '$PKGMK_PKGFILE' dosyası bulunamadı"
  1029. exit $E_TALIMAT
  1030. fi
  1031. . $PKGMK_PKGFILE
  1032. if [ -z $group ]; then
  1033. group="`echo $isim | cut -d "-" -f1`"
  1034. fi
  1035. if [ "$group" == "$isim" ]; then
  1036. unset group
  1037. fi
  1038. if [ -z "$surum" ]; then
  1039. if [ ! -z "$group" ];then
  1040. if [ -f ../$group/$PKGMK_PKGFILE ];then
  1041. . ../$group/$PKGMK_PKGFILE
  1042. unset run
  1043. . $PKGMK_PKGFILE
  1044. else
  1045. warning "$PKGMK_PKGFILE dosyası içinde 'surum' değişkeni ayarlı değil veya yer almıyor."
  1046. fi
  1047. else
  1048. warning "$PKGMK_PKGFILE dosyası içinde 'surum' değişkeni ayarlı değil veya yer almıyor."
  1049. fi
  1050. fi
  1051. if [ "$PKGMK_SHOW_VERSION" == "evet" ]; then
  1052. echo "$surum"
  1053. exit 0
  1054. fi
  1055. ## bu bilgiler gösterilmeyecek<
  1056. #info "DERLE_KUR: $DERLE_KUR"
  1057. #info "PAKET_KURMA: $PAKET_KURMA"
  1058. #info "DERLEME_SANTIYE: $DERLEME_SANTIYE"
  1059. #info "DERLEME_KAYNAKDIZIN: $DERLEME_KAYNAKDIZIN"
  1060. #if [ "$DERLE_KUR" = "yok" ]; then
  1061. # PKGMK_CLEAN="yok"
  1062. # warning "TEMIZLIK PAS GECILDI."
  1063. #else
  1064. # info "PKGMK_KEEP_SOURCES: $PKGMK_KEEP_SOURCES"
  1065. # info "PKGMK_CLEAN: $PKGMK_CLEAN"
  1066. #fi
  1067. #if [ "$PKGMK_CLEAN" != "yok" ]; then
  1068. # DOSYAIZLEME_YOKSAY="evet"
  1069. # MD5SUM_YOKSAY="evet"
  1070. # warning "FOOTPRINT AND MD5SUM IGNORED"
  1071. #else
  1072. # if [ "$PKGMK_UPDATE_REPO" != "evet" ]; then
  1073. # info "REPO_YOKSAY: $REPO_YOKSAY"
  1074. # else
  1075. # info "PKGMK_UPDATE_REPO: $PKGMK_UPDATE_REPO"
  1076. # fi
  1077. # info "DOSYAIZLEME_YOKSAY: $DOSYAIZLEME_YOKSAY"
  1078. # info "MD5SUM_YOKSAY: $MD5SUM_YOKSAY"
  1079. #fi
  1080. #if [ "$REPO_YOKSAY" == "evet" ]; then
  1081. # info "$REPO_DOSYASI dosyası silenecek"
  1082. #fi
  1083. #info "PKT_SIKISTIRMA: $PKT_SIKISTIRMA"
  1084. #if [ "$PKT_SIKISTIRMA" != "yok" ]; then
  1085. # info "PKT_SIKISTIRMA_MODU: $PKT_SIKISTIRMA_MODU"
  1086. #fi
  1087. ## >bu bilgiler gösterilmeyecek
  1088. info "isim: ${isim}"
  1089. if [ ! -z "$surum" ]; then
  1090. info "surum: $surum"
  1091. fi
  1092. if [ ! -z "$devir" ]; then
  1093. info "devir: $devir"
  1094. fi
  1095. if [ ! -z "$group" ]; then
  1096. info "grup: $group"
  1097. fi
  1098. PKGMK_MD5SUM="$isim.`uname -m`.md5sum"
  1099. HASH_KONTROL_DOSYA="$isim.hash"
  1100. check_directory "$DERLEME_KAYNAKDIZIN"
  1101. check_directory "$PAKETLEME_DIZIN"
  1102. check_directory "`dirname $DERLEME_SANTIYE`"
  1103. check_pkgfile
  1104. get_package_list
  1105. case $PKT_SIKISTIRMA_MODU in
  1106. lz|gz|bz2|xz)
  1107. if [ -z $TARGETS ]; then
  1108. TARGET="$PAKETLEME_DIZIN/${isim}#$surum-MIMARI.$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU"
  1109. fi;;
  1110. *)
  1111. error "Sıkıştırma modu '$PKT_SIKISTIRMA_MODU' desteklenmiyor"
  1112. exit $E_GENERAL
  1113. ;;
  1114. esac
  1115. case $PKT_SIKISTIRMA_MODU in
  1116. gz) COMPRESSION="-z" ;;
  1117. bz2) export COMPRESSION="-j" ;;
  1118. xz) export COMPRESSION="-J" ;;
  1119. esac
  1120. if [ "$PKGMK_CLEAN_ONLY" = "evet" ]; then
  1121. clean
  1122. remove_source
  1123. update_repo
  1124. exit 0
  1125. fi
  1126. if [ "$PKGMK_UPDATE_REPO" = "evet" ]; then
  1127. update_repo
  1128. exit 0
  1129. fi
  1130. if [ "$PKGMK_UPDATE_FOOTPRINT" = "evet" ]; then
  1131. update_footprint
  1132. exit 0
  1133. fi
  1134. if [ "$SOZDIZIM_KONTROL" = "evet" ]; then
  1135. info "tanım: $description"
  1136. info "url: $url"
  1137. info "paketçi: $packager"
  1138. info "tamirci: $maintainer"
  1139. exit 0
  1140. fi
  1141. if [ "$PKGMK_UPDATE_MD5SUM" = "evet" ]; then
  1142. kaynak_indir
  1143. check_file "$PKGMK_MD5SUM"
  1144. make_md5sum > $PKGMK_MD5SUM
  1145. info "Md5sum updated."
  1146. exit 0
  1147. fi
  1148. if [ "$PKGMK_DOWNLOAD_ONLY" = "evet" ]; then
  1149. kaynak_indir
  1150. exit 0
  1151. fi
  1152. if [ "$PKGMK_EXTRACT_ONLY" = "evet" ]; then
  1153. kaynak_indir
  1154. make_work_dir
  1155. info "Extracting sources of package '${isim}-$surum'."
  1156. unpack_source
  1157. exit 0
  1158. fi
  1159. if [ "$PKGMK_UP_TO_DATE" = "evet" ]; then
  1160. if [ ! -z $TARGETS ]; then
  1161. for TARGET in ${TARGETS[@]}; do
  1162. if [ "`build_needed`" = "evet" ]; then
  1163. info "Package '$TARGET' is not up to date."
  1164. else
  1165. info "Package '$TARGET' is up to date."
  1166. fi
  1167. done
  1168. else
  1169. if [ "`build_needed`" = "evet" ]; then
  1170. info "Package '$TARGET' is not up to date."
  1171. else
  1172. info "Package '$TARGET' is up to date."
  1173. fi
  1174. fi
  1175. exit 0
  1176. fi
  1177. # From here on it's need to check the base package not any group which means
  1178. if [ -z $TARGETS ]; then
  1179. TARGET=$PAKETLEME_DIZIN/${isim}#$surum-$MIMARI.$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
  1180. if [ "`build_needed`" = "yok" ] && [ "$PKGMK_FORCE" = "yok" ] && [ "$PKGMK_CHECK_MD5SUM" = "yok" ]; then
  1181. info "Package '$TARGET' is up to date."
  1182. else
  1183. kaynak_indir
  1184. derleme_yap
  1185. fi
  1186. else
  1187. FOUND=false
  1188. for TARGET in ${TARGETS[@]}; do
  1189. if [ "`build_needed`" = "yok" ] && [ "$PKGMK_FORCE" = "yok" ] && [ "$PKGMK_CHECK_MD5SUM" = "yok" ]; then
  1190. if [ "`get_package_arch $TARGET`" = "$MIMARI" ]; then
  1191. FOUND=true
  1192. fi
  1193. info "Package '$TARGET' is up to date."
  1194. else
  1195. kaynak_indir
  1196. derleme_yap
  1197. break
  1198. fi
  1199. done
  1200. fi
  1201. if [ ! -z $FOUND ] ; then
  1202. if [ $FOUND != true ]; then
  1203. kaynak_indir
  1204. PKGMK_BUILDVER="`get_package_builddate $TARGET`"
  1205. TARGET=$PAKETLEME_DIZIN/${isim}#$surum-$MIMARI.$PKT_UZANTISI
  1206. derleme_yap $TARGET
  1207. fi
  1208. fi
  1209. if [ "$DERLE_KUR" != "yok" ]; then
  1210. install_package
  1211. fi
  1212. if [ "$PKT_SIKISTIRMA" = "evet" ]; then
  1213. cd $PAKETLEME_DIZIN
  1214. get_package_list
  1215. for TARGET in ${TARGETS[@]}; do
  1216. if [ "${TARGET:$((${#TARGET} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
  1217. compress_archive $TARGET
  1218. fi
  1219. done
  1220. fi
  1221. if [ "$PKGMK_KEEP_SOURCES" != "evet" ]; then
  1222. remove_source
  1223. fi
  1224. if [ "$PKGMK_CLEAN" != "yok" ]; then
  1225. clean
  1226. unset TARGETS
  1227. if [ "$REPO_YOKSAY" == "evet" ];then
  1228. clean_repo_files
  1229. fi
  1230. fi
  1231. if [ "$REPO_YOKSAY" != "evet" ] && [ "$PKGMK_CLEAN" != "evet" ]; then
  1232. update_repo
  1233. fi
  1234. exit 0
  1235. }
  1236. trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
  1237. export LC_ALL=POSIX
  1238. DERLEME_AYARDOSYASI="/etc/mpsd.conf"
  1239. ANADERLEME_AYARDOSYASI="/sources/milis.git/ayarlar/mpsd.conf"
  1240. readonly PKGMK_VERSION="1.0"
  1241. readonly PKGMK_COMMAND="$0"
  1242. readonly PKGMK_ROOT="$PWD"
  1243. PAKETLEME_DIZIN="$PWD"
  1244. PKGMK_BUILDVER=`date +%s`
  1245. #PKGMK_BUILDVER="#"
  1246. PKT_UZANTISI="mps"
  1247. REPO_DOSYASI=".PKGREPO"
  1248. PKGMK_PKGFILE="talimat"
  1249. PKGMK_MD5SUM="$isim.`uname -m`.md5sum"
  1250. PKGMK_NOSTRIP=".nostrip"
  1251. PKGMK_KEEP_SOURCES="yok"
  1252. PKGMK_CLEAN="evet"
  1253. PAKET_KURMA="evet"
  1254. PAKET_GRUPLAR=()
  1255. PAKET_LOKAL="tr"
  1256. PKGMK_SOURCE_MIRRORS=()
  1257. DERLEME_KAYNAKDIZIN="$PWD"
  1258. DERLEME_SANTIYE="$PWD/work"
  1259. PKGMK_DOWNLOAD="yok"
  1260. DOSYAIZLEME_YOKSAY="evet"
  1261. PKGMK_IGNORE_NEW="evet"
  1262. MD5SUM_YOKSAY="evet"
  1263. HASH_KONTROL_YAP="evet"
  1264. DEVIR_YOKSAY="yok"
  1265. REPO_YOKSAY="evet"
  1266. PKGMK_NO_STRIP="yok"
  1267. PKT_SIKISTIRMA_MODU="lz"
  1268. PKT_SIKISTIRMA="yok"
  1269. DERLE_KUR="yok"
  1270. PKGMK_RECURSIVE="yok"
  1271. PKGMK_DOWNLOAD_ONLY="yok"
  1272. PKGMK_EXTRACT_ONLY="yok"
  1273. PKGMK_IGNORE_UNPACK="yok"
  1274. PKGMK_UP_TO_DATE="yok"
  1275. PKGMK_UPDATE_FOOTPRINT="yok"
  1276. PKGMK_FORCE="yok"
  1277. PKGMK_KEEP_WORK="yok"
  1278. PKGMK_UPDATE_MD5SUM="yok"
  1279. PKGMK_CHECK_MD5SUM="yok"
  1280. main "$@"
  1281. # End of file