lfs-mekanizma 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  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
  889. mount -vt proc proc $LFS/proc
  890. mount -vt sysfs sysfs $LFS/sys
  891. if [ -h /dev/shm ]; then rm -f $LFS/dev/shm;mkdir $LFS/dev/shm;fi
  892. mount -vt tmpfs shm $LFS/dev/shm
  893. chmod 1777 /dev/shm
  894. }
  895. chroot_gir(){
  896. root_kontrol
  897. lfs_kontrol
  898. unmount_islemi
  899. mount_islemi
  900. cp ayarlar/bashrc_chroot "$LFS"/etc/bashrc
  901. chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' /bin/bash --login
  902. #chroot "$LFS" /usr/bin/env -i HOME=/root PS1='\u:\w\$ ' /bin/bash --login +h
  903. }
  904. unmount_islemi() {
  905. lfs_kontrol
  906. if [ "$LFS" != "" ];then
  907. umount -lf $LFS/dev/shm
  908. umount -lf $LFS/dev/pts
  909. umount -lf $LFS/dev
  910. umount -lf $LFS/run
  911. umount -lf $LFS/proc
  912. umount -lf $LFS/sys
  913. else
  914. echo "LFS boş tanımlı"
  915. fi
  916. }
  917. bash_kur(){
  918. cd $LFS/root/talimatname/temel/bash
  919. for PACK in *.lz; do tar xf $PACK -C $LFS;done
  920. }
  921. onsistem_sfs(){
  922. tarih=`date +%Y-%m-%d`
  923. mv $LFS/sources /mnt/sources_depo
  924. mksquashfs $LFS malfs-asama1-onsistem_$tarih.sfs -comp xz
  925. }
  926. temel_sfs(){
  927. unmount_islemi
  928. tarih=`date +%Y-%m-%d`
  929. mv $LFS/sources /mnt/sources_depo
  930. mv $LFS/tools /mnt/tools_ydk
  931. mv $LFS/paket_depo /mnt/base_paket_depo
  932. mksquashfs $LFS malfs-asama2-temel_$tarih.sfs -comp xz
  933. mv /mnt/sources_depo $LFS/sources
  934. }
  935. son_sfs(){
  936. unmount_islemi
  937. tarih=`date +%Y-%m-%d`
  938. mv $LFS/sources /mnt/sources_depo
  939. mv $LFS/paket_depo /mnt/paket_depo
  940. rm -r -f $LFS/usr/src
  941. mksquashfs $LFS malfs-asama3-sonsistem_$tarih.sfs -comp xz
  942. }
  943. baslatici_olustur(){
  944. rm /boot/initramfs
  945. #kernelv=`ls /boot/kernel-* | cut -d'-' -f2`
  946. kernelv=`ls /lib/modules`
  947. #mkdir -p /usr/lib/dracut/modules.d/01milis
  948. #cp /root/bin/dracut/* /usr/lib/dracut/modules.d/01milis/
  949. #dracut -N --xz --force-add milis --omit systemd /boot/initramfs $kernelv
  950. dracut -N --force --xz --add 'dmsquash-live pollcdrom' --omit systemd /boot/initramfs $kernelv
  951. }
  952. grub_efi_boot(){
  953. : ${BASE_ARCH:=$(uname -m)}
  954. : ${KEYMAP:=tr}
  955. : ${LOCALE:=tr_TR.UTF-8}
  956. : ${INITRAMFS_COMPRESSION:=xz}
  957. : ${SQUASHFS_COMPRESSION:=xz}
  958. : ${BOOT_TITLE:="Milis_Linux"}
  959. ISO_VOLUME="MILIS_LIVE"
  960. IMAGEDIR="iso_icerik"
  961. IMAGEDIR=$(readlink -f $IMAGEDIR)
  962. BOOT_DIR="$IMAGEDIR/boot"
  963. ISOLINUX_DIR="$BOOT_DIR/isolinux"
  964. GRUB_DIR="$BOOT_DIR/grub"
  965. ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg"
  966. SPLASH_IMAGE="$ISOLINUX_DIR/back.jpg"
  967. #noaer vs yazabiliriz.
  968. BOOT_CMDLINE=""
  969. KERNELVERSION=`uname -r`
  970. mkdir -p $GRUB_DIR
  971. cp -f ayarlar/grub/grub.cfg $GRUB_DIR/
  972. cp -f ayarlar/grub/grub_milis.cfg.in $GRUB_DIR/grub_milis.cfg
  973. sed -i -e "s|@@SPLASHIMAGE@@|$(basename ${SPLASH_IMAGE})|" \
  974. -e "s|@@KERNVER@@|${KERNELVERSION}|" \
  975. -e "s|@@KEYMAP@@|${KEYMAP}|" \
  976. -e "s|@@ARCH@@|$BASE_ARCH|" \
  977. -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
  978. -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
  979. -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_milis.cfg
  980. mkdir -p $GRUB_DIR/fonts
  981. cp -f ayarlar/grub/fonts/unicode.pf2 $GRUB_DIR/fonts/
  982. modprobe -q loop || :
  983. # EFI vfat imajı olusturuyoruz.
  984. truncate -s 16M $GRUB_DIR/efiboot.img >/dev/null 2>&1
  985. mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
  986. GRUB_EFI_TMPDIR="$(mktemp --tmpdir=/tmp -d)"
  987. LOOP_DEVICE="$(losetup --show --find ${GRUB_DIR}/efiboot.img)"
  988. mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
  989. cp -a $IMAGEDIR/boot $LFS
  990. echo "chroot gir"
  991. 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"
  992. echo "chroot cik"
  993. if [ $? -ne 0 ]; then
  994. umount "$GRUB_EFI_TMPDIR"
  995. losetup --detach "${LOOP_DEVICE}"
  996. echo "EFI yukleyici olusturulması basarısız!"
  997. exit 1
  998. fi
  999. echo "${GRUB_EFI_TMPDIR} silinecek"
  1000. mkdir -p ${GRUB_EFI_TMPDIR}/EFI/BOOT
  1001. cp -f $LFS/tmp/bootx64.efi ${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOTX64.EFI
  1002. umount "$GRUB_EFI_TMPDIR"
  1003. echo " ${LOOP_DEVICE} silinecek"
  1004. losetup --detach "${LOOP_DEVICE}"
  1005. rm -rf $GRUB_EFI_TMPDIR
  1006. }
  1007. squashfs_olustur(){
  1008. unmount_islemi
  1009. lfs_kontrol
  1010. #son ayar yuklemeleri
  1011. cp rootfs/etc/bashrc $LFS/etc/bashrc
  1012. cp rootfs/etc/profile $LFS/etc/profile
  1013. cp ./ayarlar/mps.conf $LFS/etc/mps.conf
  1014. cp -f ./rootfs/etc/rc.d/init.d/* $LFS/etc/rc.d/init.d/
  1015. iso_etiket="MILIS_LIVE"
  1016. rm iso_icerik/boot/kernel
  1017. rm iso_icerik/boot/initramfs
  1018. rm -r iso_icerik/LiveOS
  1019. cp $LFS/boot/kernel-* iso_icerik/boot/kernel
  1020. cp $LFS/boot/initramfs* iso_icerik/boot/initramfs
  1021. anayer=$(du -sm "$LFS"|awk '{print $1}')
  1022. fazladan="$((anayer))"
  1023. mkdir -p tmp
  1024. mkdir -p tmp/LiveOS
  1025. #fallocate -l 32G tmp/LiveOS/rootfs.img
  1026. #if [ -f $bos_imaj ];
  1027. #then
  1028. #cp $bos_imaj tmp/LiveOS/ext3fs.img
  1029. #else
  1030. #dd if=/dev/zero of=tmp/LiveOS/ext3fs.img bs=1MB count="$((anayer+fazladan))"
  1031. dd if=/dev/zero of=tmp/LiveOS/ext3fs.img bs=1MB count=16384
  1032. #dd if=/dev/zero of=tmp/LiveOS/ext3fs.img bs=1MB count=16192
  1033. mke2fs -t ext4 -L $iso_etiket -F tmp/LiveOS/ext3fs.img
  1034. mkdir -p temp-root
  1035. mount -o loop tmp/LiveOS/ext3fs.img temp-root
  1036. cp -dpR $LFS/* temp-root/
  1037. #rsync -a kur/ temp-root
  1038. umount -l temp-root
  1039. rm -rf temp-root
  1040. mkdir -p iso_icerik/LiveOS
  1041. mksquashfs tmp iso_icerik/LiveOS/squashfs.img -comp xz -b 256K -Xbcj x86
  1042. chmod 444 iso_icerik/LiveOS/squashfs.img
  1043. rm -rf tmp
  1044. }
  1045. iso_olustur(){
  1046. rm milis_live.iso
  1047. genisoimage -l -V MILIS_LIVE -R -J -pad -no-emul-boot -boot-load-size 4 -boot-info-table \
  1048. -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o milis_live.iso iso_icerik && isohybrid milis_live.iso
  1049. }
  1050. iso_olustur_efili() {
  1051. cp $LFS/usr/lib/syslinux/isohdpfx.bin iso_icerik/boot/isolinux/isohdpfx.bin
  1052. xorriso -as mkisofs \
  1053. -iso-level 3 -rock -joliet \
  1054. -max-iso9660-filenames -omit-period \
  1055. -omit-version-number -relaxed-filenames -allow-lowercase \
  1056. -volid "MILIS_LIVE" \
  1057. -eltorito-boot boot/isolinux/isolinux.bin \
  1058. -eltorito-catalog boot/isolinux/isolinux.cat \
  1059. -no-emul-boot -boot-load-size 4 -boot-info-table \
  1060. -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
  1061. -isohybrid-mbr iso_icerik/boot/isolinux/isohdpfx.bin \
  1062. -output "milislinux-live.iso" iso_icerik || echo "ISO imaj olusturalamadı";exit 1
  1063. }
  1064. temizlik(){
  1065. rm -r /tools/*
  1066. rm -r chroot/.log/*
  1067. rm -r /tmp/work
  1068. }
  1069. lfs_kontrol(){
  1070. if [ -z "${LFS}" ]; then
  1071. echo "export LFS=/mnt/lfs"
  1072. echo "komutu verilmeli"
  1073. exit 1
  1074. fi
  1075. }
  1076. root_kontrol(){
  1077. if [ ! $(whoami) == "root" ]; then
  1078. echo "mekanizma işlemleri için root olmalısınız."
  1079. exit 1
  1080. fi
  1081. }
  1082. #calisma ortaminin klonlanmasi
  1083. git_clone(){
  1084. git clone git://github.com/milisarge/malfs malfs
  1085. }
  1086. kaynak_kodlar_indir(){
  1087. lfs_kontrol
  1088. mkdir -p $LFS/sources
  1089. for link in `cat kaynaklar.liste`
  1090. do
  1091. #MD5SUM=`echo $i|cut -d "|" -f1`
  1092. MD5SUM="iptal"
  1093. wget -nc --no-check-certificate $link -P $LFS/sources
  1094. if [ "$MD5SUM" != "iptal" ]; then
  1095. echo "$MD5SUM $FILE" >> $LFS/sources/.md5sums
  1096. fi
  1097. done
  1098. }
  1099. parametre_analiz() {
  1100. while [ "$1" ]; do
  1101. case $1 in
  1102. -h|--help)
  1103. print_help
  1104. exit 0;;
  1105. -gk|--gerek-kontrol)
  1106. ./bin/version-check.sh
  1107. exit 0;;
  1108. -ki|--kaynak-indir)
  1109. kaynak_kodlar_indir
  1110. exit 0;;
  1111. -cg|--chroot-gir)
  1112. chroot_gir
  1113. exit 0;;
  1114. -os|--onsistem-sfs)
  1115. onsistem_sfs
  1116. exit 0;;
  1117. -ts|--temel-sfs)
  1118. temel_sfs
  1119. exit 0;;
  1120. -ss|--son-sfs)
  1121. son_sfs
  1122. exit 0;;
  1123. -bo|--initrd-yap)
  1124. baslatici_olustur
  1125. exit 0;;
  1126. -geb)
  1127. grub_efi_boot
  1128. exit 0;;
  1129. -so|--squashfs-yap)
  1130. squashfs_olustur
  1131. exit 0;;
  1132. -io|--iso-yap)
  1133. iso_olustur
  1134. exit 0;;
  1135. -iof|--iso-yap-efili)
  1136. iso_olustur_efili
  1137. exit 0;;
  1138. -ba|--birinci-ayarlar)
  1139. birinci_ayarlar
  1140. exit 0;;
  1141. -ia|--ikinci-ayarlar)
  1142. ikinci_ayarlar
  1143. exit 0;;
  1144. -mi|--mount-islemi)
  1145. mount_islemi
  1146. exit 0;;
  1147. -bk|--bash-kur)
  1148. bash_kur
  1149. exit 0;;
  1150. -ui|--unmount-islemi)
  1151. unmount_islemi
  1152. exit 0;;
  1153. -te|--temizlik)
  1154. temizlik
  1155. exit 0;;
  1156. -td|--tlm-derle)
  1157. if [ ! "$2" ]; then
  1158. echo "talimatname dizini giriniz."
  1159. echo "ornek: lfs-mekanizma -td temel"
  1160. exit 1
  1161. fi
  1162. TALIMATNAME="$2"
  1163. talimatname_derle
  1164. shift;;
  1165. -v|--version)
  1166. echo "`basename $0` $VERSION"
  1167. exit 0;;
  1168. *)
  1169. echo "`basename $0`: gecersiz parametre $1"
  1170. exit 1 ;;
  1171. esac
  1172. shift
  1173. done
  1174. }
  1175. parametre_analiz "$@"