차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
| linuxfromscratch:auto-lfs [2024/05/16 09:31] – [파일 다운로드 링크 처리] baecy | linuxfromscratch:auto-lfs [2024/06/07 20:14] (현재) – [파일 다운로드 링크 처리] baecy | ||
|---|---|---|---|
| 줄 124: | 줄 124: | ||
| - alias 등록 확인 | - alias 등록 확인 | ||
| - wget, git, gawk 설치 여부 확인 | - wget, git, gawk 설치 여부 확인 | ||
| + | |||
| + | 수정할 사항 | ||
| + | - git clone 사용 할 때 작업 디렉터리에 먼저 받고 source 디렉터리에 복사하는 방식으로 변경 필요. | ||
| 줄 133: | 줄 136: | ||
| <code lang=bash> | <code lang=bash> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | # 파일명이나 다운로드 링크를 입려가면 압축해제 후 해당 디렉토리로 이동하는 스크립트. | + | |
| - | # 입력받은 문자열이 파일 다운로드 링크인지 파일명인지 확인. | + | Green=' |
| - | # 1. 입력받은 문자열이 | + | BIGreen=' |
| - | # 2. 링크면 다운로드후 진행. | + | Red=' |
| - | # 2-1. 파일명이면 압축 해제하고 디렉토리 변경 시도. | + | Yellow=' |
| - | # 2-2. 파일명과 디렉토리에 일관성이 없으면 가장 최근에 생성된 디렉토리로 이동 | + | Color_Off=' |
| - | # | + | |
| + | if [ "$(type -t p4c)" | ||
| + | echo -e "p4c is not ${Yellow}alias registered${Color_Off}, | ||
| + | source ${HOME}/.bash_aliases | ||
| + | | ||
| + | fi | ||
| if [ -z " | if [ -z " | ||
| InputStringType=$(echo " | InputStringType=$(echo " | ||
| 줄 147: | 줄 156: | ||
| GitDirCheck=$(basename -s .git " | GitDirCheck=$(basename -s .git " | ||
| GitCheck=${TargetFile: | GitCheck=${TargetFile: | ||
| + | ZipCheck=${TargetFile: | ||
| + | TargetDir=$(echo " | ||
| NotFoundMsg1=" | NotFoundMsg1=" | ||
| However, it does not exist, so it will move to the ${Yellow}most recent directory created${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." | Please check if it is correct." | ||
| - | TargetDir=$(echo " | + | |
| + | if [ $(stat -c %u $BuildBase) | ||
| function chg_dir() { | function chg_dir() { | ||
| 줄 161: | 줄 173: | ||
| } | } | ||
| - | # 이상한 것! | + | # Change directory " |
| if [ " | if [ " | ||
| chg_dir " | chg_dir " | ||
| fi | fi | ||
| - | ## .git URL 처리 | + | ## Handling Git |
| if [ " | if [ " | ||
| if [ -d " | if [ -d " | ||
| 줄 172: | 줄 184: | ||
| return | return | ||
| else | else | ||
| + | pushd $SourceBase | ||
| + | if [ -d $GitDirCheck ] ; then | ||
| + | rm -rf $GitDirCheck | ||
| + | fi | ||
| git clone " | git clone " | ||
| - | | + | cp -R $GitDirCheck $BuildBase |
| + | popd | ||
| + | # | ||
| chg_dir " | chg_dir " | ||
| return | return | ||
| 줄 179: | 줄 197: | ||
| fi | fi | ||
| - | # 입력이 URL이면 다운로드 | ||
| case " | case " | ||
| https|http|ftp) | https|http|ftp) | ||
| - | wget --no-verbose --no-clobber | + | wget --no-verbose -nc --directory-prefix=" |
| ;; | ;; | ||
| *) | *) | ||
| 줄 188: | 줄 205: | ||
| esac | esac | ||
| - | # Zip와 다른 타르볼처리 | + | # 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 " | ||
| 줄 200: | 줄 218: | ||
| fi | fi | ||
| + | |||
| + | unset InputStringType BuildBase SourceBase TargetFile GitDirCheck GitCheck ZipCheck TargetDir NotFoundMsg1 | ||
| </ | </ | ||