lfs-mekanizma 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. #!/bin/bash
  2. VERSION="1.0"
  3. ANADIZIN="`pwd`"
  4. TALIMATNAMELER="talimatname"
  5. DERLEME_SIRASI="derleme.sira"
  6. PAKETCI="mpsd"
  7. TALIMATNAME=""
  8. LOG_DIZIN="log"
  9. AYARLAR="ayarlar"
  10. PAKETCI_AYAR="mpsd.conf"
  11. INSTALL_COMMAND="`basename $0`"
  12. readonly CODE_NAME="malfs"
  13. birinci_ayarlar(){
  14. root_kontrol
  15. lfs_kontrol
  16. #lfs dizinin olusturulması
  17. mkdir -p $LFS
  18. #lfs kullanici-grup silme sıfırlama
  19. userdel lfs
  20. rm -r /home/lfs
  21. groupdel lfs
  22. #lfs kullanici-grup olusturma
  23. groupadd lfs
  24. useradd -s /bin/bash -g lfs -m -k /dev/null lfs
  25. passwd lfs
  26. #lfs icin gerekli dizin ve izinlerinin olusturulması
  27. mkdir -p /home/lfs
  28. mkdir -vp $LFS/{sources,tools}
  29. ln -svf $LFS/tools /
  30. ln -svf $LFS/sources /
  31. chown -v lfs $LFS/{tools,sources}
  32. chmod -v a+wt $LFS/sources
  33. chown -v lfs $LFS
  34. cp -a $ANADIZIN/ayarlar /home/lfs/
  35. cp -a $ANADIZIN/bin /home/lfs/
  36. cp -a $ANADIZIN/talimatname /home/lfs/
  37. cp -a $ANADIZIN/lfs-mekanizma /home/lfs/
  38. chown -R lfs:lfs /home/lfs/
  39. cp ayarlar/.bashrc /home/lfs/
  40. cp ayarlar/.bash_profile /home/lfs/
  41. su - lfs
  42. }
  43. paket_kur(){
  44. $PAKETCI -d -cf $ANADIZIN/$AYARLAR/$PAKETCI_AYAR -i || exit 1
  45. for i in *mps*
  46. do
  47. echo "=======> '$i' basarili sekilde kuruldu." >> $ANADIZIN/$LOG_DIZIN/$talimat.log
  48. done
  49. }
  50. talimatname_derle(){
  51. #dongu icerisinde talimatların derlenmesi
  52. if [ "$TALIMATNAME" == "onsistem" ]; then
  53. PAKETCI_AYAR="onmpsd.conf"
  54. fi
  55. if [ ! -d $ANADIZIN/$LOG_DIZIN ]; then
  56. mkdir -p $ANADIZIN/$LOG_DIZIN
  57. fi
  58. for dizin in `cat $ANADIZIN/$TALIMATNAMELER/$TALIMATNAME/$DERLEME_SIRASI`
  59. do
  60. talimat=`basename $dizin`
  61. derleme="evet"
  62. if [ -f $ANADIZIN/$LOG_DIZIN/$talimat.log ]; then
  63. derleme=`grep -q "basarili" $ANADIZIN/$LOG_DIZIN/$talimat.log; [ $? -eq 0 ] && echo "hayir" || echo "evet"`
  64. fi
  65. if [ "$derleme" == "evet" ]; then
  66. cd $ANADIZIN/$TALIMATNAMELER/$TALIMATNAME/$dizin
  67. touch $ANADIZIN/$LOG_DIZIN/$talimat.log
  68. $PAKETCI -d -cf $ANADIZIN/$AYARLAR/$PAKETCI_AYAR -kw 2>&1|tee $ANADIZIN/$LOG_DIZIN/$talimat.log || exit 1
  69. case $talimat in
  70. gcc)
  71. rm -fv /usr/lib{,64}/libgcc_s.so{,.1}
  72. rm -fv /usr/lib{,64}/libstdc++.so{,.6}
  73. rm -fv /usr/lib{,64}/libstdc++.la
  74. ;;
  75. bash)
  76. rm /bin/bash
  77. rm /bin/sh
  78. echo "bash chroot dısına cıkılıp elle kurulmalıdır."
  79. echo "=======> '$i' basarili sekilde kuruldu." >> $ANADIZIN/$LOG_DIZIN/$talimat.log
  80. exit 1
  81. ;;
  82. coreutils)
  83. rm -f /usr/bin/env
  84. for i in cat echo pwd stty
  85. do
  86. rm -f /bin/$i
  87. done
  88. ;;
  89. perl)
  90. rm -f /usr/bin/perl
  91. ;;
  92. esac
  93. if [ "$TALIMATNAME" != "onsistem" ] && [ "$talimat" != "bash" ]; then
  94. paket_kur
  95. fi
  96. fi
  97. if ( grep "^=======>" $ANADIZIN/$LOG_DIZIN/$talimat.log| tail -1 |grep "ERROR" > /dev/null);then
  98. exit 1
  99. fi
  100. cd -
  101. done
  102. }
  103. ikinci_ayarlar(){
  104. root_kontrol
  105. lfs_kontrol
  106. unmount_islemi
  107. mv /mnt/sources_depo $LFS/sources
  108. chown -R root:root $LFS
  109. install -dv -m0750 $LFS/root
  110. rm -r $LFS/root/bin
  111. rm -r $LFS/root/$TALIMATNAMELER
  112. rm -r $LFS/root/$LOG_DIZIN
  113. cp -a $ANADIZIN/bin $LFS/root/
  114. cp -a $TALIMATNAMELER $LFS/root/
  115. cp -a $AYARLAR $LFS/root/
  116. cp -a $ANADIZIN/lfs-mekanizma $LFS/root/
  117. cp -a $ANADIZIN/rootfs/* $LFS/
  118. cp /etc/resolv.conf $LFS/etc/
  119. gerekli_dizinler
  120. lokalizasyon
  121. fstab_olustur
  122. passwd_olustur
  123. grup_olustur
  124. bash_profil_olustur
  125. bashrc_olustur
  126. dmrc_olustur
  127. generate_hosts
  128. generate_inputrc
  129. generate_shells
  130. generate_dircolors_sh
  131. generate_extrapaths_sh
  132. generate_readline_sh
  133. generate_umask_sh
  134. generate_profile
  135. generate_hosts
  136. generate_inputrc
  137. generate_modules
  138. generate_createfiles
  139. generate_mouse
  140. generate_udev_retry
  141. generate_rc_site
  142. generate_etc_bashrc
  143. generate_blfs_bootscripts
  144. generate_milis_version
  145. cp $ANADIZIN/ayarlar/mpsd.conf $LFS/etc/
  146. cp $ANADIZIN/ayarlar/onmpsd.conf $LFS/etc/
  147. mkdir -p $LFS/var/lib/pkg/DB
  148. }
  149. generate_milis_version() {
  150. local FILE
  151. FILE="milis-version"
  152. [ -f ${LFS}/var/lib/pkg/$FILE ] && return
  153. [ ! -d ${LFS}/var/lib/pkg ] && mkdir -pv ${LFS}/var/lib/pkg
  154. echo "name ${CODE_NAME}
  155. version $VERSION" > ${LFS}/var/lib/pkg/$FILE
  156. }
  157. generate_blfs_bootscripts() {
  158. [ -f ${LFS}/etc/${LFS}/etc/blfs-bootscripts ] && return
  159. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  160. echo "scripts=blfs-bootscripts
  161. scriptsversion=20150924" > ${LFS}/etc/blfs-bootscripts
  162. }
  163. generate_etc_bashrc() {
  164. local FILE
  165. FILE="bashrc"
  166. [ -f ${LFS}/etc/$FILE ] && return
  167. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  168. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  169. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  170. ${LFS}/etc/$FILE
  171. return
  172. fi
  173. cat > ${LFS}/etc/$FILE << "EOF"
  174. # Begin /etc/bashrc
  175. # Written for Beyond Linux From Scratch
  176. # by James Robertson <jameswrobertson@earthlink.net>
  177. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  178. # System wide aliases and functions.
  179. # System wide environment variables and startup programs should go into
  180. # /etc/profile. Personal environment variables and startup programs
  181. # should go into ~/.bash_profile. Personal aliases and functions should
  182. # go into ~/.bashrc
  183. # Provides a colored /bin/ls command. Used in conjunction with code in
  184. # /etc/profile.
  185. alias ls='ls --color=auto'
  186. # Provides prompt for non-login shells, specifically shells started
  187. # in the X environment. [Review the LFS archive thread titled
  188. # PS1 Environment Variable for a great case study behind this script
  189. # addendum.]
  190. #export LC_ALL="tr_TR.UTF-8"
  191. NORMAL="\[\e[0m\]"
  192. RED="\[\e[1;31m\]"
  193. GREEN="\[\e[1;32m\]"
  194. WHITE="\[\e[1;37m\]"
  195. case $TERM in
  196. xterm|rxvt*)
  197. TITLEBAR='\[\033]0;\u@\h \007\]'
  198. ;;
  199. *)
  200. TITLEBAR=''
  201. ;;
  202. esac
  203. if [[ $EUID == 0 ]] ; then
  204. PS1="$TITLEBAR$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  205. else
  206. PS1="$TITLEBAR$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  207. fi
  208. # End /etc/bashrc
  209. EOF
  210. }
  211. generate_rc_site() {
  212. local FILE
  213. FILE="rc.site"
  214. [ -f ${LFS}/etc/sysconfig/$FILE ] && return
  215. [ ! -d ${LFS}/etc/sysconfig ] && mkdir -pv ${LFS}/etc/sysconfig
  216. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  217. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  218. ${LFS}/etc/sysconfig/$FILE
  219. return
  220. fi
  221. cat > ${LFS}/etc/sysconfig/$FILE << "EOF"
  222. # rc.site
  223. # Optional parameters for boot scripts.
  224. # Distro Information
  225. # These values, if specified here, override the defaults
  226. #DISTRO="Linux From Scratch" # The distro name
  227. #DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
  228. #DISTRO_MINI="LFS" # Short name used in filenames for distro config
  229. # Define custom colors used in messages printed to the screen
  230. # Please consult `man console_codes` for more information
  231. # under the "ECMA-48 Set Graphics Rendition" section
  232. #
  233. # Warning: when switching from a 8bit to a 9bit font,
  234. # the linux console will reinterpret the bold (1;) to
  235. # the top 256 glyphs of the 9bit font. This does
  236. # not affect framebuffer consoles
  237. # These values, if specified here, override the defaults
  238. #BRACKET="\\033[1;34m" # Blue
  239. #FAILURE="\\033[1;31m" # Red
  240. #INFO="\\033[1;36m" # Cyan
  241. #NORMAL="\\033[0;39m" # Grey
  242. #SUCCESS="\\033[1;32m" # Green
  243. #WARNING="\\033[1;33m" # Yellow
  244. # Use a colored prefix
  245. # These values, if specified here, override the defaults
  246. #BMPREFIX=" "
  247. #SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
  248. #FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
  249. #WARNING_PREFIX="${WARNING} *** ${NORMAL}"
  250. # Interactive startup
  251. #IPROMPT="yes" # Whether to display the interactive boot prompt
  252. #itime="3" # The amount of time (in seconds) to display the prompt
  253. # The total length of the distro welcome string, without escape codes
  254. #wlen=$(echo "Welcome to ${DISTRO}" | wc -c )
  255. #welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}"
  256. # The total length of the interactive string, without escape codes
  257. #ilen=$(echo "Press 'I' to enter interactive startup" | wc -c )
  258. #i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup"
  259. # Set scripts to skip the file system check on reboot
  260. #FASTBOOT=yes
  261. # Skip reading from the console
  262. #HEADLESS=yes
  263. # Write out fsck progress if yes
  264. #VERBOSE_FSCK=no
  265. # Speed up boot without waiting for settle in udev
  266. #OMIT_UDEV_SETTLE=y
  267. # Speed up boot without waiting for settle in udev_retry
  268. #OMIT_UDEV_RETRY_SETTLE=yes
  269. # Skip cleaning /tmp if yes
  270. #SKIPTMPCLEAN=no
  271. # For setclock
  272. #UTC=1
  273. #CLOCKPARAMS=
  274. # For consolelog
  275. #LOGLEVEL=5
  276. # For network
  277. #HOSTNAME=milis
  278. # Delay between TERM and KILL signals at shutdown
  279. #KILLDELAY=3
  280. # Optional sysklogd parameters
  281. #SYSKLOGD_PARMS="-m 0"
  282. # Console parameters
  283. #UNICODE=1
  284. KEYMAP="trq"
  285. #KEYMAP_CORRECTIONS="euro2"
  286. #FONT="lat0-16 -m 8859-9"
  287. #LEGACY_CHARSET=
  288. EOF
  289. }
  290. generate_udev_retry() {
  291. local FILE
  292. FILE="udev_retry"
  293. [ -f ${LFS}/etc/sysconfig/$FILE ] && return
  294. [ ! -d ${LFS}/etc/sysconfig ] && mkdir -pv ${LFS}/etc/sysconfig
  295. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  296. cp /etc/sysconfig/$FILE \
  297. ${LFS}/etc/sysconfig/$FILE
  298. return
  299. fi
  300. cat > ${LFS}/etc/sysconfig/$FILE << "EOF"
  301. ########################################################################
  302. # Begin /etc/sysconfig/udev_retry
  303. #
  304. # Description : udev_retry script configuration
  305. #
  306. # Authors :
  307. #
  308. # Version : 00.00
  309. #
  310. # Notes : Each subsystem that may need to be re-triggered after mountfs
  311. # runs should be listed in this file. Probable subsystems to be
  312. # listed here are rtc (due to /var/lib/hwclock/adjtime) and sound
  313. # (due to both /var/lib/alsa/asound.state and /usr/sbin/alsactl).
  314. # Entries are whitespace-separated.
  315. ########################################################################
  316. rtc
  317. # End /etc/sysconfig/udev_retry
  318. EOF
  319. }
  320. generate_createfiles() {
  321. local FILE
  322. FILE="createfiles"
  323. [ -f ${LFS}/etc/sysconfig/$FILE ] && return
  324. [ ! -d ${LFS}/etc/sysconfig ] && mkdir -pv ${LFS}/etc/sysconfig
  325. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  326. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  327. ${LFS}/etc/sysconfig/$FILE
  328. return
  329. fi
  330. cat > ${LFS}/etc/sysconfig/$FILE << "EOF"
  331. ########################################################################
  332. # Begin /etc/sysconfig/createfiles
  333. #
  334. # Description : Createfiles script config file
  335. #
  336. # Authors :
  337. #
  338. # Version : 00.00
  339. #
  340. # Notes : The syntax of this file is as follows:
  341. # if type is equal to "file" or "dir"
  342. # <filename> <type> <permissions> <user> <group>
  343. # if type is equal to "dev"
  344. # <filename> <type> <permissions> <user> <group> <devtype>
  345. # <major> <minor>
  346. #
  347. # <filename> is the name of the file which is to be created
  348. # <type> is either file, dir, or dev.
  349. # file creates a new file
  350. # dir creates a new directory
  351. # dev creates a new device
  352. # <devtype> is either block, char or pipe
  353. # block creates a block device
  354. # char creates a character deivce
  355. # pipe creates a pipe, this will ignore the <major> and
  356. # <minor> fields
  357. # <major> and <minor> are the major and minor numbers used for
  358. # the device.
  359. ########################################################################
  360. # End /etc/sysconfig/createfiles
  361. EOF
  362. }
  363. generate_modules() {
  364. local FILE
  365. FILE="modules"
  366. [ -f ${LFS}/etc/sysconfig/$FILE ] && return
  367. [ ! -d ${LFS}/etc/sysconfig ] && mkdir -pv ${LFS}/etc/sysconfig
  368. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  369. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  370. ${LFS}/etc/sysconfig/$FILE
  371. return
  372. fi
  373. cat > ${LFS}/etc/sysconfig/$FILE << "EOF"
  374. ########################################################################
  375. # Begin /etc/sysconfig/modules
  376. #
  377. # Description : Module auto-loading configuration
  378. #
  379. # Authors :
  380. #
  381. # Version : 00.00
  382. #
  383. # Notes : The syntax of this file is as follows:
  384. # <module> [<arg1> <arg2> ...]
  385. #
  386. # Each module should be on its own line, and any options that you want
  387. # passed to the module should follow it. The line deliminator is either
  388. # a space or a tab.
  389. ########################################################################
  390. # End /etc/sysconfig/modules
  391. EOF
  392. }
  393. generate_mouse() {
  394. local FILE
  395. FILE="mouse"
  396. [ -f ${LFS}/etc/$FILE ] && return
  397. [ ! -d ${LFS}/etc/sysconfig ] && mkdir -pv ${LFS}/etc/sysconfig
  398. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  399. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  400. ${LFS}/etc/sysconfig/$FILE
  401. return
  402. fi
  403. cat > ${LFS}/etc/sysconfig/$FILE << "EOF"
  404. MDEVICE="/dev/input/mice"
  405. PROTOCOL="imps2"
  406. EOF
  407. }
  408. generate_inputrc() {
  409. local FILE
  410. FILE="inputrc"
  411. [ -f ${LFS}/etc/$FILE ] && return
  412. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  413. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  414. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  415. ${LFS}/etc/$FILE
  416. return
  417. fi
  418. cat > ${LFS}/etc/$FILE << "EOF"
  419. # Begin /etc/inputrc
  420. # Modified by Chris Lynn <roryo@roryo.dynup.net>
  421. # Allow the command prompt to wrap to the next line
  422. set horizontal-scroll-mode Off
  423. # Enable 8bit input
  424. set meta-flag On
  425. set input-meta On
  426. # Turns off 8th bit stripping
  427. set convert-meta Off
  428. # Keep the 8th bit for display
  429. set output-meta On
  430. # none, visible or audible
  431. set bell-style none
  432. # All of the following map the escape sequence of the value
  433. # contained in the 1st argument to the readline specific functions
  434. "\eOd": backward-word
  435. "\eOc": forward-word
  436. # for linux console
  437. "\e[1~": beginning-of-line
  438. "\e[4~": end-of-line
  439. "\e[5~": beginning-of-history
  440. "\e[6~": end-of-history
  441. "\e[3~": delete-char
  442. "\e[2~": quoted-insert
  443. # for xorg-term
  444. "\eOH": beginning-of-line
  445. "\eOF": end-of-line
  446. # for Konsole
  447. "\e[H": beginning-of-line
  448. "\e[F": end-of-line
  449. # End /etc/inputrc
  450. EOF
  451. }
  452. generate_hosts() {
  453. local FILE
  454. FILE="hosts"
  455. [ -f ${LFS}/etc/$FILE ] && return
  456. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  457. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  458. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  459. ${LFS}/etc/$FILE
  460. return
  461. fi
  462. cat > ${LFS}/etc/$FILE << "EOF"
  463. # Begin /etc/hosts
  464. 127.0.0.1 localhost.localdomain localhost
  465. 127.0.0.1 milis
  466. # End /etc/hosts
  467. EOF
  468. }
  469. generate_shells() {
  470. local FILE
  471. FILE="shells"
  472. [ -f ${LFS}/etc/$FILE ] && return
  473. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  474. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  475. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  476. ${LFS}/etc/$FILE
  477. return
  478. fi
  479. cat > ${LFS}/etc/$FILE << "EOF"
  480. # Begin /etc/shells
  481. /bin/sh
  482. /bin/bash
  483. # End /etc/shells
  484. EOF
  485. }
  486. generate_umask_sh() {
  487. local FILE
  488. FILE="umask.sh"
  489. [ -f ${LFS}/etc/profile.d/$FILE ] && return
  490. [ ! -d ${LFS}/etc/profile.d ] && mkdir -pv ${LFS}/etc/profile.d
  491. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  492. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  493. ${LFS}/etc/profile.d/$FILE
  494. return
  495. fi
  496. cat > ${LFS}/etc/profile.d/$FILE << "EOF"
  497. # By default we want the umask to get set.
  498. if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
  499. umask 002
  500. else
  501. umask 022
  502. fi
  503. EOF
  504. }
  505. generate_readline_sh() {
  506. local FILE
  507. FILE="readline.sh"
  508. [ -f ${LFS}/etc/profile.d/$FILE ] && return
  509. [ ! -d ${LFS}/etc/profile.d ] && mkdir -pv ${LFS}/etc/profile.d
  510. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  511. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  512. ${LFS}/etc/profile.d/$FILE
  513. return
  514. fi
  515. cat > ${LFS}/etc/profile.d/$FILE << "EOF"
  516. # Setup the INPUTRC environment variable.
  517. if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
  518. INPUTRC=/etc/inputrc
  519. fi
  520. export INPUTRC
  521. EOF
  522. }
  523. generate_extrapaths_sh() {
  524. local FILE
  525. FILE="extrapaths.sh"
  526. [ -f ${LFS}/etc/profile.d/$FILE ] && return
  527. [ ! -d ${LFS}/etc/profile.d ] && mkdir -pv ${LFS}/etc/profile.d
  528. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  529. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  530. ${LFS}/etc/profile.d/$FILE
  531. return
  532. fi
  533. cat > ${LFS}/etc/profile.d/$FILE << "EOF"
  534. if [ -d /usr/local/lib/pkgconfig ] ; then
  535. pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
  536. fi
  537. if [ -d /usr/local/bin ]; then
  538. pathprepend /usr/local/bin
  539. fi
  540. if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
  541. pathprepend /usr/local/sbin
  542. fi
  543. if [ -d ~/bin ]; then
  544. pathprepend ~/bin
  545. fi
  546. #if [ $EUID -gt 99 ]; then
  547. # pathappend .
  548. #fi
  549. EOF
  550. }
  551. generate_dircolors_sh() {
  552. local FILE
  553. FILE="dircolors.sh"
  554. [ -f ${LFS}/etc/profile.d/$FILE ] && return
  555. [ ! -d ${LFS}/etc/profile.d ] && mkdir -pv ${LFS}/etc/profile.d
  556. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  557. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  558. ${LFS}/etc/profile.d/$FILE
  559. return
  560. fi
  561. cat > ${LFS}/etc/profile.d/$FILE << "EOF"
  562. # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
  563. if [ -f "/etc/dircolors" ] ; then
  564. eval $(dircolors -b /etc/dircolors)
  565. if [ -f "$HOME/.dircolors" ] ; then
  566. eval $(dircolors -b $HOME/.dircolors)
  567. fi
  568. fi
  569. alias ls='ls --color=auto'
  570. EOF
  571. }
  572. generate_profile() {
  573. local FILE
  574. FILE="profile"
  575. [ -f ${LFS}/etc/$FILE ] && return
  576. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  577. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  578. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  579. ${LFS}/etc/$FILE
  580. return
  581. fi
  582. cat > ${LFS}/etc/$FILE << "EOF"
  583. # Begin /etc/profile
  584. # Written for Beyond Linux From Scratch
  585. # by James Robertson <jameswrobertson@earthlink.net>
  586. # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
  587. # System wide environment variables and startup programs.
  588. # System wide aliases and functions should go in /etc/bashrc. Personal
  589. # environment variables and startup programs should go into
  590. # ~/.bash_profile. Personal aliases and functions should go into
  591. # ~/.bashrc.
  592. # Functions to help us manage paths. Second argument is the name of the
  593. # path variable to be modified (default: PATH)
  594. pathremove () {
  595. local IFS=':'
  596. local NEWPATH
  597. local DIR
  598. local PATHVARIABLE=${2:-PATH}
  599. for DIR in ${!PATHVARIABLE} ; do
  600. if [ "$DIR" != "$1" ] ; then
  601. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  602. fi
  603. done
  604. export $PATHVARIABLE="$NEWPATH"
  605. }
  606. pathprepend () {
  607. pathremove $1 $2
  608. local PATHVARIABLE=${2:-PATH}
  609. export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
  610. }
  611. pathappend () {
  612. pathremove $1 $2
  613. local PATHVARIABLE=${2:-PATH}
  614. export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
  615. }
  616. export -f pathremove pathprepend pathappend
  617. export LC_ALL="tr_TR.UTF-8"
  618. # Set the initial path
  619. export PATH=/usr/bin:/bin:/usr/sbin:/sbin
  620. if [ $EUID -eq 0 ] ; then
  621. unset HISTFILE
  622. fi
  623. # Setup some environment variables.
  624. export HISTSIZE=1000
  625. export HISTIGNORE="&:[bf]g:exit"
  626. # Set some defaults for graphical systems
  627. export XDG_DATA_DIRS=/usr/share/
  628. export XDG_CONFIG_DIRS=/etc/xdg/
  629. # Setup a red prompt for root and a green one for users.
  630. NORMAL="\[\e[0m\]"
  631. RED="\[\e[1;31m\]"
  632. GREEN="\[\e[1;32m\]"
  633. if [[ $EUID == 0 ]] ; then
  634. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  635. else
  636. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  637. fi
  638. for script in /etc/profile.d/*.sh ; do
  639. if [ -r $script ] ; then
  640. . $script
  641. fi
  642. done
  643. unset script RED GREEN NORMAL
  644. # End /etc/profile
  645. EOF
  646. }
  647. dmrc_olustur() {
  648. local FILE
  649. FILE=".dmrc"
  650. [ -f ${LFS}/etc/skel/$FILE ] && return
  651. [ ! -d ${LFS}/etc/skel ] && mkdir -pv ${LFS}/etc/skel
  652. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  653. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  654. ${LFS}/etc/skel/$FILE
  655. return
  656. fi
  657. cat > ${LFS}/etc/skel/$FILE << "EOF"
  658. [Desktop]
  659. Session=default
  660. EOF
  661. }
  662. bashrc_olustur() {
  663. local FILE
  664. FILE=".bashrc"
  665. [ -f ${LFS}/etc/skel/$FILE ] && return
  666. [ ! -d ${LFS}/etc/skel ] && mkdir -pv ${LFS}/etc/skel
  667. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  668. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  669. ${LFS}/etc/skel/$FILE
  670. return
  671. fi
  672. cat > ${LFS}/etc/skel/$FILE << "EOF"
  673. # Personal aliases and functions.
  674. # Personal environment variables and startup programs should go in
  675. # ~/.bash_profile. System wide environment variables and startup
  676. # programs are in /etc/profile. System wide aliases and functions are
  677. # in /etc/bashrc.
  678. if [ -f "/etc/bashrc" ] ; then
  679. source /etc/bashrc
  680. fi
  681. alias ll='ls -l'
  682. alias l='ls -alh'
  683. alias duh='du -h --max-depth=1'
  684. alias dfh='df -h'
  685. # End ~/.bashrc
  686. EOF
  687. [ -f ${LFS}/root/$FILE ] && return
  688. [ ! -d ${LFS}/root ] && install -dv -m0750 ${LFS}/root
  689. cp -v ${LFS}/etc/skel/$FILE \
  690. ${LFS}/root
  691. }
  692. bash_profil_olustur() {
  693. local FILE
  694. FILE=".bash_profile"
  695. [ -f ${LFS}/etc/skel/$FILE ] && return
  696. [ ! -d ${LFS}/etc/skel ] && mkdir -pv ${LFS}/etc/skel
  697. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  698. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  699. ${LFS}/etc/skel/$FILE
  700. return
  701. fi
  702. cat > ${LFS}/etc/skel/$FILE << "EOF"
  703. # Personal environment variables and startup programs.
  704. # Personal aliases and functions should go in ~/.bashrc. System wide
  705. # environment variables and startup programs are in /etc/profile.
  706. # System wide aliases and functions are in /etc/bashrc.
  707. append () {
  708. # First remove the directory
  709. local IFS=':'
  710. local NEWPATH
  711. for DIR in $PATH; do
  712. if [ "$DIR" != "$1" ]; then
  713. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  714. fi
  715. done
  716. # Then append the directory
  717. export PATH=$NEWPATH:$1
  718. }
  719. if [ -f "$HOME/.bashrc" ] ; then
  720. source $HOME/.bashrc
  721. fi
  722. # unset append
  723. # End ~/.bash_profile
  724. EOF
  725. [ ! -d ${LFS}/root ] && install -dv -m0750 ${LFS}/root
  726. [ -f ${LFS}/root/$FILE ] && return
  727. cp -v ${LFS}/etc/skel/$FILE \
  728. ${LFS}/root
  729. }
  730. gerekli_dizinler() {
  731. mkdir ${LFS}/{dev,sys,proc,run,tmp,home,srv,mnt}
  732. mkdir -p ${LFS}/var/tmp
  733. mkdir -p ${LFS}/usr/{,local/}lib
  734. chmod 1777 ${LFS}/{,var/}tmp
  735. mkdir -v ${LFS}/var/{mail,spool}
  736. mkdir -pv ${LFS}/var/run/lock
  737. mknod -m 600 ${LFS}/dev/console c 5 1
  738. mknod -m 666 ${LFS}/dev/null c 1 3
  739. }
  740. lokalizasyon() {
  741. [ ! -d ${LFS}/etc/locale ] && mkdir -p ${LFS}/etc/locale
  742. if [ -d ${LFS}/usr/lib/locale ]; then
  743. rm -r ${LFS}/usr/lib/locale
  744. ln -sv /etc/locale/ ${LFS}/usr/lib/locale
  745. fi
  746. }
  747. fstab_olustur() {
  748. local FILE
  749. FILE="fstab"
  750. [ -f ${LFS}/etc/$FILE ] && return
  751. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  752. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  753. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  754. ${LFS}/etc/$FILE
  755. return
  756. fi
  757. cat > ${LFS}/etc/$FILE << "EOF"
  758. # Begin /etc/fstab
  759. # file system mount-point type options dump fsck
  760. # order
  761. proc /proc proc nosuid,noexec,nodev 0 0
  762. sysfs /sys sysfs nosuid,noexec,nodev 0 0
  763. devpts /dev/pts devpts gid=5,mode=620 0 0
  764. tmpfs /run tmpfs defaults 0 0
  765. devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
  766. EOF
  767. }
  768. grup_olustur() {
  769. [ -f ${LFS}/etc/group ] && return
  770. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  771. cat > ${LFS}/etc/group << "EOF"
  772. root:x:0:
  773. bin:x:1:
  774. sys:x:2:
  775. kmem:x:3:
  776. tape:x:4:
  777. tty:x:5:
  778. daemon:x:6:
  779. floppy:x:7:
  780. disk:x:8:
  781. lp:x:9:
  782. dialout:x:10:
  783. audio:x:11:gdm
  784. video:x:12:gdm
  785. utmp:x:13:
  786. usb:x:14:
  787. cdrom:x:15:
  788. adm:x:16:
  789. atd:x:17:
  790. messagebus:x:18:
  791. lpadmin:x:19:
  792. named:x:20:
  793. gdm:x:21:
  794. fcron:x:22:
  795. www:x:24:
  796. apache:x:25:
  797. smmsp:x:26:
  798. polkitd:x:27:
  799. wheel:x:30:root
  800. exim:x:31:
  801. postfix:x:32:
  802. postdrop:x:33:
  803. mail:x:34:
  804. vmailman:x:35:
  805. news:x:36:
  806. kdm:x:37:
  807. mysql:x:40:
  808. postgres:x:41:
  809. dovecot:x:42:
  810. dovenull:x:43:
  811. ftp:x:45:
  812. proftpd:x:46:
  813. vsftpd:x:47:
  814. rsyncd:x:48:
  815. sshd:x:50:
  816. stunnel:x:51:
  817. svn:x:56:
  818. svntest:x:57:
  819. pulse:x:58:
  820. pulse-access:x:59:
  821. games:x:60:
  822. kvm:x:61:
  823. wireshark:x:62:
  824. lightdm:x:63:
  825. sddm:x:64:
  826. scanner:x:70:
  827. colord:x:71:
  828. vboxusers:x:80:
  829. ldap:x:83:
  830. avahi:x:84:
  831. avahi-autoipd:x:85:
  832. netdev:x:86:
  833. ntp:x:87:
  834. unbound:x:88:
  835. nogroup:x:99:
  836. users:x:999:
  837. EOF
  838. }
  839. passwd_olustur() {
  840. [ -f ${LFS}/etc/passwd ] && return
  841. [ ! -d ${LFS}/etc ] && mkdir -pv ${LFS}/etc
  842. cat > ${LFS}/etc/passwd << "EOF"
  843. root::0:0:root:/root:/bin/bash
  844. bin:x:1:1:bin:/dev/null:/bin/false
  845. lp:x:9:9:Print Service User:/dev/null:/bin/false
  846. atd:x:17:17:add daemon:/dev/null:/bin/false
  847. messagebus:x:18:18:D-Bus Message Daemon User:/dev/null:/bin/false
  848. named:x:20:20:BIND Owner:/home/named:/bin/false
  849. gdm:x:21:21:GDM Daemon User:/var/lib/gdm:/bin/false
  850. fcron:x:22:22:Fcron User:/dev/null:/bin/false
  851. www:x:24:24:Nginx Server:/dev/null:bin/false
  852. apache:x:25:25:Apache Server:/dev/null:/bin/false
  853. smmsp:x:26:26:Sendmail Daemon:/dev/null:/bin/false
  854. polkitd:x:27:27:Policy Kit Daemon User:/etc/polkit-1:/bin/false
  855. exim:x:31:31:Exim Daemon:/dev/null:/bin/false
  856. postfix:x:32:32:Postfix Daemon User:/var/spool/postfix:/bin/false
  857. sendmail:x:34:34:Sendmail Daemon:/dev/null:/bin/false
  858. vmailman:x:35:35:Vmail Daemon:/dev/null:/bin/false
  859. news:x:36:36:News Daemon:/dev/null:/bin/false
  860. kdm:x:37:37:KDM Daemon Owner:/var/lib/kdm:/bin/false
  861. mysql:x:40:40:MySQL Server:/dev/null:/bin/false
  862. postgres:x:41:41:PostgreSQL Server:/srv/pgsql/data:/bin/bash
  863. dovecot:x:42:42:Dovecot unprivileged user:/dev/null:/bin/false
  864. dovenull:x:43:43:Dovecot login user:/dev/null:/bin/false
  865. ftp:x:45:45:anonymous_user:/home/ftp:/bin/false
  866. proftpd:x:46:46:proftpd:/srv/ftp:/usr/bin/proftpdshell
  867. vsftpd:x:47:47:vsftpd User:/dev/null:/bin/false
  868. rsyncd:x:48:48:rsyncd Daemon:/home/rsync:/bin/false
  869. sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
  870. stunnel:x:51:51:stunnel Daemon:/var/lib/stunnel:/bin/false
  871. svn:x:56:56:SVN Owner:/home/svn:/bin/false
  872. games:x:60:60:Games High Score Owner:/var/games:/bin/false
  873. lightdm:x:63:63:Light Display Manager:/var/lib/lightdm:/sbin/nologin
  874. sddm:x:64:64:Simple Desktop Display Manager:/var/lib/sddm:/bin/false
  875. colord:x:71:71:Color Daemon Owner:/var/lib/colord:/bin/false
  876. ldap:x:83:83:OpenLDAP Daemon Owner:/var/lib/openldap:/bin/false
  877. avahi:x:84:84:Avahi Daemon Owner:/var/run/avahi-daemon:/bin/false
  878. avahi-autoipd:x:85:85:Avahi autoip Daemon:/:/var/run/avahi-autoipd:/bin/false
  879. ntp:x:87:87:Network Time Protocol:/var/lib/ntp:/bin/false
  880. unbound:x:88:88:Unbound DNS resolver:/var/lib/unbound:/bin/false
  881. anonymous:x:98:99:Unprivileged User:/dev/null:/bin/false
  882. nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
  883. EOF
  884. }
  885. mount_islemi(){
  886. cp -v /etc/resolv.conf $LFS/etc
  887. mount -v -B /dev $LFS/dev
  888. #mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
  889. #mount -vt devpts devpts $LFS/dev/pts
  890. # make hatası düzeliyor-segm fault
  891. mount --bind /dev/pts $LFS/dev/pts
  892. mount -vt proc proc $LFS/proc
  893. #bazı durumlarda bu kullanılacak tty değilde pty i kullanan derlemelerde
  894. #mount --bind /dev/pts $LFS/dev/pts
  895. mount -vt sysfs sysfs $LFS/sys
  896. #if [ -h /dev/shm ]; then rm -f $LFS/dev/shm;mkdir $LFS/dev/shm;fi
  897. #mount -vt tmpfs shm $LFS/dev/shm
  898. #chmod 1777 /dev/shm
  899. }
  900. chroot_gir(){
  901. root_kontrol
  902. lfs_kontrol
  903. unmount_islemi
  904. mount_islemi
  905. cp ayarlar/bashrc_chroot "$LFS"/etc/bashrc
  906. chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' /bin/bash --login
  907. #chroot "$LFS" /usr/bin/env -i HOME=/root PS1='\u:\w\$ ' /bin/bash --login +h
  908. }
  909. unmount_islemi() {
  910. lfs_kontrol
  911. if [ "$LFS" != "" ];then
  912. umount -lf $LFS/dev/shm
  913. umount -lf $LFS/dev/pts
  914. umount -lf $LFS/dev
  915. umount -lf $LFS/run
  916. umount -lf $LFS/proc
  917. umount -lf $LFS/sys
  918. else
  919. echo "LFS boş tanımlı"
  920. fi
  921. }
  922. bash_kur(){
  923. cd $LFS/root/talimatname/temel/bash
  924. for PACK in *.lz; do tar xf $PACK -C $LFS;done
  925. }
  926. onsistem_sfs(){
  927. tarih=`date +%Y-%m-%d`
  928. mv $LFS/sources /mnt/sources_depo
  929. mksquashfs $LFS malfs-asama1-onsistem_$tarih.sfs -comp xz
  930. }
  931. temel_sfs(){
  932. unmount_islemi
  933. tarih=`date +%Y-%m-%d`
  934. mv $LFS/sources /mnt/sources_depo
  935. mv $LFS/tools /mnt/tools_ydk
  936. mv $LFS/paket_depo /mnt/base_paket_depo
  937. mksquashfs $LFS malfs-asama2-temel_$tarih.sfs -comp xz
  938. mv /mnt/sources_depo $LFS/sources
  939. }
  940. son_sfs(){
  941. unmount_islemi
  942. tarih=`date +%Y-%m-%d`
  943. mv $LFS/sources /mnt/sources_depo
  944. mv $LFS/paket_depo /mnt/paket_depo
  945. rm -r -f $LFS/usr/src
  946. mksquashfs $LFS malfs-asama3-sonsistem_$tarih.sfs -comp xz
  947. }
  948. baslatici_olustur(){
  949. rm /boot/initramfs
  950. #kernelv=`ls /boot/kernel-* | cut -d'-' -f2`
  951. kernelv=`ls /lib/modules`
  952. #mkdir -p /usr/lib/dracut/modules.d/01milis
  953. #cp /root/bin/dracut/* /usr/lib/dracut/modules.d/01milis/
  954. #dracut -N --xz --force-add milis --omit systemd /boot/initramfs $kernelv
  955. dracut -N --force --xz --add 'crypt dmsquash-live pollcdrom livenet' --omit systemd /boot/initramfs $kernelv
  956. }
  957. grub_efi_boot(){
  958. : ${BASE_ARCH:=$(uname -m)}
  959. : ${KEYMAP:=tr}
  960. : ${LOCALE:=tr_TR.UTF-8}
  961. : ${INITRAMFS_COMPRESSION:=xz}
  962. : ${SQUASHFS_COMPRESSION:=xz}
  963. : ${BOOT_TITLE:="Milis_Linux"}
  964. ISO_VOLUME="MILIS_CALISAN"
  965. IMAGEDIR="iso_icerik"
  966. IMAGEDIR=$(readlink -f $IMAGEDIR)
  967. BOOT_DIR="$IMAGEDIR/boot"
  968. ISOLINUX_DIR="$BOOT_DIR/isolinux"
  969. GRUB_DIR="$BOOT_DIR/grub"
  970. ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg"
  971. SPLASH_IMAGE="$ISOLINUX_DIR/back.jpg"
  972. #noaer vs yazabiliriz.
  973. BOOT_CMDLINE=""
  974. KERNELVERSION=`uname -r`
  975. mkdir -p $GRUB_DIR
  976. cp -f ayarlar/grub/grub.cfg $GRUB_DIR/
  977. cp -f ayarlar/grub/grub_milis.cfg.in $GRUB_DIR/grub_milis.cfg
  978. sed -i -e "s|@@SPLASHIMAGE@@|$(basename ${SPLASH_IMAGE})|" \
  979. -e "s|@@KERNVER@@|${KERNELVERSION}|" \
  980. -e "s|@@KEYMAP@@|${KEYMAP}|" \
  981. -e "s|@@ARCH@@|$BASE_ARCH|" \
  982. -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
  983. -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
  984. -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_milis.cfg
  985. mkdir -p $GRUB_DIR/fonts
  986. cp -f ayarlar/grub/fonts/unicode.pf2 $GRUB_DIR/fonts/
  987. modprobe -q loop || :
  988. # EFI vfat imajı olusturuyoruz.
  989. truncate -s 16M $GRUB_DIR/efiboot.img >/dev/null 2>&1
  990. mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
  991. GRUB_EFI_TMPDIR="$(mktemp --tmpdir=/tmp -d)"
  992. LOOP_DEVICE="$(losetup --show --find ${GRUB_DIR}/efiboot.img)"
  993. mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
  994. cp -a $IMAGEDIR/boot $LFS
  995. echo "chroot gir"
  996. chroot "$LFS" /usr/bin/env -i grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi" --format="x86_64-efi" --output="/tmp/bootx64.efi" "ayarlar/grub/grub.cfg"
  997. echo "chroot cik"
  998. if [ $? -ne 0 ]; then
  999. umount "$GRUB_EFI_TMPDIR"
  1000. losetup --detach "${LOOP_DEVICE}"
  1001. echo "EFI yukleyici olusturulması basarısız!"
  1002. exit 1
  1003. fi
  1004. echo "${GRUB_EFI_TMPDIR} silinecek"
  1005. mkdir -p ${GRUB_EFI_TMPDIR}/EFI/BOOT
  1006. cp -f $LFS/tmp/bootx64.efi ${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOTX64.EFI
  1007. umount "$GRUB_EFI_TMPDIR"
  1008. echo " ${LOOP_DEVICE} silinecek"
  1009. losetup --detach "${LOOP_DEVICE}"
  1010. rm -rf $GRUB_EFI_TMPDIR
  1011. }
  1012. squashfs_olustur(){
  1013. unmount_islemi
  1014. lfs_kontrol
  1015. #son ayar yuklemeleri
  1016. cp rootfs/etc/bashrc $LFS/etc/bashrc
  1017. cp rootfs/etc/profile $LFS/etc/profile
  1018. cp ./ayarlar/mps.conf $LFS/etc/mps.conf
  1019. cp -f ./rootfs/etc/rc.d/init.d/* $LFS/etc/rc.d/init.d/
  1020. iso_etiket="MILIS_DISK_IMAJ"
  1021. rm -rf iso_icerik/boot/kernel
  1022. rm -rf iso_icerik/boot/initramfs
  1023. rm -rf iso_icerik/LiveOS
  1024. cp $LFS/boot/kernel-* iso_icerik/boot/kernel
  1025. cp $LFS/boot/initramfs* iso_icerik/boot/initramfs
  1026. anayer=$(du -sm "$LFS"|awk '{print $1}')
  1027. fazladan="$((anayer))"
  1028. mkdir -p tmp
  1029. #yeni dracut guncellemesiyle-210817 gerek yok
  1030. #mkdir -p tmp/LiveOS
  1031. #dd if=/dev/zero of=tmp/LiveOS/ext3fs.img bs=1MB count=16192
  1032. #dd if=/dev/zero of=tmp/ext3fs.img bs=1MB count=16384
  1033. fallocate -l 16G tmp/rootfs.img
  1034. mke2fs -t ext4 -L $iso_etiket -F tmp/rootfs.img
  1035. mkdir -p temp-root
  1036. mount -o loop tmp/rootfs.img temp-root
  1037. cp -dpR $LFS/* temp-root/
  1038. #rsync -a kur/ temp-root
  1039. umount -l temp-root
  1040. rm -rf temp-root
  1041. mkdir -p iso_icerik/LiveOS
  1042. mksquashfs tmp iso_icerik/LiveOS/squashfs.img -comp xz -b 256K -Xbcj x86
  1043. chmod 444 iso_icerik/LiveOS/squashfs.img
  1044. rm -rf tmp
  1045. }
  1046. iso_olustur(){
  1047. iso_etiket="MILIS_CALISAN"
  1048. rm milis_calisan.iso
  1049. genisoimage -l -V $iso_etiket -R -J -pad -no-emul-boot -boot-load-size 4 -boot-info-table \
  1050. -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o milis_calisan.iso iso_icerik && isohybrid milis_calisan.iso
  1051. }
  1052. iso_olustur_efili() {
  1053. cp $LFS/usr/lib/syslinux/isohdpfx.bin iso_icerik/boot/isolinux/isohdpfx.bin
  1054. xorriso -as mkisofs \
  1055. -iso-level 3 -rock -joliet \
  1056. -max-iso9660-filenames -omit-period \
  1057. -omit-version-number -relaxed-filenames -allow-lowercase \
  1058. -volid "MILIS_LIVE" \
  1059. -eltorito-boot boot/isolinux/isolinux.bin \
  1060. -eltorito-catalog boot/isolinux/isolinux.cat \
  1061. -no-emul-boot -boot-load-size 4 -boot-info-table \
  1062. -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
  1063. -isohybrid-mbr iso_icerik/boot/isolinux/isohdpfx.bin \
  1064. -output "milislinux-live.iso" iso_icerik || echo "ISO imaj olusturalamadı";exit 1
  1065. }
  1066. temizlik(){
  1067. rm -r /tools/*
  1068. rm -r chroot/.log/*
  1069. rm -r /tmp/work
  1070. }
  1071. lfs_kontrol(){
  1072. if [ -z "${LFS}" ]; then
  1073. echo "export LFS=/mnt/lfs"
  1074. echo "komutu verilmeli"
  1075. exit 1
  1076. fi
  1077. }
  1078. root_kontrol(){
  1079. if [ ! $(whoami) == "root" ]; then
  1080. echo "mekanizma işlemleri için root olmalısınız."
  1081. exit 1
  1082. fi
  1083. }
  1084. #calisma ortaminin klonlanmasi
  1085. git_clone(){
  1086. git clone git://github.com/milisarge/malfs malfs
  1087. }
  1088. kaynak_kodlar_indir(){
  1089. lfs_kontrol
  1090. mkdir -p $LFS/sources
  1091. for link in `cat kaynaklar.liste`
  1092. do
  1093. #MD5SUM=`echo $i|cut -d "|" -f1`
  1094. MD5SUM="iptal"
  1095. wget -nc --no-check-certificate $link -P $LFS/sources
  1096. if [ "$MD5SUM" != "iptal" ]; then
  1097. echo "$MD5SUM $FILE" >> $LFS/sources/.md5sums
  1098. fi
  1099. done
  1100. }
  1101. parametre_analiz() {
  1102. while [ "$1" ]; do
  1103. case $1 in
  1104. -h|--help)
  1105. print_help
  1106. exit 0;;
  1107. -gk|--gerek-kontrol)
  1108. ./bin/version-check.sh
  1109. exit 0;;
  1110. -ki|--kaynak-indir)
  1111. kaynak_kodlar_indir
  1112. exit 0;;
  1113. -cg|--chroot-gir)
  1114. chroot_gir
  1115. exit 0;;
  1116. -os|--onsistem-sfs)
  1117. onsistem_sfs
  1118. exit 0;;
  1119. -ts|--temel-sfs)
  1120. temel_sfs
  1121. exit 0;;
  1122. -ss|--son-sfs)
  1123. son_sfs
  1124. exit 0;;
  1125. -bo|--initrd-yap)
  1126. baslatici_olustur
  1127. exit 0;;
  1128. -geb)
  1129. grub_efi_boot
  1130. exit 0;;
  1131. -so|--squashfs-yap)
  1132. squashfs_olustur
  1133. exit 0;;
  1134. -io|--iso-yap)
  1135. iso_olustur
  1136. exit 0;;
  1137. -iof|--iso-yap-efili)
  1138. iso_olustur_efili
  1139. exit 0;;
  1140. -ba|--birinci-ayarlar)
  1141. birinci_ayarlar
  1142. exit 0;;
  1143. -ia|--ikinci-ayarlar)
  1144. ikinci_ayarlar
  1145. exit 0;;
  1146. -mi|--mount-islemi)
  1147. mount_islemi
  1148. exit 0;;
  1149. -bk|--bash-kur)
  1150. bash_kur
  1151. exit 0;;
  1152. -ui|--unmount-islemi)
  1153. unmount_islemi
  1154. exit 0;;
  1155. -te|--temizlik)
  1156. temizlik
  1157. exit 0;;
  1158. -td|--tlm-derle)
  1159. if [ ! "$2" ]; then
  1160. echo "talimatname dizini giriniz."
  1161. echo "ornek: lfs-mekanizma -td temel"
  1162. exit 1
  1163. fi
  1164. TALIMATNAME="$2"
  1165. talimatname_derle
  1166. shift;;
  1167. -v|--version)
  1168. echo "`basename $0` $VERSION"
  1169. exit 0;;
  1170. *)
  1171. echo "`basename $0`: gecersiz parametre $1"
  1172. exit 1 ;;
  1173. esac
  1174. shift
  1175. done
  1176. }
  1177. parametre_analiz "$@"