linuxfromscratch:auto-lfs

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
linuxfromscratch:auto-lfs [2024/04/30 20:42] – [파일 다운로드 링크 처리] baecylinuxfromscratch:auto-lfs [2024/06/07 20:14] (현재) – [파일 다운로드 링크 처리] baecy
줄 12: 줄 12:
 <code lang=bash> <code lang=bash>
 #!/bin/bash #!/bin/bash
-Begin auto-lfs +# LFS 12.1-systemd에 맞춤 
-+# <7.2 소유자 변경이후에 사용 
-# For LFS 12.1-systemd +커널 가상 파일 마운트/언마운트 지원용 스크립트 
-you can use it after proceeding with <7.2 Changing Owner>  +# Begin ~/bin/lfs-env-config
-Mount and unmount kernel virtual file system and entering to chroot environment+
  
 +VERSION=0.1.7
 LFS=/mnt/lfs LFS=/mnt/lfs
-LFS_PART=/dev/nvme0n1p6 +LFS_PART=/dev/nvme0n1p8 
-VERSION=0.1.5 +LFS_BOOT=/dev/nvme0n1p6 
-# Dedicated partition mount +LFS_EFI=/dev/nvme0n1p2 
-if mountpoint -q $LFS; then true; else mount $LFS_PART $LFS; fi +LFS_HOME=/dev/nvme0n1p7
-if mountpoint -q $LFS/boot; then true; else mount /dev/nvme0n1p3 $LFS/boot; fi +
-if mountpoint -q $LFS/boot/efi; then true; else  mount /dev/nvme0n1p1 $LFS/boot/efi; fi +
-if mountpoint -q $LFS/home; then true; else  mount /dev/nvme0n1p4 $LFS/home; fi+
  
-Mount point dirctory check+필요한 별도의 파티션 마운트 
 +if ! mountpoint -q $LFS;          then mount $LFS_PART $LFS; fi 
 +if ! mountpoint -q $LFS/boot;     then mount $LFS_BOOT $LFS/boot; fi 
 +if ! mountpoint -q $LFS/boot/efi; then mount $LFS_EFI $LFS/boot/efi; fi 
 +if ! mountpoint -q $LFS/home;     then mount $LFS_HOME $LFS/home; fi 
 +if ! mountpoint -q $LFS/sources;  then mount /mnt/nfs/sources $LFS/sources; fi 
 + 
 +# /dev 존재 확인 후 필요한 조치 진행
 if [ ! -d $LFS/dev ]; then if [ ! -d $LFS/dev ]; then
         echo "Make necessary directories"         echo "Make necessary directories"
줄 35: 줄 39:
 fi fi
  
-To prepare for run 'chroot', run 'umount' block if a directory exists, or run 'mount' block+입력에 따라 chroot 실행 또는 exit 후 사용한 커널 가상 파일 시스템 언마운트
 case $1 in case $1 in
     clean|c|-c)     clean|c|-c)
줄 42: 줄 46:
             echo "LFS is now set to '"$LFS"'"             echo "LFS is now set to '"$LFS"'"
             echo "Now proceed with the unmount of <Kernel Virtual File System> for chroot"             echo "Now proceed with the unmount of <Kernel Virtual File System> for chroot"
-            for kvfs in dev/shm dev/pts sys proc run dev sources; do +            for kvfs in dev/shm dev/pts sys proc run dev ; do 
-                    umount -q $LFS/$kvfs+                    if mountpoint $LFS/$kvfs; then umount -q $LFS/$kvfs; fi
             done             done
-            findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep lfs+            findmnt -D -R $LFS 
             echo "Ok unmount unnecessary devices"             echo "Ok unmount unnecessary devices"
             echo "Good bye"             echo "Good bye"
줄 51: 줄 55:
         else         else
             echo "Cleanup of Kernel Virtual File System is Complete."             echo "Cleanup of Kernel Virtual File System is Complete."
-            findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep lfs+            findmnt -D -R $LFS
             exit 0             exit 0
         fi         fi
줄 59: 줄 63:
         echo "Now proceed with the mount of <Kernel Virtual File System> for chroot"         echo "Now proceed with the mount of <Kernel Virtual File System> for chroot"
         echo "LFS is now set to '"$LFS"'"         echo "LFS is now set to '"$LFS"'"
