7 local self=gitit cmd=$1 ; shift
10 local p=${1} x=${2} d D
13 for d in $(find ${D} -name "${p}" -type d) ; do
23 for d in $(find ${D} -name "*.git" -type d) ; do
25 until GIT_DIR=${d} git gc ; do sync ; done
32 for i in $(seq $1 $2) ; do until git svn fetch -r ${i} ; do : ; done ; done
35 local repo=${1} dir=${2}.gitsvn
38 GIT_DIR=${dir} git init --bare
39 GIT_DIR=${dir} git svn init "${repo}" ${@:--s}
43 p=${r##*/} ; p=${p%.git}
44 git ls-remote $r 'refs/heads/*' 'refs/tags/*' | tee lr.$p
48 [ $# = 1 ] && { n=$(basename $1) ; n=${n%.git} ; } || n=$2
50 c="$(pwd)" ; cd "${1}" ; d="$(pwd)" ; cd "${c}"
51 rm -r "${n}"/.git/{objects,refs}
52 ln -s "${d}"/{objects,packed-refs} "${n}"/.git || :
53 cp -a "${d}"/refs "${n}"/.git
56 local d=$(realpath ${GIT_DIR:-.})
60 [ "$PREFIX" ] && d="$PREFIX" || {
65 v=$(git describe --tags $b 2>/dev/null || git show --format=format:%h -s $b)
68 git archive --format=tar --prefix="$d-$v/" $b
73 [ "$h" = "${h#refs/}" ] && h=refs/heads/$h
74 #[ -n "$2" ] && h=refs/$2${h#refs}
78 git ls-remote ${GIT_DIR:-.} ${@:-'refs/*'} | awk '{print $2}' | sed '/\^{}$/d'
81 local shallow="${GIT_DIR:+$GIT_DIR/}shallow"
83 [ -f "$shallow" ] || return
84 $self check_branch_completeness $(cat "$shallow") > "$shallow.grafted"
86 [ -s "$shallow.grafted" ] && { mv "$shallow.grafted" "$shallow" ; r=1 ; } || rm "$shallow.grafted"
89 check_branch_completeness)
91 local shallow="${GIT_DIR:+$GIT_DIR/}shallow"
92 [ -f "$shallow" ] && mv "$shallow" "${shallow}~"
93 for b in ${@:-$($self lsref "refs/*")} ; do
94 git log --format=%h $b &>/dev/null || echo $b
96 [ -f "${shallow}~" ] && mv "${shallow}~" "$shallow"
100 local r=${2:?ref} l d
101 r=$($self refhead $r)
102 [ -n "$GITIT_NAMESPACE" ] && l=refs/$GITIT_NAMESPACE${r#refs} || l=$r
103 if [ "$(git ls-remote . $l)" ] ; then
104 d="--negotiation-tip=$l"
106 d="--depth ${GITIT_DEPTH:-1}"
109 echo git fetch -v $d "$u" "${GITIT_FORCED_FETCH++}$r:$l"
110 git fetch -v $d "$u" "${GITIT_FORCED_FETCH++}$r:$l"
114 local u=${1:?url} h r t i l
116 local shallow="${GIT_DIR:+$GIT_DIR/}shallow"
119 r=$($self refhead $h)
120 [ -n "$GITIT_NAMESPACE" ] && {
121 l=refs/$GITIT_NAMESPACE${r#refs}
122 $self rmref 'refs/tags/*'
123 git push ${GIT_DIR:-.} "refs/$GITIT_NAMESPACE/tags/*:refs/tags/*"
125 t=$(git ls-remote . $l)
127 [ "$t" ] || $self fetch "$u" "$h"
129 while [ -e "$shallow" ] ; do
131 $self check_shallow && break
134 echo git fetch -v --deepen ${GITIT_DEEPEN:-300} --negotiation-tip=$l "$u" "${GITIT_FORCED_FETCH++}$r:$l"
137 git fetch -v --deepen ${GITIT_DEEPEN:-300} --negotiation-tip=$l "$u" "${GITIT_FORCED_FETCH++}$r:$l"
138 [ "$DEBUG" ] && read -p "loop $i"
140 [ -n "$GITIT_NAMESPACE" ] && {
141 git push ${GIT_DIR:-.} "refs/tags/*:refs/$GITIT_NAMESPACE/tags/*"
142 $self rmref 'refs/tags/*'
147 $self lsref 'refs/*/heads/*' | sed 's|refs/\(.*\)/heads/.*|\1|' | uniq
150 git push ${1:?repo} "${GITIT_FORCED_FETCH++}refs/*:refs/${2:?namespace}/*"
153 git fetch -v ${GITIT_DEPTH+--depth $GITIT_DEPTH} ${1:?repo} "${GITIT_FORCED_FETCH++}refs/${2:?namespace}/*:refs/*"
155 fetch_namespace_heads)
157 local n=${2:?namespace}
160 if [ -n "$1" ] ; then
162 for i in $@ ; do s="$s ${GITIT_FORCED_FETCH++}refs/$n/heads/$i:refs/heads/$i" ; done
163 else s="${GITIT_FORCED_FETCH++}refs/$n/heads/*:refs/heads/*"
165 #echo $@ ; echo $u ; echo $n ; echo $s ; read -p '<>'
166 (GIT_DIR=$u git push $u "refs/$n/tags/*:refs/tags/*")
167 git fetch -v ${GITIT_DEPTH+--depth $GITIT_DEPTH} $u $s
168 (GIT_DIR=$u $self rmref "refs/tags/*")
170 fetch_namespace_tags)
171 git fetch -v ${GITIT_DEPTH+--depth $GITIT_DEPTH} ${1:?repo} "${GITIT_FORCED_FETCH++}refs/${2:?namespace}/tags/*:refs/tags/*"
174 git fetch -v ${GITIT_DEPTH+--depth $GITIT_DEPTH} ${1:?repo} "+refs/${2:?namespace}/heads/*:refs/heads/*"
177 local b u=${1:?url} s h
179 for b in ${@:-$($self lsref "refs/heads/*")} ; do s=$($self refhead $b) ; h="$h ${GITIT_FORCED_FETCH++}$s:$s" ; done
185 for r in $($self lsref $@) ; do git push ${GIT_DIR:-.} :$r ; done
188 : ${GITIT_BASE:?} ${GITIT_PUSH_REPO:?}
190 local b=$(realpath $GITIT_BASE)
191 local p=$(pathit tail "$GITIT_BASE" "$d")
193 [ -z "$p" ] && return 1
198 git commit -m "${@:-.}"
199 git push $GITIT_PUSH_REPO "${GITIT_FORCED_PUSH++}HEAD:refs/$p"
200 [ -n "$GITIT_LOCAL_REPO" ] && git push $GITIT_LOCAL_REPO "HEAD:refs/$p"
204 : ${GITIT_BASE:?} ${GITIT_PULL_REPO:?}
206 b=$($self refhead $b)
207 local p=$GITIT_BASE/${b#refs/}
210 git fetch -v ${GITIT_DEPTH:---depth 1} ${GITIT_DEPTH:+--depth $GITIT_DEPTH} "$GITIT_PULL_REPO" $b:$b- &&
213 git push . HEAD:refs/heads/master
220 : ${GITIT_BASE:?} ${GITIT_PULL_REPO:?}
222 local b=$(realpath $GITIT_BASE)
223 local p=$(pathit tail "$GITIT_BASE" "$d")
227 git -C "$d" fetch -v --deepen ${1:-1} "$GITIT_PULL_REPO" "refs/$p:m"
233 ( cd "$d" ; git fetch --depth 1 "$u" refs/${d#*/}:tip && git checkout tip )
235 fetch_regular_to_combo)
238 fetch_combo_to_regular)
244 ns=${2#https://github.com/}
246 GITIT_NAMESPACE="$ns" gitit unshallow "$2" ${3:-master}
250 echo "${self} dup <srcdir>"
258 local S=alpineit R=$APK_HOME
260 [ $# -gt 0 ] && shift
264 : ${APK_HOME:=$(realpath "$1")}
265 : ${APK_REPO_ALPINE:="main community"}
266 : ${APK_SERVER_ALPINE:="http://dl-cdn.alpinelinux.org/alpine"}
267 : ${APK_VERSION_ALPINE:=v3.13}
268 : ${APK_LOCAL_ALPINE:="$APK_HOME/dist/alpine"}
271 distroit gen-db "$1" "dist/*/*/*/*/*"
277 for r in $APK_REPO_ALPINE ; do echo $APK_VERSION_ALPINE/$r ; done
280 #expr " $APK_REPO_ALPINE " : ".* $r " >/dev/null && echo "$APK_VERSION_ALPINE/$r"
281 echo "$APK_VERSION_ALPINE/$r"
288 for r in $($S gen-repo-path) ; do
289 echo "${APK_SERVER_ALPINE#*://}/$r/$APK_ARCH=$APK_LOCAL_ALPINE/$r/$APK_ARCH"
293 download-apk-static|extract-apk-static)
298 $S download-apk-static
299 $S extract-apk-static
301 #$S simfetch alpine-base
302 $S simfetch busybox alpine-baselayout apk-tools alpine-keys
305 #echo sudo $APK_APP_STATIC $($S repo-opt) --allow-untrusted --root "$APK_SYSROOT" --initdb add ${@:-alpine-base}
306 #sudo $APK_APP_STATIC $($S repo-opt) --allow-untrusted --root "$APK_SYSROOT" --initdb add ${@:-alpine-base}
308 echo sudo $($S echo-cmd add) --initdb ${@:-alpine-base} # alpine-baselayout apk-tools alpine-keys
309 sudo $($S echo-cmd add) --initdb ${@:-alpine-base}
317 $self curlit distroit fsit sudoit shit strit
319 local self=apkit SH=${APKIT:-apkit} H=$APK_HOME
320 local cmd=$1 ; shift 2>/dev/null
326 d=$(shit lvpre APK_REPO_)
327 APK_DISTS=$(echo $d | sed 's/APK_REPO_//g')
328 : ${APK_HOME:=$(realpath "$1")}
329 : ${APK_ARCH:=$($self print-arch)}
331 for D in $APK_DISTS ; do
333 p=$(shit ive APK_LOCAL_$D)
334 for r in $(${d}it gen-repo-path) ; do
335 mkdir -pv "$p/$r/$APK_ARCH"
343 [ "$v" ] || echo "APK_ARCH APK_DISTS APK_HOME APK_REPO_ALPINE APK_SERVER_ALPINE APK_VERSION_ALPINE" &&
345 echo "$s=$(shit ive $s)"
349 unset $(shit lvpre APK_)
352 if [ "$APK_ARCH" ] ; then echo "$APK_ARCH"
353 elif [ -x "$APK_APP_STATIC" ] ; then $APK_APP_STATIC --print-arch
359 for d in ${APK_DISTS_ORDER:-$APK_DISTS} ; do echo $(strit lower $d) ; done
363 local d=APK_REPO_$(strit upper $1) r
364 for r in $(shit ive $d); do echo $r ; done
368 for dist in $APK_DISTS ; do
369 d=$(strit lower $dist)
370 D=$(strit upper $dist)
371 s=$(shit ive APK_SERVER_$D)
372 r=$(${d}it gen-repo-path)
374 echo curlit sync "$H/dist/$d/$l/$APK_ARCH" "$s/$l/$APK_ARCH/APKINDEX.tar.gz"
375 (CURLIT_SYNC_DB_IGNORE=1 curlit sync "$H/dist/$d/$l/$APK_ARCH" "$s/$l/$APK_ARCH/APKINDEX.tar.gz")
379 download-apk-static) # dist repo
380 : ${1:?dist} ${2:?repo}
381 local d=$1 p r=$2 s v
382 p=$(${d}it gen-repo-path $r)/$APK_ARCH
383 s=$(shit ive APK_SERVER_$(strit upper $d))
384 v=$(bsdtar -x -O -f "$H/dist/$d/$p/APKINDEX.tar.gz" APKINDEX | sed -n '/P:apk-tools-static/,/^$/s/^V://p')
385 u="$s/$p/apk-tools-static-$v.apk"
386 echo curlit sync "$H/dist/$d/$p" "$u"
387 curlit sync "$H/dist/$d/$p" "$u"
389 extract-apk-static) # dist repo
390 : ${1:?dist} ${2:?repo}
392 p=$(${d}it gen-repo-path $r)/$APK_ARCH
393 if [ -f "$H/dist/$d/$p/APKINDEX.tar.gz" ] ; then
394 v=$(bsdtar -x -O -f "${H}/dist/${d}/${p}/APKINDEX.tar.gz" APKINDEX | sed -n '/P:apk-tools-static/,/^$/s/^V://p')
395 f="$H/dist/$d/$p/apk-tools-static-$v.apk"
397 f="$H/dist/$d/$p"/apk-tools-static-*.apk
399 APK_SYSROOT="$H/sysroot/$d/$(shit ive APK_VERSION_$(strit upper $d))/$APK_ARCH"
400 mkdir -p "$APK_SYSROOT" && ( cd "$APK_SYSROOT" && bsdtar -x -f "$f" sbin/apk.static )
401 APK_APP_STATIC="$APK_SYSROOT/sbin/apk.static"
402 $self cmd add --initdb
411 p=$(${d}it gen-repo-path $r 2>/dev/null)
412 [ "$p" ] && echo "-X $H/dist/$d/$p"
416 for d in $($self list-dist) ; do
417 for r in $(${d}it gen-repo-path) ; do
418 [ "$r" ] && echo "-X $H/dist/$d/$r"
423 cmdrepo|echo-cmdrepo)
424 : ${2:?cmd} ${APK_APP_STATIC:?}
427 [ "$cmd" = "echo-cmdrepo" ] && cmd=echo || cmd=
428 $cmd $APK_APP_STATIC $($self repo-opt $repos) --allow-untrusted -p "$APK_SYSROOT" "$@"
431 : ${1:?cmd} ${APK_APP_STATIC:?}
432 #$APK_APP_STATIC $($self repo-opt) --allow-untrusted -p "$APK_SYSROOT" "$@"
433 [ "$cmd" = "echo-cmd" ] && cmd=echo- || cmd=
434 $self ${cmd}cmdrepo '' "$@"
437 $self cmd search "$@"
441 while read -p '>>> ' r ; do [ "$r" ] && $self cmd info -a $r ; done
443 simfetch) # <pkg ...>
445 $self cmd fetch --simulate -R "$@" | sed 's|^Downloading ||' | sort -u
450 for d in $($self list-dist) ; do
452 for r in $(shit ive APK_REPO_$D) ; do
453 o=$($self cmdrepo $d/$r search -x $1)
455 s=$(shit ive APK_SERVER_$D)
456 echo "$s/$(${d}it gen-repo-path $r)/$APK_ARCH"
464 for p in $(cat "$1") ; do
472 for p in $($self simfetch "$@") ; do
473 l=$($self which-repo ${p%-*-r*})
480 for d in $($self list-dist) ; do
481 read -p "download distro ${d}? " a
483 echo curlit table "$1" $(${d}it gen-dl-hash)
487 distroit check "$1" "$(shift ; [ -z "$1" ] && echo 'cd $''d ; ls dist/*/*/*/*/*' || echo "$@")"
490 distroit whatnew "$1" "$2" 'dist/*/*/*/'"$($self print-arch)"
494 sudo mkdir -p "$APK_SYSROOT/dist"
495 sudo /bin/sh -c "rm $APK_SYSROOT/etc/apk/repositories 2>/dev/null"
496 for d in $($self list-dist) ; do
497 for r in $(${d}it gen-repo-path) ; do
498 sudo /bin/sh -c "echo /dist/$d/$r >> $APK_SYSROOT/etc/apk/repositories"
504 distroit chroot "${1:-$APK_SYSROOT}}"
507 local d=${1:-$APK_SYSROOT}
509 fsit mb "$H/dist" "$d/dist"
512 local s=$(sudoit init)
519 local d=${1:-$APK_SYSROOT}
523 echo "$SH setup <dir>"
524 echo "$SH state | unstate | print-arch"
525 echo "$SH update-index"
526 echo "$SH init [ alpine-baselayout apk-tools alpine-keys ]"
527 echo "$SH download-apk-static | extract-apk-static <dist> <repo>"
529 echo "$SH search | simfetch | which-repo <pkg ...>"
530 echo "$SH gen-dl <pkg ...>"
531 echo "$SH dlt <file>"
538 local S=luautil c=$1 e=0
539 [[ $# -gt 0 ]] && shift
541 cat) # <file> <block_size> <offset> [block_count]
542 local s="(function(f,b,o,n) f = assert(io.open(f)) b = assert(tonumber(b)) o = assert(tonumber(o)) n = n and assert(tonumber(n)) assert(f:seek('set',o)) local c = 0 repeat local d = f:read(b) if d then io.write(d) io.flush() else break end c = c + 1 until n and c >= n f:close() end)(table.unpack(arg))"
545 http-headers) # <sep> <file> <header ...>
546 local s="(function(s,h,...) h=io.open(h) local t={} repeat local l,a,v=h:read('*l') if not l then break end a,v=l:match '^([^:]-): (.-)\r$' if a then t[a:lower()]=v end until nil h:close() local r,f,i={},{...} for i=1,#f do local s=string.lower(f[i]) r[#r+1]=t[s] or '' end io.write(table.concat(r,s)) io.flush() end)(table.unpack(arg))"
550 (( e )) && lua5.3 -e "${s}" /dev/null "$@"
558 [ $# -gt 0 ] && shift
561 local min_size block_size save_dir url base_file base_size temp_size start block new_base_size base_size_align r
564 base_file=${3:-${2##*/}}
565 [ ! -d "${save_dir}" ] && return 1
566 min_size=${CURLIT_TEMP_MS:-$(( 300*1024*1024 ))}
567 block_size=${CURLIT_TEMP_BS:-$(( 4*1024 ))}
568 [ ${min_size} -lt ${block_size} ] && return 2
569 [ -f "${save_dir}/${base_file}" ] && base_size=$(stat -L -c %s -- "${save_dir}/${base_file}") || base_size=0
570 base_size_align=$(( ${base_size} % ${block_size} ))
572 temp_size=$(stat -L -c %s -- "${base_file}.${base_size}" 2>/dev/null) || temp_size=0
573 if [ ${temp_size} -gt ${min_size} ] ; then
575 if [ ${base_size_align} -gt 0 ] ; then
576 n=$(( ${block_size}-${base_size_align} ))
577 luautil cat "${base_file}.${base_size}" $n 0 1 >> "${save_dir}/${base_file}" || return 3
580 block=$(( (${temp_size}-${n}) / ${block_size} ))
581 if [ $block -gt 0 ] ; then
582 if [ $n -gt 0 ] ; then
583 luautil cat "${base_file}.${base_size}" $block_size $n $block >> "${save_dir}/${base_file}" || return 4
585 luautil cat "${base_file}.${base_size}" $block_size 0 $block >> "${save_dir}/${base_file}" || return 5
588 n=$(( ${n} + (${block}*${block_size}) ))
589 new_base_size=$(( ${base_size} + ${n} ))
590 luautil cat "${base_file}.${base_size}" $block_size $n > "${base_file}.${new_base_size}" && rm -- "${base_file}.${base_size}" || return 6
591 base_size=$new_base_size
592 temp_size=$(( ${temp_size} - ${n} ))
593 if [ -n "${DLI_HOOK_SYNC}" ] ; then echo "DLI_HOOK_SYNC: $DLI_HOOK_SYNC" ; $DLI_HOOK_SYNC ; fi
594 [ -x dlihook ] && ./dlihook
596 start=$(( ${base_size} + ${temp_size} ))
597 echo "$base_file" 1>&2
598 local pre=$(date '+%s');
599 curl -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Falkon/3.1.0 Chrome/69.0.3497.128 Safari/537.36' -L -k -N -Y 100 -y 13 -C ${start} ${CURLIT_OPTS} -D "${base_file}.h" "${url}" >> "${base_file}.${base_size}"
601 read -t 1 -p "curl return: $r"
612 local post=$(date '+%s')
613 [ $(( $post - $pre )) -le 3 ] && read -t 3 -p 'too fast, slowing down '
615 #[ -s "${base_file}.${base_size}" ] || { rm -- "${base_file}.${base_size}" ; return 7 ; }
617 local status=$(sed -n -- '/^HTTP/p' "${base_file}.h" | tail -1)
618 if [ -n "${status}" ] ; then
621 fs=$(stat -L -c %s -- "${base_file}.${base_size}")
624 cl=$(luautil http-headers "" "${base_file}.h" "Content-Length") ;;
626 cl=$(luautil http-headers "" "${base_file}.h" "Content-Range") ; cl=${cl#*/}
627 fs=$(( ${fs} + ${base_size} ))
635 lu=$(luautil http-headers "" "${base_file}.h" "Last-Modified")
638 echo "cl:$cl fs:$fs" 1>&2
639 if [ $r = 0 -a "$cl" = "$fs" ] ; then
640 if [ $base_size = 0 ] ; then
641 mv -- "${base_file}.0" "${save_dir}/${base_file}" || return 8
643 echo "cat \"${base_file}.${base_size}\" >> \"${save_dir}/${base_file}\"" 1>&2
644 echo "rm -- \"${base_file}.${base_size}\"" 1>&2
645 cat -- "${base_file}.${base_size}" >> "${save_dir}/${base_file}" && rm -- "${base_file}.${base_size}" || return 9
647 [ -n "$lu" ] && touch -d "$lu" -- "$save_dir/$base_file"
648 echo "$save_dir/$base_file $fs $(date ${lu:+-d "$lu"} '+%s')"
652 local u=${1:?} sl=${2:-0} dl=${3:-0} sr dr r f=$(mktemp XXXXX) s c=0
653 until curl -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Falkon/3.1.0 Chrome/69.0.3497.128 Safari/537.36' -kILs --connect-timeout 30 "$u" > "${f}" ; do
655 [ "$CURLIT_ATTR_RETRY" ] && [ $c -ge $CURLIT_ATTR_RETRY ] && { rm -- "$f" ; return 1 ; }
657 s=$(luautil http-headers "|" "${f}" "Content-Length" "Last-Modified")
658 IFS="|" ; set -- $s ; unset IFS
659 sr=$1 ; [ -z "$sr" ] && sr=0
660 dr=$2 ; [ -z "$dr" ] && dr=0 || dr=$(date -d "$dr" "+%s")
661 if [ "$sl" = "$sr" -a "$dl" = "$dr" ] ; then r=0 ; s='='
662 elif [ "$sl" = "$sr" ] ; then [ "$dl" -lt "$dr" ] && { r=2 ; s='T' ; } || { r=3 ; s='t' ; }
663 elif [ "$dl" = "$dr" ] ; then [ "$sl" -lt "$sr" ] && { r=4 ; s='S' ; } || { r=5 ; s='s' ; }
666 [ -e "$f" ] && rm -- "$f"
673 for u in $(cat $1) ; do
675 echo "$u" > curlit.attr
676 set -- $(sed -n /${f//./\\.}/p curlit.ok)
678 set -- $(curlit attr $u $2 $3)
679 [ "$3" != '=' ] && echo $f $@ $u
683 local d="${1:?dir}" f="${2:?file}" s r
685 [ -n "$NOPATH" ] && p=$f || p="$d/$f"
687 s=$(sed -n -- "\.${p//./\\.}.p" "${CURLIT_EXIST:-curlit.ok}" "${CURLIT_ERROR:-curlit.err}" 2>/dev/null | while read s ; do
689 if [ "${1##*/}" = "$f" ] ; then shift ; echo $* ; break ; fi
691 [ -n "$s" ] && { r=0 ; echo "$s" ; } || r=1
695 local d="${1:?}" f="${2:?}" r
698 echo $(stat -L -c "%s %Y" -- "$d/$f")
703 local d="${1:?}" f="${2:?}" s
704 [ -z "$CURLIT_SYNC_DB_IGNORE" ] && s=$($self exist-db "$d" "$f") || s=$($self exist-local "$d" "$f") && echo $s
707 local d="${1:?}" u="${2:?}" f="$3" s r sync
708 [ -z "$f" ] && f=${u##*/}
709 s=$($self exist "$d" "$f")
712 if [ "$CURLIT_SYNC_REMOTE" = 1 ] ; then
713 s=$($self attr "$u" $*)
720 read -p "(local = remote) size, sync time? " r
721 if [ "$r" = y ] ; then
722 [ -f "$d/$f" ] && touch -d @$2 "$d/$f"
723 sed -i "/^$f/d" "${CURLIT_EXIST:-curlit.ok}" 2>/dev/null
724 echo "$f $1 $2" >> "${CURLIT_EXIST:-curlit.ok}"
727 4|5) echo "$r (local = remote) date" ; sync=1 ;;
731 if [ $r = 0 ] ; then return
735 if [ "$sync" = 1 ] ; then
737 [ -n "$CURLIT_SYNC_DRYRUN" ] && return
738 [ -n "$CURLIT_SYNC_INTERACTIVE" ] && {
740 [ "$r" != y ] && return
742 [ -f "$d/$f" ] && mv -f -- "$d/$f" "$d/$f".old
743 if s=$($self temp "$d" "$u" "$f") ; then
744 [ -z "$CURLIT_SYNC_DB_IGNORE" ] && {
745 sed -i "/^$f/d" "${CURLIT_EXIST:-curlit.ok}" 2>/dev/null
746 echo $s >> "${CURLIT_EXIST:-curlit.ok}"
749 [ -f "$d/$f".old ] && rm -- "$d/$f".old
751 [ -z "$CURLIT_SYNC_DB_IGNORE" ] && {
752 echo $f 0 0 >> "${CURLIT_ERROR:-curlit.err}"
762 p=${t%=*} ; d=${t#*=}
763 [ -d "${d}" ] || mkdir -p "$d"
764 for u in $(grep -v '^#' $l | grep "$p") ; do
765 [ -n "$HOOK" ] && $HOOK "$d" "$u"
766 if [ -n "$CURLIT_TABLE_DRYRUN" ] ; then
771 [ -f pause ] && read -p 'pause...'
776 while : ; do curl -kLN --connect-timeout 10 --limit-rate 40000 -Y 300 -y 5 "$1" > /dev/null ; done
779 echo "CURLIT_TEMP_MS=$((300*1024*1024)) CURLIT_TEMP_BS=4096 CURLIT_OPTS='--limit-rate 33000'"
780 echo "$self temp <dir> <url> [alt]"
781 echo "$self attr <url> [size] [time]"
782 echo "CURLIT_SYNC_REMOTE=1 CURLIT_SYNC_DRYRUN=1 CURLIT_SYNC_INTERACTIVE=1 CURLIT_SYNC_DB_IGNORE=1"
783 echo "$self sync <dir> <url> [alt]"
784 echo "CURLIT_TABLE_DRYRUN=1"
785 echo "$self table <file> <patern=dir ...>"
786 echo "$self null <url>"
792 $self curlit distroit shit sudoit pathit setit
795 local S=pacmanit SH=${PACMANIT:-pacmanit} R=$PACMAN_HOME
797 [ $# -gt 0 ] && shift
802 PACMAN_DISTS=${PACMAN_DISTS_ORDER^^}
803 : ${PACMAN_HOME:=$(realpath "$1")}
804 : ${PACMAN_ARCH:=$(uname -m)}
805 for d in $PACMAN_DISTS ; do
806 mkdir -p "$R"/dist/${d,,}/{repo,sync}
808 echo "Server = ${!s}" > "$R"/dist/${d,,}/mirror-list
810 [ "$PACMAN_DB" ] && mkdir -p "$PACMAN_DB"/{gnupg,local,pkg,sync,conf}
811 [ -e "$PACMAN_DB/conf/pacman.conf" ] || $S gen-conf
815 l=$(shit lvpre PACMAN_)
816 for v in $l ; do echo "$v='$(shit ive $v)'" ; done
823 for d in ${PACMAN_DISTS_ORDER:-$PACMAN_DISTS} ; do
828 echo "Include = $R/dist/${d,,}/mirror-list"
834 expac '%n %N %G' | sed -n '/ $/s/ $//p'
837 for p in $(pacman $PACMAN_OPTS -Qeq 2>/dev/null) ; do
838 s=$(pacman $PACMAN_OPTS -Qi $p 2>/dev/null | grep -e '^Groups *: None' -e '^Required By *: None')
839 case $s in Groups*Required*) c=a ;; Groups*) c=g ;; Required*) c=r ;; '') c=0 ;; esac
840 if [ $c = a -o $c = r ] ; then echo "$c $p" ; fi
845 { cat <<"#PACMAN.CONF#"
849 # See the pacman.conf(5) manpage for option and repository directives
855 # The following paths are commented out with their default values listed.
856 # If you wish to use different paths, uncomment and update the paths.
858 DBPath = @PACMAN_DIR@/
859 CacheDir = @PACMAN_DIR@/pkg/
860 LogFile = @PACMAN_DIR@/pacman.log
861 GPGDir = @PACMAN_DIR@/gnupg/
862 HookDir = @PACMAN_DIR@/hooks/
863 HoldPkg = pacman glibc
864 #XferCommand = /usr/bin/curl -C - -f %u > %o
865 #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
866 #CleanMethod = KeepInstalled
870 # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
884 # By default, pacman accepts packages signed by keys that its local keyring
885 # trusts (see pacman-key and its man page), as well as unsigned packages.
886 #SigLevel = Required DatabaseOptional
888 LocalFileSigLevel = Optional
889 #RemoteFileSigLevel = Required
891 # NOTE: You must run `pacman-key --init` before first using pacman; the local
892 # keyring can then be populated with the keys of all official Cromnix
893 # packagers with `pacman-key --populate archlinux cromnix`.
897 # - can be defined here or included from another file
898 # - pacman will search repositories in the order defined here
899 # - local/custom mirrors can be added here or in separate files
900 # - repositories listed first will take precedence when packages
901 # have identical names, regardless of version number
902 # - URLs will have $repo replaced by the name of the current repo
903 # - URLs will have $arch replaced by the name of the architecture
905 # Repository entries are of the format:
907 # Server = ServerName
908 # Include = IncludePath
910 # The header [repo-name] is crucial - it must be present and
911 # uncommented to enable the repo.
915 } | sed "s|@PACMAN_DIR@|$PACMAN_DB|g" > "$PACMAN_DB/conf/pacman.conf"
916 $S gen-repo-list >> "$PACMAN_DB/conf/pacman.conf"
919 local d r u l dist repo
920 for d in ${@:-${PACMAN_DISTS_ORDER:-$PACMAN_DISTS}} ; do
921 #read -p "sync ${d,,} repo? " r
924 [ "$dist" = "$d" ] && repo= || repo=${d#*/}
925 u=$(shit ive PACMAN_SERVER_${dist^^})
926 for r in ${repo:-$(shit ive PACMAN_REPO_${dist^^})} ; do
927 l="$(repo=$r arch=$PACMAN_ARCH eval echo $u)/$r.db"
928 #echo curlit sync "$R/dist/${d,,}/sync" "$l"
929 (CURLIT_SYNC_DB_IGNORE=1 curlit sync "${R}/dist/$dist/sync" "$l")
935 pacman --config "$PACMAN_DB"/conf/pacman.conf "$@"
938 expac -S -l ' ' --config "$PACMAN_DB"/conf/pacman.conf "$@"
942 #local f="$(realpath "$1").dlt"
945 pacman --config "$PACMAN_DB"/conf/pacman.conf -Sp $(sed -e '/^#/d;s/^. //' $@) | sort -u > "$f" || return 1
946 grep -Fi systemd "$f" 1>&2
950 distroit gen-db "$1" "dist/*/repo/*/*"
953 local d r u l sd sr alias
956 if [ $sd = $d ] ; then
957 sr=PACMAN_REPO_${d^^}
962 u=PACMAN_SERVER_${sd^^}
965 l="$(repo=$r arch=$PACMAN_ARCH eval echo $u)"
967 alias=$(shit ive PACMAN_REPO_${sd^^}_ALIAS)
968 echo "$l=dist/${alias:-${sd,,}}/repo/$r"
973 #$S expac '%n %N' | sed -n '/ $/ s| $||p'
974 $S expac '%n %N' "$@" | awk '$2 == "" { print $1 }'
977 $S expac '%r/%n %P' | sed "/ $/d"
979 gen_provide_from_dlt)
981 for p in $($S expac -1 "%P" $($S x_name "$1")) ; do echo $p ; done | sort -u
983 query_pkg_that_provide) # <provide ...>
985 [ "$PROVIDE_DB" ] && f="$PROVIDE_DB" || {
986 f=$(mktemp XXXXX.provide_all)
987 $S gen_provide_all > "$f"
991 echo $p $(for s in $(sed -n -e "/ $p[ =<>]/p ; / $p"'$/p' "$f" | awk '{print $1}') ; do echo ${s#*/} ; done | sort -u)
993 [ "$gen" ] && rm "$f"
998 [ -f "$t".provide.all ] || $S gen_provide_all > "$t".provide.all
999 PROVIDE_DB="$t".provide.all $S query_pkg_that_provide $($S gen_provide_from_dlt "$t".dlt) > "$t".rev_provide.dlt
1000 sed -e "/^[^ ]\+ [^ ]\+$/d" "$t".rev_provide.dlt > "$t".rev_provide.dlt3
1001 $S tag_selected_pkg_that_provide "$t" "$t".rev_provide.dlt3 | tee "$t".rev_provide.dlt3.tag
1005 local f=$(realpath "$1")
1008 cd "$R"/tmp || return 1
1009 curlit table "$f" $($S gen-dl-hash ${@:-$PACMAN_DISTS})
1012 outdate0) # <tag> <dir>
1014 local a=$(mktemp XXXXX) b=$(mktemp XXXXX)
1015 (cd "$2" ; ls dist/*/repo/*/*) > "$a"
1016 (CURLIT_SYNC_DRYRUN=1 CURLIT_TABLE_DRYRUN=1 $S dlt "$1".dlt) > "$b"
1017 setit lua_fa-fb "$a" "$b"
1020 outdate) # <tag> <dir>
1023 o=$(cd "$2" ; ls dist/*/repo/*/*)
1024 n=$(CURLIT_SYNC_DRYRUN=1 CURLIT_TABLE_DRYRUN=1 $S dlt "$1".dlt)
1027 purge_outdate) # <tag> <dir>
1030 a=$($S outdate "$1" "$2")
1031 [ "$a" ] || { echo up to date ; return ; }
1032 n=$(cd "$2" ; ls outdate*.tzs | sort -n | tail -1)
1039 (cd "$2" ; tar c $a) | zstd -19 > "$2"/outdate${n}.tzs
1043 local d="${1:-$PACMAN_HOME}"
1044 [ -n "$1" ] && shift
1045 distroit check "$d" "$(if [ -z "$1" ] ; then echo 'ls dist/*/repo/*/*' ; else echo "$@" ; fi)"
1050 distroit cp "$R" "$d" "$([ -z "$1" ] && echo 'cd $''PACMAN_HOME ; ls dist/*/repo/*/*' || echo "$@")"
1054 [ -f "$2".dlt ] || $S gen-dl "$2"
1055 distroit whatnew "$1" "$2".dlt $(shift 2 ; $S gen-dl-hash ${@:-$PACMAN_DISTS})
1059 f=$($S whatnew "$1" "$2")
1063 #[ -s "$f" ] || { cat "$t" ; echo ; awk '{print $1}' "$s.cached" ; } > "$t.snap"
1067 [ "$*" ] && pathit cat $@ | sed '/^[ \t]*$/d' || echo "###"
1069 awk '{print $1}' "$s.cached"
1074 cat "$1" | while read l ; do
1079 echo "$p" $(curlit attr "$u" $(curlit exist-db "$d" "$f"))
1084 local repo r db wd=$(pwd) distdir=$(realpath "$1") pl=$(realpath "$2")
1085 repo=$(distroit pkg-x-path "$pl" | sed 's|/[^/]\+$||' | sort -u)
1089 ( cd "$distdir/$r" ; repo-add "$wd/$db.db.tar.gz" $(distroit pkg-x-path "$pl" | grep -F -- $r | sed "s|$r/||") )
1096 for d in $PACMAN_DISTS_ORDER ; do
1097 r=$(eval echo \$PACMAN_REPO_${d^^})
1099 for l in $r ; do m="$m:$p/dist/$d/repo/$l" ; done ||
1100 for l in $(echo $p/dist/$d/repo/*) ; do m="$m:$l" ; done
1104 fsit mo overlay "$p" -t overlay -o lowerdir=$m
1109 l=$(echo $($S x_name "$1"))
1111 while read -p '>>> ' r ; do
1113 $S pacman -Si $r || {
1114 echo group: ; $S pacman -Sg $r ||
1115 echo search: ; $S pacman -Ssq $r
1117 a=$($S expac -1 '%N' $r)
1121 setit in l $p && echo $p
1129 expac -S --readone -l ' ' --config "$PACMAN_DB"/conf/pacman.conf "%n %o" $@
1132 $S query_optdep_1 $@ | sed '/ $/d'
1135 $S query_optdep_1 $@ | sed -e '/ $/d' -e 's| .*$||'
1138 local p s n=500 i=0 ni nt
1143 s=$($S x_name "$1.dlt" | sed -n $ni,$nt"p")
1145 $S query_optdep_3 $s
1151 for l in $(cat $@) ; do l=${l##*/} ; l=${l%-*} ; n=${l%-*-*} v=${l#$n-} ; echo $n $v ; done
1155 $S x_name_ver "$1" | sed 's| .*||'
1159 $S gen-dl "$1" "$2"/pkg/* "$2"/opt/* || return 1
1160 opt=$($S query_optdep_dlt "$1")
1161 #unq=$(for p in $(sed -e '/^#/d' -e 's/ .*//' "$2"/opt/*) ; do echo $p ; done | sort -u)
1162 unq=$(awk '{print $1}' "$2"/opt/* | sed '/^#/d')
1167 rewhole) # <tag> <theme dir>
1168 local po lpo p ign opt r
1169 [ -f "$2"/opt/all ] && {
1170 read -p "$2/opt/all exists, delete? " r
1171 [ "$r" = y ] && rm "$2"/opt/all "$1".subs
1174 ln -s "$2"/opt/all "$1".opt
1175 #ign=$(sed 's| .*$||' "$2"/ignore/*)
1176 ign=$(awk '{print $1}' "$2"/ignore/*)
1185 echo "lpo: $(echo $lpo)"
1186 read -p "po: $(echo $po)"
1187 [ "$po" -a "$po" != "$lpo" ] || { [ "$po" ] && echo $po > "$1".unsolve ; break ; }
1189 SORTED=1 setit in ign $p && continue
1191 for opt in $($S expac -1 '%o' $p) ; do
1192 SORTED=1 setit in ign $opt && {
1193 #read -p "ignore $opt from $p"
1194 local s=$(sed -n -e "/^$opt""$""/p" -e "/^$opt /p" "$2"/ignore/*)
1195 echo $p $s >> "$1".subs
1197 [ "$s" ] && { l="$l $s" ; : read -p "subs: [$l ] for $opt" ; }
1201 echo $p$l | tee -a "$2"/opt/all
1205 $S nvs "$1".dlt | sort -n | tee "$1".nvs
1206 CURLIT_SYNC_DRYRUN=1 CURLIT_TABLE_DRYRUN=1 $S dlt "$1".dlt > "$1".rlist
1209 reverse_depend_package|rdp)
1211 local pkg=$($S x_name "$f")
1213 read -p "---$pkg---"
1217 [ "$r" ] || continue
1218 for p in $($S expac -l ' ' -1 '%N' $r) ; do
1221 #expr "$pkg" ":" ".* $p " &>/dev/null && echo $p
1222 setit in pkg $p && echo $p
1228 $S expac -1 '%k %n %v %m' $($S x_name "$1")
1230 tag_selected_pkg_that_provide) # <tag> <file generated by query_provide>
1232 local pl=$($S x_name "$1".dlt) p l pro s
1233 cat "$2" | while read l ; do
1235 pro=${l%% *} ; # echo $pro : ${l#$pro}
1236 for p in ${l#$pro} ; do
1237 setit in pl $p && s="$s <"$p">" || s="$s $p"
1242 query_seed_pkg) # <tag> <*pkg>
1245 install_create_dir|install01)
1246 [ $# -gt 0 ] && eval $(shit arg $@)
1248 : oblog -t "Check for needed directory"
1250 for d in dev/{pts,shm} var/cache/pacman/pkg var/lib/pacman var/log dev run etc etc/pacman.d ; do
1251 if ! [ -d "$NEWROOT/$d" ]; then
1252 : oblog -w "Create $NEWROOT/$d directory"
1253 sudo mkdir -m 0755 -p "$NEWROOT/$d" || return 1
1255 : oblog "$NEWROOT/$d directory already exist"
1258 for d in sys proc ; do
1259 if ! [ -d "$NEWROOT/$d" ] ; then
1260 : oblog -w "Create $NEWROOT/$d directory"
1261 sudo mkdir -m 0555 -p "$NEWROOT"/{sys,proc} || return 1
1263 : oblog "$NEWROOT/$d directory already exist"
1266 if ! [ -d "$NEWROOT/tmp" ]; then
1267 : oblog -w "Create $NEWROOT/tmp directory"
1268 sudo mkdir -m 1777 -p "$NEWROOT"/tmp || return 1
1270 : oblog "$NEWROOT/tmp directory already exist"
1273 install_copy_file|install02)
1274 [ $# -gt 0 ] && eval $(shit arg $@)
1277 if [ ! -e "$NEWROOT/etc/resolv.conf" ]; then
1278 sudo cp /etc/resolv.conf "$NEWROOT/etc/resolv.conf" || { return 1 ; die " Impossible to copy the file resolv.conf" "clean_install" ; }
1280 : oblog "File resolv.conf already exists"
1283 install_mount_filesystem|install03)
1284 [ -n "$*" ] && eval $(shit arg $@)
1285 : ${NEWROOT:?}${CACHEDIR:?}${SYNCDB:? }
1287 fsit mpfs "$NEWROOT" &&
1288 fsit mb "$CACHEDIR" $NEWROOT/var/cache/pacman/pkg &&
1289 fsit mb "$SYNCDB" $NEWROOT/var/lib/pacman/sync
1291 install_package|install04)
1292 [ -n "$*" ] && eval $(shit arg $@)
1293 : ${NEWROOT:?}${PACMANCONF:?}${CACHEDIR:?}${PACKAGELIST:?}
1295 local item item_base tidy_loop rc
1296 local installed list list_base result result_base pacman_list aur_list
1298 if [ ! -e $PACKAGELIST/pkg/base ] ; then
1299 : die "The file named base at $GENERAL_DIR/$CONFIG_DIR/package_list/ must exist, please create one." "clean_install"
1300 echo "The file named base at $PACKAGELIST must exist, please create one."
1304 # bash is the first package installed by pacman
1305 # if $NEWROOT/usr/bin/bash doesn't exist means that is the first pass
1306 # into the function install_system; so install base package first
1307 if ! [ -x "$NEWROOT/usr/bin/bash" ] ; then
1308 read -p "installing base"
1309 sudo pacman -r "$NEWROOT" -S --config "$PACMANCONF" --cachedir "$CACHEDIR" ${AUTO:+--noconfirm} --dbpath "$NEWROOT/var/lib/pacman" $(grep -h -v ^# $PACKAGELIST/pkg/base) || { return 1 ; die " Failed to install base system" "clean_install" ; }
1312 installed=$(echo $(pacman -r "$NEWROOT" -Qsq --config "$PACMANCONF"))
1313 read -p "installed : $installed"
1314 list_base=$(grep -h -v ^# $PACKAGELIST/pkg/base | sed "/^\s*$/d" | sort -du)
1315 result_base=$(setit x-y list_base installed)
1316 read -p "result_base: $result_base"
1318 if [ "$result_base" ]; then
1319 : oblog -w "Install missing base packages"
1320 sudo pacman -S -r "$NEWROOT" --config "$PACMANCONF" --cachedir "$CACHEDIR" ${AUTO:+--noconfirm} --dbpath "$NEWROOT/var/lib/pacman" $result_base 2>/dev/null || { return 1 ; die " Failed to install packages" "clean_install" 1 ; }
1323 : oblog "Nothing to do for base system"
1326 # check installed packages
1328 : oblog -t "Check installed packages, this may take time..."
1330 installed=$(echo $(pacman -r "$NEWROOT" -Qsq --config "$PACMANCONF"))
1331 #list=$(grep -h -v ^# $PACKAGELIST/pkg/* $PACKAGELIST/opt/* | sed "/^\s*$/d" | sort -du)
1332 list=$(for p in $(sed '/^#/d' $PACKAGELIST/pkg/* $PACKAGELIST/opt/*) ; do echo $p ; done | sort -du)
1333 result=$(setit x-y list installed)
1334 read -p "result: $(echo $result)"
1336 #install missing package if necessary
1337 if [ "$result" ] ; then
1339 for tidy_loop in $result ; do
1340 choose_installer "$tidy_loop"
1345 pacman_list="$pacman_list $tidy_loop"
1349 aur_list+="$aur_list $tidy_loop"
1353 die "$tidy_loop can not be installed by pacman or AUR helper" "clean_install"
1359 if [ "$pacman_list" ] ; then
1360 read -p "pacman_list : $(echo $pacman_list)"
1361 : oblog -w "Install missing packages coming from repo define in pacman.conf"
1362 sudo pacman -r "$NEWROOT" -S --config "$PACMANCONF" --cachedir "$CACHEDIR" ${AUTO:+--noconfirm} --dbpath "$NEWROOT/var/lib/pacman" $pacman_list || { return 1 ; die " Failed to install packages with pacman" "clean_install" ; }
1364 if [ "$aur_list" ]; then
1365 read -p "aur_list : $aur_list"
1366 oblog -w "Install missing packages coming from AUR"
1368 for tidy_loop in ${aur_list[@]}; do
1369 aur_install "$tidy_loop"
1373 : oblog "All packages are already installed, nothing to do."
1376 unset item item_base tidy_loop installed list list_base result result_base pacman_list aur_list
1378 install_copy_rootfs|install05)
1379 [ -n "$*" ] && eval $(shit arg $@)
1380 : ${NEWROOT:?}${ROOTFS:?}
1381 : oblog -t "Copying configuration files in ${NEWROOT}"
1382 sudo cp -avf "$ROOTFS"/* "$NEWROOT" || { return 5 ; die " Impossible to copy files" "clean_install" ; }
1384 install_set_root_user|install06)
1385 [ -n "$*" ] && eval $(shit arg $@)
1387 local s=$(sudoit init)
1389 pass_exist=$(sudo grep "root" $NEWROOT/etc/shadow | awk -F':' '{print $2}')
1391 if sudo grep "root::" $NEWROOT/etc/shadow ; then
1392 : oblog -t "Create root user on $NEWROOT"
1393 echo "Chg root user shell to /bin/sh"
1394 sudo usermod -R "$NEWROOT" -s /bin/sh root
1397 sudo mkdir -p -m 0700 "$NEWROOT/root"
1398 if [ -z "$pass_exist" -o "$force" = 1 ]; then
1399 distroit chroot_passwd "$NEWROOT" "root" toor || { return 6 ; die "unable to set the root password" "clean_install" ; }
1402 install_set_hostname|install07)
1403 [ -n "$*" ] && eval $(shit arg $@)
1404 : ${NEWROOT:?}${HOSTNAME:?}
1406 if [ "$HOSTNAME" != "" ]; then
1407 sudo sed -i 's/ .*$//' "$NEWROOT"/etc/hosts
1410 #echo "$HOSTNAME" > "$NEWROOT"/etc/hostname
1411 sudo /bin/sh -c "echo $HOSTNAME > $NEWROOT/etc/hostname"
1412 sudo /bin/sh -c "echo 127.0.0.1 localhost.localdomain localhost $HOSTNAME > $NEWROOT/etc/hosts"
1413 sudo /bin/sh -c "echo ::1 localhost.localdomain localhost $HOSTNAME >> $NEWROOT/etc/hosts"
1415 #sudo sed -i '/127.0.0.1/s/$/ '$HOSTNAME'/' "$NEWROOT"/etc/hosts
1416 #sudo sed -i '/::1/s/$/ '$HOSTNAME'/' "${NEWROOT}"/etc/hosts
1418 : oblog "hostname was configured successfully"
1420 install_set_locale|install08)
1421 [ -n "$*" ] && eval $(shit arg $@)
1425 # make sure the variable LOCALE is not empty before launch locale-gen
1426 locale="${LOCALE:-en_US.UTF-8}"
1427 sudo sed -i "s:^#${locale}:${locale}:g" "$NEWROOT"/etc/locale.gen
1429 sudo chroot "$NEWROOT" locale-gen
1431 sudo /bin/sh -c "echo LANG=\"$locale\" > \"$NEWROOT\"/etc/locale.conf"
1432 sudo /bin/sh -c "echo LC_COLLATE=C >> \"$NEWROOT\"/etc/locale.conf"
1434 : oblog "Locale was created successfully"
1436 install_set_localetime|install09)
1437 [ -n "$*" ] && eval $(shit arg $@)
1438 : ${NEWROOT:?}${ZONE:=GMT}
1439 local LOCALTIME="/usr/share/zoneinfo"
1440 if [ -n "$SUBZONE" ] ; then
1441 sudo chroot "$NEWROOT" ln -sf $LOCALTIME/$ZONE/$SUBZONE /etc/localtime
1443 sudo chroot "$NEWROOT" ln -sf $LOCALTIME/$ZONE /etc/localtime
1446 : oblog "Localetime was configured successfully"
1448 install_set_user|install10)
1449 [ -n "$*" ] && eval $(shit arg $@)
1450 : ${NEWROOT:?}${NEWUSER:?}
1451 sudo chroot "$NEWROOT" useradd ${USERID+-u $USERID} -m -G "audio,floppy,log,network,rfkill,scanner,storage,optical,power,wheel,video,users" -s /bin/sh "$NEWUSER"
1452 distroit chroot_passwd "$NEWROOT" "$NEWUSER" toor || { return 6 ; die "unable to set the root password" "clean_install" ; }
1453 : oblog "User $NEWUSER was created successfully"
1455 install_set_xkeymap|install11)
1456 [ -n "$*" ] && eval $(shit arg $@)
1457 : ${NEWROOT:?}${XKEYMAP:?}
1458 if [ -e "$NEWROOT/etc/X11/xorg.conf.d/00-keyboard.conf" ]; then
1459 : oblog -t "Define keymap for X server in /etc/X11/xorg.conf.d/00-keyboard.conf"
1460 sudo sed -i 's:Option "XkbLayout"\ .*$:Option "XkbLayout" "'$XKEYMAP'":g' "$NEWROOT"/etc/X11/xorg.conf.d/00-keyboard.conf
1461 : oblog "Desktop xkeymap was configured successfully"
1465 echo "$SH setup <dir>"
1466 echo "$SH gen-pkg > ${R}/pkg.list"
1468 echo "$SH gen-dl <pkg.list> -> pkg.dlt-$(date +%Y%m%d-%H%M)"
1469 echo "$SH gen-dl-db <dest> > ${R}/curlit.ok"
1470 echo "$SH gen-dl-hash <dist ...>"
1471 echo "(CURLIT_SYNC_REMOTE=1 CURLIT_SYNC_INTERACTIVE=1 ${SH} sync-db [dist ...])"
1472 echo "(CURLIT_SYNC_DRYRUN=1 CURLIT_TABLE_DRYRUN=1 ${SH} dlt <pkg.dlt>)"
1473 echo "$SH check [dir] [code block]"
1474 echo "$SH backup <dest> [code block]"
1475 echo "$SH whatnew <dest> <pkg.list>"
1476 echo "$SH snapshot <dest> <pkg.list> -> pkg-{snapshot}.xz"
1477 echo "$SH gen-db <dest> <pkg-{snapshot}.xz>"
1478 echo "$SH mount_cache <dest>"
1486 local S=obarunit R=${OBARUN_HOME}
1488 [ $# -gt 0 ] && shift
1492 PACMAN_REPO_ARCH="core extra community multilib"
1493 : ${PACMAN_SERVER_ARCH:='http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch'}
1494 : ${PACMAN_SERVER_ARCH:='http://mirrors.edge.kernel.org/archlinux/$repo/os/$arch'}
1495 : ${PACMAN_REPO_OBARUN:="obcore obextra obcommunity observice"}
1496 : ${PACMAN_SERVER_OBARUN:='https://repo.obarun.org/$repo'}
1497 PACMAN_DISTS_ORDER="obarun arch"
1498 : ${PACMAN_HOME:=$(realpath "$1")}
1502 local s=$(realpath "$1")
1503 local d=$(realpath "$2")
1504 mkdir -p "$d/iso" &&
1505 sudo mount -r "$s" "$d/iso" &&
1506 mkdir -p "$d/sfs" &&
1507 sudo mount -r "$d/iso/arch/x86_64/airootfs.sfs" "$d/sfs"
1511 sudo umount "$1/sfs" && sudo umount "$1/iso"
1516 local d=$(realpath "$1")
1519 git init --bare $GIT_DIR
1520 git config repo.url 'https://framagit.org/pkg/$repo/$pkg.git'
1521 git config repo.refspec '+refs/heads/master:refs/$repo/$pkg/heads/master +refs/tags/*:refs/$repo/$pkg/tags/*'
1527 local url=$(git config --get repo.url)
1528 local refspec=$(git config --get repo.refspec)
1533 [ -e pause ] && read -p pause
1534 echo git fetch -n "$(eval echo $url)" $(eval echo $refspec)
1535 [ ! -e stop ] && git fetch -n "$(eval echo $url)" $(eval echo $refspec)
1541 local h d p=${1:-~/pool/homin/ob/snapshot}
1542 for i in $(cd "$p" ; git log --oneline | awk '{print $1"="$2}') ; do
1543 h=${i%=*} ; d=${i#*=}
1544 (cd "$p" ; git archive --prefix $d/ $h) | tar x
1555 local S=artixit R=${PACMAN_HOME}
1557 [ $# -gt 0 ] && shift
1561 : ${PACMAN_HOME:=$(realpath "$1")}
1562 : ${PACMAN_REPO_ARCH:="extra community multilib"}
1563 : ${PACMAN_REPO_ARTIX:="system world galaxy lib32"}
1564 : ${PACMAN_SERVER_ARCH:='http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch'}
1565 : ${PACMAN_SERVER_ARTIX:='http://mirror1.artixlinux.org/repos/$repo/os/$arch'}
1566 : ${PACMAN_DISTS_ORDER:="artix arch"}
1567 : ${PACMAN_DB:=$PACMAN_HOME/dist/artix/db}
1570 echo "https://gitea.artixlinux.org/packagesP/pacman/raw/branch/master/trunk/pacman.conf"
1571 echo "https://gitea.artixlinux.org/packagesA/artix-mirrorlist/raw/branch/master/trunk/mirrorlist"
1574 : ${PACMAN_REPO_OBARUN:="obextra obcommunity observice"}
1575 : ${PACMAN_SERVER_OBARUN:='https://repo.obarun.org/$repo'}
1576 PACMAN_DISTS_ORDER="artix obarun arch"
1581 for s in dinit s6 suite66 ; do artixit expac -s '%n' '.*-'$s | sed 's|-'$s'||' ; done | sort -u
1585 local l=$(sed "/^#/d" "$1") s p
1586 for s in dinit s6 suite66 ; do
1601 local now past pre post p pass
1602 pass=$(sudoit init 1) || return 1
1605 #until modprobe -r qcserial ; do read -t 1 ; done
1606 until lsmod | grep option > /dev/null || { sudoit refresh $pass ; sudo /bin/sh -c "modprobe option && echo '05c6 9201' >> /sys/bus/usb-serial/drivers/option1/new_id" ; } || read -t 1 ; do : ; done
1611 sudoit refresh $pass
1612 PPPD_LINK=001:005:cyborg-e488:smartfren4g:nodetach:3 sudo -E pppd call smartfren4g ttyUSB2 nodetach unit 8
1616 if [ $(( ${post} - ${pre} )) -lt 1 ] ; then
1617 read -t 1 p && [ "$p" = p ] && read -p 'slowing pause...'
1619 [ -e /run/w/pppd.stop ] && break
1620 [ -e /run/w/pppd.pause ] && read -t 180 -p 'pppd.pause pause...'
1621 sudoit refresh $pass
1622 lsusb ; sudo eject /dev/sr0 ; read -t 1 ; lsusb
1629 local self=transmissionit
1634 : ${1:?}${2:?}${3:?}${4:?}${TRANSMISSIONIT_CMD:?}
1636 $TRANSMISSIONIT_CMD "$1/$3/"*$h* "$2/$3/"
1639 $self cm "$1" "$2" torrents "$3"
1642 $self cm "$1" "$2" resume "$3"
1645 TRANSMISSIONIT_CMD="cp -uv" $self cmt $@ &&
1646 TRANSMISSIONIT_CMD="cp -uv" $self cmr $@
1649 TRANSMISSIONIT_CMD="mv -uv" $self cmt $@ &&
1650 TRANSMISSIONIT_CMD="mv -uv" $self cmr $@
1653 [ -z "$2" ] && return
1655 rm "$1/torrents/"*$h* "$1/resume/"*$h*
1659 while read -p 'hash ' h ; do [ "$h" ] || continue ; $self cp "$1" "$2" $h ; done
1664 read -p 'magnet: ' m
1665 [ -z "$m" ] && continue
1666 m=${m#magnet:\?xt=urn:btih:}
1667 m=${m:0:16} ; m=${m,,}
1669 o=$({ ls "$d"/*$m* || ls "$d"/*/*$m* ; } 2>/dev/null)
1670 [ -n "$o" ] && break
1672 [ -n "$o" ] && echo "$m found" || echo "$m not found"
1677 [ -f "$1/.gitignore" ] || {
1679 cp "$GITIT_BASE"/heads/tmpl/transmission/{.gitignore,settings.json} "$1"
1682 ( export TR_CONFIG_DIR="$c" ; transmission-gtk -g "$TR_CONFIG_DIR" &>/dev/null & )
1685 : ${1:?src}${2:?dst}
1688 t="$2/$(date -r "$f" '+%Y%V')"
1689 [ -d "$t" ] || mkdir -p "$t"
1696 while read -p "> " r ; do
1697 [ "$r" ] || continue
1701 while setit pop i r ; [ "$i" ] ; do
1705 if [ "$s" ] ; then eval "grep -i $h *$s"
1715 [ -d "$d" ] || return
1719 cp "$s"/torrents/$l.torrent "$d/$(stat -c "%Y" "$s/torrents/$l.torrent")-$l.torrent"
1722 cp "$s"/torrents/*.torrent "$d"/torrents &&
1723 cp "$s"/resume/*.resume "$d"/resume
1728 while read -p '> ' r ; do
1729 [ "$r" ] && $self cpt "$1" "$2" $r
1733 transmission-show "$1" | sed -n '/^Name: /s|^Name: ||p'
1736 [ -d "$1/." ] || return
1738 for f in "$1"/* ; do $self st "$f" ; done
1741 [ -d "$1/l" ] || return
1743 for d in $1/?? ; do n=${d##*/} ; $self ld $d/torrents > $1/l/$n ; done
1746 echo "$self cp|mv <srcdir> <destdir> <hash>"
1754 local S=yt c=$1 H=${YT_HOME:-~/yt}
1759 [ $# = 2 ] && o=-country
1761 #~/youtube-dl -v --cookies cookies --no-check-certificate --write-pages --external-downloader curl --geo-bypass$o $2 -j -f best https://www.youtube.com/watch?v=$1 > "$H/$1"
1762 #~/youtube-dl -v --cookies cookies --no-check-certificate --write-pages --external-downloader curl -j -f best https://www.youtube.com/watch?v=$1 > "$H/$1"
1763 #~/youtube-dl -v --no-check-certificate --call-home --external-downloader curl -j -f best --sub-lang en --write-auto-sub https://www.youtube.com/watch?v=$1 > "$H/$1"
1764 ~/youtube-dl -v ${YT_USER:+-u $YT_USER} ${YT_PASS:+-p $YT_PASS} --no-check-certificate --external-downloader curl -j -f best --sub-lang en --write-auto-sub $YT_UP https://www.youtube.com/watch?v=$1 > "$H/$1"
1766 ls -l -- "$H/$1" 1>&2
1768 do [ -e yt.stop -o -n "$2" ] && break
1773 local LUA_INIT="do local topdir = os.getenv('HOME') package.path = topdir..'/lua/?.lua;' .. package.path end"
1775 [ -s "$H/$1" ] || $S up $1
1776 lua5.3 -l yt -e "print(p('$H/$1',${2:-_}))"
1779 local id=${1:?<id>} fmt=${2:-18} URL DIR ALT s r
1780 until ! [ "$s" = 0 -o -z "$s" ] ; do
1781 [ -e yt.stop ] && return
1782 if [ -s "$H/$id" ] ; then
1783 eval $($S list $id $fmt | sed -n "/^URL=/p")
1784 s=$(curlit attr "$URL")
1791 if [ "$s" = 0 -o -z "$s" ] ; then
1792 until $S update-json $id ; do [ -e yt.stop ] && break ; read -t 0.3 ; done
1799 curl -kIL "$($S ls $1 $2 | sed -n '/^URL=/s|^URL="\(.*\)";|\1|p')"
1804 for f in ${@:-18} ; do
1806 until s=$($S list-update $h $f) ; echo "$s" 1>&2 ; [ -n "$s" ] && eval "$s" ; do
1808 [ -e yt.stop ] && return
1809 read -p "return code $r " -t 0.3
1811 7|10) read -p "return code $r " -t 1
1820 local s=$($S ls $1 | sed -n "/^$2 :/p" | sed '/:NA$/d')
1827 [ -s "$H/$1" ] || $S up $1
1828 for i in ${2//,/ } ; do
1830 [ -n "$($S ls $1 | sed -n "/^$i :/p")" ] && {
1831 [ -n "$3" ] && s="$($S ls $1 $i)" || s="$($S lsf $1 $i)"
1833 [ -z "$s" ] && continue
1834 $S dl $1 $i && { ok=$i ; break ; }
1836 [ "$ok" ] && { echo $ok ; return ; }
1843 [ $? = 0 ] || continue
1844 case $v in 22|18) continue ;; esac
1852 local f=$($S min_size $h $@)
1853 [ -z "$f" ] && return 1
1858 YT_LOWER_RES=1 $S dl1080p $1
1872 $S dlo $1 251 140 ||
1876 local f=${1:?} n=${2:-1} h fmt=$3
1877 local cmd=${YT_CMD:-$S dla}
1879 h=$(sed -n "${n}p" "$f")
1880 [ "---" = "${h:0:3}" ] && { [ "$BREAK" ] && break ; read -p 'pause' ; h=${h#---} ; [ -z "$h" ] && break ; }
1881 [ -n "$h" -a "${h:0:1}" != "#" ] &&
1882 if [ -n "$fmt$YT_FMT" ] ; then
1883 (YT_PLO=$n yt dl $h $([ "$YT_FMT" ] && echo $YT_FMT || echo $fmt))
1885 else (YT_PLO=$n $cmd $h)
1888 [ -n "$ONCE" ] && break
1889 [ "$YT_INTER_DELAY" ] && read -t $YT_INTER_DELAY -p "pause $YT_INTER_DELAY seconds"
1896 CURLIT_TEMP_MS=$((1333**3)) BREAK=1 ONCE=${ONCE-1} YT_ALT='' YT_CMD="$S dlau" $S dlpl $f $n
1900 CURLIT_TEMP_MS=$((1333**3)) BREAK=1 xONCE=1 YT_ALT='' YT_CMD=${YT_CMD:-$S dlvi} $S dlpl $1 $2
1903 ~/youtube-dl --no-check-certificate --external-downloader curl --external-downloader-args '-b cookies -k' --geo-bypass -v --cookies cookies --write-description --write-info-json --write-annotations --prefer-free-formats -k -o '%(upload_date)s-%(id)s %(title)s-%(format_note)s-%(filesize)s.%(ext)s' -f 18 https://www.youtube.com/watch?v=${1#https://www.youtube.com/watch?v=}
1906 #~/youtube-dl --sub-lang en --write-auto-sub https://www.youtube.com/watch?v=${1:?}
1907 #~/youtube-dl -v --call-home --skip-download --sub-lang en --write-sub https://www.youtube.com/watch?v=${1:?}
1908 ~/youtube-dl -v --skip-download --sub-lang ${YT_SUB_LANG:-en} --write-sub https://www.youtube.com/watch?v=${1:?}
1912 for s in $(cat "$1") ; do until [ -f *$s* ] ; do yt sub $s ; done ; done
1915 ~/youtube-dl --list-subs https://www.youtube.com/watch?v=${1:?}
1917 rdhd) $S rd $1 "$S hd" ;;
1918 h) sed -i 's|.*/watch?v=\(.\{11\}\).*|\1|' "${1:?}" ;;
1920 ~/youtube-dl --geo-bypass --geo-bypass-country us --retries infinite --fragment-retries infinite --no-overwrites --continue --write-info-json --verbose --no-check-certificate --sub-lang en --write-sub --keep-video $@
1925 until ~/youtube-dl -c -f 248 --fragment-retries infinite --external-downloader curl --external-downloader-args "--connect-timeout 30 -Y 300 -y 19" https://www.youtube.com/watch?v=$h ; do read -t 1 ; done
1928 s) while read -p '> ' c ; do [ -n "$c" ] && yt sub $c ; done
1931 local LUA_INIT="do local topdir = os.getenv('HOME') package.path = topdir..'/lua/?.lua;' .. package.path end"
1934 [ -s "$H/$f" ] || $S up $f
1936 r=$(lua5.3 -l yt -e "min_size('$H/$f')" /dev/null "$@")
1937 [ -n "$r" ] && echo $r || return 1
1940 $S dlo $1 244 135 397 || {
1941 [ "$YT_LOWER_RES" ] &&
1946 local v=$($S min_size $1 136 247 398)
1947 local a=$($S min_size $1 140 251)
1948 local v22=$($S get_size $1 22)
1950 [ "$v" ] && va=$(( ${v#* } + ${a#* } )) || va=$v22
1957 [ "$v22" ] || return 1
1959 [ "$va" -lt "$v22" ] &&
1964 $S dlo $1 299 399 248 137 || {
1965 [ "$YT_LOWER_RES" ] &&
1974 echo $(eval $(yt lu $1 $2 2>/dev/null | sed -n '/^SIZE=/p') ; echo $SIZE)
1980 echo '(cd ; mkdir yt ; curlit temp . https://yt-dl.org/downloads/latest/youtube-dl ; chmod +x youtube-dl)'
1988 local c=$1 ; shift 2>/dev/null
1991 date --date "$*" '+%s'
1994 local now=$($S epoch "$($S)")
1995 local future=$($S epoch "$*")
1996 #echo $now $future $((future-now))
1997 read -t $((future-now)) 2>/dev/null
2000 local now=$(date '+%s')
2001 local pin=$($S epoch "$*")
2002 TIMEIT_CORRECTION=$((pin-now))
2003 echo "TIMEIT_CORRECTION=$TIMEIT_CORRECTION"
2007 if [ -n "$TIMEIT_CORRECTION" ] ; then
2008 t=$(date "+%s") ; t="--date @$((t+TIMEIT_CORRECTION))"
2010 date $t "${c:-+%Y%m%d %T}"
2023 local u=${POD_UNTIL:+$(timeit epoch ${POD_UNTIL})} m f r
2026 m=$(timeit epoch $(timeit))
2029 [ $r -le 0 ] && break
2032 local x='-x 127.0.0.1:7777'
2033 local ua="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Falkon/3.1.0 Chrome/77.0.3865.129 Safari/537.36"
2034 f=$1-$(timeit "+%Y%m%d-%H:%M:%S").pod
2036 #echo curl -L -k -N -Y 1 -y 3 $m --connect-timeout 5 "$2" \> "$f"
2037 curl --http0.9 -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -A "$ua" -L -k -N -Y 1 -y 3 $m --connect-timeout 5 "$2" > "$f"
2039 local s=$(stat -c '%s' "$f")
2040 [ 1000 -gt "$s" ] && { cat "$f" ; rm "$f" ; }
2046 [ -n "$4" ] && c="count=$((4*$4))" ;
2047 dd if="$1" bs=1024 skip=$((4*$2+${3:-0})) $c > v
2051 alias elshintajkt='pod dl Elshinta "http://202.137.4.147:8000/;"'
2052 cri2030(){ [ -z "$1" ] && set -- $(timeit) ; (timeit at "$1 20:30:00" ; POD_UNTIL="$1 21:05:00" pod dl Elshinta "http://202.137.4.147:8000/;") ; }
2053 cri0500(){ [ -z "$1" ] && set -- $(timeit) ; (timeit at "$1 05:00:00" ; POD_UNTIL="$1 05:35:00" pod dl Elshinta "http://202.137.4.147:8000/;") ; }
2063 : ${1:?<dir>} ${2:?<dir>} ${3:?<expr>}
2064 local d=$(realpath "$1")
2065 local D=$(realpath "$2")
2068 (cd "$d" ; tar c $(eval "$@")) | (cd "$D" ; tar x)
2071 : ${1:?<dir>} ${2:?<expr>}
2072 local src=$(realpath "$1")
2074 #eval "(cd \"$src\" ; rm -rf $@)"
2075 (cd "$src" ; rm -rf $(eval "$@"))
2078 : ${1:?<dir>} ${2:?<file>} ${3:?<glob>...}
2079 local d=$(realpath "$1")
2084 s=$(cd "$d" ; _f=${f##*/} eval ls "$p" 2>/dev/null) && break
2085 done && { echo "$s" ; echo "$f" 1>&3 2>/dev/null ; } || echo "$f" 1>&2
2088 : ${1:?<dir>} ${2:?<file>} ${3:?<glob>...}
2089 local dir="$(realpath "$1")"
2090 local file="$(realpath "$2")"
2093 for f in $(cat "$file") ; do
2094 $S locate "$dir" "$f" $@
2098 : ${2:?} : ${3:?<glob>}
2099 local f l=$(realpath "${2%.dlt}")
2100 [ -f "$l.dlt.whatnew" ] && mv "$l.dlt.whatnew" "$l.dlt.whatnew~"
2101 [ -f "$l.dlt.haved" ] && mv "$l.dlt.haved" "$l.dlt.haved~"
2102 distroit locate-in "$1" "$l.dlt" "$3"/'$_f' 2>"$l.dlt.whatnew" 3>"$l.dlt.haved" >"$l.haved"
2103 echo "$l.dlt.whatnew"
2106 local cache=${1:?dir}
2111 for u in $(cat "$fl") ; do
2115 if [ "${u#*$a}" = "$u" ] ; then continue
2118 [ -f "$cache/$f" ] && echo "$f $u" || echo $u 1>&2
2123 [ $match = n ] && echo $u 1>&3
2127 local cache=${1:?dir}
2128 local file=${2:?file}
2129 local p="$file.$(date '+%H%M')"
2131 $S whatnew-c $@ > "$p.cached" 2>"$p.new" 3>"$p.hmm"
2136 local d=$(realpath "$1")
2139 #rm compress.err 2>/dev/null
2140 (cd "$d" ; $S check-archive $(eval "$@")) 2>compress.err
2141 [ ! -s compress.err ] && rm compress.err
2148 *.xz|*.txz) xz -tqq "$f" ;;
2149 *.bz2|*.tbz2) bzip2 -tq "$f" ;;
2150 *.zst|*.tzs) zstd -tqq "$f" ;;
2151 *.apk|*.gz|*.tgz) gzip -tq "$f" ;;
2153 esac || echo "$p/$f" 1>&2 && echo "$p/$f"
2157 : ${1:?<dir>} ${2:?<glob>}
2158 local d="$(realpath "$1")"
2162 for f in $(ls $2) ; do
2163 set -- $(stat -L -c "%n %s %Y" "$f")
2164 [ -n "$NOPATH" ] && echo "${1##*/} $2 $3" || echo $@
2170 for u in $(cat "$1") ; do
2171 echo "$u" > __CHECKING__
2173 s=$(curlit attr "$u" $(curlit exist-db "$f"))
2176 [ $r != 0 ] && echo "$r $3 $u"
2177 [ -f stop ] && break
2182 sed -e '/^#/d' -e '/^$/q' "$1" | sed '/^$/d'
2189 : ${1:?pkg.xz} ${2:?pkg.list} ${3:?pkg.haved}
2190 local t==$(mktemp -u XXXXX)
2191 $S pkg-x-path "$1" > "$t.base"
2192 diff "$t.base" "$3" | grep '^> ' | sed 's|^..||' | sort -u > "$t.new"
2195 { cat "$2" ; echo ; cat "$t.new" ; } | xz -9 > "$p"+$(date '+%Y%m%d').xz
2201 for p in $(sed '/^#/d' "$1"/*) ; do echo $p ; done | sort -u
2204 : ${1:?rootdir}${2:?user}${3:?password}
2205 local root="$1" user="$2" pass="$3"
2206 printf "%b\n" "$pass\n$pass" | sudo -n chroot "$root" passwd "$user"
2209 : ${1:?dir} user=$3 mfs=$4
2210 local newroot=$(realpath "$1") overlay="$2" theroot d p user=$3 mfs=$4
2211 p=$(sudoit init 1) || return 1
2214 [ "$overlay" ] && theroot=$(fsit mov "$newroot" "$overlay") || return 1
2216 local FS_MINIMAL=$mfs
2217 fsit mpfs "$theroot" || return 1
2218 if [ -n "$BIND_DIRS" ] ; then
2219 for d in $BIND_DIRS ; do
2220 fsit mo "$d" "$theroot/$d" -r -o bind
2225 echo "Type exit when you have finished"
2226 if [ "$user" ] ; then
2227 sudo chroot "$theroot" /usr/bin/env -i HOME=/home/$user TERM="$TERM" PS1='\u:\w\# ' PATH=/bin:/usr/bin:/sbin:/usr/sbin LESSHISTFILE=- HISTFILE=/tmp/.sh_history_"$user" /bin/su -s /bin/sh "$user"
2229 sudo chroot "$theroot" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin LESSHISTFILE=- HISTFILE=/tmp/.sh_history_root /bin/sh
2231 [ "$AUTO_UMOUNT" ] && {
2233 [ "$overlay" ] && fsit ua "${theroot%/*}"
2251 [ -f "$p" ] || continue
2253 echo -n "$d/$f.zst "
2254 if [ ! -f "$d/$f.zst" ] ; then
2255 if [ "$c" = cp ] ; then
2256 zstd --rm -19 -q "$p"
2257 /bin/cp -ud --preserve=all "$p".zst "$d"
2258 else cat "$p" | zstd -19 > "$d/$f".zst
2260 zstd -tq "$d/$f".zst && echo OK || echo NOK
2267 [ ! -d "$1" ] && return
2269 until f=${d##*/} ; d=${d%/*} ; [ -n "$f" ] ; do : ; done
2271 if [ "$d" = "$f" ] ; then tar c "$f"
2272 else (cd "$d" ; tar c "$f")
2273 fi | zstd -19 > "$f".tzs
2280 p=${f%.zst} ; p=$p.zst
2282 { zstd -tq "$d/$p" && echo -n OK || echo -n NOK ; echo " in $d" ; } ||
2289 for i in "$@" ; do rm "$i".zst ; done
2296 : ${1:?'/run/archiso/img_dev/pkg/Obarun-Plasma_x86_64-2019-05.279b8bc4aa69c16e79e9fd5e696fc45e.pkgs.txz'}
2297 : ${2:?'/run/archiso/img_dev/pkg/alpine/backup_static-20200607.tzst'}
2301 sudo mv z w mnt /run
2306 for l in $(lsblk -P -o TYPE,HOTPLUG,FSTYPE,PATH,MOUNTPOINT,UUID) ; do
2309 if [ "$5" = "MOUNTPOINT=\"\"" ] ; then
2312 d=${4#*=\"} ; d=${d%?}
2314 #echo ${1} ${4} ${3}
2315 mkdir -p $p ; sudo mount -r $d $p
2321 mount_partition ; unset mount_partition
2326 sudo pacman -U --noconfirm dist/*/repo/*/{\
2327 gnome-mpv-*,lua52-5.2.*,mpv-*,libcdio-paranoia-*,rubberband-*,vamp-plugin-sdk-*,\
2328 xvkbd-*,libxp-*,xaw3d-*,\
2329 spacefm-*,udevil-*,ffmpegthumbnailer-*,\
2330 lxterminal-*,vte3-*,vte-common-*,\
2331 fbreader-*,libunibreak-*,\
2332 lua51-luajson-*,lua51-lpeg-*,lua51-5.1.*,\
2333 sylpheed-*,compface-*,gtkspell-*,enchant-*,aspell-*,hspell-*,libvoikko-*,\
2335 lxappearance-gtk3-*,\
2336 transmission-gtk-*,\
2345 sudo 66-disable networkmanager ; sudo 66-stop networkmanager
2346 sudo 66-disable wpa_supplicant ; sudo 66-stop wpa_supplicant
2347 sudo killall -9 ModemManager
2348 #local D=$(ls -d /run/mnt/*/obarun-20180915/pacman)
2349 (cd / ; sudo tar x --zstd -f "$2")
2350 sudo ln -s ~/.Xdefault /root/.Xresources
2352 rm -r .cache .local ; mkdir z/.cache z/.local ; ln -s z/.cache z/.local .
2353 ln -s z/t/transmission-finish
2359 local __S=bckp __c=$1
2364 d="$(realpath "$1")"
2369 (cd polipo-cache ; ls) | zstd -19 > list.zst
2370 tar c polipo-cache | zstd -19 > polipo-cache.tzs
2371 tar c list.zst polipo-cache.tzs > ${2+${2}/}polipo-cache-$(date +%Y%m%d-%H%M).tar
2375 local BACKUP_user=~/.gitconfig
2378 #sudo ls -l $(shit lvpre BACKUP_) | less -S
2379 sudo tar c $(shit lvpre BACKUP_) | zstd -19 > backup_static-$(date '+%Y%m%d').tzs
2382 ( cd ; tar c z/t | zstd -19 > z/z.$(date '+%Y%m%d').tzs )
2385 ( local t="$(readlink -f "$1")" IFS=$'\n' ; cd ~/z/t ; tar c xs note $(find torrents -type f -newer "$t" -exec /bin/sh -c 't="{}" ; r=resume${t#torrents} ; r=${r%torrent}resume ; echo "$t" ; [ -f "$r" ] && echo "$r"' \;) ) | zstd -19 > "z+$(date +%Y%m%d%H%M).tzs"
2392 : ${APK_HOME:=$(pwd)/distros}
2393 : ${APK_VERSION_ALPINE=v3.11}
2395 export APK_HOME APK_VERSION_ALPINE
2396 : ${1:?ALPINE_TARBALL}${2:?LUAPOLIPO}${3:?XS}
2397 local ALPINE_TARBALL="$1"
2398 local LUAPOLIPO="$2"
2401 #[ ! -e "${ALPINE_TARBALL}" -o ! -e "${LUAPOLIPO}" ] && { echo "not exist" ; return ; }
2402 sudo -E /bin/sh -c ". $XS alpineit ; alpineit setup $APK_HOME ; (cd $APK_HOME/dist ; tar xf $ALPINE_TARBALL) ; alpineit init alpine-baselayout apk-tools alpine-keys ; mkdir -p \$APK_SYSROOT/run/tmp/cache ; chmod -R o+r,o+w,o+x \$APK_SYSROOT/root \$APK_SYSROOT/run/tmp ; alpineit mountsys ; echo \$APK_SYSROOT > $APK_HOME/path"
2404 APK_SYSROOT=$(cat $APK_HOME/path)
2405 sudo chroot "$APK_SYSROOT" /usr/sbin/adduser -D -u 3333 -s /bin/sh hmq
2406 #sudo chroot "$APK_SYSROOT" /bin/chown -R 3333:3333 /home/hmq
2407 #sudo chroot "$APK_SYSROOT" /bin/sed -i 's|1001:1001|1000:1000|' /etc/passwd
2409 ( cd "$APK_SYSROOT"/home/hmq ; tar xf ${LUAPOLIPO} )
2410 sudo cp -f /etc/resolv.conf /etc/hosts "$APK_SYSROOT"/etc
2412 #apk add --allow-untrusted lua5.1-sec lua5.1-copas lua5.1-curl lua5.1-filesystem lua5.1-inspect lua5.1-md5 lua5.1-basexx lua5.1-lzlib
2413 sudo chroot "$APK_SYSROOT" /sbin/apk add --allow-untrusted lua5.3-sec lua5.3-copas lua5.3-curl lua5.3-filesystem lua5.3-inspect lua5.3-md5 lua5.3-basexx lua5.3-lzlib
2414 #apk add --allow-untrusted openssl curl
2415 sudo -E /bin/sh -c ". $XS alpineit ; alpineit setup $APK_HOME ; alpineit umountsys $APK_SYSROOT"
2416 unset APK_HOME APK_SYSROOT APK_VERSION_ALPINE
2420 polipo_alpine '/a/d/alpine-3.11.polipo.txz' '/a/d/lua-polipo-3.txz' '/run/pool/homin/heads/script/xs'
2422 distroit chroot alpine/sysroot/alpine/v3.11/x86_64 '' hmq 1
2424 export LUA_INIT="do local topdir = os.getenv('HOME') package.path = topdir..'/polipo/?.lua;' .. package.path end"
2426 d="${HOME}/polipo-cache $(ls -dr ${HOME}/polipo-cache-*)";d="$(echo $d)";d=${d// /;};lua5.3 ${HOME}/polipo/xavante-polipo.lua 7777=${d}
2428 lua5.3 -e "Polipo = require 'polipokit' OW='yes' Polipo.params.inter.minimalLength=300000 Polipo.params.inter.minimalLengthCutOff=1 Polipo.repl_cache_alt('${HOME}/polipo-cache')"
2430 lua5.3 -e "xDEF_ACT='overwrite' Polipo = require 'polipokit' OW='yes' Polipo.params.inter.minimalLength=30000 Polipo.params.inter.minimalLengthCutOff=nil Polipo.repl_cache_alt('${HOME}/polipo-cache',1)"
2435 $self gitit transmissionit zstdit timeit fsit md5it
2436 alias cp='cp -uvd --preserve=all'
2437 alias T="transmissionit start /run/pool/homin/heads/T"
2438 alias TH='(d=/run/pool/rm/th/$(eval timeit "+%Y/%V") ; [ -d "$d/torrents/.git" ] || git init "$d/torrents" ; transmissionit start "$d")'
2439 alias kq='killall mpv /usr/bin/kded5 kdeinit5 konqueror kglobalaccel5 /usr/lib/kactivitymanagerd /usr/lib/accounts-daemon /usr/lib/polkit-1/polkitd /usr/lib/upowerd baloo_file gnome-mpv spacefm okular falkon 2>/dev/null'
2440 alias lsblk='lsblk -o NAME,LABEL,MOUNTPOINT,SIZE,UUID'
2441 #alias benqhd='xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync ; xrandr --addmode DP1 1368x768_60.00 ; xrandr --output DP1 --mode 1368x768_60.00'
2444 [ -d /run/pool ] || {
2445 mkdir -p pool/rm/yt w yt
2446 ln -s /run/pool/homin/heads/script/lua
2447 touch w/pppd.pause w/pppd.stop-
2454 local __S=gitlab_common __c=$1 s
2455 local api=${GITLAB_API:-/api/v4}
2456 local host=${GITLAB_HOST:-https://framagit.org}
2460 user-query|uq) s="/users?username=$1" ;;
2461 user-query-id|uqi) s="/users/$1" ;;
2462 user-project|up) s="/users/$1/projects" ;;
2463 project-id|pi) s="/projects/$1" ;;
2464 group-query|gq) s="/groups?search=$1&top_level_only=true" ;;
2465 group-subgroup|gs) s="/groups/$1/subgroups" ;;
2466 group-project|gp) s="/groups/$1/projects" ;;
2468 echo "$__S uq|user-query <str>"
2469 echo "$__S ui|user-query-id <num>"
2470 echo "$__S up|user-project <num>"
2471 echo "$__S pi|project-id <num>"
2472 echo "$__S gq|group-query <str>"
2473 echo "$__S gs|group-subgroup <num>"
2474 echo "$__S gp|group-project <num>"
2479 [ "$q" = "$s" ] && q='?' || q='&'
2480 [ -n "$GITLAB_PAGE" ] && s="$s$q""per_page=${GITLAB_PERPAGE:-100}&page=$GITLAB_PAGE"
2482 curl $GITLAB_CURL "$host$api$s"
2487 local __S=pathit __c=$1
2491 local b=$(realpath $1) d=$2 p=$2 q match=0
2493 [ "$b" = "$(realpath $p)" ] && { match=1 ; break ; }
2495 [ "$q" = "$p" ] && break || p=$q
2498 [ "$match" = 1 ] && { q=${d#$p} ; q=${q#?} ; [ -n "$q" ] && echo $($__S tidy $q) ; }
2501 echo "$@" | sed -e 's|/\+|/|g' -e 's|/*$||'
2505 for p in $@ ; do f=${p##*/} ; echo "### $f" ; cat $p ; done
2508 local tmp=$(mktemp /tmp/commentsort.XXXXX) dst=$(mktemp /tmp/commentsort.XXXXX) h t
2509 sed -n '/^##*/p' "$1" > $tmp
2510 sed -e '/^#*[ \t#]*$/d' -e 's/^##*//' "$1" | sort -u > $dst
2512 for w in $(cat $tmp) ; do
2515 t=$(echo $t | sed 's/\//\\\//g')
2517 sed -i "/^$t$""/s/.*/$h$t/" $dst
2529 local __S=fsit __c=$1
2533 #arg="$@" sudo -E /bin/sh -c 'f(){ [ -d "$1" ] || mkdir -p "$1" ; local m=$(realpath "$1") ; shift ; if mount | grep " $m " &>/dev/null ; then : ; else mount "$@" ; fi ; } ; f $arg'
2534 : ${2:?path dir [options...]}
2535 local p=$(realpath -m "$2")
2536 mount | awk '{print $3}' | grep "^$p$" && return
2537 [ -d "$p" ] || mkdir -p "$p" || return 1
2538 sudo mount "$@" || return 1
2542 #arg="$@" sudo -E /bin/sh -c 'f(){ local m=$(realpath "$1") ; if mount | grep " $m " ; then umount "$m" ; fi ; } ; for d in $arg ; do f $d ; done'
2546 mount | awk '{print $3}' | grep "^$r$" && sudo umount "$r"
2550 $__S mo "$1" "$2" -o bind
2556 $__S mb "$s" "$d/$s"
2559 mount_pseudo_fs|mpfs)
2561 d=$(realpath "$d") || return 1
2562 $__S mo proc "$d/proc" -t proc -o nosuid,noexec,nodev &&
2563 $__S mo sys "$d/sys" -t sysfs -o nosuid,noexec,nodev,ro &&
2564 $__S mo dev "$d/dev" -t devtmpfs -o mode=0755,nosuid &&
2565 $__S mo devpts "$d/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec &&
2566 $__S mo shm "$d/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev &&
2567 $__S mo tmp "$d/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid &&
2568 [ "$FS_MINIMAL" ] || $__S mo run "$d/run" -t tmpfs -o nosuid,nodev,mode=0755 &&
2573 umount_pseudo_fs|upfs)
2575 $__S uo "$d/proc" "$d/sys" "$d/dev/pts" "$d/dev/shm" "$d/run" "$d/tmp" "$d/dev"
2583 $__S uo "$d/proc" "$d/sys" "$d/dev/pts" "$d/dev/shm" "$d/tmp" "$d/dev"
2587 p=$(realpath "$1")/ || return
2588 [ "$p" = '/' ] && return
2589 p="/^${p//\//\\\/}/"
2591 s=$(mount | awk '$3 ~ '"$p"' {print $3}')
2592 #echo ; read -p "$s >"
2593 [ "$s" -a "$s" != "$r" ] && $__S uo $s || break
2601 root=$(realpath "$1")
2602 over=$(realpath "$2")
2603 mkdir -p "$over"/{r,u,w} &&
2604 $__S mo overlay "$over"/r -t overlay -o lowerdir="$root",upperdir="$over"/u,workdir="$over"/w &&
2608 : ${1:?src}${2:?ref}${3:?dst}
2609 find "$1" -newer "$2" -type f -exec cp -vud {} "$3" \;
2617 local __S=sudoit __c=$1
2622 [ -n "$*" ] && sudo -K || { sudo -n true 2>/dev/null && return ; }
2623 read -s -p "paassword(sudo): " s
2624 $__S refresh $s || return 1
2629 #echo $1 | sudo -Sv -p ''
2630 echo $1 | sudo -Sv 2>/dev/null
2638 local __S=... __c=$1
2644 for p in $(find "$1" -type f ! -regex '.*\.git.*') ; do
2651 local p=${2:-"https://www.linuxfromscratch.org/~thomas/multilib"}
2652 for l in $(cat "$1") ; do
2654 [ "$l" = "$d" ] || mkdir -p "$d"
2655 curl -k -x 127.0.0.1:7777 "$p/$l" > "$l"
2664 local __S=github __c=$1
2670 u=${u#https://github.com/}
2672 git init --bare $u.git
2673 (GIT_DIR=$u.git gitit fetch_depth $1 ${@:-master})
2676 : ${1:?repo} ${2:?dir}
2678 for d in $p/*/* ; do
2681 (GIT_DIR=$d gitit push_namespace $r $n)
2687 for r in $@ ; do GIT_DIR=$d GITIT_NAMESPACE=$r gitit fetch_init https://github.com/$r master ; done
2695 local __S=setit __c=$1
2697 local __ws=$(printf " \t\na") ; __ws=${__ws%?}
2698 local __nl=${__ws#??}
2702 local a=$(shit ive $1)
2703 local b=$(shit ive $2)
2704 [ "$SORTED" ] || $__S uniq b
2709 { found=y ; break ; } ||
2710 [ "$i" '<' "$j" ] &&
2713 [ "$found" = n ] && echo $i
2719 local a=$(shit ive $1)
2720 local b=$(shit ive $2)
2725 i=$(echo $a | wc -w)
2726 j=$(echo $b | wc -w)
2728 if [ $i -gt $j ]; then
2733 #echo i:$i ; echo j:$j ; read -p '>'
2734 if [ "$i" = "$j" ] ; then
2736 [ "$ONCE" ] && return
2738 elif [ "$i" '<' "$j" ] ; then break
2746 local a=$(shit ive $1)
2747 [ "$SORTED" ] || $__S uniq a
2748 for i in $a ; do [ "$i" = "$e" ] && return || [ "$i" ">" "$e" ] && break ; done
2764 eval $1'=${'$2'%%[$__ws]*}'
2765 eval "$2="'${'$2'#*[$__ws]}'
2768 eval 'if [ ${#'$2'} = 0 ] ; then '$2'=$'$1' ; else '$2'=${'$2'}${__nl}${'$1'}$__nl ; fi'
2771 eval "$1"'=$(for i in $'"$1"' ; do echo $i ; done | LC_ALL=C sort -u)$__nl'
2775 for i in $(shit ive $1) ; do echo $i ; done
2778 local X=$(shit ive $1)
2779 local Y=$(shit ive $2)
2780 local x y actx acty actc
2782 '<') actx='echo $x' ;;
2783 '>') acty='echo $y' ;;
2784 '=') actc='echo $x' ;;
2791 if [ "$ONCE" ] ; then
2793 for s in actx acty actc ; do
2794 [ "$(shit ive $s)" ] && eval "$s"'="$'$s' ; return"'
2803 while [ "$x$y" ] ; do
2804 if [ ! "$x" ] ; then
2805 if [ ! "$acty" ] && { [ "$actx" ] || [ "$actc" ] ; } ; then break ; fi
2806 while [ "$y" ] ; do eval "$acty" ; $__S pop y Y ; done
2807 elif [ ! "$y" ] ; then
2808 if [ ! "$actx" ] && { [ "$acty" ] || [ "$actc" ] ; } ; then break ; fi
2809 while [ "$x" ] ; do eval "$actx" ; $__S pop x X ; done
2811 if [ "$x" '<' "$y" ] ; then
2814 elif [ "$x" '>' "$y" ] ; then
2825 #read -p "${#x}:${#X} ${#y}:${#Y}"
2836 lua5.3 -e 'b = "\n"..io.open(arg[2]):read "*a" fa = io.open(arg[1]) repeat a = fa:read "*l" if not a then break end if not b:match("\n"..a:gsub("%-","%%-"):gsub("%.","%%."):gsub("%+","%%+").."\n") then print(a) end until nil fa:close()' /dev/null "$1" "$2"
2853 lv|list_variables)# ${!var*}
2854 set | sed -n "/^$1/s|=.*||p"
2856 ive|indirect_variable_expansion) # ${!var}
2857 [ "$1" ] && echo $(eval echo "$"$1)
2861 for i in $($__s lv) ; do [ "${i#$1}" = "$i" ] || echo $i ; done
2865 while [ -n "$1" ] ; do
2866 [ "${1#*=}" = "$1" ] && r="$r $1" || k="$k $1"
2869 [ -n "$k$r" ] && echo local$k$r || echo :
2874 [ "$1" ] && c='_r_=$1 ; shift 2>/dev/null' || c='read _r_'
2875 while eval "$c" ; do
2888 local __S=md5it __c=$1
2891 h|hash) md5sum "$1" | sed 's| .*$||' ;;
2897 [ -e *.$h.$e ] || ln "$f" "${f%.*}.$h.$e"
2911 [ "$h" = "$x" ] || echo "$f"
2921 local __S=strit __c=$1
2925 echo $@ | tr '[:lower:]' '[:upper:]'
2928 echo $@ | tr '[:upper:]' '[:lower:]'
2936 local __S=mpvit __c=$1
2940 local f=$1 t=$2 n=$3
2941 set -- $(sed -n ${n}p "$t")
2943 mpv --volume=${VOLUME:-50} --start=$1 --length=$2 "$f"
2946 local f=${1:?file} t=${2:?tt} n
2948 for n in $(shuf -e $@) ; do
2949 $__S play "$f" "$t" $n
2956 [ $# -gt 1 ] && { shift ; $self $@ ; }
2966 local __S=... __c=$1
2975 local mirror='https://github.com/skarnet/$repo.git'
2976 #local mirror='git://git.skarnet.org/skalibs/$repo'
2977 gitit cbd skarnet $m skalibs execline s6 s6-rc s6-portable-utils s6-linux-utils s6-dns s6-networking s6-linux-init lh-bootstrap mdevd utmps nsss bcnm s6-frontend skabus
2981 local m='git://git.alpinelinux.org/$repo'
2982 local m='https://git.alpinelinux.org/$repo'
2983 gitit cbd alpine $m abuild alpine-baselayout alpine-conf apk-tools aports ca-certificates docker-abuild lua-aports mkinitfs
2988 m='git://git.exherbo.org/$repo.git'
2989 gitit cbd exherbo $m arbor
2990 m='git://git.exherbo.org/paludis/$repo.git'
2991 gitit cbd exherbo $m paludis paludis-scripts
2995 gitit cbd transmission 'https://github.com/transmission/$repo' transmission dht libb64 libevent libnatpmp libutp miniupnpc
2999 gitit cbd obarun 'https://framagit.org/Obarun/$repo.git' \
3000 pacman cower rootfs-obarun oblog ConsoleKit2 \
3001 oblibs boot-user-66mod 66 66-tools \
3002 obarun-mkiso obarun-libs obarun-install-themes obarun-install obarun-docker obarun-build \
3003 applysys obarun-lxdm-themes
3007 gitit cbd obarun 'git://git.archlinux.org/$repo.git' \
3008 arch-install-scripts archiso devtools kde-build linux mkinitcpio namcap \
3009 pacman-contrib pacman
3010 #svntogit/community svntogit/packages
3018 ip addr add ${2}/24 dev ${1}
3019 ip link set up dev ${1}
3021 list|ls) iptables -nvL ;;
3023 iptables --flush ; iptables --table nat --flush ; iptables --delete-chain ; iptables --table nat --delete-chain
3024 iptables -t nat -A POSTROUTING -o $2 -j MASQUERADE
3025 iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
3026 iptables -A FORWARD -i ${1} -o ${2} -j ACCEPT
3027 # iptables -I INPUT -p udp --dport 53 -s 192.168.123.0/24 -j ACCEPT
3028 # iptables -I INPUT -p tcp --dport 53 -s 192.168.123.0/24 -j ACCEPT
3029 echo 1 > /proc/sys/net/ipv4/ip_forward
3032 echo "nat iface <dev> <addr/24>"
3034 echo "nat up <local ifece> <internet ifece>"
3038 nat iface eth0 192.168.123.100
3045 ip addr add 192.168.123.1/24 dev enp2s0
3046 ip route add default dev enp2s0 via 192.168.123.100
3047 ip link set dev enp2s0 up
3052 http://www.mirrorservice.org/sites/ [ openmandriva netbsd gutenberg libreboot gentoo-distfiles sourceware ]
3053 http://mirror.aarnet.edu.au/pub/ [ gutenberg netbsd sourceware voidlinux ]
3054 http://mirrors.dotsrc.org/ [ archlinuxarm artix devuan exherbo mxlinux qubes voidlinux ]
3055 http://mirrors.nju.edu.cn/ [ netbsd archlinuxarm lede lfs openresty ]
3056 http://mirror.csclub.uwaterloo.ca/ [ gentoo-distfiles gutenberg netbsd ]
3057 http://mirror.clarkson.edu/ [ artix slitaz voidlinux ]
3058 http://ftp.acc.umu.se/mirror/ [ calculate-linux mxlinux netbsd openmandriva qubes sabayon voidlinux ]
3059 http://ftp.halifax.rwth-aachen.de/ [ archlinuxarm mxlinux qubes slackwarearm ]
3061 http://sourceforge.mirrorservice.org/${project:0:1}/${project:0:2}/${project}/
3066 HYPERBOLA_REMOTE_MIRROR='https://ftp.cixug.es/hyperbola/gnu-plus-linux-libre/stable/${repo}/os/${arch}'
3067 HYPERBOLA_REPOS='core extra community multilib'
3072 [[ -z "${1}" ]] && t=3 || t=${1}
3073 read -t ${t} -p "[s]kip [a]bort [p]ause " r
3074 if [ "$r" = s ] ; then echo 'break'
3075 elif [ "$r" = a ] ; then echo return
3076 elif [ "$r" = p ] ; then read -p 'pause... ' r ; echo ':'
3081 . /home/hacxzuan/esys3/bash/core.bash
3083 while until { lsmod | grep option > /dev/null && modprobe -r option ; modprobe option ; } || read -t 1 ; do : ; done ; echo '05c6 9201' > /sys/bus/usb-serial/drivers/option1/new_id ; now=$(date) ; echo ${past} - ${now} ; past=${now} ; PPPD_LINK=001:005:cyborg-e488:smartfren4g:nodetach:3 pppd call smartfren4g ttyUSB2 nodetach unit 8 ; : ; do : ; done
3084 nat() { local c=$1; shift; case $c in iface) ip addr add ${2}/24 dev ${1}; ip link set up dev ${1}; ;; list|ls) iptables -nvL ;; up) iptables --flush ; iptables --table nat --flush ; iptables --delete-chain ; iptables --table nat --delete-chain; iptables -t nat -A POSTROUTING -o ${2} -j MASQUERADE; iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT; iptables -A FORWARD -i ${1} -o ${2} -j ACCEPT; echo 1 > /proc/sys/net/ipv4/ip_forward; ;; *) echo "nat iface <dev> <addr/24>"; echo nat ls; echo "nat up <local ifece> <internet ifece>"; esac; }
3085 nat iface eth0 192.168.123.100