initial commit

This commit is contained in:
fox 2020-11-25 23:40:40 +00:00
commit 4d2538d329
22 changed files with 856 additions and 0 deletions

20
LICENSE Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2020 "yafox"
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4
README Normal file
View File

@ -0,0 +1,4 @@
lix-os-utilities
================
contains some scripts yafox has found useful for maintaining lix os.

45
alpine-prep.sh Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env sh
set -e
export GITURL="http://git.fuwafuwaqtlkkxwc.onion/yafox"
basicup() {
git clone $GITURL/$1
cd $1
make install
cd ..
}
apk add build-base coreutils cmake git curl rsync cryptsetup autoconf
git clone $GITURL/vercmp
cd vercmp
make lix-os-formats
make install
cd ..
basicup shsort
git clone $GITURL/how
cd how
make lix-os-how
make install
cd ..
basicup chin
basicup src
basicup lmr
basicup lyr
basicup lix
git clone $GITURL/lix-os-utilities
mkdir bootstrap
./lix-os-utilities/mkbootstrap.sh bootstrap
# TODO: make this generic
mkdir linux-mnt
lix --bootstrap=bootstrap pull linux-kernel
lix --bootstrap=bootstrap mount linux-mnt linux-kernel
cp /mnt2/ppc64le-config linux-mnt/mnt/src/.config
lix umount linux-mnt linux-kernel
rmdir linux-mnt

23
bootstrap.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -e
[ "$1" ] || { echo "usage: bootstrap.sh [--skip-to <pkg>] <bootstrap directory>" && exit 0; }
trap 'trap - INT; kill -s INT "$$"' INT
deps="$(lix deps lix-os | cut -d' ' -f1)"
skipping=0
if [ "$1" = "--skip-to" ]; then
skipto="$2"
shift
shift
fi
for dep in $deps; do
[ "$skipto" ] && [ "$dep" != "$skipto" ] || skipping=1
[ "$skipping" -ne 0 ] || continue
echo "bootstrapping $dep"
lix --bootstrap=$1 add $dep
done

180
compendium.sh Normal file
View File

