Results 1 to 1 of 1

Thread: How to check if PPA is already added in a bash script

  1. #1
    Join Date
    Jan 2023
    Beans
    12

    How to check if PPA is already added in a bash script

    Hi,
    I found a solution on how to check if PPA is already added to apt sources list in a bash script.
    The code worked fine until the previous version of ubuntu 22.04. Now I noticed that the file /etc/apt/sources.list has been moved to /etc/apt/sources.list.d/ubuntu.sources.
    Moreover, the "format" of the file has been changed (it no longer contains the deb prefix for some PPAs).
    "Old"
    Code:
    deb [arch=amd64 signed-by=file.gpg] URL stable main
    "New"
    Code:
    Types: deb
    URIs: URL
    Suites: noble
    Components: main
    Signed-By:
    I then modified the code accordingly by removing ^.deb and it works fine. Is this correct? Or is there a better way to achieve this?
    Code:
    myPPA=
    if ! grep -q ".*$myPPA" /etc/apt/sources.list.d/*; then
         add-apt-repository ppa:$myPPA -y
    fi
    Thank you
    Last edited by alfredino; June 14th, 2024 at 10:02 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •