차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
| linuxfromscratch:auto-lfs [2024/05/03 09:43] – [파일 다운로드 링크 처리] baecy | linuxfromscratch: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, | + | 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 " | echo " | ||
| - | findmnt -o FSTYPE, | + | findmnt -D -R $LFS |
| exit 0 | exit 0 | ||
| fi | fi | ||
| 줄 70: | 줄 70: | ||
| if ! mountpoint -q $LFS/ | if ! mountpoint -q $LFS/ | ||
| if ! mountpoint -q $LFS/ | if ! mountpoint -q $LFS/ | ||
| - | findmnt -o FSTYPE, | + | findmnt -D -R $LFS |
| # Run ' | # Run ' | ||
| chroot " | chroot " | ||
| 줄 105: | 줄 105: | ||
| </ | </ | ||
| ===== 파일 다운로드 링크 처리 ===== | ===== 파일 다운로드 링크 처리 ===== | ||
| + | |||
| + | 다음과 같이 등록하고 사용해야 '' | ||
| + | |||
| + | <code lang=bash> | ||
| + | alias < | ||
| + | </ | ||
| + | |||
| 다운로드 링크 입력: 다운로드 -> 압축 해제 -> 디렉토리 이동 | 다운로드 링크 입력: 다운로드 -> 압축 해제 -> 디렉토리 이동 | ||
| + | |||
| + | 추가한 사항 | ||
| + | - 입력받은 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 | user@host:[ ~ ] $ pre-stage | ||
| 줄 113: | 줄 136: | ||
| <code lang=bash> | <code lang=bash> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | # 파일명이나 다운로드 링크를 입려가면 압축해제 후 해당 디렉토리로 이동하는 스크립트. | + | |
| - | # 입력받은 문자열이 파일 다운로드 링크인지 파일명인지 확인. | + | Green=' |
| - | # 링크면 다운로드후 진행. | + | BIGreen=' |
| - | # 파일명이면 압축 해제하고 디렉토리 변경 시도. | + | Red=' |
| - | # 파일명과 디렉토리에 일관성이 없으면 디렉토리 변경 실패. | + | Yellow=' |
| - | # 수정 1: 입력받은 문자열이 | + | Color_Off=' |
| - | # 수정 2: 적합한 디렉토리가 없는 경우 가장 최근에 만들어진 디렉토리로 이동 | + | |
| - | # 수정 | + | if [ "$(type -t p4c)" |
| - | if [ ! -z $1 ]; then echo -e " | + | echo -e "p4c is not ${Yellow}alias registered${Color_Off}, |
| + | | ||
| + | return | ||
| + | fi | ||
| + | |||
| + | if [ -z "$1" | ||
| InputStringType=$(echo " | InputStringType=$(echo " | ||
| BuildBase=" | BuildBase=" | ||
| 줄 128: | 줄 156: | ||
| GitDirCheck=$(basename -s .git " | GitDirCheck=$(basename -s .git " | ||
| GitCheck=${TargetFile: | GitCheck=${TargetFile: | ||
| + | ZipCheck=${TargetFile: | ||
| TargetDir=$(echo " | TargetDir=$(echo " | ||
| + | NotFoundMsg1=" | ||
| + | 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"; | ||
| function chg_dir() { | function chg_dir() { | ||
| - | | + | |
| - | cd " | + | cd " |
| 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 [ " | if [ " | ||
| chg_dir " | chg_dir " | ||
| fi | fi | ||
| - | # | + | ## Handling Git |
| - | if [ " | + | if [ " |
| - | git clone " | + | if [ -d "$GitdirCheck" |
| - | | + | |
| + | return | ||
| + | else | ||
| + | pushd $SourceBase | ||
| + | if [ -d $GitDirCheck ] ; then | ||
| + | rm -rf $GitDirCheck | ||
| + | fi | ||
| + | | ||
| + | cp -R $GitDirCheck $BuildBase | ||
| + | popd | ||
| + | # echo "Git #1" | ||
| + | | ||
| return | return | ||
| + | fi | ||
| fi | fi | ||
| case " | case " | ||
| https|http|ftp) | https|http|ftp) | ||
| - | wget --no-verbose --no-clobber | + | wget --no-verbose -nc --directory-prefix=" |
| ;; | ;; | ||
| *) | *) | ||
| 줄 162: | 줄 206: | ||
| # Prepare Package Build | # Prepare Package Build | ||
| - | if file "$TargetFile" | + | if [ "$ZipCheck" |
| mkdir -p " | mkdir -p " | ||
| chg_dir " | chg_dir " | ||
| - | unzip -q " | + | unzip -q "$SourceBase"/" |
| + | return | ||
| else | else | ||
| if [ ! -d " | if [ ! -d " | ||
| - | tar -xf " | + | tar -xf " |
| fi | fi | ||
| chg_dir " | chg_dir " | ||
| fi | fi | ||
| - | </ | + | |
| + | unset InputStringType BuildBase SourceBase TargetFile GitDirCheck GitCheck ZipCheck TargetDir NotFoundMsg1 | ||
| + | </ | ||