@ -0,0 +1,180 @@
#!/bin/sh -e
# source this file and use these functions.
# getalpinepatches <tree>/<package> [timeout]
getalpinepatches() {
[ -n "$1" ] \
|| { echo "usage: $(basename $0) <package> [timeout]" && exit 0; }
[ "$1" != "-c" ] || { shift; cached="yes"; }
[ "$1" != "-r" ] || { shift; reparse="yes"; }
name="$1"
timeout=${2:-5}
cleanup() { [ -f "$temp" ] && rm "$temp"; }
trap cleanup EXIT
temp="$(mktemp)"
# main
#url="https://git.alpinelinux.org/aports/tree/$name?h=master"
#pre="tree listing"
#pst="<\/table"
#rex="href='.+\/([^\/]+.patch)'"
#plain="https://git.alpinelinux.org/aports/plain"
# github mirror
url="https://github.com/alpinelinux/aports/tree/master/$name"
pre="repository-content"
pst="footer container"
rex='title="([^\/]+.patch)"'
plain="https://raw.githubusercontent.com/alpinelinux/aports/master"
# extract the text between the pre and post regexes on the target webpage.
{ curl --compressed -m $timeout -L -s $url \
|| { echo "url failed" >&2 && continue; }; } \
| awk "sub(/^.*$pre/,\"\"){echo=1} /$pst/{echo=0} echo" \
> $temp
perl -n -e "/$rex/ && print \"\$1\\n\"" $temp | while read path; do
curl -LO "$plain/$name/$path"
done
}
# importalpinepatches <tree>/<package> [timeout]
importalpinepatches() {
mkdir patches-enabled patches-available
cd patches-available
getalpinepatches $1 $2
[ "$(ls)" ] || { cd .. && return 0; }
cd ../patches-enabled
ln -s ../patches-available/* .
ls
cd ..
}
# howfromalpine <tree>/<package> [lix-name [timeout]]
howfromalpine() {
alpinepkg="$1"
pkg="$2"
pkgs="${HOWROOT:-/lix-os/how}/pkg"
[ "$pkg" ] || pkg="${alpinepkg#*/}"
cd "$pkgs"
mkdir -p "$pkg/default"
cd "$pkg/default"
plain="https://raw.githubusercontent.com/alpinelinux/aports/master"
curl -LO "$plain/$alpinepkg/APKBUILD"
cp APKBUILD "conf.sh"
cp APKBUILD "make.sh"
cp APKBUILD "inst.sh"
cp "$pkgs/../default/deps" .
chmod +x *.sh
importalpinepatches "$alpinepkg" $3
cat APKBUILD | grep "source="
}
# srcnewtar <name> <version> <type> <arc url> [sig url]
srcnewtar() {
[ "$SRCROOT" != "" ] || { echo "please specify SRCROOT" && exit 1; }
if [ ! "$4" ]; then
echo "usage: $0 <name> <version> <type> <arc url> [sig url]"
exit
fi
name="$1"
version="$2"
type="$3"
arcurl="$(eval "echo \"$4\"")"
sigurl="$(eval "echo \"$5\"")"
mkdir -p $SRCROOT/pkg/$name
tmpdir="$(mktemp -d)"
arcdest="$tmpdir/$name-$version.$type"
sigdest="$tmpdir/$name-$version.$type.sig"
[ ! "$(echo "$name" | cut -d/ -f2)" ] || mkdir -p "$tmpdir/$(dirname "$name")"
curl -L -o "$arcdest" "$arcurl"
size="$(wc -c "$arcdest" | cut -d' ' -f1)"
sum="$(sha512sum "$arcdest" | cut -d' ' -f1)"
cat << EOF > $SRCROOT/pkg/$name/defaults.sh
version="$version"
type="$type"
EOF
printf "\$version\t\$type\tarc\t$4\n" >> $SRCROOT/pkg/$name/urls
printf "$version\t$type\tarc\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
if [ "$sigurl" ]; then
curl -L -o "$sigdest" "$sigurl"
size="$(wc -c "$sigdest" | cut -d' ' -f1)"
sum="$(sha512sum "$sigdest" | cut -d' ' -f1)"
printf "\$version\t\$type\tsig\t$5\n" >> $SRCROOT/pkg/$name/urls
printf "$version\t$type\tsig\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
fi
printf "\n$name defaults.sh\n======\n"
cat $SRCROOT/pkg/$name/defaults.sh
printf "\n$name urls\n======\n"
cat $SRCROOT/pkg/$name/urls
printf "\n$name checks\n======\n"
cat $SRCROOT/pkg/$name/checks
rm -fr "$tmpdir"
}
# srcnewgit <name> <version> <arc url>
srcnewgit() {
[ "$SRCROOT" != "" ] || { echo "please specify SRCROOT" && exit 1; }
if [ ! "$3" ]; then
echo "usage: $0 <name> <version> <arc url>"
exit
fi
name="$1"
version="$2"
arcurl="$(eval "echo \"$3\"")"
mkdir -p $SRCROOT/pkg/$name
tmpdir="$(mktemp -d)"
arcdest="$tmpdir/$name-$version"
git clone --mirror "$arcurl" "$arcdest"
cd "$arcdest"
size="$(git count-objects -vH | grep size-pack | cut -d': ' -f2)"
sum="$(find . -type f ! -path '**/.git/**' ! -name '.git' | sort | xargs sha512sum | cut -d' ' -f1 | sha512sum | cut -d' ' -f1)"
cd - >/dev/null
cat << EOF > $SRCROOT/pkg/$name/defaults.sh
version="$version"
type="git"
EOF
printf "\$version\tgit\tarc\t$3\n" >> $SRCROOT/pkg/$name/urls
printf "$version\tgit\tarc\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
printf "\n$name defaults.sh\n======\n"
cat $SRCROOT/pkg/$name/defaults.sh
printf "\n$name urls\n======\n"
cat $SRCROOT/pkg/$name/urls
printf "\n$name checks\n======\n"
cat $SRCROOT/pkg/$name/checks
rm -fr "$tmpdir"
}

26
convert-git.sh Executable file
View File

