mpsd 36 KB

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