linuxfromscratch:auto-lfs

차이

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

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
linuxfromscratch:auto-lfs [2024/05/03 09:43] – [파일 다운로드 링크 처리] baecylinuxfromscratch:auto-lfs [2024/06/07 20:14] (현재) – [파일 다운로드 링크 처리] baecy
줄 49: 줄 49:
                     if mountpoint $LFS/$kvfs; then umount -q $LFS/$kvfs; fi                     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"
줄 55: 줄 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
줄 70: 줄 70:
         if ! mountpoint -q $LFS/dev/shm; then 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 mount --rbind /mnt/nfs/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 \
줄 105: 줄 105:
 </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
줄 113: 줄 136:
 <code lang=bash> <code lang=bash>
 #!/bin/bash #!/bin/bash
-# 파일명이나 다운로드 링크를 입려가면 압축해제 후 해당 디렉토리로 이동하는 스크립트. + 
-# 입력받은 문자열이 파일 다운로드 링크인지 파일명인지 확인. +Green='\033[0;32m' 
-# 링크면 다운로드후 진행. +BIGreen='\033[1;32m' 
-# 파일명이면 압축 해제하고 디렉토리 변경 시도. +Red='\033[0;31m' 
-# 파일명과 디렉토리에 일관성이 없으면 디렉토리 변경 실패. +Yellow='\033[0;33m' 
-# 수정 1: 입력받은 문자열이 "git"로 끝나면 별도 처리 +Color_Off='\033[0m' 
-# 수정 2: 적합한 디렉토리가 없는 경우 가장 최근에 만들어진 디렉토리로 이동 + 
-# 수정 2: 간단한 안내문 출력 +if [ "$(type -t p4c)!= 'alias' ] ; then 
-if [ -z $1 ]; then echo -e "${Green}An appropriate factor (file name or download link) is required."; exit 1; fi+        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 }') InputStringType=$(echo "$1" | awk 'BEGIN { FS = ":" } ; { print $1 }')
 BuildBase="$LFS"/workbench BuildBase="$LFS"/workbench
줄 128: 줄 156:
 GitDirCheck=$(basename -s .git "$1") GitDirCheck=$(basename -s .git "$1")
 GitCheck=${TargetFile: -3} 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() {
-        if [ -d "$1" ]; then  +    if [ -d "$1" ]; then  
-                cd "$1"+        cd "$1"
         else          else 
-# 파일명에서 유추한 디렉토리가 없는 경우 시간순으로 가장 최근에 생성된 디렉토리로 이동 
-# 간단한 안내문 출력 
                 cd $(ls -tcA -w1 | head -n1)                 cd $(ls -tcA -w1 | head -n1)
-                echo -e "${Yellow}No directory was found that matched the file name,\nso you moved to the most recently created directory.\nPlease make sure that the directory\nwhere you want to compile is correct and proceed.${Color_Off}"+                echo -e "$NotFoundMsg1"
         fi         fi
 } }
  
-# BuildBase로 이동+Change directory "$BuildBase"
 if [ "$PWD" != "$BuildBase" ]; then  if [ "$PWD" != "$BuildBase" ]; then 
         chg_dir "$BuildBase"         chg_dir "$BuildBase"
 fi fi
  
-+## Handling Git 
-if [ "$GitCheck" == "git"&& -d $GitDirCheck ]]; then  +if [ "$GitCheck" == "git"; then  
-        git clone "$1" +        if [ -d "$GitdirCheck" ] ; then 
-        cd "$GitDirCheck"+        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         return
 +    fi
 fi fi
  
 case "$InputStringType" in case "$InputStringType" in
         https|http|ftp)         https|http|ftp)
-            wget --no-verbose --no-clobber --directory-prefix="$SourceBase" "$1"+            wget --no-verbose -nc --directory-prefix="$SourceBase" "$1"
         ;;         ;;
         *)         *)
줄 162: 줄 206:
  
 # 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 "SourceBase"/"$TargetFile"+        unzip -q "$SourceBase"/"$TargetFile" 
 +        return
 else else
         if [ ! -d "$TargetDir" ]; then          if [ ! -d "$TargetDir" ]; then 
-                tar -xf "$SourceBase"/"$TargetFile"+                tar -xf "$SourceBase"/"$TargetFile" 2>/dev/null
         fi         fi
         chg_dir "$TargetDir"         chg_dir "$TargetDir"
  
 fi fi
-</code> \\+ 
 +unset  InputStringType BuildBase SourceBase TargetFile GitDirCheck GitCheck ZipCheck TargetDir NotFoundMsg1 
 +</code>  
  • linuxfromscratch/auto-lfs.1714729421.txt.gz
  • 마지막으로 수정됨: 2024/05/03 09:43
  • 저자 baecy