-        if mountpoint -q $LFS/dev; then true; else mount --bind /dev $LFS/dev; fi +        if mountpoint -q $LFS/dev;     then mount --bind /dev $LFS/dev;                             fi 
-        if mountpoint -q $LFS/dev/pts; then true; else mount -t devpts devpts -o gid=5,mode=0620 $LFS/dev/pts; fi +        if mountpoint -q $LFS/dev/pts; then mount -t devpts devpts -o gid=5,mode=0620 $LFS/dev/pts; fi 
-        if mountpoint -q $LFS/proc; then true; else mount -t proc proc $LFS/proc; fi +        if mountpoint -q $LFS/proc;    then mount -t proc proc $LFS/proc;                           fi 
-        if mountpoint -q $LFS/sys; then true; else mount -t sysfs sysfs $LFS/sys; fi +        if mountpoint -q $LFS/sys;     then mount -t sysfs sysfs $LFS/sys;                          fi 
-        if mountpoint -q $LFS/run; then true; else mount -t tmpfs tmpfs $LFS/run; fi +        if mountpoint -q $LFS/run;     then mount -t tmpfs tmpfs $LFS/run;                          fi 
-        if mountpoint -q $LFS/dev/shm; then true; else mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm; fi +        if mountpoint -q $LFS/dev/shm; then mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm;      fi 
-        if mountpoint -q $LFS/sources; then  true; else mount --bind /mnt/sources $LFS/sources; fi +        if mountpoint -q $LFS/sources; then mount --rbind /mnt/nfs/sources $LFS/sources;            fi 
-        findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep lfs+        findmnt -D -R $LFS
         # Run 'chroot'         # Run 'chroot'
         chroot "$LFS" $(type -p env) -i \         chroot "$LFS" $(type -p env) -i \
줄 94: 줄 98:
     *)     *)
         #Guidance on the factors needed to execute script         #Guidance on the factors needed to execute script
-        echo "sh ./Auto_LFS.sh [ start | clean | help | version ]"+        echo "sh ./lfs-env-config [ start | clean | help | version ]"
         exit 0         exit 0
     ;;     ;;
 esac esac
 +## End ~/bin/lfs-env-config
 </code> \\ \\ </code> \\ \\
 ===== 파일 다운로드 링크 처리 ===== ===== 파일 다운로드 링크 처리 =====
 +
 +다음과 같이 등록하고 사용해야 ''cd'' 가 작동을 합니다.
 +
 +<code lang=bash>
 +alias <filename>='source <filename>'
 +</code>
 +
 다운로드 링크 입력: 다운로드 -> 압축 해제 -> 디렉토리 이동 다운로드 링크 입력: 다운로드 -> 압축 해제 -> 디렉토리 이동
 +
 +추가한 사항
 +  - 입력받은 URL이 Git인 경우 처리 추가
 +  - 확장자가 .zip인 경우 처리 추가
 +  - 이미 다운로드 완료한 파일의 경우 처리 추가
 +  - 작업 디렉토리의 소유권 확인 추가
 +  - 출력 색상 변수 설정
 +
 +추가할 사항
 +  - alias 등록 확인
 +  - wget, git, gawk 설치 여부 확인
 +
 +수정할 사항
 +  - git clone 사용 할 때 작업 디렉터리에 먼저 받고 source 디렉터리에 복사하는 방식으로 변경 필요.
 +
 +
 <code user=user host=host lang=bash> <code user=user host=host lang=bash>
 user@host:[ ~ ] $ pre-stage  https://xorg.freedesktop.org/archive/individual/proto/xcb-proto-1.17.0.tar.xz user@host:[ ~ ] $ pre-stage  https://xorg.freedesktop.org/archive/individual/proto/xcb-proto-1.17.0.tar.xz
줄 108: 줄 136:
 <code lang=bash> <code lang=bash>
 #!/bin/bash #!/bin/bash