@ -0,0 +1,26 @@
set -e
cp -a /mu/pkg/$1 .
cd $1
[ -z "$2" ] || version="$(cat version)"
git clone --bare "$(cat url)" "git-bare"
cd "git-bare"
git worktree add -f "../git-worktree" $version
cd ../git-worktree
[ -n "$version" ] || git log | head -n1 | cut -d' ' -f2 > ../version
cd ..
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$(cat version)" "$(cat type)" "arc" "$(expr $(du -sk git-worktree | cut -f1) \* 1024)" "$(cat sha512)">checks
printf %s\\t%s\\t%s\\t%s\\n "$(cat version)" "$(cat type)" "arc" "$(cat url)">urls
printf "version=\"$(cat version)\"\\ntype=\"$(cat type)\"\\n">defaults.sh
rm -fr git-bare git-worktree type url sha512 version patch inst.sh make.sh conf.sh pull.sh
echo "done!"
cat urls
echo
cat checks
echo
cat defaults.sh

8
convert-how.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
cd $1
mkdir default
mv *.sh default/
mv patch default/
rm *
cat default/*.sh

36
convert-tarball.sh Executable file
View File

@ -0,0 +1,36 @@
set -e
mu="$MUROOT/pkg/$1"
[ -d $1 ] || cp -a /mu/pkg/$1 .
cd $1
export version="$(cat $mu/version)"
export type="$(cat $mu/type)"
export url="$(cat $mu/url)"
curl -L -o src.$type "$(eval "echo \"$url\"")"
(echo "$url" | grep -q '$version') \
&& urlversion='$version' \
|| urlversion="$version"
if [ -f sig-url ]; then
export sigurl="$(cat $mu/sig-url)"
curl -L -o src.${type}.sig "$(eval "echo \"$sigurl\"")"
fi
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "arc" "$(wc -c src.$type | cut -d' ' -f1)" "$(sha512sum src.$type | cut -d' ' -f1)">>checks
printf %s\\t%s\\t%s\\t%s\\n "$urlversion" "$type" "arc" "$url">>urls
if [ -f "src.${type}.sig" ]; then
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "sig" "$(wc -c src.${type}.sig | cut -d' ' -f1)" "$(sha512sum src.${type}.sig | cut -d' ' -f1)">>checks
printf %s\\t%s\\t%s\\t%s\\n "$urlversion" "$type" "sig" "$sigurl">>urls
fi
printf "version=\"$version\"\\ntype=\"$type\"\\n">defaults.sh
rm "src.$type" "src.${type}.sig" type url sig-url sha512 version patch inst.sh make.sh conf.sh pull.sh || true
echo "done!"
cat urls
echo
cat checks
echo
cat defaults.sh

39
get-alpine-patches.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh -e
[ -n "$1" ] \
|| { echo "usage: $(basename $0) <package> [timeout]" && exit 0; }
[ "$1" != "-c" ] || { shift; cached="yes"; }
[ "$1" != "-r" ] || { shift; reparse="yes"; }
name="$1"
timeout=${2:-5}
cleanup() { [ -f "$temp" ] && rm "$temp"; }
trap cleanup EXIT
temp="$(mktemp)"
# main
#url="https://git.alpinelinux.org/aports/tree/$name?h=master"
#pre="tree listing"
#pst="<\/table"
#rex="href='.+\/([^\/]+.patch)'"
#plain="https://git.alpinelinux.org/aports/plain"
# github mirror
url="https://github.com/alpinelinux/aports/tree/master/$name"
pre="repository-content"
pst="footer container"
rex='title="([^\/]+.patch)"'
plain="https://raw.githubusercontent.com/alpinelinux/aports/master"
# extract the text between the pre and post regexes on the target webpage.
{ curl --compressed -m $timeout -L -s $url \
|| { echo "url failed" >&2 && continue; }; } \
| awk "sub(/^.*$pre/,\"\"){echo=1} /$pst/{echo=0} echo" \
> $temp
perl -n -e "/$rex/ && print \"\$1\\n\"" $temp | while read path; do
curl -LO "$plain/$name/$path"
done

51
install.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
set -e
[ "$1" ] || { echo "usage: install.sh <target directory>" && exit 0; }
lixmnt="$(mktemp -d)"
trap 'trap - INT; kill -s INT "$$"; rmdir "$lixmnt"' INT
trap 'rmdir "$lixmnt"' EXIT
echo "pulling the lix-os package..."
lix pull lix-os
echo "transferring lix-os dependency chroot contents to target..."
lix deps lix-os | awk '{ print "lix/" $1 "/" $2 "/fs" }' | while read layer; do
echo "copying from $layer"
rsync -ah --info=progress2 --force "$(lyr upperdir $layer)/" "$1/"
done
## below is the old way this was done. this required a custom "mount" binary.
## works fine in lix os, but not in host distributions used for bootstrapping.
## lix os' mount sets aside a whopping 8KiB for the option string. if the
## option string is too long for the memory set aside, the "mount"
## implementations the author has used fail silently!
#echo "transferring lix-os chroot contents to target..."
#lix mount "$lixmnt" lix-os
#rsync -ah --info=progress2 --force "$lixmnt/" "$1/"
#lix umount "$lixmnt" lix-os
#umount "$lixmnt"
transfer() {
if [ -d "$1" ]; then
mkdir -p "$2"
rsync -ah --info=progress2 --force "$1" "$2"
else
echo "unable to find $1! transfer manually before proceeding..." >&2
fi
}
echo "transferring lyr state to target..."
transfer "/usr/var/lyr/" "$1/var/lyr/"
echo "transferring src state to target..."
transfer "/usr/var/src/" "$1/var/src/"
echo "transferring src state to target..."
transfer "/usr/var/src/" "$1/var/src/"
echo "removing LICENSE and README in target system root..."
[ ! -f "$1/LICENSE" ] || rm "$1/LICENSE"
[ ! -f "$1/README" ] || rm "$1/README"

3
installed.sh Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
find /bin /lib /etc /share -type l -exec readlink {} \; | grep lyr/upper/lix | cut -d/ -f7-8 | sort | uniq

18
leaves.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -e
# given a sorted list of packages, finds the ones which appear in none of the
# dependencies of the listed packages.
[ "$1" ] || { >&2 echo "usage: leaves <file>" && exit 1; }
tmp="$(mktemp)"
#trap "rm $tmp" EXIT INT HUP
cat "$1" | while read foobar; do
echo "getting $foobar dependencies..."
lix deps "$foobar" | cut -d' ' -f1 >> "$tmp"
done
cp "$tmp" "$tmp.bak"
cat "$tmp" | sort | uniq > "$tmp"
comm -23 "$1" "$tmp"
echo "$tmp"

0
list-upped.sh Normal file
View File

36
make-src-tarball.sh Executable file
View File

@ -0,0 +1,36 @@
set -e
mu="$MUROOT/pkg/$1"
[ -d $1 ] || cp -a "$mu" .
cd $1
export version="$(cat $mu/version)"
export type="$(cat $mu/type)"
export url="$(cat $mu/url)"
curl -L -o src.$type "$(eval "echo \"$url\"")"
(echo "$url" | grep -q '$version') \
&& urlversion='$version' \
|| urlversion="$version"
if [ -f sig-url ]; then
export sigurl="$(cat $mu/sig-url)"
curl -L -o src.${type}.sig "$(eval "echo \"$sigurl\"")"
fi
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "arc" "$(wc -c src.$type | cut -d' ' -f1)" "$(sha512sum src.$type | cut -d' ' -f1)">>checks
printf %s\\t%s\\t%s\\t%s\\n "$urlversion" "$type" "arc" "$url">>urls
if [ -f "src.${type}.sig" ]; then
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "sig" "$(wc -c src.${type}.sig | cut -d' ' -f1)" "$(sha512sum src.${type}.sig | cut -d' ' -f1)">>checks
printf %s\\t%s\\t%s\\t%s\\n "$urlversion" "$type" "sig" "$sigurl">>urls
fi
printf "version=\"$version\"\\ntype=\"$type\"\\n">defaults.sh
rm "src.$type" "src.${type}.sig" type url sig-url sha512 version patch inst.sh make.sh conf.sh pull.sh || true
echo "done!"
cat urls
echo
cat checks
echo
cat defaults.sh

6
makechecks.sh Executable file
View File

@ -0,0 +1,6 @@
type="$1"
version="$2"
curl -o src.$type -L "$(eval "echo \"$(cat "urls")\"" | awk "/\tarc\t/" | cut -f4)"
printf %s\\t%s\\t%s\\t%s\\t%s\\n $version $type "arc" "$(wc -c src.$type | cut -d' ' -f1)" "$(sha512sum src.$type | cut -d' ' -f1)" >> checks
curl -o src.$type.sig -L "$(eval "echo \"$(cat "urls")\"" | awk "/\tsig\t/" | cut -f4)"
printf %s\\t%s\\t%s\\t%s\\t%s\\n $version $type "sig" "$(wc -c src.$type.sig | cut -d' ' -f1)" "$(sha512sum src.$type.sig | cut -d' ' -f1)" >> checks

68
mkbootstrap.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/sh
# populates a directory with host directories.
# modify and use as needed.
[ "$1" ] || echo "usage: mkbootstrap <target path>"
if [ ! -d "$1" ]; then
echo "$1 is not a directory!" >&2
exit 1
fi
dest="$1"
case "$dest" in
/usr/*|/lib/*|/libexec/*|/etc/*|/bin/*|/share/*)
echo "destination path cannot be a subpath of the source paths." >&2
exit 1
;;
esac
up() {
printf "$(echo "checking $1 .........." | head -c 20)"
if [ -d "/$1" ] && [ ! -d "$dest/$1" ]; then
printf " merging $1\n"
# is this a symlink to a directory?
[ -h "/$1" ] \
&& cp -a "/$1" "$dest/" \
|| mkdir "$dest/$1" && lmr "/$1" "$dest/$1"
else
printf " skipping $1\n"
fi
}
up lib
up libexec
up etc
up bin
up share
mkdir -p "$dest/boot"
# force bootstrap directory into lix os-style directory structure.
lmr -f /usr $dest \
&& echo "merged /usr into $dest" \
|| echo "did not lmr /usr into $dest"
lmr -f $dest/local $dest \
&& echo "merged $dest/local into $dest" \
|| echo "did not lmr $dest/local into $dest"
rm -fr $dest/local \
&& echo "removed $dest/local" \
|| echo "did not remove $dest/local"
lmr -f $dest/sbin $dest/bin \
&& echo "merged $dest/sbin into $dest/bin" \
|| echo "did not lmr $dest/sbin into $dest/bin"
rm -fr $dest/sbin \
&& echo "removed $dest/sbin" \
|| echo "did not remove $dest/sbin"
ln -sf . $dest/usr \
&& echo "ln'ed $dest/usr to ." \
|| echo "did not ln $dest/usr to ."
ln -sf ./bin $dest/sbin \
&& echo "ln'ed $dest/sbin to ./bin" \
|| echo "did not ln $dest/sbin to ./bin"

69
mkbootstrap2.sh Executable file
View File

@ -0,0 +1,69 @@
#!/bin/sh
# populates a directory with host directories.
# modify and use as needed.
[ "$1" ] || echo "usage: mkbootstrap <target path>"
if [ ! -d "$1" ]; then
echo "$1 is not a directory!" >&2
exit 1
fi
dest="$1"
case "$dest" in
/usr/*|/lib/*|/libexec/*|/etc/*|/bin/*|/share/*)
echo "destination path cannot be a subpath of the source paths." >&2
exit 1
;;
esac
up() {
printf "$(echo "checking $1 .........." | head -c 20)"
if [ -d "/$1" ] && [ ! -d "$dest/$1" ]; then
printf " merging $1\n"
# is this a symlink to a directory?
[ -h "/$1" ] \
&& cp -a "/$1" "$dest/" \
|| mkdir "$dest/$1" && lmr "/$1" "$dest/$1"
else
printf " skipping $1\n"
fi
}
up lib
up libexec
up etc
up bin
up sbin
up share
mkdir -p "$dest/boot"
# facilitate lix os' "/usr is a soft link to /" scheme.
lmr -f /usr $dest \
&& echo "merged /usr into $dest" \
|| echo "did not lmr /usr into $dest"
ln -sf . $dest/usr \
&& echo "ln'ed $dest/usr to ." \
|| echo "did not ln $dest/usr to ."
#lmr -f $dest/local $dest \
#&& echo "merged $dest/local into $dest" \
#|| echo "did not lmr $dest/local into $dest"
#
##rm -fr $dest/local \
#&& echo "removed $dest/local" \
#|| echo "did not remove $dest/local"
lmr -f $dest/sbin $dest/bin \
&& echo "merged $dest/sbin into $dest/bin" \
|| echo "did not lmr $dest/sbin into $dest/bin"
rm -fr $dest/sbin \
&& echo "removed $dest/sbin" \
|| echo "did not remove $dest/sbin"
ln -sf ./bin $dest/sbin \
&& echo "ln'ed $dest/sbin to ./bin" \
|| echo "did not ln $dest/sbin to ./bin"

68
o2n.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/sh
set -e
[ "$1" ] \
&& pkg="$1" \
|| pkg="$(head -n1 ../todo)"
echo "converting $pkg"
cd $pkg
type="$(cut -d' ' -f1 checksums)"
version="$(cut -d' ' -f2 checksums)"
checksum="$(cut -d' ' -f3 checksums)"
url="$(eval "echo \"$(head -n1 $type-urls)\"")"
echo "$type"
echo "$version"
echo "$checksum"
echo "$url"
if [ -f "$type-sigurls" ]; then
sigurl="$(eval "echo \"$(head -n1 $type-sigurls)\"")"
fi
echo "pulling archive"
if [ "$type" = "git" ]; then
git clone --bare "$url" "git-bare"
cd "git-bare"
git worktree add -f "../git-worktree" $version
cd ../git-worktree
version="$(git log | head -n1 | cut -d' ' -f2)" # force use of commit hash
cd ..
size="$(expr $(du -sk git-worktree | cut -f1) \* 1024)"
rm -fr git-worktree git-bare
printf %s\\t%s\\t%s\\t%s\\n '$version' "$type" "arc" "$(head -n1 $type-urls)">urls
else
curl -o src.$type -L "$url"
[ "$checksum" ] || checksum="$(sha512sum src.$type | cut -d' ' -f1)"
[ "$(sha512sum src.$type | cut -d' ' -f1)" = "$checksum" ] || { echo "checksum mismatch" && exit 1; }
size="$(wc -c src.$type | cut -d' ' -f1)"
rm src.$type
printf %s\\t%s\\t%s\\t%s\\n '$version' '$type' "arc" "$(head -n1 $type-urls)">urls
fi
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "arc" "$size" "$checksum">checks
printf "version=\"$version\"\\ntype=\"$type\"\\n">defaults.sh
if [ "$sigurl" ]; then
echo "pulling signature"
curl -o sig -L "$sigurl"
size="$(wc -c sig | cut -d' ' -f1)"
checksum="$(sha512sum sig | cut -d' ' -f1)"
[ "$(sha512sum sig | cut -d' ' -f1)" = "$checksum" ] || { echo "signature checksum mismatch" && exit 1; }
printf %s\\t%s\\t%s\\t%s\\n '$version' '$type' "sig" "$(head -n1 $type-sigurls)">>urls
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "sig" "$size" "$checksum">>checks
rm sig
fi
rm -fr checksums defaults *-sigurls *-urls
echo
cat urls
echo
cat checks
echo
cat defaults.sh

25
sloc.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env sh
#find lix how src lyr lmr chin vercmp -name README ! -path "**/**/**" \
#| xargs sed -n 's/^[^0-9]*\([0-9]\+\) ELOC.*$/\1/p' \
sum="0"
while read line; do
cd $line
loc="$(./sloc.sh)"
printf "%s:\\t%s\\n" "$line" "$loc"
sum="$(expr $sum + $loc)"
cd - > /dev/null
done <<EOF
lix
how
src
lyr
lmr
chin
vercmp
shsort
EOF
echo "-"
printf "total:\\t%s\\n" "$sum"

32
softlink.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
set -e
[ "$1" ] || { echo "usage: softlink.sh <target directory>" && exit 0; }
echo "chrooting into target and setting up softlinks..."
cd "$1"
>"_softlink.sh" cat <<EOF
#!/bin/sh
#if [ "$(ls /boot)" != "" ]; then
# >&2 echo "refusing to overwrite /boot contents!"
# exit 1
#fi
echo "about to softlink..."
deps="\$(lix deps lix-os | cut -d' ' -f1)"
for dep in \$deps; do
echo "linking \$dep"
lix up -f \$dep
done
echo "wiping /boot links."
rm -fr /boot/*
EOF
chmod +x "_softlink.sh"
chin "$1" "./_softlink.sh"
cd - >/dev/null
rm "$1/_softlink.sh"

44
src-new-git.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/sh
set -e
[ "$SRCROOT" != "" ] || { echo "please specify SRCROOT" && exit 1; }
if [ ! "$3" ]; then
echo "usage: $0 <name> <version> <arc url>"
exit
fi
name="$1"
version="$2"
arcurl="$(eval "echo \"$3\"")"
mkdir -p $SRCROOT/pkg/$name
tmpdir="$(mktemp -d)"
arcdest="$tmpdir/$name-$version"
git clone --mirror "$arcurl" "$arcdest"
cd "$arcdest"
size="$(git count-objects -vH | grep size-pack | cut -d': ' -f2)"
sum="$(find . -type f ! -path '**/.git/**' ! -name '.git' | sort | xargs sha512sum | cut -d' ' -f1 | sha512sum | cut -d' ' -f1)"
cd - >/dev/null
cat << EOF > $SRCROOT/pkg/$name/defaults.sh
version="$version"
type="git"
EOF
printf "\$version\tgit\tarc\t$3\n" >> $SRCROOT/pkg/$name/urls
printf "$version\tgit\tarc\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
printf "\n$name defaults.sh\n======\n"
cat $SRCROOT/pkg/$name/defaults.sh
printf "\n$name urls\n======\n"
cat $SRCROOT/pkg/$name/urls
printf "\n$name checks\n======\n"
cat $SRCROOT/pkg/$name/checks
rm -fr "$tmpdir"

55
src-new-tarball.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
set -e
[ "$SRCROOT" != "" ] || { echo "please specify SRCROOT" && exit 1; }
if [ ! "$4" ]; then
echo "usage: $0 <name> <version> <type> <arc url> [<sig url>]"
exit
fi
name="$1"
version="$2"
type="$3"
arcurl="$(eval "echo \"$4\"")"
sigurl="$(eval "echo \"$5\"")"
mkdir -p $SRCROOT/pkg/$name
tmpdir="$(mktemp -d)"
arcdest="$tmpdir/$name-$version.$type"
sigdest="$tmpdir/$name-$version.$type.sig"
[ ! "$(echo "$name" | cut -d/ -f2)" ] || mkdir -p "$tmpdir/$(dirname "$name")"
curl -L -o "$arcdest" "$arcurl"
size="$(wc -c "$arcdest" | cut -d' ' -f1)"
sum="$(sha512sum "$arcdest" | cut -d' ' -f1)"
cat << EOF > $SRCROOT/pkg/$name/defaults.sh
version="$version"
type="$type"
EOF
printf "\$version\t\$type\tarc\t$4\n" >> $SRCROOT/pkg/$name/urls
printf "$version\t$type\tarc\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
if [ "$sigurl" ]; then
curl -L -o "$sigdest" "$sigurl"
size="$(wc -c "$sigdest" | cut -d' ' -f1)"
sum="$(sha512sum "$sigdest" | cut -d' ' -f1)"
printf "\$version\t\$type\tsig\t$5\n" >> $SRCROOT/pkg/$name/urls
printf "$version\t$type\tsig\t$size\t$sum\n" >> $SRCROOT/pkg/$name/checks
fi
printf "\n$name defaults.sh\n======\n"
cat $SRCROOT/pkg/$name/defaults.sh
printf "\n$name urls\n======\n"
cat $SRCROOT/pkg/$name/urls
printf "\n$name checks\n======\n"
cat $SRCROOT/pkg/$name/checks
rm -fr "$tmpdir"