Skip to content

Commit 0aa9868

Browse files
author
emmett1
committed
fixesss
1 parent f0ff3d0 commit 0aa9868

File tree

10 files changed

+149
-63
lines changed

10 files changed

+149
-63
lines changed

pkgadd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ msg2() {
3636
}
3737

3838
msgerr() {
39-
echo "==> ERROR: $1"
39+
echo "==> ERROR: $1" >&2
4040
}
4141

4242
msgwarn() {
43-
echo "==> WARNING: $1"
43+
echo "==> WARNING: $1" >&2
4444
}
4545

4646
help() {
@@ -140,7 +140,7 @@ LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
140140
}
141141

142142
[ -d "$ROOT_DIR/$INDEX_DIR" ] || {
143-
msgerr "Package's database directory not exist! ($ROOT_DIR/$INDEX_DIR)"
143+
msgerr "Package's database directory not exist: $ROOT_DIR/$INDEX_DIR"
144144
ret 1
145145
}
146146

pkgbase

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/bin/sh
22
#
3-
# script to remove all packages other than base and any user input
3+
# scratchpkg
4+
#
5+
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
#
21+
# script to remove all packages other than base and any user input
422
#
523

624
parseopt() {

pkgbuild

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,59 @@ msg2() {
2727
}
2828

2929
msgerr() {
30-
echo "==> ERROR: $1"
30+
echo "==> ERROR: $1" >&2
3131
}
3232

3333
msgwarn() {
34-
echo "==> WARNING: $1"
34+
echo "==> WARNING: $1" >&2
3535
}
3636

3737
updatemdsum() {
38-
msg "Generating .checksums..."
38+
for s in $(getsourcelist); do
39+
if [ ! -f $s ]; then
40+
msgerr "Source file '$s' not found."
41+
err=1
42+
fi
43+
done
44+
[ "$err" = 1 ] && abort 1
3945
generatemdsum > .checksums
46+
msg "Checksums updated."
4047
}
4148

42-
generatemdsum() {
43-
if [ -z "$source" ]; then
44-
echo SKIP
45-
return 0
46-
fi
47-
48-
for src in $source; do
49-
if echo $src | grep -qE "::(ftp|http|https)://"; then
50-
FILENAME=$SOURCE_DIR/$(echo $src | awk -F '::' '{print $1}')
51-
elif echo $src | grep -qE "(ftp|http|https)://"; then
52-
FILENAME=$SOURCE_DIR/$(basename $src)
49+
getsourcelist() {
50+
for s in $source; do
51+
if echo $s | grep -qE "::(ftp|http|https)://"; then
52+
FILENAME=$SOURCE_DIR/$(echo $s | awk -F '::' '{print $1}')
53+
elif echo $s | grep -qE "(ftp|http|https)://"; then
54+
FILENAME=$SOURCE_DIR/$(basename $s)
5355
else
54-
FILENAME=$src
56+
FILENAME=$PWD/$s
5557
fi
56-
needupdatechecksum="$needupdatechecksum $FILENAME"
58+
echo $FILENAME
5759
done
58-
59-
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
6060
}
6161

62-
checkmdsum() {
62+
generatemdsum() {
63+
for s in $(getsourcelist); do
64+
if [ -f $s ]; then
65+
needupdatechecksum="$needupdatechecksum $s"
66+
fi
67+
done
68+
if [ "$needupdatechecksum" ]; then
69+
md5sum $needupdatechecksum | sed -e 's| .*/| |' | sort -k 2
70+
else
71+
echo SKIP
72+
fi
73+
}
74+
75+
checkmdsum() {
76+
[ "$CHECK_MDSUM" = 0 ] || [ "$IGNORE_MDSUM" = yes ] && return 0
6377
TMPCHECKSUM=$WORK_DIR/checksumstmp.$$
6478
ORICHECKSUM=$WORK_DIR/checksumsori.$$
6579
DIFCHECKSUM=$WORK_DIR/checksumsdiff.$$
6680

6781
if [ ! -f .checksums ]; then
68-
msg "Generating .checksums..."
69-
generatemdsum > .checksums
82+
updatemdsum
7083
else
7184
msg "Checking checksums..."
7285
generatemdsum > "$TMPCHECKSUM"
@@ -134,8 +147,6 @@ download_src() {
134147
}
135148

136149
prepare_src() {
137-
[ "$IGNORE_MDSUM" -o "$CHECK_MDSUM" = 0 ] || checkmdsum
138-
139150
SRC=$WORK_DIR/$name/src
140151
PKG=$WORK_DIR/$name/pkg
141152

@@ -160,6 +171,11 @@ prepare_src() {
160171
break
161172
fi
162173
done
174+
if [ ! -f $FILENAME ]; then
175+
msgerr "File source '$FILENAME' not found."
176+
err=1
177+
continue
178+
fi
163179
if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then
164180
case $FILENAME in
165181
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
@@ -171,7 +187,7 @@ prepare_src() {
171187
MODE="Unpacking" ;;
172188
*)
173189
COMMAND="cp $FILENAME $SRC"
174-
MODE="Preparing" ;;
190+
MODE="Preparing" ;;
175191
esac
176192
msg "$MODE '$(basename $FILENAME)'..."
177193
$COMMAND || {
@@ -216,8 +232,30 @@ run_build() {
216232
cd - >/dev/null
217233
}
218234

235+
pkglint() {
236+
linterror=0
237+
238+
# cant package empty PKG
239+
if [ ! "$(find $PKG/* -maxdepth 1 -type d 2>/dev/null)" ]; then
240+
msgerr "PKG is empty."
241+
abort 1
242+
fi
243+
244+
# check for backup file
245+
for f in $backup; do
246+
if [ ! -f $PKG/$f ]; then
247+
msgerr "Backup file '$f' not exist in PKG!"
248+
linterror=1
249+
fi
250+
done
251+
252+
if [ "$linterror" = 1 ]; then
253+
abort 1
254+
fi
255+
}
256+
219257
removeemptydirs() {
220-
find . -type d -empty -delete
258+
find . -type d -empty -delete
221259
}
222260

223261
removelibtool() {
@@ -287,12 +325,7 @@ compressinfomanpages() {
287325

288326
backupconf() {
289327
for FILE in $backup; do
290-
if [ ! -f $FILE ]; then
291-
msgerr "File '$FILE' not exist!"
292-
abort 1
293-
else
294-
mv $FILE $FILE.spkgnew
295-
fi
328+
mv $FILE $FILE.spkgnew
296329
done
297330
}
298331

@@ -316,6 +349,9 @@ removelocales() {
316349
}
317350

318351
packaging() {
352+
# lint $PKG before packaging
353+
pkglint
354+
319355
for FILE in $INCLUDEINPKG; do
320356
if [ -f $FILE ]; then
321357
install -m644 $FILE $PKG/.pkg$FILE
@@ -333,9 +369,6 @@ packaging() {
333369
find usr/share/fonts \( -name fonts.dir -o -name fonts.scale \) -delete
334370
}
335371

336-
# remove pseudo directories
337-
#rm -fr dev sys proc run tmp
338-
339372
[ "$KEEP_EMPTYDIR" = 0 ] && removeemptydirs
340373
[ "$KEEP_LIBTOOL" = 0 ] && removelibtool
341374
[ "$STRIP_BINARY" = 1 ] && strip_files
@@ -380,11 +413,11 @@ generate_pkgfiles() {
380413
excludefile="$excludefile --exclude=.pkg$i"
381414
done
382415

383-
msg "Generating .pkgfiles..."
384416
tar -tvf "$PACKAGE_DIR/$PKGNAME" $excludefile \
385417
| awk '{$3=$4=$5=""; print $0}' \
386418
| sed "s,lib/modules/$(uname -r),lib/modules/<kernelversion>,g" \
387419
| sort -k 3 > .pkgfiles
420+
msg "Pkgfiles updated."
388421
}
389422

390423
cleanup() {
@@ -579,13 +612,13 @@ extract_opts() {
579612
echo $opts
580613
}
581614

582-
main() {
615+
main() {
583616
parse_opts $(extract_opts "$@")
584617

585618
if [ -f "$PKGBUILD_CONF" ]; then
586619
. "$PKGBUILD_CONF"
587620
else
588-
msgerr "Config file not found ('$PKGBUILD_CONF')"
621+
msgerr "Config file not found: $PKGBUILD_CONF"
589622
exit 1
590623
fi
591624

@@ -603,7 +636,7 @@ main() {
603636

604637
if [ -f "$PKGBUILD_BSCRIPT" ]; then
605638
description=$(grep "^# description[[:blank:]]*:" $PKGBUILD_BSCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
606-
. ./$PKGBUILD_BSCRIPT
639+
. ./$PKGBUILD_BSCRIPT
607640
else
608641
msgerr "'$PKGBUILD_BSCRIPT' file not found."
609642
exit 1
@@ -631,14 +664,12 @@ main() {
631664

632665
# extract source only
633666
[ "$EXTRACT_ONLY" ] && {
634-
download_src
635667
prepare_src
636668
exit 0
637669
}
638670

639671
# update md5sum
640672
[ "$UPDATE_MDSUM" ] && {
641-
download_src
642673
updatemdsum
643674
exit 0
644675
}
@@ -673,6 +704,7 @@ main() {
673704
else
674705
msg "Building '$name-$version-$release'..."
675706
download_src
707+
checkmdsum
676708
prepare_src
677709
run_build
678710
packaging

pkgdel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ msg2() {
3636
}
3737

3838
msgerr() {
39-
echo "==> ERROR: $1"
39+
echo "==> ERROR: $1" >&2
4040
}
4141

4242
msgwarn() {
43-
echo "==> WARNING: $1"
43+
echo "==> WARNING: $1" >&2
4444
}
4545

4646
help() {

pkgdepends

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
#!/bin/sh
2-
32
#
4-
# script to check dependencies
3+
# scratchpkg
4+
#
5+
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
#
21+
# script to check shared libraries dependencies
522
#
623

724
get_libpath() {

pkgfix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ if [ "$REBUILD" = 1 ]; then
128128
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
129129
}
130130
for p in $order; do
131-
scratch build -f $p && scratch install -r $p || exit 1
131+
scratch build -f $p || exit 1
132+
scratch install -r $p || exit 1
132133
done
133134
else
134135
echo "Broken packages:"

pkgrebuild

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/bin/sh
22
#
3-
# script to rebuild base packages in right toolchain order
3+
# scratchpkg
4+
#
5+
# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
#
21+
# script to rebuild base packages in right toolchain order
422
#
523

624
LIST="/tmp/$(basename $0)-list"

portcreate

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ if [ -d "$1" ]; then
2424
else
2525
mkdir "$1"
2626
echo "# description :
27-
# homepage :
28-
# maintainer :
2927
# depends :
3028
3129
name=$1

revdep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ rebuild() {
114114
confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled."
115115
fi
116116
for p in $order; do
117-
scratch build -f $p && scratch install -r $p || { cleanup; exit 1; }
117+
scratch build -f $p || { cleanup; exit 1; }
118+
scratch install -r $p || { cleanup; exit 1; }
118119
done
119120
fi
120121
}

0 commit comments

Comments
 (0)