mpsd 36 KB

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