|
| 1 | +#!/bin/bash |
| 2 | +cur=$(cd "$(dirname "$0")"; pwd) |
| 3 | +cd $cur |
| 4 | +set +e |
| 5 | +logfile=$cur/oneBuild-syncer.log |
| 6 | +dpkg=$cur/.ws/down_pkg |
| 7 | +dbin=$cur/.ws/down_bin; mkdir -p $dpkg $dbin |
| 8 | +function print_time_cost(){ |
| 9 | + local item_name=$1 |
| 10 | + local begin_time=$2 |
| 11 | + gawk 'BEGIN{ |
| 12 | + print "['$item_name']本操作从" strftime("%Y年%m月%d日%H:%M:%S",'$begin_time'),"开始 ,", |
| 13 | + strftime("到%Y年%m月%d日%H:%M:%S",systime()) ,"结束,", |
| 14 | + " 共历时" systime()-'$begin_time' "秒"; |
| 15 | + }' 2>&1 | tee -a $logfile |
| 16 | +} |
| 17 | + |
| 18 | +# https://github.com/crazy-max/undock/releases/download/v0.8.0/undock_0.8.0_linux_amd64.tar.gz |
| 19 | +# https://github.com/crazy-max/undock/releases/download/v0.8.0/undock_0.8.0_linux_arm64.tar.gz |
| 20 | +function loadBins(){ |
| 21 | + file=undock_0.8.0_linux_amd64.tar.gz; URL=https://github.com/crazy-max/undock/releases/download/v0.8.0/$file |
| 22 | + curl -o- -k -fSL $URL > $dpkg/$file; |
| 23 | + # AUTH=root:root; curl -o- -u $AUTH http://172.25.23.203/repository1/platform/2024/$file > $dpkg/$file |
| 24 | + # view |
| 25 | + # echo "cur: $cur"; pwd; |
| 26 | + ls -lh $dpkg/ |
| 27 | + |
| 28 | + tar -zxf $dpkg/$file -C $dbin/ |
| 29 | + ls -lh $dbin/ |
| 30 | +} |
| 31 | +loadBins |
| 32 | + |
| 33 | +# authConf |
| 34 | + |
| 35 | +export VERSION="1.26.2" |
| 36 | +export LOG_NOCOLOR=true |
| 37 | +lognocolor="--log-nocolor" |
| 38 | +function doUndock(){ |
| 39 | + rootfs=.ws/rootfs; rm -rf $rootfs |
| 40 | + # echo xxx |docker login $REPO1 --username=admin --password-stdin |
| 41 | + # rmdist="--rm-dist" |
| 42 | + $dbin/undock $lognocolor --include=/rootfs/nginx --insecure $rmdist --all $REPO1/infrastlabs/build-nginx:latest $rootfs/ |
| 43 | + # exit 0 |
| 44 | + # view |
| 45 | + # find $rootfs* -type f -name .wh..wh..opq |xargs rm -rf #清理冗余文件(undock's bug?) |
| 46 | + find $rootfs* -type f |sort |
| 47 | + |
| 48 | + # armv7 |
| 49 | + archs=(amd64 arm64 armv7); pkgs=$cur/.ws/pkgs; mkdir -p $pkgs |
| 50 | + for arch in ${archs[@]}; do |
| 51 | + echo "arch: $arch"; |
| 52 | + files1=$cur/$rootfs/linux_$arch/rootfs/; cd $files1 |
| 53 | + tar -zcf $pkgs/nginx-$VERSION-$arch.tar.gz nginx |
| 54 | + ls -lhS $pkgs/*.tar.gz |
| 55 | + done; |
| 56 | +} |
| 57 | + |
| 58 | +# REPO1=registry-1.docker.io |
| 59 | +REPO1=registry.cn-shenzhen.aliyuncs.com |
| 60 | +doUndock |
| 61 | +# wait |
| 62 | + |
| 63 | +# lst.txt |
| 64 | +cd $cur/../../ |
| 65 | +find .github/workflows/.ws/pkgs/ -name *.tar.gz |sort > .github/workflows/.ws/pkgs/_lst.txt |
| 66 | + |
| 67 | +exit 0 |
| 68 | +# headless @ barge in .../.github/workflows |11:32:30 |dev U:1 ?:6 ✗| |
| 69 | +# $ ./undock -h |
| 70 | +# Usage: undock <source> <dist> [flags] |
| 71 | +# Extract contents of a container image in a local folder. More info: https://github.com/crazy-max/undock |
| 72 | +# Arguments: |
| 73 | +# <source> Source image. (eg. alpine:latest) |
| 74 | +# <dist> Dist folder. (eg. ./dist) |
| 75 | +# Flags: |
| 76 | +# -h, --help Show context-sensitive help. |
| 77 | +# --version |
| 78 | +# --log-level="info" Set log level ($LOG_LEVEL). |
| 79 | +# --log-json Enable JSON logging output ($LOG_JSON). |
| 80 | +# --log-caller Add file:line of the caller to log output ($LOG_CALLER). |
| 81 | +# --log-nocolor Disable colorized output ($LOG_NOCOLOR). |
| 82 | +# --cachedir=STRING Set cache path. (eg. ~/.local/share/undock/cache) ($UNDOCK_CACHE_DIR) |
| 83 | +# --platform=STRING Enforce platform for source image. (eg. linux/amd64) |
| 84 | +# --all Extract all architectures if source is a manifest list. |
| 85 | +# --include=INCLUDE,... Include a subset of files/dirs from the source image. |
| 86 | +# --insecure Allow contacting the registry or docker daemon over HTTP, or HTTPS with failed TLS verification. |
| 87 | +# --rm-dist Removes dist folder. |
| 88 | +# --wrap For a manifest list, merge output in dist folder. |
0 commit comments