차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
linuxfromscratch:auto-lfs [2024/05/01 00:20] – [파일 다운로드 링크 처리] baecy | linuxfromscratch: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에 맞춤 |
- | # | + | # < |
- | # For LFS 12.1-systemd | + | # 커널 가상 파일 마운트/ |
- | # you can use it after proceeding with < | + | # Begin ~/ |
- | # Mount and unmount kernel virtual file system and entering to chroot environment | + | |
+ | VERSION=0.1.7 | ||
LFS=/ | LFS=/ | ||
- | LFS_PART=/ | + | LFS_PART=/ |
- | 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/ | + | |
- | 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/ | ||
+ | if ! mountpoint -q $LFS/ | ||
+ | if ! mountpoint -q $LFS/ | ||
+ | if ! mountpoint -q $LFS/ | ||
+ | |||
+ | # /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 ' | + | # 입력에 따라 |
case $1 in | case $1 in | ||
clean|c|-c) | clean|c|-c) | ||
줄 42: | 줄 46: | ||
echo "LFS is now set to '" | echo "LFS is now set to '" | ||
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 | + | |
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" | ||
줄 51: | 줄 55: | ||
else | else | ||
echo " | echo " | ||
- | findmnt -o FSTYPE, | + | 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 '" | echo "LFS is now set to '" | ||
- | if mountpoint -q $LFS/dev; then true; else mount --bind /dev $LFS/dev; fi | + | if ! mountpoint -q $LFS/ |
- | if mountpoint -q $LFS/ | + | if ! mountpoint -q $LFS/ |
- | if mountpoint -q $LFS/proc; then true; else mount -t proc proc $LFS/proc; fi | + | if ! mountpoint -q $LFS/ |
- | if mountpoint -q $LFS/sys; then true; else mount -t sysfs sysfs $LFS/sys; fi | + | if ! mountpoint -q $LFS/ |
- | if mountpoint -q $LFS/run; then true; else mount -t tmpfs tmpfs $LFS/run; fi | + | if ! mountpoint -q $LFS/ |
- | 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 " | ||
줄 94: | 줄 98: | ||
*) | *) | ||
#Guidance on the factors needed to execute script | #Guidance on the factors needed to execute script | ||
- | echo "sh ./Auto_LFS.sh | + | echo "sh ./lfs-env-config |
exit 0 | exit 0 | ||
;; | ;; | ||
esac | esac | ||
+ | ## End ~/ | ||
</ | </ | ||
===== 파일 다운로드 링크 처리 ===== | ===== 파일 다운로드 링크 처리 ===== | ||
+ | |||
+ | 다음과 같이 등록하고 사용해야 '' | ||
+ | |||
+ | <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 | ||
줄 108: | 줄 136: | ||
<code lang=bash> | <code lang=bash> | ||
#!/bin/bash | #!/bin/bash | ||
- | # 파일명이나 다운로드 링크를 입려가면 압축해제 후 해당 디렉토리로 이동하는 스크립트. | ||
- | # 입력받은 문자열이 파일 다운로드 링크인지 파일명인지 확인. | ||
- | # 입력받은 문자열이 " | ||
- | # 링크면 다운로드후 진행. | ||
- | # 파일명이면 압축 해제하고 디렉토리 변경 시도. | ||
- | # 파일명과 디렉토리에 일관성이 없으면 디렉토리 변경 실패. | ||
+ | Green=' | ||
+ | BIGreen=' | ||
+ | Red=' | ||
+ | Yellow=' | ||
+ | Color_Off=' | ||
+ | |||
+ | if [ " | ||
+ | echo -e "p4c is not ${Yellow}alias registered${Color_Off}, | ||
+ | source ${HOME}/ | ||
+ | return 2>&/ | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
InputStringType=$(echo " | InputStringType=$(echo " | ||
- | BuildBase=/ | + | BuildBase=" |
- | SourceBase=/ | + | SourceBase=" |
TargetFile=$(basename " | TargetFile=$(basename " | ||
+ | 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() { | ||
+ | if [ -d " | ||
cd " | cd " | ||
+ | else | ||
+ | cd $(ls -tcA -w1 | head -n1) | ||
+ | echo -e " | ||
+ | fi | ||
} | } | ||
- | # BuildBase로 이동 | + | # Change directory "$BuildBase" |
if [ " | if [ " | ||
chg_dir " | chg_dir " | ||
fi | fi | ||
- | # | + | ## Handling Git |
- | if [ " | + | if [ " |
- | | + | |
- | | + | |
+ | return | ||
+ | else | ||
+ | pushd $SourceBase | ||
+ | if [ -d $GitDirCheck ] ; then | ||
+ | rm -rf $GitDirCheck | ||
+ | fi | ||
+ | | ||
+ | cp -R $GitDirCheck $BuildBase | ||
+ | popd | ||
+ | # echo "Git #1" | ||
+ | chg_dir " | ||
return | return | ||
+ | fi | ||
fi | fi | ||
+ | |||
case " | case " | ||
https|http|ftp) | https|http|ftp) | ||
- | wget -P / | + | wget --no-verbose -nc --directory-prefix=" |
;; | ;; | ||
*) | *) | ||
줄 146: | 줄 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 | ||
- | tar -xf " | + | |
+ | | ||
+ | fi | ||
chg_dir " | chg_dir " | ||
+ | |||
fi | fi | ||
- | </ | + | |
+ | unset InputStringType BuildBase SourceBase TargetFile GitDirCheck GitCheck ZipCheck TargetDir NotFoundMsg1 | ||
+ | </ |