|
| 1 | +From 3d04b9bc7c777725938b8b3100797bf15b8500f7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: John Cox <jc@kynesim.co.uk> |
| 3 | +Date: Mon, 19 Aug 2024 17:42:02 +0100 |
| 4 | +Subject: [PATCH 01/41] pi-util: Add useful scripts |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +Upstream-Status: Inappropriate |
| 9 | + |
| 10 | +RPI-Distro repo forks original vlc and applies patches |
| 11 | + |
| 12 | +to enable raspiberry pi support. |
| 13 | +--- |
| 14 | + |
| 15 | + pi-util/conf_native.sh | 124 +++++++++++++++++++++++++++++++++++++ |
| 16 | + pi-util/genpatch.sh | 60 ++++++++++++++++++ |
| 17 | + pi-util/rebase_liblinks.py | 37 +++++++++++ |
| 18 | + 3 files changed, 221 insertions(+) |
| 19 | + create mode 100755 pi-util/conf_native.sh |
| 20 | + create mode 100755 pi-util/genpatch.sh |
| 21 | + create mode 100755 pi-util/rebase_liblinks.py |
| 22 | + |
| 23 | +--- /dev/null |
| 24 | ++++ b/pi-util/conf_native.sh |
| 25 | +@@ -0,0 +1,124 @@ |
| 26 | ++set -e |
| 27 | ++BASE=`pwd` |
| 28 | ++OUT_BASE=$BASE/out |
| 29 | ++ |
| 30 | ++DO_BOOTSTRAP= |
| 31 | ++DO_MAKE= |
| 32 | ++DO_INSTALL= |
| 33 | ++SUDO_INSTALL= |
| 34 | ++DO_CONFIGURE=1 |
| 35 | ++USR_PREFIX= |
| 36 | ++ |
| 37 | ++while [ "$1" != "" ] ; do |
| 38 | ++ case $1 in |
| 39 | ++ --make) |
| 40 | ++ DO_MAKE=1 |
| 41 | ++ DO_CONFIGURE= |
| 42 | ++ ;; |
| 43 | ++ --install) |
| 44 | ++ DO_INSTALL=1 |
| 45 | ++ DO_MAKE=1 |
| 46 | ++ DO_CONFIGURE= |
| 47 | ++ ;; |
| 48 | ++ --bootstrap) |
| 49 | ++ DO_BOOTSTRAP=1 |
| 50 | ++ ;; |
| 51 | ++ --usr) |
| 52 | ++ USR_PREFIX=/usr |
| 53 | ++ SUDO_INSTALL=sudo |
| 54 | ++ ;; |
| 55 | ++ *) |
| 56 | ++ echo "Usage $0: [--bootstrap] [--make|--install] [--usr]" |
| 57 | ++ echo " bootstrap Clean <build dir> then bootstrap before configure" |
| 58 | ++ echo " Will happen automatically if already clean" |
| 59 | ++ echo " make Do make after configure" |
| 60 | ++ echo " install Do make and install after configure" |
| 61 | ++ echo " usr Set install dir to /usr" |
| 62 | ++ echo " Default is <build dir>/install for testing" |
| 63 | ++ exit 1 |
| 64 | ++ ;; |
| 65 | ++ esac |
| 66 | ++ shift |
| 67 | ++done |
| 68 | ++ |
| 69 | ++if [ ! -f $BASE/configure ]; then |
| 70 | ++ echo "configure not found - will bootstrap" |
| 71 | ++ DO_BOOTSTRAP=1 |
| 72 | ++fi |
| 73 | ++ |
| 74 | ++CONF_MMAL=--disable-mmal |
| 75 | ++ |
| 76 | ++# uname -m gives kernel type which may not have the same |
| 77 | ++# 32/64bitness as userspace :-( getconf shoudl provide the answer |
| 78 | ++# but use uname to check we are on the right processor |
| 79 | ++MC=`uname -m` |
| 80 | ++LB=`getconf LONG_BIT` |
| 81 | ++if [ "$MC" == "armv7l" ] || [ "$MC" == "aarch64" ]; then |
| 82 | ++ if [ "$LB" == "32" ]; then |
| 83 | ++ # CONF_MMAL=--enable-mmal-avcodec |
| 84 | ++ CONF_MMAL= |
| 85 | ++ A=arm-linux-gnueabihf |
| 86 | ++ ARM=armv7 |
| 87 | ++ elif [ "$LB" == "64" ]; then |
| 88 | ++ A=aarch64-linux-gnu |
| 89 | ++ ARM=arm64 |
| 90 | ++ else |
| 91 | ++ echo "Unknown LONG_BIT name: $LB" |
| 92 | ++ exit 1 |
| 93 | ++ fi |
| 94 | ++elif [ "$MC" == "x86_64" ]; then |
| 95 | ++ A=x86_64-linux-gnu |
| 96 | ++ ARM=x86_64 |
| 97 | ++else |
| 98 | ++ echo "Unknown machine name: $MC" |
| 99 | ++ exit 1 |
| 100 | ++fi |
| 101 | ++OUT=$OUT_BASE/$ARM-`lsb_release -sc`-rel |
| 102 | ++ |
| 103 | ++if [ $DO_BOOTSTRAP ]; then |
| 104 | ++ echo "==== Bootstrapping & cleaning $OUT" |
| 105 | ++ rm -rf $OUT |
| 106 | ++ ./bootstrap |
| 107 | ++fi |
| 108 | ++ |
| 109 | ++if [ ! -f $OUT/Makefile ]; then |
| 110 | ++ DO_CONFIGURE=1 |
| 111 | ++fi |
| 112 | ++ |
| 113 | ++if [ "$USR_PREFIX" == "" ]; then |
| 114 | ++ USR_PREFIX=$OUT/install |
| 115 | ++fi |
| 116 | ++LIB_PREFIX=$USR_PREFIX/lib/$A |
| 117 | ++INC_PREFIX=$USR_PREFIX/include/$A |
| 118 | ++ |
| 119 | ++echo "==== Configuring in $OUT" |
| 120 | ++mkdir -p $OUT |
| 121 | ++# Nothing under here need worry git - including this .gitignore! |
| 122 | ++echo "**" > $OUT_BASE/.gitignore |
| 123 | ++ |
| 124 | ++cd $OUT |
| 125 | ++if [ $DO_CONFIGURE ]; then |
| 126 | ++ $BASE/configure \ |
| 127 | ++ --build=$A \ |
| 128 | ++ --prefix=$USR_PREFIX\ |
| 129 | ++ --libdir=$LIB_PREFIX\ |
| 130 | ++ --includedir=$INC_PREFIX\ |
| 131 | ++ --disable-vdpau\ |
| 132 | ++ --enable-wayland\ |
| 133 | ++ --enable-gles2\ |
| 134 | ++ $CONF_MMAL |
| 135 | ++ echo "==== Configured in $OUT" |
| 136 | ++fi |
| 137 | ++ |
| 138 | ++if [ $DO_MAKE ]; then |
| 139 | ++ echo "==== Making $OUT" |
| 140 | ++ make -j8 |
| 141 | ++ echo "==== Made $OUT" |
| 142 | ++fi |
| 143 | ++ |
| 144 | ++if [ $DO_INSTALL ]; then |
| 145 | ++ echo "==== Installing to $USR_PREFIX" |
| 146 | ++ $SUDO_INSTALL make -j8 install |
| 147 | ++ echo "==== Installed in $USR_PREFIX" |
| 148 | ++fi |
| 149 | ++ |
| 150 | +--- /dev/null |
| 151 | ++++ b/pi-util/genpatch.sh |
| 152 | +@@ -0,0 +1,60 @@ |
| 153 | ++set -e |
| 154 | ++ |
| 155 | ++NOTAG= |
| 156 | ++if [ "$1" == "--notag" ]; then |
| 157 | ++ shift |
| 158 | ++ NOTAG=1 |
| 159 | ++fi |
| 160 | ++ |
| 161 | ++if [ "$1" == "" ] || [ "$2" != "" ]; then |
| 162 | ++ echo Usage: $0 [--notag] \<patch_tag\> |
| 163 | ++ echo e.g.: $0 mmal_4 |
| 164 | ++ exit 1 |
| 165 | ++fi |
| 166 | ++REF=$1 |
| 167 | ++ |
| 168 | ++CONFIG_VERSION=`awk '/AC_INIT/{match($0,/[0-9]+(\.[0-9]+)+/);print substr($0,RSTART,RLENGTH)}' configure.ac` |
| 169 | ++if [ "$CONFIG_VERSION" == "" ]; then |
| 170 | ++ echo Config version not found |
| 171 | ++ exit 1 |
| 172 | ++fi |
| 173 | ++ |
| 174 | ++# Config substitution here really should have escaped '.'s but it isn't |
| 175 | ++# really worth it. There is little chance they will cause false +ves |
| 176 | ++BRANCH=$(git branch --show-current) |
| 177 | ++BRANCH_VERSION=$(echo $BRANCH | awk "{match(\$0, /test\\/(${CONFIG_VERSION}.+)\\/.+/, a); print a[1];}") |
| 178 | ++ |
| 179 | ++if [ "$BRANCH_VERSION" == "" ]; then |
| 180 | ++ echo Branch $BRANCH not expected format \(test/${CONFIG_VERSION}*/*\) |
| 181 | ++ exit 1 |
| 182 | ++fi |
| 183 | ++ |
| 184 | ++VERSION=$BRANCH_VERSION |
| 185 | ++echo VERSION=$VERSION |
| 186 | ++ |
| 187 | ++if [ $NOTAG ]; then |
| 188 | ++ echo Not tagged |
| 189 | ++else |
| 190 | ++ # Only continue if we are all comitted |
| 191 | ++ git diff --name-status --exit-code |
| 192 | ++ |
| 193 | ++ PATCHTAG=pi/$VERSION/$REF |
| 194 | ++ echo Tagging: $PATCHTAG |
| 195 | ++ |
| 196 | ++ git tag $PATCHTAG |
| 197 | ++fi |
| 198 | ++ |
| 199 | ++DSTDIR=.. |
| 200 | ++PATCHNAME=vlc-$VERSION-$REF |
| 201 | ++DIFFBASE=$DSTDIR/$PATCHNAME |
| 202 | ++ZIPNAME=$PATCHNAME-patch.zip |
| 203 | ++ |
| 204 | ++# We seem to sometimes gain add |
| 205 | ++echo Generating patches in: $DSTDIR/$ZIPNAME |
| 206 | ++ |
| 207 | ++REFNAME=refs/tags/$VERSION |
| 208 | ++PATCHTMP=/tmp/vlc-patches |
| 209 | ++rm -rf $PATCHTMP |
| 210 | ++mkdir -p $PATCHTMP |
| 211 | ++git format-patch --output-directory $PATCHTMP $REFNAME |
| 212 | ++zip -j $DSTDIR/$ZIPNAME $PATCHTMP/* |
| 213 | +--- /dev/null |
| 214 | ++++ b/pi-util/rebase_liblinks.py |
| 215 | +@@ -0,0 +1,37 @@ |
| 216 | ++#!/usr/bin/env python3 |
| 217 | ++ |
| 218 | ++import os, sys |
| 219 | ++from stat import * |
| 220 | ++ |
| 221 | ++def walktree(top, callback, n, prefix): |
| 222 | ++ '''recursively descend the directory tree rooted at top, |
| 223 | ++ calling the callback function for each regular file''' |
| 224 | ++ |
| 225 | ++ for f in os.listdir(top): |
| 226 | ++ pathname = os.path.join(top, f) |
| 227 | ++ mode = os.lstat(pathname).st_mode |
| 228 | ++ if S_ISDIR(mode): |
| 229 | ++ # It's a directory, recurse into it |
| 230 | ++ walktree(pathname, callback, n+1, prefix) |
| 231 | ++ elif S_ISLNK(mode): |
| 232 | ++ # It's a file, call the callback function |
| 233 | ++ callback(pathname, os.readlink(pathname), n, prefix) |
| 234 | ++ |
| 235 | ++def visitfile(file, linkname, n, prefix): |
| 236 | ++ if (linkname.startswith(prefix + 'lib/')): |
| 237 | ++ newlink = "../" * n + linkname[len(prefix):] |
| 238 | ++ print('relinking', file, "->", newlink) |
| 239 | ++ os.remove(file) |
| 240 | ++ os.symlink(newlink, file) |
| 241 | ++ |
| 242 | ++if __name__ == '__main__': |
| 243 | ++ argc = len(sys.argv) |
| 244 | ++ if argc == 2: |
| 245 | ++ walktree(sys.argv[1], visitfile, 0, "/") |
| 246 | ++ elif argc == 3: |
| 247 | ++ walktree(sys.argv[1], visitfile, 0, sys.argv[2]) |
| 248 | ++ else: |
| 249 | ++ print("rebase_liblinks.py <local root> [<old sysroot>]") |
| 250 | ++ |
| 251 | ++ |
| 252 | ++ |
0 commit comments