Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#The declair statment is used to check if a function exists #See: https://stackoverflow.com/questions/85880/determine-if-a-function-exists-in-bash declare -f -F trap_push > /dev/null && \ source trap_stack.sh source bind_functions.sh initialize_chroot #The trap_stack lets us nest multiple trap statments. See: # https://stackoverflow.com/questions/16115144/save-and-restore-trap-state-easy-way-to-manage-multiple-handlers-for-traps # https://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal process_pet_specs(){ local specs_txt=`cat "$1" | head --lines=1` #https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash #http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/#post3270796 specs=(${specs_txt//|/ }) process_pet_specs_FULL_NAME=specs[0] process_pet_specs_PKG_NAME=[1] process_pet_specs_VERSION=specs[2] process_pet_CATEGORY=specs[4] process_pet_SIZE=specs[5] process_pet_BRANCH=specs[6] #Repository Folder process_pet_FILE_NAME=specs[7] #File Namer process_pet_FILE_DEPENDS=specs[8] process_pet_FILE_SHORT_DESC=specs[9] process_pet_FILE_COMPILED WITHIN=specs[10] process_pet_FILE_COMPAT_DISTRO_VER=specs[11] process_pet_REPO_NAME=specs[12] } mk_tazpkg_receipt(){ parse_pkg_dirname "$1" local pkg_path="$path__ppd" local pkg_name="$pkg_name__ppd" local pkg_short_name="$pkg_short_ppd" local pkg_version="$pkg_version__ppd" if [ -f "$pkg_path/receipt" ]; then process_pet_specs echo 'PACKAGE="$process_pet_specs_PKG_NAME" VERSION="$process_pet_specs_VERSION" CATEGORY="$process_pet_CATEGORY" SHORT_DESC="$process_pet_SHORT_DESC" WEB_SITE="$web_site" MAINTAINER="$maintainer" DEPENDS="$process_pet_FILE_DEPENDS" ' > $pkg_path/receipt #TODO add che for pkgmanager type and suport for toher package managers fi } delete_petspec_fm_file(){ local field_val=$1 local pkg_rootfs=${2:-"$s_rootfs"} local spec_list_name=${3:-'*-packages'} if [ -z "$4" ]; then if [[ $field_val == *"-"* ]]; then local field=1 else local field=2 fi else local field="$4" fi #TODO if prk_rootfs="/" or "" give warning #TODO Give the option to compare more than one field. #https://www.gnu.org/software/gawk/manual/html_node/Boolean-Ops.html #TODO consider how to deal with miskes like dashes when there should be AWK_PRG="BEGIN{FS=\"|\"} { if ( \$$field != \"$field_val\" ) { print } }" #TODO we probably need logic to expand wildards local file_spec_lists=( `ls -1 "$pkg_rootfs/root/.packages/$spec_list_name"` ) 2>/dev/null mkdir -p /tmp/trim_puppy/ for spec_list in "${file_spec_lists[@]}"; do spec_name=`basename "$spec_list"` cat "$spec_list" | awk "$AWK_PRG" >> "/tmp/trim_puppy/$spec_name" echo "about to" echo "rm \"$spec_list\" mv \"/tmp/trim_puppy/$spec_name\" \"$spec_list\" " #read -p "Press enter to continue" set -x rm "$spec_list" mv "/tmp/trim_puppy/$spec_name" "$spec_list" set +x #read -p "Press enter to continue" done } parse_pkg_dirname(){ path__ppd=$1 pkg_name__ppd=${pkg_name%.extracted} pkg_type__ppd=${pkg_name__ppd##*.} pkg_name__ppd=${pkg_name%"$pkg_type__ppd"} pkg_name__ppd=${pkg_name%.tazpkg} pkg_name__ppd=${pkg_name%.pet} pkg_name__ppd=${pkg_name%.txz} pkg_name__ppd=${pkg_name%.deb} pkg_short_name__ppd=${pkg_name%%-*} pkg_version__ppd=${pkg_name#*-} } inst_pkg_fm_anywhere(){ set -x parse_pkg_dirname $1 source_dir="$path__ppd" #local pkg_type="$pkg_type__ppd" pkg_name="$pkg_name__ppd" #local pkg_short_name="$pkg_short_name__ppd" #local #local dest_root=... dest_root=${2:-"$curdir/$s_rootfs"} #TODO make the default more robust with regards to slashes if [ "$dest_root" = "/" ]; then echo "warning about to install package into system rootfs" #read -p "Press enter to continue" fi local pkg_name=${3:-`basename $1`} #TODO add logic for different location of files.list pkg_name=${pkg_name%%.*} if [ -d "$source_dir/fs" ]; then source_dir_fs="$source_dir/fs" else source_dir_fs="$source_dir" fi system_root_check_and_warn \ $source_dir_fs -m="source_dir_fs=$source_dir_fs" \ $dest_root -m="dest_root=$dest_root" set +x echo " cp --remove-destination -arf $source_dir_fs/* $dest_root/ 2>/dev/null" #read -p "Press enter to continue" cp --remove-destination -arf $source_dir_fs/* \ $dest_root/ 2>/dev/null cd "$source_dir" find . -mindepth 1 -name '*' > "$source_dir/$pkg_name" #"$dest_file_list_prefixed" update_pkg_specs "$source_dir" "$dest_root" run_in_chroot } do_post_inst(){ local a_rootfs=$1 local pkg_type=${pkg_type:-pet} initialize_rootfs "$a_rootfs" case pkg_type in pet) pinst_trys=( "pet" "tazpkg" "txz" "deb" ) ;; tazpkg) pinst_trys=( "tazpkg" "pet" "txz" "deb" ) ;; txz) pinst_trys=( "pet" "tazpkg" "txz" "deb" ) ;; deb) pinst_trys=( "pet" "tazpkg" "txz" "deb" ) ;; esac for a_pinst in "${pinst_trys[@]}"; do case a_pinst in pet) #A slitaz package if [ -z "$source_dir/pinstall.sh" ]; then cp $source_dir/pinstall.sh $dest_root/pinstall.sh run_in_chroot $pinstall.sh break fi ;; tazpkg) #A slitaz package if [ -z "$source_dir/receipt" ] && [ $(grep -cF "post_install()") -gt 0 ]; then echo " . /etc/slitaz/slitaz.conf #Not sure if this is needed (s243a) . /etc/slitaz/tazpkg.conf #Not sure if this is needed (s243a) . /lib/libtaz.sh #Not sure if this is needed (s243a) . /usr/lib/slitaz/libpkg.sh #Not sure if this is needed (s243a) . /usr/libexec/tazpkg/find-depends #Not sure if this is needed (s243a) source /var/lib/tazpkg/installed/$pkg_name/receipt #Not sure if this is needed (s243a) post_instal" > $dest_root/start.sh cp $source_dir/pinstall.sh $dest_root/pinstall.sh chmod +x $dest_root/start.sh run_in_chroot start.sh ;; break fi ;; txz) #A slackware package #TODO ;; deb) #A debian package #TODO ;; esac done } update_pkg_specs(){ parse_pkg_dirname "$1" local source_dir="$path__ppd" local pkg_name="$pkg_name__ppd" local pkg_short_name="$pkg_short_name__ppd" local pkg_version="$pkg_version__ppd" local post_install_script_run=0 #Consider having different install modes #For example maybe we want to run both a pinstall.sh as well as the tazpkg #post install script POST_INSTALL_MODE=${POST_INSTALL_MODE:-first} #e.g (first, all, non local dest_root=${2:-"$curdir/$s_rootfs"} #TODO make the default more robust with regards to slashes if [ ! -z "$3" ]; then spec_types_arry_name=$3 else spec_types_arry=( "pet" "tazpkg" ) spec_types_arry_name="spec_types_arry" fi mkdir -p "$dest_root/root/.packages/builtin_files" mkdir -p "$dest_root/var/lib/tazpkg/installed/$pkg_short_name" for spec_type in $(eval 'echo "${'$spec_types_arry_name'[@]}"'); do case "$spec_type" in pet|.pet) pet_specs_fm_dir "$source_dir" "$dest_root"/ cp "$source_dir/pet.specs" \ "$dest_root/root/.packages/builtin_files/$pkg_short_name" ;; tazpkg) tazpkg_specs_fm_dir "$source_dir" cp "$source_dir/$pkg_name" "$dest_root/var/lib/tazpkg/installed/$pkg_short_name/files.list" ;; esac done } system_root_check_and_warn(){ args=() #let count=0 let arg_count=0 for arg in "$@"; do if [[ "$arg" = "-m="* ]]; then message=${arg#-m=} args[-1]="$message" else args+=( "$arg" "arg$arg_count=$arg" ) fi #let count++ let arg_count++ done while read a b; do if [ "$a" = "/" ]; then echo "Warning! Action may involve system root:" echo "$b" read -p "Press enter to continue" fi done < <( "${args[@]}" ) } tazpkg_specs_fm_dir(){ parse_pkg_dirname "$1" local pkg_path="$path__ppd" local pkg_name="$pkg_name__ppd" local pkg_short_name="$pkg_short_name__ppd" local pkg_version="$pkg_version__ppd" local receipt_target_root=${2:-"$curdir/$s_rootfs"} if [ ! "$pkg_path/receipt" ]; then mk_tazpkg_receipt $pkg_path fi #https://unix.stackexchange.com/questions/266627/bash-source-without-polluting-own-namespace-get-variables-from-other-scripts/477443 set +x eval $(source "$pkg_path/recepit" &> /dev/null; echo pkg_short_name=${PACKAGE:-"$pkg_short_name"}; echo pkg_version=${VERSION:-"$pkg_version"};) set -x local pkg_name2="$pkg_short_name" if [ ! -z "$receipt_target_root" ]; then if [ "$receipt_target_root" = "/" ]; then echo "Warning: installing package receipt to system rootfs" #read -p "Press enter to continue" fi receipt_target=$receipt_target_root/var/lib/tazpkg/installed/$pkg_name2/receipt mkdir -p `dirname "$receipt_target"` system_root_check_and_warn \ $pkg_path -m="pkg_path/receipt=$pkg_path/receipt" \ $receipt_target_root -m="receipt_target=$receipt_target" cp -f "$pkg_path/receipt" "$receipt_target" fi set +x } pet_specs_fm_dir(){ set -x parse_pkg_dirname "$1" local source_dir="$path__ppd" local pkg_name="$pkg_name__ppd" local pkg_short_name="$pkg_short_name__ppd" local pkg_version="$pkg_version__ppd" local receipt_target_root=${2:-"$curdir/$s_rootfs"} #if [ -z "$3" ]; then # local target_pet_spec_path="$file_spec_list_path" #else # local installer=${3:-woof} # local target_pet_spec_path="$receipt_target_root/root/.packages/$installer"'-installed-packages' #fi local installer=${3:-woof} local target_pet_spec_path="$receipt_target_root/root/.packages/$installer"'-installed-packages' if [ ! -f "$source_dir/pet.specs" ]; then cd "$source_dir/.." old_name=`basename "$source_dir"` if [ -f "$source_dir/receipt" ]; then eval $(source "$source_dir/receipt" &> /dev/null; echo pkg_short_name=${PACKAGE:-"$pkg_short_name"}; echo pkg_version=${VERSION:-"$pkg_version"}; echo pkg_category=$CATEGORY; echo pkg_depends=$DEPENDS;) mv "$old_name" "$pkg_short_name"-"$pkg_version" dir2pet -g -s -p="$pkg_name" -c="$pkg_category" #-d="$pkg_depends" TODO Need to fix the format of depends option mv "$pkg_short_name"-"$pkg_version" "$old_name" else mv "$old_name" "$pkg_name" dir2pet -g -s -p="$pkg_name" mv "$pkg_name" "$old_name" fi fi set +x if [ -f "$source_dir/pet.specs" ]; then #&& [ -d "$receipt_target_root/var" ]; then if [ -f "$target_pet_spec_path" ]; then echo "TODO: maybe we need a forced option if the package exists" #TODO maybe remove old package before deleting. delete_petspec_fm_file "$pkg_name" "$dest_root" "$spec_list_name" #"1" We don't need to specify the field else mkdir -p "$receipt_target_root/root/.packages" touch "$target_pet_spec_path" fi cat "$source_dir/pet.specs" >> "$target_pet_spec_path" fi } copy_pet_specs(){ local spec_target=$1 if [ -z "$spec_target" ]; then spec_target="$inst_pkg_specs_target" fi AWK_PRG="BEGIN{FS=\"|\"} { if ( \$2 == \"$app\" ) { print } }" file_spec_list=( "$rootfs_full/root/.packages/"*"-installed-packages" ) #cat "${file_spec_list[@]}" | awk -F'|' "$AWK_PRG" #'{print $2;}' spec=$( cat "${file_spec_list[@]}" | awk "$AWK_PRG" >> "$spec_target" ) match_cnt=$( grep -cF "$spec" "$spec_target" ) if [ $match_cnt -eq 0 ]; then echo "$spec" >> "$spec_target" fi } copy_built_in(){ set -x app=$1 file_list="$curdir/$s_rootfs/root/.packages/builtin_files/$app" if [ ! -f "$file_list" ] && [ $retry -eq 1 ]; then file_list="$alt_s_rootfs/root/.packages/builtin_files/$app" using_alt_list=1 else using_alt_list=0 fi if [ "${target:0:1}" = "/" ]; then target_root="$target" else target_root="$curdir/$target" fi target_file_list="$target_root/root/.packages/builtin_files/$app" echo "file_list=$file_list" mkdir -p /tmp/trim_puppy exec 10<> /tmp/trim_puppy/fd_10 subdir="/" mkdir -p /tmp/trim_puppy/ rm "/tmp/trim_puppy/$app" touch "/tmp/trim_puppy/$app" #mkdir -p inst_pkg_specs_target="$target_root/root/.packages/"$arr_name"-installed-packages" mkdir -p `dirname "$inst_pkg_specs_target"` copy_pet_specs while IFS=$'\n' read -r -d $'\n' -u10 line ; do line=`echo "$line" | tr -d '[:space:]'` if [ ! "${line:0:1}" = "/" ]; then line=$subdir$line fi echo $line>>"/tmp/trim_puppy/$app" if [ "${target:0:1}" = "/" ]; then target_prefixed="$target$line" #target_root="$target" #Defined above else #target_root="$curdir/$target" #Defined above target_prefixed="$curdir/$target$line" fi if [ "${s_rootfs:0:1}" = "/" ]; then source_prefixed="$s_rootfs$line" cd "$s_rootfs" #this is necessary for the cpio command below else source_prefixed="$curdir/$s_rootfs$line" cd "$curdir/$s_rootfs" #this is necessary for the cpio command below fi if [ -d "$source_prefixed" ]; then subdir="$line" echo ".$line" | cpio -pd "$target_root" subdir=${subdir%/}/ else target_dir=`dirname $target_prefixed` if [ ! -d "$target_dir" ]; then source_dir=`dirname $line` echo ".$source_dir" | cpio -pd "$target_root" fi if [ ! -f "$source_prefixed" ] && [ $retry -eq 1 ]; then source_prefixed="$alt_s_rootfs$line" cp -a -u "$source_prefixed" "$target_prefixed" elif [ ! "$arr_action" = "mv" ]; then cp -a -u "$source_prefixed" "$target_prefixed" else mv -uf "$source_prefixed" "$target_prefixed" if [ -f "$source_prefixed" ]; then rm "$source_prefixed" fi fi fi done 10< <( cat "$file_list" ) exec 10>&- set +x if [ ! "$arr_action" = "mv" ]; then mkdir -p `dirname "$target_file_list"` cp -a -u "$file_list" "$target_file_list" else mv -uf "$file_list" "$target_file_list" sed -i "\%|${app}|%d" "$curdir/$s_rootfs/root/.packages/"*"-installed-packages" if [ -f "$file_list" ]; then rm "$file_list" fi fi } dissect_rootfs(){ #arr_names=${1:-ALL_ArrNames} arry_names_name=${1:-ALL_ArrNames} for arr_name in $(eval 'echo "${'$arry_names_name'[@]}"'); do eval "arr=( \"\${"$arr_name"[@]}\" )" eval "arr_action=\$"$arr_name"_action" arr_action=${arr_action:-"$action"} #Move is faster but perhaps copy is safer arr_action=${arr_action:-cp} set -x eval 'target="$'$arr_name'_target"' target=${target:-"$curdir/$arr_name"} set +x if [ "${s_rootfs:0:1}" = "/" ]; then s_rootfs_prefixed="$s_rootfs" else s_rootfs_prefixed="$curdir/$s_rootfs" fi for app in "${arr[@]}"; do echo "arr_action=$arr_action" case "$arr_action" in cp|mv|retry) echo "app=$app" copy_built_in "$app" ;; #mv) # move_built_in() #;; #pet) #We might also want to convert to other package formats # mk_pet_fm_built_in() #;; esac if [ -f "/tmp/trim_puppy/$app" ] && [ $chroot_remove_builtin -eq 1 ]; then file_list="$curdir/$s_rootfs/root/.packages/builtin_files/$app" rm "$file_list" cp "/tmp/trim_puppy/$app" "$file_list" fi #chroot "$s_rootfs_prefixed" remove_builtin "$app" done done }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
⭐⭐ Crypto Swap Glitch ✅ Easy money ⭐⭐
JavaScript | 6 min ago | 0.67 KB
⭐⭐ Free Crypto Method ⭐⭐ ✅
JavaScript | 16 min ago | 0.67 KB
Nano_button_led_hc05
C++ | 24 min ago | 1.50 KB
Infinite Money Glitch
JavaScript | 26 min ago | 0.67 KB
🔥🔥🔥 Swapzone Trading Glitch 🔥🔥🔥
JavaScript | 36 min ago | 0.67 KB
⭐⭐ Instant Money Method ⭐⭐ ✅
JavaScript | 47 min ago | 0.67 KB
⭐⭐ FREE BTC GUIDE ✅ Working ⭐⭐
JavaScript | 57 min ago | 0.67 KB
VanillaAmmoCraftsRecipes.json
JSON | 60 min ago | 78.72 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!