From de02991724cae1941e2e10d5059b5ef08d8c9a52 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 30 Nov 2022 09:25:30 -0800 Subject: [PATCH] Add Bug report template to reduce asking for additional details --- .github/ISSUE_TEMPLATE/bug_report.yml | 67 +++++++++ .github/ISSUE_TEMPLATE/config.yml | 7 + .github/ISSUE_TEMPLATE/feature_request.md | 11 ++ adafruit-pitft-mipi.py | 8 +- adafruit-pitft.py | 2 + adafruit_fanservice.py | 7 + joy-bonnet.py | 9 +- libgpiod.py | 2 +- pi-touch-cam.py | 127 +++++++++++++++++ raspi-blinka.py | 2 + raspi-spi-reassign.py | 3 +- retrogame.py | 98 +++++++++++++ rpi_pin_kernel_firmware.py | 2 + rtc.py | 163 ++++++++++++++++++++++ 14 files changed, 501 insertions(+), 7 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100755 pi-touch-cam.py create mode 100755 retrogame.py create mode 100755 rtc.py diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..bd390a9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,67 @@ +name: 🐞 Bug Report +description: Create a bug report to help us improve +labels: + - bug +body: + - type: markdown + attributes: + value: >- + Thanks! for using the installer scripts. Now that you have encountered a + bug... you can file a report for it. + - type: textarea + id: script + attributes: + label: Script Command + description: >- + Include the exact command you're running with any parameters. There are quite + a handful of scripts and knowing which one is helpful. :) + placeholder: sudo python3 adafruit-pitft.py --display=28r --rotation=90 --install-type=console + render: shell + validations: + required: true + - type: textarea + id: os + attributes: + label: Operating System + description: Which OS was the script running under? Include details such as if it + was 32 or 64-bit, Whether it was the Lite of Full Desktop version. If it's on an older or newer + kernel, include that as well. + placeholder: | + 64-bit Raspberry Pi OS Lite with Bullseye + validations: + required: true + - type: textarea + id: hardware + attributes: + label: Hardware + description: This is the board or computer you are running the script on. + placeholder: | + Raspberry Pi 4B + validations: + required: true + - type: textarea + id: behavior + attributes: + label: Behavior + description: What happens when you run the script above? Include error messages (if any). + placeholder: | + An error occurs at line 459 with this message... + validations: + required: true + - type: textarea + id: description + attributes: + label: Description + description: Optionally, describe the bug in more detail. + placeholder: | + - I selected options 1, then 3, then 4... + - Only happens when... + - might be related to #123... + - type: textarea + id: more-info + attributes: + label: Additional information + description: >- + Optionally, add any other information like hardware connection, scope + output etc. If you have already done some debugging, mention it here. + placeholder: Removing [this](url) line resolves the issue. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..2990e0d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +contact_links: + - name: 🔗 Adafruit Forum + url: https://forums.adafruit.com/ + about: Official Adafruit technical support forum. Good for getting help on getting a project working. + - name: 🔗 Adafruit Discord + url: https://adafru.it/discord + about: Unofficial chat with many helpful folks and normally prompt replies. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..aaee0d7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,11 @@ +--- +name: 🚀 Feature Request +about: Suggest an idea for this project +title: '' +labels: 'enhancement' +assignees: '' + +--- + + diff --git a/adafruit-pitft-mipi.py b/adafruit-pitft-mipi.py index 5066afa..f199e02 100755 --- a/adafruit-pitft-mipi.py +++ b/adafruit-pitft-mipi.py @@ -1,6 +1,8 @@ """ -Adafruit PiTFT Installer Script +Adafruit PiTFT MIPI Display Installer Script (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Written by Melissa LeBlanc-Williams for Adafruit Industries """ import time @@ -8,7 +10,7 @@ import os try: import click except ImportError: - raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click") + raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install --upgrade click") try: from adafruit_shell import Shell except ImportError: @@ -352,7 +354,7 @@ def update_pointercal(): def install_mipi(): global mipi_data - + if "mipi_data" in pitft_config: mipi_data.update(pitft_config['mipi_data']) if not compile_display_fw(): diff --git a/adafruit-pitft.py b/adafruit-pitft.py index 90b1abc..216953d 100755 --- a/adafruit-pitft.py +++ b/adafruit-pitft.py @@ -1,6 +1,8 @@ """ Adafruit PiTFT Installer Script (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Written in Python by Melissa LeBlanc-Williams for Adafruit Industries """ import time diff --git a/adafruit_fanservice.py b/adafruit_fanservice.py index c8b1139..8403aef 100644 --- a/adafruit_fanservice.py +++ b/adafruit_fanservice.py @@ -1,3 +1,10 @@ +""" +Adafruit Raspberry Pi Fan Service Setup Script +(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries +""" + import os try: diff --git a/joy-bonnet.py b/joy-bonnet.py index 5aa145e..accdfa3 100755 --- a/joy-bonnet.py +++ b/joy-bonnet.py @@ -1,3 +1,10 @@ +""" +Adafruit Raspberry Pi Joy Bonnet Setup Script +(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries +""" + try: from adafruit_shell import Shell except ImportError: @@ -107,7 +114,7 @@ Updating package index files...""") Settings take effect on next boot. """) shell.prompt_reboot() - + # Main function if __name__ == "__main__": shell.require_root() diff --git a/libgpiod.py b/libgpiod.py index d71348a..adc5f46 100755 --- a/libgpiod.py +++ b/libgpiod.py @@ -8,7 +8,7 @@ try: import click except ImportError: - raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click==7.0") + raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install --upgrade click") try: from adafruit_shell import Shell except ImportError: diff --git a/pi-touch-cam.py b/pi-touch-cam.py new file mode 100755 index 0000000..c5d5039 --- /dev/null +++ b/pi-touch-cam.py @@ -0,0 +1,127 @@ +""" +Adafruit Pi Touch Cam Setup Script +(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries + +Note: Currently Untested +""" + +try: + from adafruit_shell import Shell +except ImportError: + raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") +import os + +shell = Shell() +shell.group="Retrogame" + +def main(): + shell.clear() + print("""This script will install and/or modify +packages needed for the Adafruit Pi +Camera project. It requires that the +adafruit-pitft.sh installer script (for +PiTFT display support) was run first. + +Operations performed include: +- In /boot/config.txt, enable camera +- apt-get update +- Install Python libraries: + picamera, pygame, PIL +- Downgrade SDL library for pygame + touch compatibility +- Download Dropbox Updater and + Adafruit Pi Cam software + +Run time 5+ minutes. Reboot required. +""") + + if not shell.prompt("CONTINUE?", default='n'): + print("Canceled.") + shell.exit() + print("Continuing...") + + + if shell.grep("dtoverlay=pitft", "/boot/config.txt"): + shell.bail("PiTFT overlay not in /boot/config.txt.\n" + "Download & run adafruit-pitft.py first.\n" + "Canceling.") + + print("Configuring camera + PiTFT settings...") + + # Set PiTFT speed to 80 MHz, 60 Hz + shell.pattern_replace("/boot/config.txt", "speed=.*,fps=.*", "speed=80000000,fps=60") + + # Check if Pi camera is enabled. If not, add it... + shell.reconfig("/boot/config.txt", "^start_x=.*", "start_x=1") + + # gpu_mem must be >= 128 MB for camera to work + result = shell.pattern_search("/boot/config.txt", "^gpu_mem=", return_match=True) + if not result: + # gpu_mem isn't set. Add to config + shell.write_text_file("/boot/config.txt", "\ngpu_mem=128", append=True) + elif result.group(1) < 128: + # gpu_mem present but too small; increase to 128MB + shell.reconfig("/boot/config.txt", "^gpu_mem=.*", "gpu_mem=128") + + print("Installing prerequisite packages...") + + # Enable Wheezy package sources (for SDL downgrade) + shell.write_text_file("/etc/apt/sources.list.d/wheezy.list", "deb http://archive.raspbian.org/raspbian wheezy main\n", append=True) + + # Set 'stable' as default package source (current OS) + shell.write_text_file("/etc/apt/apt.conf.d/10defaultRelease", "APT::Default-release \"stable\";\n", append=True) + + # Set priority for libsdl from Wheezy higher than current package + shell.write_text_file("/etc/apt/preferences.d/libsdl", ( + "Package: libsdl1.2debian\n" + "Pin: release n=stretch\n" + "Pin-Priority: -10\n" + "Pin: release n=jessie\n" + "Pin-Priority: -10\n" + "Package: libsdl1.2debian\n" + "Pin: release n=wheezy\n" + "Pin-Priority:900\n" + )) + + # Update the APT package index files, install Python libraries + print("Updating System Packages") + if not shell.run_command("sudo apt-get update"): + shell.bail("Apt failed to update indexes!") + print("Installing packages...") + if not shell.run_command("sudo apt-get -y --force-yes install python-picamera python-pygame python-imaging"): + shell.bail("Apt failed to install software!") + + print("Downgrading SDL library...") + + if not shell.run_command("apt-get -y --force-yes install libsdl1.2debian/wheezy"): + shell.bail("Apt failed to downgrade SDL library!") + + print("Downloading Dropbox uploader and") + print("Adafruit Pi Cam to home directory...") + + shell.chdir("~pi") + shell.run_command("wget https://github.com/andreafabrizi/Dropbox-Uploader/archive/master.zip") + shell.run_command("unzip master.zip") + shell.remove("master.zip") + shell.move("Dropbox-Uploader-master", "Dropbox-Uploader") + + shell.run_command("wget https://github.com/adafruit/adafruit-pi-cam/archive/master.zip") + shell.run_command("unzip master.zip") + shell.remove("master.zip") + shell.chown("Dropbox-Uploader", "pi", recursive=True) + shell.chown("adafruit-pi-cam-master", "pi", recursive=True) + + # Add lines to /etc/rc.local (commented out by default): + shell.pattern_replace("/etc/rc.local", "^exit 0", "# Enable this line to run camera at startup:\n# cd /home/pi/adafruit-pi-cam-master ; sudo python cam.py\n\nexit 0") + + # Prompt to reboot! + print("\nCamera and PiTFT settings won't take") + print("effect until next boot.") + shell.prompt_reboot() + +# Main function +if __name__ == "__main__": + shell.require_root() + main() \ No newline at end of file diff --git a/raspi-blinka.py b/raspi-blinka.py index f63b65a..c094e67 100644 --- a/raspi-blinka.py +++ b/raspi-blinka.py @@ -1,6 +1,8 @@ """ Adafruit Raspberry Pi Blinka Setup Script (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Written by Melissa LeBlanc-Williams for Adafruit Industries """ try: diff --git a/raspi-spi-reassign.py b/raspi-spi-reassign.py index ae1cb24..9a3fd55 100644 --- a/raspi-spi-reassign.py +++ b/raspi-spi-reassign.py @@ -6,12 +6,11 @@ Adafruit Raspberry Pi SPI Chip Enable Reassignment Script try: import click except ImportError: - raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click") + raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install --upgrade click") try: from adafruit_shell import Shell except ImportError: raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") -import os shell = Shell() shell.group="SPI Reassign" diff --git a/retrogame.py b/retrogame.py new file mode 100755 index 0000000..598e5da --- /dev/null +++ b/retrogame.py @@ -0,0 +1,98 @@ +""" +Adafruit Retrogame Setup Script +(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries + +Note: Currently Untested +""" + +try: + from adafruit_shell import Shell +except ImportError: + raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") +import os + +shell = Shell() +shell.group="Retrogame" + +def main(): + shell.clear() + print("""This script downloads and installs +retrogame, a GPIO-to-keypress utility +for adding buttons and joysticks, plus +one of several configuration files. +Run time <1 minute. Reboot recommended. +""") + + # Grouped by config name and menu label + config = { + "pigrrl2": "PiGRRL 2 controls", + "pocket": "Pocket PiGRRL", + "zero": "PiGRRL Zero", + "super": "Super Game Pi", + "2button": "Two buttons + joystick", + "6button": "Six buttons + joystick", + "bonnet": "Adafruit Arcade Bonnet", + "cupcade-orig": "Cupcade (gen 1 & 2 only)" + } + + RETROGAME_SELECT = shell.select_n( + "Select configuration:", list(config.values()) + ["Quit without installing"] + ) + + if RETROGAME_SELECT <= len(config): + CONFIG_NAME = list(config.keys())[RETROGAME_SELECT-1] + + if shell.exists("/boot/retrogame.cfg"): + print("/boot/retrogame.cfg already exists.\n" + "Continuing will overwrite file.\n") + if not shell.prompt("CONTINUE?", default='n'): + print("Canceled.") + shell.exit() + + print("Downloading, installing retrogame...", end="") + # Download to tmpfile because might already be running + if shell.run_command("curl -f -s -o /tmp/retrogame https://raw.githubusercontent.com/adafruit/Adafruit-Retrogame/master/retrogame"): + shell.move("/tmp/retrogame", "/usr/local/bin/") + os.chmod("/usr/local/bin/retrogame", 0o755) + print("OK") + else: + print("ERROR") + + print("Downloading, installing retrogame.cfg...", end="") + if shell.run_command(f"curl -f -s -o /boot/retrogame.cfg https://raw.githubusercontent.com/adafruit/Adafruit-Retrogame/master/configs/retrogame.cfg.{CONFIG_NAME}"): + print("OK") + else: + print("ERROR") + + print("Performing other system configuration...", end="") + + # Add udev rule (will overwrite if present) + shell.write_text_file("/etc/udev/rules.d/10-retrogame.rules", ( + r"SUBSYSTEM==\"input\", ATTRS{name}==\"retrogame\", " + r"ENV{ID_INPUT_KEYBOARD}=\"1\"" + )) + + if CONFIG_NAME == "bonnet": + # If Bonnet, make sure I2C is enabled. Call the I2C + # setup function in raspi-config (noninteractive): + shell.run_command("raspi-config nonint do_i2c 0") + + # Start on boot + if shell.run_command("grep retrogame /etc/rc.local", suppress_message=True): + # retrogame already in rc.local, but make sure correct: + shell.pattern_replace("/etc/rc.local", "^.*retrogame.*$", "/usr/local/bin/retrogame &") + else: + # Insert retrogame into rc.local before final 'exit 0' + shell.pattern_replace("/etc/rc.local", "^exit 0", "/usr/local/bin/retrogame &\nexit 0") + + print("OK") + + shell.prompt_reboot() + print("Done") + +# Main function +if __name__ == "__main__": + shell.require_root() + main() diff --git a/rpi_pin_kernel_firmware.py b/rpi_pin_kernel_firmware.py index e7676ae..71a2279 100644 --- a/rpi_pin_kernel_firmware.py +++ b/rpi_pin_kernel_firmware.py @@ -1,6 +1,8 @@ """ Adafruit Raspberry Pi Script to Pin a specific version of the rpi kernel and firmware (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries """ try: diff --git a/rtc.py b/rtc.py new file mode 100755 index 0000000..c92bdfd --- /dev/null +++ b/rtc.py @@ -0,0 +1,163 @@ +""" +Adafruit Raspberry Pi Real Time Clock Setup Script + +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. + +This script is licensed under the terms of the MIT license. +Unless otherwise noted, code reproduced herein +was written for this script. + +Originally written by the - The Pimoroni Crew - + +Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries + + +Note: Currently Untested +""" + +try: + from adafruit_shell import Shell +except ImportError: + raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") + +shell = Shell() + +productname = "Real Time Clock module" # the name of the product to install +rtcsubtype = "ds1307" +baseurl = "http://www.adafru.it" +scriptname = "rtc.py" # the name of this script + +spacereq = 1 # minimum size required on root partition in MB +debugmode = False # whether the script should use debug routines +debuguser = None # optional test git user to use in debug mode +debugpoint = None # optional git repo branch or tag to checkout +forcesudo = True # whether the script requires to be ran with root privileges +promptreboot = False # whether the script should always prompt user to reboot +customcmd = True # whether to execute commands specified before exit +i2creq = True # whether the i2c interface is required +i2sreq = False # whether the i2s interface is required +spireq = False # whether the spi interface is required +uartreq = False # whether uart communication is required +armhfonly = True # whether the script is allowed to run on other arch +armv6 = True # whether armv6 processors are supported +armv7 = True # whether armv7 processors are supported +armv8 = True # whether armv8 processors are supported +raspbianonly = True # whether the script is allowed to run on other OSes +macosxsupport = False # whether Mac OS X is supported by the script +osreleases = ( "Raspbian" ) # list os-releases supported +oswarning = ( "Debian", "Ubuntu", "Mate" ) # list experimental os-releases +squeezesupport = False # whether Squeeze is supported +wheezysupport = False # whether Wheezy is supported +jessiesupport = True # whether Jessie is supported + +DEVICE_TREE = True +ASK_TO_REBOOT = False +CURRENT_SETTING = False +UPDATED_DB = False + +BOOTCMD = "/boot/cmdline.txt" +CONFIG = "/boot/config.txt" +APTSRC = "/etc/apt/sources.list" +INITABCONF = "/etc/inittab" +BLACKLIST = "/etc/modprobe.d/raspi-blacklist.conf" +LOADMOD = "/etc/modules" +DTBODIR = "/boot/overlays" + +def raspbian_old(): + return shell.get_raspbian_version() in ("wheezy", "squeeze") + +def dt_check(): + # Check if /boot/config.txt exists and de + return shell.exists(CONFIG) and not shell.pattern_search(CONFIG, "^device_tree=$") + +#Perform all global variables declarations as well as function definition +#above this section for clarity, thanks! + +def main(): + os_release = shell.get_raspbian_version() + IS_SUPPORTED = os_release in osreleases + IS_EXPERIMENTAL = os_release in oswarning + + if not shell.is_armhf() or shell.is_arm64(): + shell.bail("This hardware is not supported, sorry!\n" + "Config files have been left untouched") + + if shell.is_raspberry_pi_os(): + if not wheezysupport and raspbian_old(): + shell.bail( + "\n--- Warning ---\n" + f"The {productname} installer\n" + "does not work on this version of Raspbian.\n" + r"Check https://github.com/{gitusername}/{gitreponame}" + "\nfor additional information and support") + elif raspbianonly: + shell.bail("This script is intended for Raspbian on a Raspberry Pi!") + else: + if not IS_SUPPORTED and not IS_EXPERIMENTAL: + shell.bail( + "Your operating system is not supported, sorry!\n" + "Config files have been left untouched") + + if forcesudo: + shell.require_root() + + print(f"\nThis script will install everything needed to use {productname}\n") + shell.warn( + "--- Warning ---\n" + "Always be careful when running scripts and commands\n" + "copied from the internet. Ensure they are from a\n" + "trusted source.\n" + "\n" + "If you want to see what this script does before\n" + "running it, you should run:\n" + " \curl -sS $baseurl/$scriptname\n" + "\n" + ) + + if shell.prompt("Do you wish to continue?", force_arg="y", default="n"): + print("\nChecking hardware requirements...") + + if i2creq == "yes": + print() + if shell.prompt("Hardware requires I2C, enable now?", force_arg="y", default="n"): + shell.run_command("sudo raspi-config nonint do_i2c 0") + + if not dt_check(): + shell.bail( + "Device Tree support required!\n" + "Config files have been left untouched\n" + ) + + rtc_values = ("ds1307", "ds3231", "pcf8523") + rtcsubtype = rtc_values[shell.select_n("What RTC would you like to install?", rtc_values) - 1] + + print("Disabling any current RTC") + shell.run_command(f"sudo sed --in-place '/dtoverlay[[:space:]]*=[[:space:]]*i2c-rtc/d' {CONFIG}") + + print(f"Adding DT overlay for {rtcsubtype}") + shell.write_text_file(CONFIG, f"dtoverlay=i2c-rtc,{rtcsubtype}", append=True) + + print("Removing fake-hwclock") + shell.run_command("sudo apt-get -y remove fake-hwclock") + shell.run_command("sudo update-rc.d -f fake-hwclock remove") + + if not shell.exists("/lib/udev/hwclock-set"): + shell.bail("Couldn't find /lib/udev/hwclock-set") + + shell.warn("Configuring HW Clock") + shell.run_command("sudo sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set") + shell.prompt_reboot() + + else: + shell.warn("\nAborting...") + +# Main function +if __name__ == "__main__": + main() \ No newline at end of file