-# Packages Build prepare (change dircetorydecompress file...) + 
-# 아래 두개의 변수를 상황에 맞게 변경해서 사용+Green='\033[0;32m' 
-BuildBase=/workbench +BIGreen='\033[1;32m' 
-SourceDir=/sources +Red='\033[0;31m' 
-wget -P $SourceDir $1 +Yellow='\033[0;33m' 
-TargetFile=$(basename $1)+Color_Off='\033[0m' 
 + 
 +if [ "$(type -t p4c)" != 'alias' ] ; then 
 +        echo -e "p4c is not ${Yellow}alias registered${Color_Off}so the functionality is not available.
 +        source ${HOME}/.bash_aliases 
 +        return 2>&/dev/null 
 +fi 
 + 
 +if [ -z "$1" ]; then echo -e "${Green}An appropriate factor (file name or download link) is required.${Color_Off}"; return; fi 
 +InputStringType=$(echo "$1" | awk 'BEGIN { FS = ":" } ; { print $1 }') 
 +BuildBase="$LFS"/workbench 
 +SourceBase="$LFS"/sources 
 +TargetFile=$(basename "$1") 
 +GitDirCheck=$(basename -s .git "$1") 
 +GitCheck=${TargetFile: -3} 
 +ZipCheck=${TargetFile: -3}
 TargetDir=$(echo "$TargetFile" | sed -e 's/\.tar.*$//' -e 's/\.tgz*$//' -e 's/\.src*$//' -e 's/\.zip*$//' -e 's@^.*/@@') TargetDir=$(echo "$TargetFile" | sed -e 's/\.tar.*$//' -e 's/\.tgz*$//' -e 's/\.src*$//' -e 's/\.zip*$//' -e 's@^.*/@@')
 +NotFoundMsg1="The directory derived from the filename is ${BIGreen}$TargetDir${Color_Off}.\n\
 +However, it does not exist, so it will move to the ${Yellow}most recent directory created${Color_Off}.\n\
 +Please check if it is correct."
 +
 +if [ $(stat -c %u $BuildBase) -ne $(id -u) ] ; then echo -e "Check ${Red}$BuildBase${Color_Off} Ownership"; return; fi
  
 function chg_dir() { function chg_dir() {
-        cd $1+    if [ -d "$1" ]; then  
 +        cd "$1
 +        else  
 +                cd $(ls -tcA -w1 | head -n1) 
 +                echo -e "$NotFoundMsg1" 
 +        fi
 } }
  
-Move to /workbench+Change directory "$BuildBase"
 if [ "$PWD" != "$BuildBase" ]; then  if [ "$PWD" != "$BuildBase" ]; then 
         chg_dir "$BuildBase"         chg_dir "$BuildBase"
 fi fi
 +
 +## Handling Git
 +if [ "$GitCheck" == "git" ] ; then 
 +        if [ -d "$GitdirCheck" ] ; then
 +        chg_dir "$GitDirCheck"
 +                return 
 +        else
 +            pushd $SourceBase
 +            if [ -d $GitDirCheck ] ; then
 +                rm -rf $GitDirCheck
 +            fi
 +            git clone "$1"
 +            cp -R $GitDirCheck $BuildBase
 +            popd
 +#        echo "Git #1"
 +        chg_dir "$GitDirCheck"
 +        return
 +    fi
 +fi
 +
 +case "$InputStringType" in
 +        https|http|ftp)
 +            wget --no-verbose -nc --directory-prefix="$SourceBase" "$1"
 +        ;;
 +        *)
 +        ;;
 +esac
  
 # Prepare Package Build # Prepare Package Build
-if file "$TargetFile| grep -q 'Zip archive data'; then+if "$ZipCheck== "zip"; then
         mkdir -p "$TargetDir"         mkdir -p "$TargetDir"
         chg_dir "$TargetDir"         chg_dir "$TargetDir"
-        unzip -q "SourceDir"/"$TargetFile"+        unzip -q "$SourceBase"/"$TargetFile" 
 +        return
 else else
-        tar -xf "$SourceDir"/"$TargetFile"+        if [ ! -d "$TargetDir" ]; then  
 +                tar -xf "$SourceBase"/"$TargetFile" 2>/dev/null 
 +        fi
         chg_dir "$TargetDir"         chg_dir "$TargetDir"
 +
 fi fi
-</code>+ 
 +unset  InputStringType BuildBase SourceBase TargetFile GitDirCheck GitCheck ZipCheck TargetDir NotFoundMsg1 
 +</code>  
  • linuxfromscratch/auto-lfs.1714509737.txt.gz
  • 마지막으로 수정됨: 2024/04/30 20:42
  • 저자 baecy